diff --git a/src/pages/Address/BTCAddressComp.tsx b/src/pages/Address/BTCAddressComp.tsx index 16ea25b80..157eca617 100644 --- a/src/pages/Address/BTCAddressComp.tsx +++ b/src/pages/Address/BTCAddressComp.tsx @@ -18,7 +18,6 @@ enum AssetInfo { export const BTCAddressOverviewCard: FC<{ address: Address }> = ({ address }) => { const { t, i18n } = useTranslation() - const { udtAccounts = [] } = address const [activeTab, setActiveTab] = useState(AssetInfo.RGBPP) const { data } = useQuery(['bitcoin addresses', address], () => @@ -26,6 +25,17 @@ export const BTCAddressOverviewCard: FC<{ address: Address }> = ({ address }) => ) const { boundLiveCellsCount, unboundLiveCellsCount } = data || { boundLiveCellsCount: 0, unboundLiveCellsCount: 0 } + const { data: udtAccounts } = useQuery( + ['bitcoin address udt accounts', address], + async () => { + const data = await explorerService.api.fetchUDTAccountsByBtcAddress(address.bitcoinAddressHash || '') + return data.udtAccounts + }, + { + initialData: [], + }, + ) + const [udts, inscriptions] = udtAccounts.reduce( (acc, cur) => { switch (cur?.udtType) { diff --git a/src/services/ExplorerService/fetcher.ts b/src/services/ExplorerService/fetcher.ts index 775a72fe0..b395471be 100644 --- a/src/services/ExplorerService/fetcher.ts +++ b/src/services/ExplorerService/fetcher.ts @@ -23,7 +23,7 @@ import { Cell } from '../../models/Cell' import { Script } from '../../models/Script' import { Block } from '../../models/Block' import { BtcTx, Transaction } from '../../models/Transaction' -import { Address, AddressType } from '../../models/Address' +import { Address, AddressType, UDTAccount } from '../../models/Address' import { OmigaInscriptionCollection, UDT } from '../../models/UDT' import { XUDT, XUDTHolderAllocation } from '../../models/Xudt' import { HashType } from '../../constants/common' @@ -254,6 +254,11 @@ export const apiFetcher = { fetchBitcoinAddresses: (address: string) => requesterV2.get(`bitcoin_addresses/${address}`).then(res => toCamelcase(res.data)), + fetchUDTAccountsByBtcAddress: (address: string) => + requesterV2 + .get(`bitcoin_addresses/${address}/udt_accounts`) + .then(res => toCamelcase<{ udtAccounts: UDTAccount[] }>(res.data.data)), + fetchCellsByTxHash: (hash: string, type: 'inputs' | 'outputs', page: Record<'no' | 'size', number>) => requesterV2 .get(`ckb_transactions/${hash}/display_${type}`, {