diff options
author | Dan Finlay <flyswatter@users.noreply.github.com> | 2017-05-25 07:36:00 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-25 07:36:00 +0800 |
commit | 764806d211e026226bf8003cbdd6ff3ec570d5db (patch) | |
tree | 51954c6b0459310b0f6c4457fa181e8e6d29e44b /app/scripts | |
parent | a5f6cfe7d7c38686679ad8a5870630d12569f8e2 (diff) | |
parent | b95f2158bb3094f6a47236c2e0e4e0ae9b87bb91 (diff) | |
download | tangerine-wallet-browser-764806d211e026226bf8003cbdd6ff3ec570d5db.tar tangerine-wallet-browser-764806d211e026226bf8003cbdd6ff3ec570d5db.tar.gz tangerine-wallet-browser-764806d211e026226bf8003cbdd6ff3ec570d5db.tar.bz2 tangerine-wallet-browser-764806d211e026226bf8003cbdd6ff3ec570d5db.tar.lz tangerine-wallet-browser-764806d211e026226bf8003cbdd6ff3ec570d5db.tar.xz tangerine-wallet-browser-764806d211e026226bf8003cbdd6ff3ec570d5db.tar.zst tangerine-wallet-browser-764806d211e026226bf8003cbdd6ff3ec570d5db.zip |
Merge pull request #1494 from MetaMask/1472-gasceiling
Add Max GasLimit Ceiling
Diffstat (limited to 'app/scripts')
-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) |