Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…frontend into testnet
  • Loading branch information
Keith-CY committed Sep 3, 2024
2 parents 7869ba4 + c682cf6 commit dccc4ba
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/pages/Address/BTCAddressComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,24 @@ enum AssetInfo {

export const BTCAddressOverviewCard: FC<{ address: Address }> = ({ address }) => {
const { t, i18n } = useTranslation()
const { udtAccounts = [] } = address
const [activeTab, setActiveTab] = useState<AssetInfo>(AssetInfo.RGBPP)

const { data } = useQuery(['bitcoin addresses', address], () =>
explorerService.api.fetchBitcoinAddresses(address.bitcoinAddressHash || ''),
)
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) {
Expand Down
7 changes: 6 additions & 1 deletion src/services/ExplorerService/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -254,6 +254,11 @@ export const apiFetcher = {
fetchBitcoinAddresses: (address: string) =>
requesterV2.get(`bitcoin_addresses/${address}`).then(res => toCamelcase<BitcoinAddresses>(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}`, {
Expand Down

0 comments on commit dccc4ba

Please sign in to comment.