diff options
author | Dan <danjm.com@gmail.com> | 2018-07-05 07:56:02 +0800 |
---|---|---|
committer | Dan <danjm.com@gmail.com> | 2018-07-05 08:17:19 +0800 |
commit | 7d7662191af708621549cfd67592375436263eb3 (patch) | |
tree | 16dd7c46f954f4759985a6fa094f7bba4df94714 /ui/app | |
parent | c47a4ce2c93d50425f580c2a166c1698cf1c508f (diff) | |
download | dexon-wallet-7d7662191af708621549cfd67592375436263eb3.tar.gz dexon-wallet-7d7662191af708621549cfd67592375436263eb3.tar.zst dexon-wallet-7d7662191af708621549cfd67592375436263eb3.zip |
Improve error and promise resolution handling in action.js updateGasData().
Diffstat (limited to 'ui/app')
-rw-r--r-- | ui/app/actions.js | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js index 408bc700..ad890f56 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) |