aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/redux/async_data.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/instant/src/redux/async_data.ts')
-rw-r--r--packages/instant/src/redux/async_data.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/packages/instant/src/redux/async_data.ts b/packages/instant/src/redux/async_data.ts
index e27ec1dc3..862f60e78 100644
--- a/packages/instant/src/redux/async_data.ts
+++ b/packages/instant/src/redux/async_data.ts
@@ -50,8 +50,24 @@ export const asyncData = {
if (!_.isEmpty(availableAddresses)) {
const activeAddress = availableAddresses[0];
store.dispatch(actions.setAccountStateReady(activeAddress));
+ await asyncData.fetchAccountBalanceAndDispatchToStore(store);
} else {
store.dispatch(actions.setAccountStateLocked());
}
},
+ fetchAccountBalanceAndDispatchToStore: async (store: Store) => {
+ const { providerState } = store.getState();
+ const web3Wrapper = providerState.web3Wrapper;
+ const account = providerState.account;
+ if (account.state !== AccountState.Ready) {
+ return;
+ }
+ try {
+ const ethBalanceInWei = await web3Wrapper.getBalanceInWeiAsync(account.address);
+ store.dispatch(actions.updateAccountEthBalance(ethBalanceInWei));
+ } catch (e) {
+ // leave balance as is
+ return;
+ }
+ },
};