on master help sign in
Lightly refactor tx submission error detection
commit4449f0097533a7cfc57f5cd56d50807b3b61477b authorFang <git@fang.io> dateMon 15 Jul 2019, 20:49 (7 years ago) parentc3085a8
1 file changed+10−8
src/lib/txn.js+10−8
src/lib/txn.js+10−8
@@ -165,14 +165,16 @@ const sendSignedTransaction = (web3, stx, doubtNonceError, confirmationCb) => {
165165 // that it's because the tank already submitted our transaction.
166166 // we just wait for first confirmation here.
167167 console.error(err);
168− if (
169− (err.message || '').includes('known transaction: ') ||
170− (doubtNonceError &&
171− (err.message || '').includes(
172− "the tx doesn't have the correct nonce."
173− ))
174− ) {
175− console.log('nonce error, likely from gas tank submission, ignoring');
168+ const isKnownError = (err.message || '').includes(
169+ 'known transaction: '
170+ );
171+ const isNonceError = (err.message || '').includes(
172+ "the tx doesn't have the correct nonce."
173+ );
174+ if (isKnownError || (doubtNonceError && isNonceError)) {
175+ console.log(
176+ 'tx send error likely from gas tank submission, ignoring'
177+ );
176178 const txHash = web3.utils.keccak256(rawTx);
177179 //TODO can we do does-exists check first?
178180 //TODO max wait time before assume fail?