From aaa7d66a7773d797b295c524e65b62b55b0d71fb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 02:44:41 +0900 Subject: [PATCH] Merge testnet into mainnet (#1531) Co-authored-by: Chen Yu --- src/components/Header/MenusComp/index.tsx | 6 + src/locales/en.json | 15 ++ src/locales/zh.json | 15 ++ src/models/Xudt/index.ts | 16 ++ src/pages/Xudt/UDTComp.tsx | 165 ++++++++++++++ src/pages/Xudt/index.tsx | 107 +++++++++ src/pages/Xudt/styled.tsx | 104 +++++++++ src/pages/Xudt/styles.module.scss | 140 ++++++++++++ src/pages/Xudts/index.tsx | 259 ++++++++++++++++++++++ src/pages/Xudts/styled.tsx | 70 ++++++ src/pages/Xudts/styles.module.scss | 252 +++++++++++++++++++++ src/routes/index.tsx | 10 + src/services/ExplorerService/fetcher.ts | 42 ++++ 13 files changed, 1201 insertions(+) create mode 100644 src/models/Xudt/index.ts create mode 100644 src/pages/Xudt/UDTComp.tsx create mode 100644 src/pages/Xudt/index.tsx create mode 100644 src/pages/Xudt/styled.tsx create mode 100644 src/pages/Xudt/styles.module.scss create mode 100644 src/pages/Xudts/index.tsx create mode 100644 src/pages/Xudts/styled.tsx create mode 100644 src/pages/Xudts/styles.module.scss diff --git a/src/components/Header/MenusComp/index.tsx b/src/components/Header/MenusComp/index.tsx index a5391a245..70afba563 100644 --- a/src/components/Header/MenusComp/index.tsx +++ b/src/components/Header/MenusComp/index.tsx @@ -37,6 +37,12 @@ const useMenuDataList = () => { type: LinkType.Inner, name: t('navbar.tokens'), children: [ + // TODO: wait for API + // { + // type: LinkType.Inner, + // name: t('navbar.xUDT'), + // url: '/xudts', + // }, { type: LinkType.Inner, name: t('navbar.sUDT'), diff --git a/src/locales/en.json b/src/locales/en.json index c3b11fe1a..2b2e65222 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -647,6 +647,21 @@ "view_original": "View Original", "repeat_inscription_symbol": "This inscription is a duplicate with an earlier release of the same symbol." }, + "xudt": { + "xudt": "xUDT", + "xudts": "xUDTs", + "name": "Name", + "symbol": "Symbol", + "total_amount": "Total Amount", + "issuer": "Issuer", + "type_script": "Type Script", + "holder_addresses": "Holder Addresses", + "decimal": "Decimal", + "transactions": "24hr Transactions", + "address_count": "Address Count", + "created_time": "Created Time", + "tokens_empty": "There are no xUDTs at this time." + }, "nft": { "nft_collection": "NFT Collection", "collection_name": "Collection Name", diff --git a/src/locales/zh.json b/src/locales/zh.json index 74addd64d..4d18dd265 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -648,6 +648,21 @@ "view_original": "查看原铭文", "repeat_inscription_symbol": "此铭文与早期发布的铭文同名" }, + "xudt": { + "xudt": "xUDT", + "xudts": "xUDTs", + "name": "名称", + "symbol": "符号", + "total_amount": "总量", + "issuer": "发行人", + "type_script": "Type Script", + "holder_addresses": "用户数", + "decimal": "小数位", + "transactions": "24小时交易数", + "address_count": "用户数", + "created_time": "创建时间", + "tokens_empty": "目前没有 xUDT。" + }, "nft": { "nft_collection": "NFT 藏品", "collection_name": "藏品名称", diff --git a/src/models/Xudt/index.ts b/src/models/Xudt/index.ts new file mode 100644 index 000000000..9d5adb810 --- /dev/null +++ b/src/models/Xudt/index.ts @@ -0,0 +1,16 @@ +import { Script } from '../Script' + +export interface XUDT { + addressesCount: string + createdAt: string + h24CkbTransactionsCount: string + issuerAddress: string + published: boolean + decimal: string | null + fullName: string | null + symbol: string | null + totalAmount: string + typeHash: string + typeScript: Script + udtType: 'xudt' +} diff --git a/src/pages/Xudt/UDTComp.tsx b/src/pages/Xudt/UDTComp.tsx new file mode 100644 index 000000000..60938543d --- /dev/null +++ b/src/pages/Xudt/UDTComp.tsx @@ -0,0 +1,165 @@ +import { Tooltip } from 'antd' +import { useTranslation } from 'react-i18next' +import { FC, useState } from 'react' +import { Link } from '../../components/Link' +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 } from '../../utils/util' +import styles from './styles.module.scss' +import AddressText from '../../components/AddressText' +import PaginationWithRear from '../../components/PaginationWithRear' +import { Transaction } from '../../models/Transaction' +import { Card, CardCellInfo, CardCellsLayout, HashCardHeader } from '../../components/Card' +import { useIsMobile } from '../../hooks' +import { isMainnet } from '../../utils/chain' +// TODO: replaced to svg format +import ArrowUpIcon from '../../assets/arrow_up.png' +import ArrowDownIcon from '../../assets/arrow_down.png' +import ArrowUpBlueIcon from '../../assets/arrow_up_blue.png' +import ArrowDownBlueIcon from '../../assets/arrow_down_blue.png' +import Script from '../../components/Script' +import { RawBtcRPC } from '../../services/ExplorerService' +import { XUDT } from '../../models/Xudt' + +const typeScriptIcon = (show: boolean) => { + if (show) { + return isMainnet() ? ArrowUpIcon : ArrowUpBlueIcon + } + return isMainnet() ? ArrowDownIcon : ArrowDownBlueIcon +} + +const IssuerContent: FC<{ address: string }> = ({ address }) => { + const { t } = useTranslation() + if (!address) { + return t('address.unable_decode_address') + } + const newAddress = deprecatedAddrToNewAddr(address) + + return ( + <> + + {newAddress} + + + {newAddress !== address && ( + + + + + + )} + + ) +} + +export const UDTOverviewCard = ({ typeHash, xudt }: { typeHash: string; xudt: XUDT | undefined }) => { + const { t } = useTranslation() + const isMobile = useIsMobile() + // const { fullName, issuerAddress, symbol, addressesCount, decimal, totalAmount, typeScript } = xudt + const [showType, setShowType] = useState(false) + + const items: CardCellInfo<'left' | 'right'>[] = [ + { + title: t('xudt.name'), + content: xudt?.fullName ?? '-', + }, + { + title: t('xudt.issuer'), + contentWrapperClass: styles.addressWidthModify, + content: xudt ? : '-', + }, + { + title: t('xudt.holder_addresses'), + content: xudt?.addressesCount ?? '-', + }, + { + title: t('xudt.symbol'), + content: xudt?.symbol ?? '-', + }, + { + title: t('xudt.decimal'), + content: xudt?.decimal ?? '-', + }, + { + title: t('xudt.total_amount'), + content: xudt?.totalAmount && xudt?.decimal ? parseUDTAmount(xudt.totalAmount, xudt.decimal) : '-', + }, + ] + + const cardTitle =
{xudt?.symbol ?? t('xudt.xudt')}
+ + return ( + <> + + {/* When encountering more complex requirements, consider extracting the components within HashCardHeader + into smaller components. Then, implement a completely new variant or freely assemble them externally. */} + {isMobile && cardTitle} + + + + + setShowType(!showType)}> +
{t('xudt.type_script')}
+ type script +
+ {showType && xudt?.typeScript &&