From 09f7304a7d8e038f72b331e4bc9639300b68ca31 Mon Sep 17 00:00:00 2001 From: Anastasios Date: Tue, 3 Sep 2024 11:35:51 +0400 Subject: [PATCH] refactor: get all inscriptions data from bis api, ref leather-io/issues#267 --- package.json | 2 +- pnpm-lock.yaml | 18 +++++++++--------- .../pending-brc-20-transfers.tsx | 11 ++++++++--- .../ordinals/brc20/use-check-order-status.ts | 12 ++++++++++-- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index ff064be58f9..83c338668b9 100644 --- a/package.json +++ b/package.json @@ -141,7 +141,7 @@ "@leather.io/constants": "0.9.1", "@leather.io/crypto": "1.4.2", "@leather.io/models": "0.13.0", - "@leather.io/query": "2.7.0", + "@leather.io/query": "2.7.1", "@leather.io/stacks": "1.0.2", "@leather.io/tokens": "0.9.0", "@leather.io/ui": "1.14.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b4200c66ae0..9d0b8ead789 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -27,7 +27,7 @@ importers: version: 0.7.0(encoding@0.1.13) '@coinbase/cbpay-js': specifier: 2.1.0 - version: 2.1.0(regenerator-runtime@0.14.1) + version: 2.1.0(regenerator-runtime@0.13.11) '@fungible-systems/zone-file': specifier: 2.0.0 version: 2.0.0 @@ -47,8 +47,8 @@ importers: specifier: 0.13.0 version: 0.13.0 '@leather.io/query': - specifier: 2.7.0 - version: 2.7.0(@stacks/network@6.13.0(encoding@0.1.13))(encoding@0.1.13)(react@18.3.1) + specifier: 2.7.1 + version: 2.7.1(@stacks/network@6.13.0(encoding@0.1.13))(encoding@0.1.13)(react@18.3.1) '@leather.io/stacks': specifier: 1.0.2 version: 1.0.2(encoding@0.1.13) @@ -2551,7 +2551,7 @@ packages: '@expo/bunyan@4.0.1': resolution: {integrity: sha512-+Lla7nYSiHZirgK+U/uYzsLv/X+HaJienbD5AKX1UQZHYfWaP+9uuQluRB4GrEVWF0GZ7vEVp/jzaOT9k/SQlg==} - engines: {node: '>=0.10.0'} + engines: {'0': node >=0.10.0} '@expo/cli@0.18.28': resolution: {integrity: sha512-fvbVPId6s6etindzP6Nzos/CS1NurMVy4JKozjebArHr63tBid5i/UY5Pp+4wTCAM20gB2SjRdwcwoL6HFC4Iw==} @@ -2779,8 +2779,8 @@ packages: '@leather.io/prettier-config@0.6.0': resolution: {integrity: sha512-QBKtLanfxFxXBlR58U/j8a6lBI0xzJzqqi36fXpGVp+9mJoEf6Ro6xrtFrixjW6seY6EOva4OApVnnPBsvOC/w==} - '@leather.io/query@2.7.0': - resolution: {integrity: sha512-IWPJ+nYH2OR7Eb2WZ9Dkvs98/ffdJ1aXyIEomExuOLkTEmsxQvdZe4Bm0MtBwqFdzzmM1C7PSmbPuR521rpkHA==} + '@leather.io/query@2.7.1': + resolution: {integrity: sha512-TIew8kDeYGUbFOBVcWeFZuYCaSa2Pp2xfDUPxf/BicIsyYqXxFGoB5fclDqugratAWw9aZTTqsYcbMzg/+pwew==} peerDependencies: react: '*' @@ -16437,9 +16437,9 @@ snapshots: picocolors: 1.0.1 sisteransi: 1.0.5 - '@coinbase/cbpay-js@2.1.0(regenerator-runtime@0.14.1)': + '@coinbase/cbpay-js@2.1.0(regenerator-runtime@0.13.11)': optionalDependencies: - regenerator-runtime: 0.14.1 + regenerator-runtime: 0.13.11 '@cspotcode/source-map-support@0.8.1': dependencies: @@ -17635,7 +17635,7 @@ snapshots: - '@vue/compiler-sfc' - supports-color - '@leather.io/query@2.7.0(@stacks/network@6.13.0(encoding@0.1.13))(encoding@0.1.13)(react@18.3.1)': + '@leather.io/query@2.7.1(@stacks/network@6.13.0(encoding@0.1.13))(encoding@0.1.13)(react@18.3.1)': dependencies: '@fungible-systems/zone-file': 2.0.0 '@hirosystems/token-metadata-api-client': 1.2.0(encoding@0.1.13) diff --git a/src/app/features/pending-brc-20-transfers/pending-brc-20-transfers.tsx b/src/app/features/pending-brc-20-transfers/pending-brc-20-transfers.tsx index 8e4c10f6831..603c5dd708f 100644 --- a/src/app/features/pending-brc-20-transfers/pending-brc-20-transfers.tsx +++ b/src/app/features/pending-brc-20-transfers/pending-brc-20-transfers.tsx @@ -2,7 +2,11 @@ import { useNavigate } from 'react-router-dom'; import { Box, Flex, HStack, Stack } from 'leather-styles/jsx'; -import { fetchInscripionById, useOrdinalsbotClient } from '@leather.io/query'; +import { + createBestInSlotInscription, + useBitcoinClient, + useOrdinalsbotClient, +} from '@leather.io/query'; import { BulletSeparator, Caption, Flag } from '@leather.io/ui'; import { noop } from '@leather.io/utils'; @@ -90,6 +94,7 @@ function PendingBrcTransfer({ order }: PendingBrcTransferProps) { const { balance } = useCurrentBtcCryptoAssetBalanceNativeSegwit(); const hasPositiveBtcBalanceForFees = balance.availableBalance.amount.isGreaterThan(0); + const client = useBitcoinClient(); return ( { // Really inefficient, find way to not have to refetch data const { data: orderInfo } = await ordinalsbotClient.orderStatus(order.id); - const { data: inscription } = await fetchInscripionById( + const { data: inscription } = await client.BestInSlotApi.getInscriptionById( (orderInfo as any).files[0].tx?.inscription ); navigate(RouteUrls.SendOrdinalInscription, { state: { - inscription, + inscription: createBestInSlotInscription(inscription), }, }); } diff --git a/src/app/query/bitcoin/ordinals/brc20/use-check-order-status.ts b/src/app/query/bitcoin/ordinals/brc20/use-check-order-status.ts index 7adf7c5040f..3af484f9e72 100644 --- a/src/app/query/bitcoin/ordinals/brc20/use-check-order-status.ts +++ b/src/app/query/bitcoin/ordinals/brc20/use-check-order-status.ts @@ -1,6 +1,10 @@ import { useQueries } from '@tanstack/react-query'; -import { fetchInscripionById, useOrdinalsbotClient } from '@leather.io/query'; +import { + createBestInSlotInscription, + useBitcoinClient, + useOrdinalsbotClient, +} from '@leather.io/query'; import { useAppDispatch } from '@app/store'; import { @@ -16,6 +20,7 @@ export function useCheckOrderStatuses(ids: string[]) { const transferMap = usePendingBrc20TransferEntities(); const dispatch = useAppDispatch(); + const client = useBitcoinClient(); return useQueries({ queries: ids.map(id => ({ @@ -39,7 +44,10 @@ export function useCheckOrderStatuses(ids: string[]) { if ('tx' in file) { // see if its on hiro indexer try { - const { data: inscription } = await fetchInscripionById(file.tx?.inscription ?? ''); + const { data: inscriptionData } = await client.BestInSlotApi.getInscriptionById( + file.tx?.inscription ?? '' + ); + const inscription = createBestInSlotInscription(inscriptionData); // use number to determine legit if (inscription.number) { dispatch(