on master help sign in
txn: more thorough nonce error detection
71bb130Fang
src/lib/txn.js+8−8
@@ -127,20 +127,20 @@ const sendSignedTransaction = (web3, stx, doubtNonceError) => {
127 // if there's a nonce error, but we used the gas tank, it's likely
127 // if there's a nonce error, but we used the gas tank, it's likely
128 // that it's because the tank already submitted our transaction.
128 // that it's because the tank already submitted our transaction.
129 // we just wait for first confirmation here.
129 // we just wait for first confirmation here.
130− console.error(err);
130+ const message = err.message || '';
131− const isKnownError = (err.message || '').includes(
131+ const isKnownError = message.includes('known transaction: ');
132− 'known transaction: '
133− );
134− const isNonceError = (err.message || '').includes(
132+ const isNonceError =
135− "the tx doesn't have the correct nonce."
133+ message.includes("the tx doesn't have the correct nonce.") ||
136− );
134+ message.includes('nonce too low');
137 if (isKnownError || (doubtNonceError && isNonceError)) {
135 if (isKnownError || (doubtNonceError && isNonceError)) {
138 console.log(
136 console.log(
139− 'tx send error likely from gas tank submission, ignoring'
137+ 'tx send error likely from gas tank submission, ignoring:',
138+ message
140 );
139 );
141 const txHash = web3.utils.keccak256(rawTx);
140 const txHash = web3.utils.keccak256(rawTx);
142 resolve(txHash);
141 resolve(txHash);
143 } else {
142 } else {
143+ console.error(err);
144 reject(err.message || 'Transaction sending failed!');
144 reject(err.message || 'Transaction sending failed!');
145 }
145 }
146 });
146 });