Skip to content

Commit

Permalink
refactor: get all inscriptions data from bis api, ref leather-io/issu…
Browse files Browse the repository at this point in the history
  • Loading branch information
alter-eggo committed Sep 3, 2024
1 parent 003a6ad commit 09f7304
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -90,6 +94,7 @@ function PendingBrcTransfer({ order }: PendingBrcTransferProps) {
const { balance } = useCurrentBtcCryptoAssetBalanceNativeSegwit();

const hasPositiveBtcBalanceForFees = balance.availableBalance.amount.isGreaterThan(0);
const client = useBitcoinClient();

return (
<Box
Expand All @@ -101,12 +106,12 @@ function PendingBrcTransfer({ order }: PendingBrcTransferProps) {
? async () => {
// 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),
},
});
}
Expand Down
12 changes: 10 additions & 2 deletions src/app/query/bitcoin/ordinals/brc20/use-check-order-status.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -16,6 +20,7 @@ export function useCheckOrderStatuses(ids: string[]) {

const transferMap = usePendingBrc20TransferEntities();
const dispatch = useAppDispatch();
const client = useBitcoinClient();

return useQueries({
queries: ids.map(id => ({
Expand All @@ -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(
Expand Down

0 comments on commit 09f7304

Please sign in to comment.