on master help sign in
More robust nonce error detection in /lib/invite
29be6a7Fang
src/bridge/lib/invite.js+2−2
@@ -389,6 +389,7 @@ async function waitForBalance(web3, address, minBalance, updateProgress) {
389 });
389 });
390}
390}
391
391
392+//TODO replace with txn.sendSignedTransaction? it can doubt nonce errors too
392async function sendAndAwaitConfirm(web3, signedTxs) {
393async function sendAndAwaitConfirm(web3, signedTxs) {
393 await Promise.all(signedTxs.map(tx => {
394 await Promise.all(signedTxs.map(tx => {
394 console.log('sending...');
395 console.log('sending...');
@@ -403,8 +404,7 @@ async function sendAndAwaitConfirm(web3, signedTxs) {
403 // this is really only the case in local dev environments.
404 // this is really only the case in local dev environments.
404 const txHash = web3.utils.keccak256(tx);
405 const txHash = web3.utils.keccak256(tx);
405 console.log(err.message);
406 console.log(err.message);
406− if (err.message.slice(0,54) ===
407− "Returned error: the tx doesn't have the correct nonce.") {
407+ if (err.message.includes("the tx doesn't have the correct nonce.")) {
408 console.log('nonce error, awaiting confirm', err.message.slice(55));
408 console.log('nonce error, awaiting confirm', err.message.slice(55));
409 //TODO max wait time before assume failure?
409 //TODO max wait time before assume failure?
410 let res = await waitForTransactionConfirm(web3, txHash);
410 let res = await waitForTransactionConfirm(web3, txHash);