THROW_ON_REVERT feature
This commit is contained in:
parent
6bb265d3b9
commit
8cb2bb0fbe
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tx-manager",
|
"name": "tx-manager",
|
||||||
"version": "0.2.5",
|
"version": "0.2.6",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -175,9 +175,6 @@ class Transaction {
|
|||||||
this.currentTxHash = null
|
this.currentTxHash = null
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (Number(receipt.status) === 0) {
|
|
||||||
throw new Error('Transaction failed')
|
|
||||||
}
|
|
||||||
|
|
||||||
const currentBlock = await this._provider.getBlockNumber()
|
const currentBlock = await this._provider.getBlockNumber()
|
||||||
const confirmations = Math.max(0, currentBlock - receipt.blockNumber)
|
const confirmations = Math.max(0, currentBlock - receipt.blockNumber)
|
||||||
@ -185,6 +182,9 @@ class Transaction {
|
|||||||
this._emitter.emit('confirmations', confirmations)
|
this._emitter.emit('confirmations', confirmations)
|
||||||
if (confirmations >= this.config.CONFIRMATIONS) {
|
if (confirmations >= this.config.CONFIRMATIONS) {
|
||||||
// Tx is mined and has enough 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
|
return receipt
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,10 +237,6 @@ class Transaction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Number(receipt.status) === 0) {
|
|
||||||
throw new Error('Transaction failed')
|
|
||||||
}
|
|
||||||
|
|
||||||
this._emitter.emit('mined', receipt)
|
this._emitter.emit('mined', receipt)
|
||||||
this.currentTxHash = receipt.transactionHash
|
this.currentTxHash = receipt.transactionHash
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ const defaultConfig = {
|
|||||||
POLL_INTERVAL: 5000,
|
POLL_INTERVAL: 5000,
|
||||||
CONFIRMATIONS: 8,
|
CONFIRMATIONS: 8,
|
||||||
ESTIMATE_GAS: true,
|
ESTIMATE_GAS: true,
|
||||||
|
THROW_ON_REVERT: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
class TxManager {
|
class TxManager {
|
||||||
|
Loading…
Reference in New Issue
Block a user