Skip to content

Commit

Permalink
fix: add error.txId if not found onchain
Browse files Browse the repository at this point in the history
  • Loading branch information
fibonacci998 committed Apr 16, 2024
1 parent a2fe13c commit 3157a2f
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions src/connectors/halotrade/halotrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
} from '../../services/error-handler';
import { DirectSecp256k1Wallet } from 'cosmjs-proto-signing-0.32';
import { GasPrice } from 'cosmjs-stargate-0.32';
import { TimeoutError } from '@cosmjs/stargate';
// import e from 'express';
// import { pow } from 'mathjs';

Expand Down Expand Up @@ -271,17 +272,28 @@ export class Halotrade {
console.log(gasUsed);
return { gasUsed };
} else {
const result = await signingClient.signAndBroadcast(
req.address,
[executeContractMsg],
'auto',
memo
);
return {
txhash: result.transactionHash,
expectedPrice: 0,
expectedAmount: 0,
};
try {
const result = await signingClient.signAndBroadcast(
req.address,
[executeContractMsg],
'auto',
memo
);
return {
txhash: result.transactionHash,
expectedPrice: 0,
expectedAmount: 0,
};
} catch (error) {
console.error(error);
if (error instanceof TimeoutError) {
return {
txhash: error.txId,
expectedPrice: 0,
expectedAmount: 0,
};
} else throw error;
}
}
}

Expand Down

0 comments on commit 3157a2f

Please sign in to comment.