fix: handleRpcError with web3 provider

This commit is contained in:
Danil Kovtonyuk 2022-07-14 00:28:26 +10:00
parent 2c17b8c3a4
commit 7c7446d46b
No known key found for this signature in database
GPG Key ID: E72A919BF08C3746
1 changed files with 33 additions and 35 deletions

View File

@ -11,12 +11,11 @@ const nonceErrors = [
/OldNonce/,
'invalid transaction nonce',
]
const nonceErrorCodes = ['SERVER_ERROR', 'NONCE_EXPIRED']
const gasPriceErrors = [
'Transaction gas price supplied is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce.',
/replacement transaction underpriced/i,
/transaction underpriced/,
/fee too low/i,
/Transaction gas price \d+wei is too low. There is another transaction with same nonce in the queue with gas price: \d+wei. Try increasing the gas price or incrementing the nonce./,
/FeeTooLow/,
/max fee per gas less than block base fee/,
@ -323,8 +322,8 @@ class Transaction {
e = e.error
}
if (e.error && nonceErrorCodes.includes(e.code)) {
const message = e.error.message
// web3 provider not wrapping message
const message = e.error?.message || e.message
// nonce is too low, trying to increase and resubmit
if (this._hasError(message, nonceErrors)) {
@ -359,7 +358,6 @@ class Transaction {
console.log('Same transaction is already in mempool, skipping submit')
return // do nothing
}
}
throw new Error(`Send error: ${e}`)
}