diff --git a/src/locales/en.json b/src/locales/en.json index 750db8663..62bb60503 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -740,6 +740,10 @@ "repeat_inscription_symbol": "This inscription is a duplicate with an earlier release of the same symbol." }, "xudt": { + "holder_allocation": "Holder Allocation", + "holder_allocation_description": "There are {{ckb}} CKB Holders and {{btc}} BTC holders of current asset.", + "lock_hash": "Lock Hash", + "count": "Count", "xudt": "xUDT", "xudts": "xUDTs", "name": "Name", diff --git a/src/locales/zh.json b/src/locales/zh.json index 5b2f8a292..2e3f0e4b3 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -741,6 +741,10 @@ "repeat_inscription_symbol": "此铭文与早期发布的铭文同名" }, "xudt": { + "holder_allocation": "地址分布", + "holder_allocation_description": "当前地址有{{ckb}} CKB地址持有人及{{btc}} BTC 地址持有人", + "lock_hash": "Lock Hash", + "count": "Count", "xudt": "xUDT", "xudts": "xUDTs", "name": "名称", diff --git a/src/models/Xudt/index.ts b/src/models/Xudt/index.ts index 79af5dc7e..f5e10c234 100644 --- a/src/models/Xudt/index.ts +++ b/src/models/Xudt/index.ts @@ -14,6 +14,14 @@ export interface XUDT { typeScript: Script udtType: 'xudt' xudtTags?: string[] + holderAllocation: { + ckbHoldersCount: string + btcHoldersCount: string + lockHoderAmount: { + lock: string + holderAmount: string + }[] + } iconFile: string operatorWebsite: string email: string diff --git a/src/pages/Xudt/HolderAllocation.module.scss b/src/pages/Xudt/HolderAllocation.module.scss new file mode 100644 index 000000000..6f6560979 --- /dev/null +++ b/src/pages/Xudt/HolderAllocation.module.scss @@ -0,0 +1,109 @@ +@import '../../styles/variables.module'; + +.holderAllocationContainer { + background-color: #fff; + margin: 15% auto; + padding: 20px 24px 20px 40px; + width: 497px; + border-radius: 4px; + display: flex; + justify-content: space-between; + + @media (max-width: $mobileBreakPoint) { + width: 90%; + margin-top: 20vh; + padding: 24px 16px; + } + + .closeIcon { + img { + width: 16px; + height: 16px; + } + } + + .holderAllocationContent { + background-color: #fff; + border-radius: 4px; + display: flex; + flex-direction: column; + align-items: center; + gap: 24px; + + @media (max-width: $mobileBreakPoint) { + align-items: flex-start; + + p { + line-height: 24px; + } + } + + h2 { + color: #333; + font-size: 16px; + font-style: normal; + font-weight: 700; + margin: 0; + } + + p { + margin: 0; + color: #333; + font-size: 14px; + font-style: normal; + font-weight: 400; + width: 100%; + word-wrap: break-word; + } + + .table { + border-radius: 4px; + border: 1px solid #e5e5e5; + padding: 1px; + + table { + thead { + background: #fafafa; + + tr { + div { + color: #666; + font-size: 14px; + font-style: normal; + font-weight: 400; + line-height: normal; + text-transform: capitalize; + } + } + } + + tbody { + tr { + div { + color: #333; + font-size: 14px; + font-style: normal; + font-weight: 400; + line-height: normal; + } + } + } + + thead, + tbody { + tr { + border-radius: 4px; + + div { + font-size: 14px; + padding: 12px 16px; + } + } + } + + width: 312px; + background: #fff; + } + } + } +} diff --git a/src/pages/Xudt/HolderAllocation.tsx b/src/pages/Xudt/HolderAllocation.tsx new file mode 100644 index 000000000..fb6f37540 --- /dev/null +++ b/src/pages/Xudt/HolderAllocation.tsx @@ -0,0 +1,69 @@ +import { useTranslation } from 'react-i18next' +import { MouseEventHandler } from 'react' +import styles from './HolderAllocation.module.scss' +import { localeNumberString } from '../../utils/number' +import CloseIcon from '../../assets/modal_close.png' +import SimpleButton from '../../components/SimpleButton' + +const HolderAllocation = ({ + ckbHolderAmount, + btcHolderAmount, + lockHoderAmount, + onClose, +}: { + ckbHolderAmount: string + btcHolderAmount: string + lockHoderAmount?: { + lock: string + holderAmount: string + }[] + onClose: MouseEventHandler +}) => { + const [t] = useTranslation() + return ( +
+
+

{t('xudt.holder_allocation')}

+

+ {t('xudt.holder_allocation_description', { + ckb: localeNumberString(ckbHolderAmount), + btc: localeNumberString(btcHolderAmount), + })} +

+ {lockHoderAmount && ( +
+ + + + + + + + + {lockHoderAmount.map(amount => ( + + + + + ))} + +
+
{t('xudt.lock_hash')}
+
+
{t('xudt.count')}
+
+
{amount.lock}
+
+
{amount.holderAmount}
+
+
+ )} +
+ + close icon + +
+ ) +} + +export default HolderAllocation diff --git a/src/pages/Xudt/UDTComp.tsx b/src/pages/Xudt/UDTComp.tsx index 4f4bc9cd4..5560f2ab9 100644 --- a/src/pages/Xudt/UDTComp.tsx +++ b/src/pages/Xudt/UDTComp.tsx @@ -8,7 +8,6 @@ import { EyeClosedIcon, EyeOpenIcon } from '@radix-ui/react-icons' import { Link } from '../../components/Link' import { CsvExport } from '../../components/CsvExport' import TransactionItem from '../../components/TransactionItem/index' -import { UDTTransactionsPagination, UDTTransactionsPanel, TypeScriptController, UDTNoResultPanel } from './styled' import { parseUDTAmount } from '../../utils/number' import { ReactComponent as OpenInNew } from '../../assets/open_in_new.svg' import { deprecatedAddrToNewAddr, getBtcUtxo } from '../../utils/util' @@ -24,6 +23,9 @@ import { RawBtcRPC } from '../../services/ExplorerService' import { XUDT } from '../../models/Xudt' import { getBtcTxList } from '../../services/ExplorerService/fetcher' import XUDTTag from '../../components/XUDTTag' +import SimpleButton from '../../components/SimpleButton' +import SimpleModal from '../../components/Modal' +import HolderAllocation from './HolderAllocation' import { ReactComponent as EditIcon } from '../../assets/edit.svg' import XUDTTokenIcon from '../../assets/sudt_token.png' @@ -67,6 +69,7 @@ export const UDTOverviewCard = ({ const { t } = useTranslation() const isMobile = useIsMobile() const [isScriptDisplayed, setIsScriptDisplayed] = useState(false) + const [showHolderAmountModal, setShowHolderAmountModal] = useState(false) const [isModifyTokenInfoModalOpen, setIsModifyTokenInfoModalOpen] = useState(false) const issuer = xudt?.issuerAddress @@ -116,7 +119,18 @@ export const UDTOverviewCard = ({ }, { title: t('xudt.holder_addresses'), - content: xudt?.addressesCount ?? '-', + content: xudt?.addressesCount ? ( + { + setShowHolderAmountModal(true) + }} + > + {xudt.addressesCount} + + ) : ( + '-' + ), }, { title: t('xudt.symbol'), @@ -181,8 +195,16 @@ export const UDTOverviewCard = ({ + + setShowHolderAmountModal(false)} + ckbHolderAmount={xudt?.holderAllocation.ckbHoldersCount ?? '0'} + btcHolderAmount={xudt?.holderAllocation.btcHoldersCount ?? '0'} + lockHoderAmount={xudt?.holderAllocation.lockHoderAmount} + /> + - + {isScriptDisplayed ? (
@@ -194,7 +216,7 @@ export const UDTOverviewCard = ({
{t('xudt.type_script_hash')}
)} -
+ {isScriptDisplayed ? ( script &&