diff options
author | Kevin Serrano <kevin.serrano@consensys.net> | 2017-05-25 07:17:03 +0800 |
---|---|---|
committer | Kevin Serrano <kevin.serrano@consensys.net> | 2017-05-25 07:17:03 +0800 |
commit | 26fd016b63c4f3a15436d08dff9e94f72d2b4041 (patch) | |
tree | 2c16bd2443cfb4284bf708552194f219bd5c1df8 /app | |
parent | 1ffc6ea0b3a44efb579d1b9df81d52099fcc06ae (diff) | |
download | tangerine-wallet-browser-26fd016b63c4f3a15436d08dff9e94f72d2b4041.tar tangerine-wallet-browser-26fd016b63c4f3a15436d08dff9e94f72d2b4041.tar.gz tangerine-wallet-browser-26fd016b63c4f3a15436d08dff9e94f72d2b4041.tar.bz2 tangerine-wallet-browser-26fd016b63c4f3a15436d08dff9e94f72d2b4041.tar.lz tangerine-wallet-browser-26fd016b63c4f3a15436d08dff9e94f72d2b4041.tar.xz tangerine-wallet-browser-26fd016b63c4f3a15436d08dff9e94f72d2b4041.tar.zst tangerine-wallet-browser-26fd016b63c4f3a15436d08dff9e94f72d2b4041.zip |
Add new blockGasLimit property to txMeta object.
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/lib/tx-utils.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/app/scripts/lib/tx-utils.js b/app/scripts/lib/tx-utils.js index 76b311653..8cf304d0b 100644 --- a/app/scripts/lib/tx-utils.js +++ b/app/scripts/lib/tx-utils.js @@ -21,19 +21,30 @@ module.exports = class txProviderUtils { this.query.getBlockByNumber('latest', true, (err, block) => { if (err) return cb(err) async.waterfall([ + self.setBlockGasLimit.bind(self, txMeta, block.gasLimit), self.estimateTxGas.bind(self, txMeta, block.gasLimit), self.setTxGas.bind(self, txMeta, block.gasLimit), ], cb) }) } + setBlockGasLimit (txMeta, blockGasLimitHex, cb) { + const blockGasLimitBN = hexToBn(blockGasLimitHex) + const saferGasLimitBN = blockGasLimitBN.muln(0.95) + txMeta.blockGasLimit = bnToHex(saferGasLimitBN) + cb() + return + } + estimateTxGas (txMeta, blockGasLimitHex, cb) { const txParams = txMeta.txParams // check if gasLimit is already specified txMeta.gasLimitSpecified = Boolean(txParams.gas) // if not, fallback to block gasLimit if (!txMeta.gasLimitSpecified) { - txParams.gas = blockGasLimitHex + const blockGasLimitBN = hexToBn(blockGasLimitHex) + const saferGasLimitBN = blockGasLimitBN.muln(0.95) + txParams.gas = bnToHex(saferGasLimitBN) } // run tx, see if it will OOG this.query.estimateGas(txParams, cb) |