make estimateGas optional

This commit is contained in:
poma 2020-10-15 02:29:59 +03:00
parent cdc6429a27
commit 49f48299f5
No known key found for this signature in database
GPG Key ID: BA20CB01FE165657
3 changed files with 7 additions and 4 deletions

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

@ -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')

@ -11,6 +11,7 @@ const defaultConfig = {
MAX_GAS_PRICE: 1000,
POLL_INTERVAL: 5000,
CONFIRMATIONS: 8,
ESTIMATE_GAS: true,
}
class TxManager {