Skip to content

Commit

Permalink
refactor: bitcoin queries, closes leather-io/issues#94 and leather-io…
Browse files Browse the repository at this point in the history
  • Loading branch information
fbwoolf committed Jul 20, 2024
1 parent 85d34b3 commit 1187acf
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 31 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"@leather.io/constants": "0.8.2",
"@leather.io/crypto": "1.0.4",
"@leather.io/models": "0.10.2",
"@leather.io/query": "1.0.2",
"@leather.io/query": "2.0.0",
"@leather.io/tokens": "0.6.2",
"@leather.io/ui": "1.6.4",
"@leather.io/utils": "0.10.2",
Expand Down
28 changes: 14 additions & 14 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
@@ -1,7 +1,7 @@
import { sanitize } from 'dompurify';
import { Box } from 'leather-styles/jsx';

import { useInscriptionTextContentQuery } from '@leather.io/query';
import { useGetInscriptionTextContentQuery } from '@leather.io/query';

import { parseJson } from '@app/components/json';
import { LoadingSpinner } from '@app/components/loading-spinner';
Expand All @@ -10,7 +10,7 @@ interface InscriptionTextProps {
contentSrc: string;
}
export function InscriptionText(props: InscriptionTextProps) {
const query = useInscriptionTextContentQuery(props.contentSrc);
const query = useGetInscriptionTextContentQuery(props.contentSrc);

if (query.isLoading) return <LoadingSpinner size="16px" />;

Expand Down
4 changes: 2 additions & 2 deletions src/app/features/activity-list/activity-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import uniqby from 'lodash.uniqby';
import {
useBitcoinPendingTransactions,
useGetAccountTransactionsWithTransfersQuery,
useGetBitcoinTransactionsByAddressesQuery,
useGetBitcoinTransactionsByAddressListQuery,
useStacksPendingTransactions,
} from '@leather.io/query';

Expand Down Expand Up @@ -52,7 +52,7 @@ export function ActivityList() {
const [
{ isLoading: isLoadingNsBitcoinTransactions, data: nsBitcoinTransactions = [] },
{ isLoading: isLoadingTrBitcoinTransactions, data: trBitcoinTransactions = [] },
] = useGetBitcoinTransactionsByAddressesQuery([nsBitcoinAddress, trBitcoinAddress]);
] = useGetBitcoinTransactionsByAddressListQuery([nsBitcoinAddress, trBitcoinAddress]);

const [{ data: nsPendingTxs = [] }, { data: trPendingTxs = [] }] = useBitcoinPendingTransactions([
nsBitcoinAddress,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useInscriptionTextContentQuery } from '@leather.io/query';
import { useGetInscriptionTextContentQuery } from '@leather.io/query';
import { OrdinalAvatarIcon } from '@leather.io/ui';

import { parseJson } from '@app/components/json';
Expand All @@ -17,7 +17,7 @@ export function InscriptionText({
onClickCallToAction,
onClickSend,
}: InscriptionTextProps) {
const query = useInscriptionTextContentQuery(contentSrc);
const query = useGetInscriptionTextContentQuery(contentSrc);

if (query.isLoading || query.isError) return null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ function areAnyQueriesFetching(...args: number[]) {

export function useIsFetchingCollectiblesRelatedQuery() {
// Ordinal inscriptions
const n1 = useIsFetching({ queryKey: [BitcoinQueryPrefixes.TaprootAddressUtxos] });
const n2 = useIsFetching({ queryKey: [BitcoinQueryPrefixes.InscriptionsByAddress] });
const n3 = useIsFetching({ queryKey: [BitcoinQueryPrefixes.InscriptionMetadata] });
const n4 = useIsFetching({ queryKey: [BitcoinQueryPrefixes.OrdinalTextContent] });
const n1 = useIsFetching({ queryKey: [BitcoinQueryPrefixes.GetTaprootUtxosByAddress] });
const n2 = useIsFetching({ queryKey: [BitcoinQueryPrefixes.GetInscriptionsByAddress] });
const n3 = useIsFetching({ queryKey: [BitcoinQueryPrefixes.GetInscription] });
const n4 = useIsFetching({ queryKey: [BitcoinQueryPrefixes.GetInscriptionTextContent] });
const n5 = useIsFetching({ queryKey: [BitcoinQueryPrefixes.GetInscriptions] });

// BNS
Expand Down
4 changes: 2 additions & 2 deletions test-app/src/components/debugger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export const Debugger = () => {
bufferCV(Buffer.from('hello, world')),
stringAsciiCV('hey-ascii'),
stringUtf8CV('hey-utf8'),
standardPrincipalCV('ST1X6M947Z7E58CNE0H8YJVJTVKS9VW0PHEG3NHN3'),
standardPrincipalCV('STS8CKF63P16J28AYF7PXW9E5AACH0NZNRV74CM7'),
trueCV(),
];
const postConditions = [
Expand All @@ -150,7 +150,7 @@ export const Debugger = () => {
console.log('creating allow mode contract call');
await doContractCall({
network,
contractAddress: 'ST1X6M947Z7E58CNE0H8YJVJTVKS9VW0PHEG3NHN3',
contractAddress: 'STS8CKF63P16J28AYF7PXW9E5AACH0NZNRV74CM7',
contractName: 'faker',
functionName: 'rawr',
functionArgs: args,
Expand Down
8 changes: 4 additions & 4 deletions tests/mocks/mock-inscriptions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type InscriptionResponseHiro, createInscriptionHiro } from '@leather.io/query';
import { type InscriptionResponseHiro, createHiroInscription } from '@leather.io/query';

export const mockInscriptionResponse1: InscriptionResponseHiro = {
address: 'bc1pwrmewwprc8k8l2k63x4advg0nx0jk50xzqnee996lm87mcuza7kq6drg2k',
Expand Down Expand Up @@ -27,7 +27,7 @@ export const mockInscriptionResponse1: InscriptionResponseHiro = {
value: '10000',
};

export const mockInscription1 = createInscriptionHiro(mockInscriptionResponse1);
export const mockInscription1 = createHiroInscription(mockInscriptionResponse1);

export const mockInscriptionResponse2: InscriptionResponseHiro = {
address: 'bc1pwrmewwprc8k8l2k63x4advg0nx0jk50xzqnee996lm87mcuza7kq6drg2k',
Expand Down Expand Up @@ -56,7 +56,7 @@ export const mockInscriptionResponse2: InscriptionResponseHiro = {
value: '10000',
};

export const mockInscription2 = createInscriptionHiro(mockInscriptionResponse2);
export const mockInscription2 = createHiroInscription(mockInscriptionResponse2);

export const mockInscriptionResponsesList = [
{
Expand Down Expand Up @@ -86,4 +86,4 @@ export const mockInscriptionResponsesList = [
value: '546',
},
];
export const mockInscriptionsList = mockInscriptionResponsesList.map(createInscriptionHiro);
export const mockInscriptionsList = mockInscriptionResponsesList.map(createHiroInscription);
1 change: 1 addition & 0 deletions tests/specs/transactions/transactions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ test.describe('Transaction signing', () => {

await testAppPage.clickContractCallButton();
const transactionRequestPage = new TransactionRequestPage(await context.waitForEvent('page'));
await transactionRequestPage.waitForTransactionRequestPage();
const error =
await transactionRequestPage.waitForTransactionRequestError('Insufficient balance');

Expand Down

0 comments on commit 1187acf

Please sign in to comment.