Skip to content

Commit

Permalink
Merge pull request #26 from thematters/develop
Browse files Browse the repository at this point in the history
Update develop to main branch
  • Loading branch information
zeckli authored May 8, 2024
2 parents 3530f08 + 66ab527 commit 0f52bb4
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 26 deletions.
4 changes: 3 additions & 1 deletion app/routes/api.fund.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
return json({ state: STATE.successful, rounds: [] })
}

const baseRounds = _.orderBy(rawRounds, d => Number(d.fromBlock), ['desc'])
const baseRounds = _.orderBy(rawRounds, (d) => Number(d.fromBlock), [
'desc',
])

const rounds = []
for (const round of baseRounds) {
Expand Down
20 changes: 17 additions & 3 deletions app/routes/api.unclaim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { isAddress } from 'viem'
import { optimism, optimismSepolia } from 'viem/chains'

import { ERROR, STATE } from '@constant'
import { formatDate, formatRoundId } from '@util/format'
import { getPublicPath, readEnvs, readFile, sendError } from '@util/server'
import { initClient, initDistribution } from '@util/viem'

Expand Down Expand Up @@ -58,18 +59,28 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
}

const rounds = _.orderBy(rawRounds, ['fromBlock'], ['desc']).map(
({ root, amountTotal: rootAmount, dirpath: path }) => ({
({
id,
root,
amountTotal: rootAmount,
dirpath: path,
fromTime,
toTime,
}) => ({
roundId: formatRoundId(id),
root,
rootAmount,
path,
from: formatDate(fromTime),
to: formatDate(toTime),
})
)

// gather each rounds' data
let count = 0
const data = []
for (const round of rounds) {
const { root, rootAmount, path } = round
const { roundId, root, rootAmount, path, from, to } = round
const distPath = getPublicPath(`${srcPath}/${path}/distrib.json`)
const treePath = getPublicPath(`${srcPath}/${path}/treedump.json`)

Expand Down Expand Up @@ -116,12 +127,15 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
const base = dist.reduce(
(r, d) => {
r.items.push({
roundId,
cid: d.id,
url: d.url,
title: d.title,
proof: tree[d.id]?.proof,
share: tree[d.id]?.share,
amount: d.clr_amount,
from,
to,
})
r.cids.push(d.id)
return r
Expand All @@ -132,7 +146,7 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
// filter out claimed
const client = initClient(chain)
const distribution = initDistribution(addressDistribution, client)
const cidChunks = _.chunk(base.cids, 2) as Array<string[]>
const cidChunks = _.chunk(base.cids, 3) as Array<string[]>

let claimed = [] as string[]
for (const cids of cidChunks) {
Expand Down
21 changes: 14 additions & 7 deletions app/routes/claim/Records/Record/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,31 @@ const Record = ({ data }: Props) => {
'gap-y-4 md:gap-y-0'
)

const leftCss = clsx('t-14', 'font-normal', 'col-span-7', 'one-line')
const linkCss = clsx('hover:text-grass')
const leftCss = clsx('font-normal', 'col-span-7')
const roundCss = clsx('t-12', 'opacity-60')
const linkCss = clsx('mt-1', 't-14', 'one-line')
const rightCss = clsx('pr-3')
const amountHeadCss = clsx('t-12', 'font-normal', 'opacity-60')
const amountCss = clsx('mt-1', 't-14', 'font-medium')
const amountUnitCss = clsx('t-12 font-normal')

return (
<section className={baseCss}>
<section className={leftCss}>
<NavLink className={linkCss} to={data.url} target="_blank">
{data.title}
</NavLink>
<section className={roundCss}>
{data.from} - {data.to} · No. {data.roundId}
</section>
<section className={linkCss}>
<NavLink className="hover:text-grass" to={data.url} target="_blank">
{data.title}
</NavLink>
</section>
</section>
<section className={rightCss}>
<section className={amountHeadCss}>Amount</section>
<section className={amountCss}>
{_.floor(data.amount, 2)}
<span className="t-12"> USDT</span>
{data.amount.toFixed(6)}
<span className={amountUnitCss}> USDT</span>
</section>
</section>
</section>
Expand Down
4 changes: 2 additions & 2 deletions app/routes/claim/Records/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Records = ({ data, callback }: Props) => {
(r, v) => {
const sub = v.items.reduce(
(r: Record<string, any>, d: Record<string, any>) => {
const amount = _.floor(Number(d.amount) / 1e6, 2)
const amount = Number(d.amount) / 1e6
r.items.push({ ...d, root: v.root, amount })
r.amount = r.amount + amount
return r
Expand Down Expand Up @@ -110,7 +110,7 @@ const Records = ({ data, callback }: Props) => {
</section>
<section className={totalCss}>
<span className={totalHeadCss}>Total Amount:</span>
<span className={totalNumCss}>{base.total.toFixed(2)} USDT</span>
<span className={totalNumCss}>{base.total.toFixed(6)} USDT</span>
</section>
<ButtonBase css={btnCss} color="dim" click={claim}>
{isPending ? <SvgSpinner css="animate-spin" height={27} /> : 'Claim'}
Expand Down
4 changes: 2 additions & 2 deletions app/routes/showcase/Board/Meta/Basic/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Props = {
}

const Meta = ({ board }: Props) => {
const { contentURI, name, redirectURI } = board
const { contentURI, name, location } = board

const baseCss = clsx('grid grid-cols-1', 'gap-y-4')
const imgCss = clsx('h-auto', 'w-full', 'rounded-2xl')
Expand All @@ -31,7 +31,7 @@ const Meta = ({ board }: Props) => {
<p className={nameCss}>{name}</p>
<p className={locationCss}>
Board Location:
<NavLink className={linkCss} to={redirectURI} target="_blank">
<NavLink className={linkCss} to={location} target="_blank">
Discover Page
<SvgLink css={svgLinkCss} />
</NavLink>
Expand Down
21 changes: 10 additions & 11 deletions app/util/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ export const formatAddress = (address: string, size = 3) =>
export const formatDate = (time: number | string, pattern = 'MMM DD YYYY') =>
dayjs(time).format(pattern)

export const formatRound = (round: Record<string, any>) => {
const id = (round.id || '').replace('#', '')
const amount = round.amount || 0
return {
...round,
id: _.padStart(id, 3, '0'),
price: amount.toFixed(2),
from: formatDate(round.from),
to: formatDate(round.to),
}
}
export const formatRoundId = (id: string) =>
_.padStart((id || '').replace('#', ''), 3, '0')

export const formatRound = (round: Record<string, any>) => ({
...round,
id: formatRoundId(round.id),
price: (round.amount || 0).toFixed(2),
from: formatDate(round.from),
to: formatDate(round.to),
})
1 change: 1 addition & 0 deletions bin/sync-up-latest-round.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const main = async (branch = 'prod') => {
}

await writeFile(`${AssetsDir}/rounds.json`, roundsContent, { signal })

console.log(
new Date(),
`written rounds.json with ${(roundsContent.length / 1024).toFixed(1)} KBytes.`
Expand Down

0 comments on commit 0f52bb4

Please sign in to comment.