aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorThomas Huang <tmashuang@users.noreply.github.com>2017-08-10 05:03:02 +0800
committerGitHub <noreply@github.com>2017-08-10 05:03:02 +0800
commit1071a35f7be1f231542e5b784cafd47720839d14 (patch)
tree1b3564599f0606c5b87f2d25fef42c6b41c35295 /app
parent7da65bdb907b35bdacea03f122bf8dd34f1f5d61 (diff)
parentb4052cd5e65c1d6ac0c81b051ddf59505a480ec6 (diff)
downloadtangerine-wallet-browser-1071a35f7be1f231542e5b784cafd47720839d14.tar.gz
tangerine-wallet-browser-1071a35f7be1f231542e5b784cafd47720839d14.tar.zst
tangerine-wallet-browser-1071a35f7be1f231542e5b784cafd47720839d14.zip
Merge pull request #1883 from MetaMask/estimateGas-fix
tx utils - detect estimateGas err and set simulationFailed
Diffstat (limited to 'app')
-rw-r--r--app/scripts/lib/tx-utils.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/app/scripts/lib/tx-utils.js b/app/scripts/lib/tx-utils.js
index b64ea6712..5af078dc4 100644
--- a/app/scripts/lib/tx-utils.js
+++ b/app/scripts/lib/tx-utils.js
@@ -20,7 +20,15 @@ module.exports = class txProvideUtil {
async analyzeGasUsage (txMeta) {
const block = await this.query.getBlockByNumber('latest', true)
- const estimatedGasHex = await this.estimateTxGas(txMeta, block.gasLimit)
+ let estimatedGasHex
+ try {
+ estimatedGasHex = await this.estimateTxGas(txMeta, block.gasLimit)
+ } catch (err) {
+ if (err.message.includes('Transaction execution error.')) {
+ txMeta.simulationFails = true
+ return txMeta
+ }
+ }
this.setTxGas(txMeta, block.gasLimit, estimatedGasHex)
return txMeta
}
@@ -35,8 +43,8 @@ module.exports = class txProvideUtil {
const saferGasLimitBN = BnMultiplyByFraction(blockGasLimitBN, 19, 20)
txParams.gas = bnToHex(saferGasLimitBN)
}
- // run tx, see if it will OOG
- return this.query.estimateGas(txParams)
+ // run tx
+ return await this.query.estimateGas(txParams)
}
setTxGas (txMeta, blockGasLimitHex, estimatedGasHex) {