Skip to content

Commit

Permalink
fix: allow 404s when checking psbt utxos for ordinals
Browse files Browse the repository at this point in the history
  • Loading branch information
teebszet committed Dec 11, 2023
1 parent fdcd995 commit 918bccc
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/app/hooks/useDetectOrdinalInSignPsbt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
mapRareSatsAPIResponseToBundle,
ParsedPSBT,
} from '@secretkeylabs/xverse-core';
import { isAxiosError } from 'axios';
import useWalletSelector from './useWalletSelector';

export type InputsBundle = (Pick<Bundle, 'satRanges' | 'totalExoticSats'> & {
Expand All @@ -21,10 +22,21 @@ const useDetectOrdinalInSignPsbt = () => {

if (parsedPsbt) {
const inputsRequest = parsedPsbt.inputs.map((input) =>
getUtxoOrdinalBundle(network.type, input.txid, input.index),
getUtxoOrdinalBundle(network.type, input.txid, input.index).catch((e) => {
// we don't reject on 404s because if the UTXO is not found,
// it is likely this is a UTXO from an unpublished txn.
// this is required for gamma.io purchase flow
if (!isAxiosError(e) || e.response?.status !== 404) {
// rethrow error if response was not 404
throw e;
}
}),
);
const inputsResponse = await Promise.all(inputsRequest);
inputsResponse.forEach((inputResponse, index) => {
if (!inputResponse) {
return;
}
const bundle = mapRareSatsAPIResponseToBundle(inputResponse);
if (
bundle.inscriptions.length > 0 ||
Expand Down

0 comments on commit 918bccc

Please sign in to comment.