Skip to content

Commit

Permalink
fix: send inscription error processing, closes #4286
Browse files Browse the repository at this point in the history
  • Loading branch information
alter-eggo committed Sep 29, 2023
1 parent 7f7c7c5 commit f73f3a4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,37 @@ export function useSendInscriptionForm() {
isCheckingFees,
async chooseTransactionFee(values: OrdinalSendFormValues) {
setIsCheckingFees(true);
// Check tx with lowest fee for errors before routing and
// generating the final transaction with the chosen fee to send
const resp = coverFeeFromAdditionalUtxos(values);

if (!resp) {
setShowError(
'Insufficient funds to cover fee. Deposit some BTC to your Native Segwit address.'
);
return;
}
try {
// Check tx with lowest fee for errors before routing and
// generating the final transaction with the chosen fee to send
const resp = coverFeeFromAdditionalUtxos(values);

if (Number(inscription.offset) !== 0) {
setShowError('Sending inscriptions at non-zero offsets is unsupported');
return;
}
if (!resp) {
setShowError(
'Insufficient funds to cover fee. Deposit some BTC to your Native Segwit address.'
);
return;
}

if (Number(inscription.offset) !== 0) {
setShowError('Sending inscriptions at non-zero offsets is unsupported');
return;
}

try {
const numInscriptionsOnUtxo = await getNumberOfInscriptionOnUtxo(utxo.txid, utxo.vout);
if (numInscriptionsOnUtxo > 1) {
setShowError('Sending inscription from utxo with multiple inscriptions is unsupported');
return;
}
} catch (error) {
void analytics.track('ordinals_dot_com_unavailable', { error });
setShowError('Unable to establish if utxo has multiple inscriptions');
return;

let message = 'Unable to establish if utxo has multiple inscriptions';
if (error instanceof Error) {
message = error.message;
}
setShowError(message);
} finally {
setIsCheckingFees(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BitcoinTx } from '@shared/models/transactions/bitcoin-transaction.model
import { AppUseQueryConfig } from '@app/query/query-config';
import { useBitcoinClient } from '@app/store/common/api-clients.hooks';

const staleTime = 5 * 1000;
const staleTime = 10 * 1000;

const queryOptions = { staleTime, refetchInterval: staleTime };

Expand Down Expand Up @@ -34,7 +34,7 @@ export function useGetBitcoinTransactionsByAddressesQuery<T extends unknown = Bi
queries: addresses.map(address => {
return {
enabled: !!address,
queryKey: ['btc-txs-by-addresses', address],
queryKey: ['btc-txs-by-address', address],
queryFn: () => client.addressApi.getTransactionsByAddress(address),
...queryOptions,
...options,
Expand Down

0 comments on commit f73f3a4

Please sign in to comment.