Skip to content

Commit

Permalink
style(holder-allocation): use ellipsis and match tag in frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Daryl-L committed Jun 28, 2024
1 parent 0f18aa9 commit 84c8929
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/pages/Xudt/HolderAllocation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import styles from './HolderAllocation.module.scss'
import { localeNumberString } from '../../utils/number'
import CloseIcon from '../../assets/modal_close.png'
import SimpleButton from '../../components/SimpleButton'
import { matchScript } from '../../utils/util'
import EllipsisMiddle from '../../components/EllipsisMiddle'

const HolderAllocation = ({
ckbHolderAmount,
Expand Down Expand Up @@ -50,7 +52,7 @@ const HolderAllocation = ({
.map(amount => (
<tr>
<td>
<div>{amount.name ?? `#${amount.codeHash.slice(2, 6)}`}</div>
<EllipsisMiddle>{matchScript(amount.codeHash)?.tag ?? amount.codeHash}</EllipsisMiddle>
</td>
<td>
<div>{localeNumberString(amount.holderCount)}</div>
Expand Down
10 changes: 7 additions & 3 deletions src/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,18 @@ export const getContractHashTag = (script: Script): ContractHashTag | undefined
return contractHashTag
}

export const matchScript = (contractHash: string, hashType: string): ContractHashTag | undefined => {
export const matchScript = (contractHash: string, hashType?: string): ContractHashTag | undefined => {
if (isMainnet()) {
return MainnetContractHashTags.find(
scriptTag => scriptTag.codeHashes.find(codeHash => codeHash === contractHash) && scriptTag.hashType === hashType,
scriptTag =>
scriptTag.codeHashes.find(codeHash => codeHash === contractHash) &&
(!hashType || scriptTag.hashType === hashType),
)
}
return TestnetContractHashTags.find(
scriptTag => scriptTag.codeHashes.find(codeHash => codeHash === contractHash) && scriptTag.hashType === hashType,
scriptTag =>
scriptTag.codeHashes.find(codeHash => codeHash === contractHash) &&
(!hashType || scriptTag.hashType === hashType),
)
}

Expand Down

0 comments on commit 84c8929

Please sign in to comment.