diff options
author | frankiebee <frankie.diamond@gmail.com> | 2017-05-25 11:10:58 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2017-05-25 11:10:58 +0800 |
commit | 3b06a29e1b1b1cf55748a9df8bdbec4bd0c8a9a7 (patch) | |
tree | 42a0991d1170dfc7369d37497bb693c17a0daec6 /app | |
parent | 473b88f399478b47bfa53d44ef9981aeb6d9960b (diff) | |
parent | 764806d211e026226bf8003cbdd6ff3ec570d5db (diff) | |
download | tangerine-wallet-browser-3b06a29e1b1b1cf55748a9df8bdbec4bd0c8a9a7.tar tangerine-wallet-browser-3b06a29e1b1b1cf55748a9df8bdbec4bd0c8a9a7.tar.gz tangerine-wallet-browser-3b06a29e1b1b1cf55748a9df8bdbec4bd0c8a9a7.tar.bz2 tangerine-wallet-browser-3b06a29e1b1b1cf55748a9df8bdbec4bd0c8a9a7.tar.lz tangerine-wallet-browser-3b06a29e1b1b1cf55748a9df8bdbec4bd0c8a9a7.tar.xz tangerine-wallet-browser-3b06a29e1b1b1cf55748a9df8bdbec4bd0c8a9a7.tar.zst tangerine-wallet-browser-3b06a29e1b1b1cf55748a9df8bdbec4bd0c8a9a7.zip |
Merge branch 'master' into reloadDapp
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/lib/inpage-provider.js | 3 | ||||
-rw-r--r-- | app/scripts/lib/tx-utils.js | 13 |
2 files changed, 14 insertions, 2 deletions
diff --git a/app/scripts/lib/inpage-provider.js b/app/scripts/lib/inpage-provider.js index e54f547bd..39196e240 100644 --- a/app/scripts/lib/inpage-provider.js +++ b/app/scripts/lib/inpage-provider.js @@ -44,8 +44,9 @@ function MetamaskInpageProvider (connectionStream) { (err) => logStreamDisconnectWarning('MetaMask RpcProvider', err) ) - // start polling + // start and stop polling to unblock first block lock engine.start() + engine.once('latest', () => engine.stop()) self.idMap = {} // handle sendAsync requests via asyncProvider 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) |