diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-11-09 09:22:21 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-11-09 09:22:21 +0800 |
commit | b147cd888505443981781d200a68b949812cb3e9 (patch) | |
tree | 913e93af0dffeea1db6a34b818c68983f36bf46b /packages/instant/src/redux/async_data.ts | |
parent | 211163b3724090347dba736cbcdcb2b1ec252bd0 (diff) | |
download | dexon-0x-contracts-b147cd888505443981781d200a68b949812cb3e9.tar.gz dexon-0x-contracts-b147cd888505443981781d200a68b949812cb3e9.tar.zst dexon-0x-contracts-b147cd888505443981781d200a68b949812cb3e9.zip |
fix(instant): fix bug where we potentially fetch balance for the wrong account
Diffstat (limited to 'packages/instant/src/redux/async_data.ts')
-rw-r--r-- | packages/instant/src/redux/async_data.ts | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/packages/instant/src/redux/async_data.ts b/packages/instant/src/redux/async_data.ts index bff9d8814..a8f632009 100644 --- a/packages/instant/src/redux/async_data.ts +++ b/packages/instant/src/redux/async_data.ts @@ -52,7 +52,8 @@ export const asyncData = { if (!_.isEmpty(availableAddresses)) { const activeAddress = availableAddresses[0]; store.dispatch(actions.setAccountStateReady(activeAddress)); - await asyncData.fetchAccountBalanceAndDispatchToStore(store); + // tslint:disable-next-line:no-floating-promises + asyncData.fetchAccountBalanceAndDispatchToStore(store); } else { store.dispatch(actions.setAccountStateLocked()); } @@ -65,8 +66,9 @@ export const asyncData = { return; } try { - const ethBalanceInWei = await web3Wrapper.getBalanceInWeiAsync(account.address); - store.dispatch(actions.updateAccountEthBalance(ethBalanceInWei)); + const address = account.address; + const ethBalanceInWei = await web3Wrapper.getBalanceInWeiAsync(address); + store.dispatch(actions.updateAccountEthBalance({ address, ethBalanceInWei })); } catch (e) { // leave balance as is return; |