more general fix for tx error

This commit is contained in:
poma 2020-11-26 10:34:40 +03:00
parent 780df01b43
commit 414fb28a5e
No known key found for this signature in database
GPG Key ID: BA20CB01FE165657
2 changed files with 10 additions and 3 deletions

@ -1,6 +1,6 @@
{
"name": "tx-manager",
"version": "0.2.8",
"version": "0.2.9",
"description": "",
"main": "index.js",
"scripts": {

@ -13,12 +13,14 @@ const nonceErrors = [
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',
'transaction underpriced',
/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./,
]
// prettier-ignore
const sameTxErrors = [
'Transaction with the same hash was already imported.',
'already known',
]
class Transaction {
@ -268,8 +270,13 @@ class Transaction {
}
_handleSendError(e) {
if (e.error && e.error.code === 'SERVER_ERROR') {
const message = e.error.error.message
if (e.error.error) {
// Sometimes ethers wraps known errors, unwrap it in this case
e = e.error
}
if (e.error && e.code === 'SERVER_ERROR') {
const message = e.error.message
// nonce is too low, trying to increase and resubmit
if (this._hasError(message, nonceErrors)) {