Skip to content

Commit cf72e09

Browse files
committed
fix: utxo inscription check html page path
1 parent a9bf7c3 commit cf72e09

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

apps/mobile/src/queries/transaction/use-check-utxos.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { TransactionInput } from '@scure/btc-signer/psbt';
44
import { bytesToHex } from '@stacks/common';
55

66
import { BitcoinError } from '@leather.io/bitcoin';
7-
import { BitcoinClient, getNumberOfInscriptionOnUtxoUsingOrdinalsCom } from '@leather.io/query';
7+
import { BitcoinClient, getNumberOfInscriptionsOnUtxoUsingOrdinalsCom } from '@leather.io/query';
88
import { isUndefined } from '@leather.io/utils';
99

1010
import { useBitcoinClient } from '../clients/bitcoin-client';
@@ -83,7 +83,7 @@ export function useCheckUnspendableUtxos(blockTxAction?: () => void) {
8383
if (isUndefined(inscriptionIndex)) {
8484
throw new Error('Inscription index is missing in the input');
8585
}
86-
const num = await getNumberOfInscriptionOnUtxoUsingOrdinalsCom(id, inscriptionIndex);
86+
const num = await getNumberOfInscriptionsOnUtxoUsingOrdinalsCom(id, inscriptionIndex);
8787
return num > 0;
8888
})
8989
);

packages/query/src/bitcoin/ordinals/inscriptions.query.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,26 @@ export function createGetInscriptionsByAddressCacheKey(address: string, networkI
88
return [BitcoinQueryPrefixes.GetInscriptionsByAddress, networkId, address];
99
}
1010

11-
// In lieu of reliable API, we scrape HTML from the Ordinals.com explorer and
12-
// parses the HTML
13-
// Example:
14-
// https://ordinals.com/output/758bd2703dd9f0a2df31c2898aecf6caba05a906498c9bc076947f9fc4d8f081:0
11+
// In lieu of reliable API, we scrape HTML from the ordinals.com explorer
12+
// Ex: https://ordinals.com/output/758bd2703dd9f0a2df31c2898aecf6caba05a906498c9bc076947f9fc4d8f081:0
1513
async function getOrdinalsComTxOutputHtmlPage(id: string, index: number) {
16-
const resp = await axios.get(`https://ordinals-explorer.generative.xyz/output/${id}:${index}`);
14+
const resp = await axios.get(`https://ordinals.com/output/${id}:${index}`);
1715
return new DOMParser().parseFromString(resp.data, 'text/html');
1816
}
1917

20-
export async function getNumberOfInscriptionOnUtxoUsingOrdinalsCom(id: string, index: number) {
18+
export async function getNumberOfInscriptionsOnUtxoUsingOrdinalsCom(id: string, index: number) {
2119
const utxoPage = await getOrdinalsComTxOutputHtmlPage(id, index);
2220

23-
// First content on page is inscrption section header and thumbnail of
24-
// inscrptions in utxo
21+
// First content on page is inscrption section header and thumbnail of inscrptions in utxo
2522
const firstSectionHeader = utxoPage.querySelector('dl > dt:first-child');
2623
if (!firstSectionHeader)
2724
throw new Error('If no element matching this selector is found, something is wrong');
2825

2926
const firstHeaderText = firstSectionHeader.textContent;
3027
const thumbnailCount = utxoPage.querySelectorAll('dl > dt:first-child + dd.thumbnails a').length;
3128

32-
// Were HTML to page to change, thumbnailCount alone would dangerously return
33-
// zero 0, hence additional check that inscrption header is also missing
29+
// Were HTML page to change, thumbnailCount alone would dangerously return zero,
30+
// hence additional check that inscription header is also missing
3431
if (thumbnailCount === 0 && firstHeaderText !== 'inscriptions') return 0;
3532

3633
return thumbnailCount;

0 commit comments

Comments
 (0)