Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5e4d76dc5 | ||
|
|
8cb2bb0fbe | ||
|
|
6bb265d3b9 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "tx-manager",
|
||||
"version": "0.2.4",
|
||||
"version": "0.2.7",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -4,10 +4,10 @@ const BigNumber = ethers.BigNumber
|
||||
const PromiEvent = require('web3-core-promievent')
|
||||
const { sleep, min, max } = require('./utils')
|
||||
|
||||
// prettier-ignore
|
||||
const nonceErrors = [
|
||||
'Transaction nonce is too low. Try incrementing the nonce.',
|
||||
'nonce too low'
|
||||
'nonce too low',
|
||||
'nonce has already been used',
|
||||
]
|
||||
|
||||
const gasPriceErrors = [
|
||||
@@ -182,6 +182,9 @@ class Transaction {
|
||||
this._emitter.emit('confirmations', confirmations)
|
||||
if (confirmations >= this.config.CONFIRMATIONS) {
|
||||
// Tx is mined and has enough confirmations
|
||||
if (this.config.THROW_ON_REVERT && Number(receipt.status) === 0) {
|
||||
throw new Error('EVM execution failed, so the transaction was reverted.')
|
||||
}
|
||||
return receipt
|
||||
}
|
||||
|
||||
@@ -234,7 +237,6 @@ class Transaction {
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Mined. Start waiting for confirmations...')
|
||||
this._emitter.emit('mined', receipt)
|
||||
this.currentTxHash = receipt.transactionHash
|
||||
}
|
||||
@@ -266,11 +268,8 @@ class Transaction {
|
||||
}
|
||||
|
||||
_handleSendError(e) {
|
||||
console.log('Got error', e)
|
||||
|
||||
if (e.code === 'SERVER_ERROR' && e.error) {
|
||||
const message = e.error.message
|
||||
console.log('Error', e.error.code, e.error.message)
|
||||
|
||||
// nonce is too low, trying to increase and resubmit
|
||||
if (this._hasError(message, nonceErrors)) {
|
||||
|
||||
@@ -13,6 +13,7 @@ const defaultConfig = {
|
||||
POLL_INTERVAL: 5000,
|
||||
CONFIRMATIONS: 8,
|
||||
ESTIMATE_GAS: true,
|
||||
THROW_ON_REVERT: true,
|
||||
}
|
||||
|
||||
class TxManager {
|
||||
|
||||
Reference in New Issue
Block a user