on master help sign in
Lightly refactor tx submission error detection
4449f00Fang
src/lib/txn.js+10−8
@@ -165,14 +165,16 @@ const sendSignedTransaction = (web3, stx, doubtNonceError, confirmationCb) => {
165 // that it's because the tank already submitted our transaction.
165 // that it's because the tank already submitted our transaction.
166 // we just wait for first confirmation here.
166 // we just wait for first confirmation here.
167 console.error(err);
167 console.error(err);
168− if (
168+ const isKnownError = (err.message || '').includes(
169− (err.message || '').includes('known transaction: ') ||
169+ 'known transaction: '
170− (doubtNonceError &&
170+ );
171− (err.message || '').includes(
171+ const isNonceError = (err.message || '').includes(
172− "the tx doesn't have the correct nonce."
172+ "the tx doesn't have the correct nonce."
173− ))
173+ );
174− ) {
174+ if (isKnownError || (doubtNonceError && isNonceError)) {
175+ console.log(
175− console.log('nonce error, likely from gas tank submission, ignoring');
176+ 'tx send error likely from gas tank submission, ignoring'
177+ );
176 const txHash = web3.utils.keccak256(rawTx);
178 const txHash = web3.utils.keccak256(rawTx);
177 //TODO can we do does-exists check first?
179 //TODO can we do does-exists check first?
178 //TODO max wait time before assume fail?
180 //TODO max wait time before assume fail?