From 49f48299f582e1fbd28d6ea3e4e0d523cd577d63 Mon Sep 17 00:00:00 2001 From: poma Date: Thu, 15 Oct 2020 02:29:59 +0300 Subject: [PATCH] make estimateGas optional --- package.json | 2 +- src/Transaction.js | 8 +++++--- src/TxManager.js | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 95d61f0..5dcf935 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tx-manager", - "version": "0.1.0", + "version": "0.1.1", "description": "", "main": "index.js", "scripts": { diff --git a/src/Transaction.js b/src/Transaction.js index 53b0436..5b39f07 100644 --- a/src/Transaction.js +++ b/src/Transaction.js @@ -111,9 +111,11 @@ class Transaction { * @private */ async _prepare() { - const gas = await this._web3.eth.estimateGas(this.tx) - if (!this.tx.gas) { - this.tx.gas = Math.floor(gas * 1.1) + if (!this.tx.gas || this.config.ESTIMATE_GAS) { + const gas = await this._web3.eth.estimateGas(this.tx) + if (!this.tx.gas) { + this.tx.gas = Math.floor(gas * 1.1) + } } if (!this.tx.gasPrice) { this.tx.gasPrice = await this._getGasPrice('fast') diff --git a/src/TxManager.js b/src/TxManager.js index a078595..dd6eb1e 100644 --- a/src/TxManager.js +++ b/src/TxManager.js @@ -11,6 +11,7 @@ const defaultConfig = { MAX_GAS_PRICE: 1000, POLL_INTERVAL: 5000, CONFIRMATIONS: 8, + ESTIMATE_GAS: true, } class TxManager {