aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-07-05 07:56:02 +0800
committerDan <danjm.com@gmail.com>2018-07-05 08:17:19 +0800
commit7d7662191af708621549cfd67592375436263eb3 (patch)
tree16dd7c46f954f4759985a6fa094f7bba4df94714 /ui
parentc47a4ce2c93d50425f580c2a166c1698cf1c508f (diff)
downloadtangerine-wallet-browser-7d7662191af708621549cfd67592375436263eb3.tar
tangerine-wallet-browser-7d7662191af708621549cfd67592375436263eb3.tar.gz
tangerine-wallet-browser-7d7662191af708621549cfd67592375436263eb3.tar.bz2
tangerine-wallet-browser-7d7662191af708621549cfd67592375436263eb3.tar.lz
tangerine-wallet-browser-7d7662191af708621549cfd67592375436263eb3.tar.xz
tangerine-wallet-browser-7d7662191af708621549cfd67592375436263eb3.tar.zst
tangerine-wallet-browser-7d7662191af708621549cfd67592375436263eb3.zip
Improve error and promise resolution handling in action.js updateGasData().
Diffstat (limited to 'ui')
-rw-r--r--ui/app/actions.js27
1 files changed, 14 insertions, 13 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js
index 408bc700b..ad890f565 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -745,26 +745,27 @@ function updateGasData ({
}) {
return (dispatch) => {
dispatch(actions.gasLoadingStarted())
- let gasPrice
return new Promise((resolve, reject) => {
background.getGasPrice((err, data) => {
- if (err !== null) return reject(err)
+ if (err) return reject(err)
return resolve(data)
})
})
.then(estimateGasPrice => {
- gasPrice = estimateGasPrice
- return estimateGas({
- estimateGasMethod: background.estimateGas,
- blockGasLimit,
- selectedAddress,
- selectedToken,
- to,
- value,
- gasPrice,
- })
+ return Promise.all([
+ Promise.resolve(estimateGasPrice),
+ estimateGas({
+ estimateGasMethod: background.estimateGas,
+ blockGasLimit,
+ selectedAddress,
+ selectedToken,
+ to,
+ value,
+ estimateGasPrice,
+ }),
+ ])
})
- .then(gas => {
+ .then(([gasPrice, gas]) => {
dispatch(actions.setGasPrice(gasPrice))
dispatch(actions.setGasLimit(gas))
return calcGasTotal(gas, gasPrice)