Skip to content

Commit

Permalink
feat: support xudt allocation from snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Jun 22, 2024
1 parent 1b4384a commit b13e419
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/pages/Xudt/HolderAllocation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const HolderAllocation = ({
}) => {
const [t] = useTranslation()
const total = Object.values(allocation).reduce((acc, cur) => acc + cur, 0)
const btc = allocation['RGB++']
const btc = allocation.BTC
const ckb = total - btc
return (
<div className={styles.holderAllocationContainer}>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Xudt/UDTComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const UDTOverviewCard = ({
const allocationDisplay = IS_MAINNET
? holderAllocation
: {
'RGB++': +(xudt?.holderAllocation?.btcHoldersCount ?? 0),
BTC: +(xudt?.holderAllocation?.btcHoldersCount ?? 0),
others: +(xudt?.holderAllocation?.ckbHoldersCount ?? 0),
}

Expand Down
14 changes: 10 additions & 4 deletions src/services/MetricsService/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ export const getHolderAllocation = async (
res.json(),
)
const allocation: Record<string, number> = {}
Object.keys(res).forEach(codeHash => {
const s = scripts.find(s => s.codeHashes.includes(codeHash))
const label = s?.tag ?? `${codeHash.slice(0, 8)}...${codeHash.slice(-8)}`
const count = res[codeHash]
Object.keys(res).forEach(key => {
let label: string | null = null

if (key === 'btc') {
label = 'BTC'
} else {
const s = scripts.find(s => s.codeHashes.includes(key))
label = s?.tag ?? `${key.slice(0, 8)}...${key.slice(-8)}`
}
const count = res[key]
allocation[label] = (allocation[label] ?? 0) + count
})
return allocation
Expand Down

0 comments on commit b13e419

Please sign in to comment.