aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/send_/send.utils.js
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-05-25 21:37:16 +0800
committerDan <danjm.com@gmail.com>2018-05-31 07:24:32 +0800
commit5a842e440f0ec565eba38aec4c1c953a775557ea (patch)
treeef31345b42b71fadf1c38731a7252e8da07f2366 /ui/app/components/send_/send.utils.js
parent0f20fce9b761fc0aa16d61b2b739fa7f9b9f6a7d (diff)
downloadtangerine-wallet-browser-5a842e440f0ec565eba38aec4c1c953a775557ea.tar.gz
tangerine-wallet-browser-5a842e440f0ec565eba38aec4c1c953a775557ea.tar.zst
tangerine-wallet-browser-5a842e440f0ec565eba38aec4c1c953a775557ea.zip
Gas estimation uses block gas limit as fallback if query.estimateGas returns an expected error.
Diffstat (limited to 'ui/app/components/send_/send.utils.js')
-rw-r--r--ui/app/components/send_/send.utils.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/ui/app/components/send_/send.utils.js b/ui/app/components/send_/send.utils.js
index 750411908..9b8f1d118 100644
--- a/ui/app/components/send_/send.utils.js
+++ b/ui/app/components/send_/send.utils.js
@@ -193,14 +193,21 @@ async function estimateGas ({ selectedAddress, selectedToken, data, blockGasLimi
roundDown: '0',
toNumericBase: 'hex',
}))
-
// run tx
return new Promise((resolve, reject) => {
- estimateGasMethod(paramsForGasEstimate, (err, estimatedGas) => {
+ return estimateGasMethod(paramsForGasEstimate, (err, estimatedGas) => {
if (err) {
- reject(err)
+ const simulationFailed = (
+ err.message.includes('Transaction execution error.') ||
+ err.message.includes('gas required exceeds allowance or always failing transaction')
+ )
+ if (simulationFailed) {
+ return resolve(paramsForGasEstimate.gas)
+ } else {
+ return reject(err)
+ }
}
- resolve(estimatedGas.toString(16))
+ return resolve(estimatedGas.toString(16))
})
})
}