aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/redux/reducer.ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-11-09 09:22:21 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-11-09 09:22:21 +0800
commitb147cd888505443981781d200a68b949812cb3e9 (patch)
tree913e93af0dffeea1db6a34b818c68983f36bf46b /packages/instant/src/redux/reducer.ts
parent211163b3724090347dba736cbcdcb2b1ec252bd0 (diff)
downloaddexon-sol-tools-b147cd888505443981781d200a68b949812cb3e9.tar
dexon-sol-tools-b147cd888505443981781d200a68b949812cb3e9.tar.gz
dexon-sol-tools-b147cd888505443981781d200a68b949812cb3e9.tar.bz2
dexon-sol-tools-b147cd888505443981781d200a68b949812cb3e9.tar.lz
dexon-sol-tools-b147cd888505443981781d200a68b949812cb3e9.tar.xz
dexon-sol-tools-b147cd888505443981781d200a68b949812cb3e9.tar.zst
dexon-sol-tools-b147cd888505443981781d200a68b949812cb3e9.zip
fix(instant): fix bug where we potentially fetch balance for the wrong account
Diffstat (limited to 'packages/instant/src/redux/reducer.ts')
-rw-r--r--packages/instant/src/redux/reducer.ts9
1 files changed, 5 insertions, 4 deletions
diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts
index 961e29619..a5a1b6f7d 100644
--- a/packages/instant/src/redux/reducer.ts
+++ b/packages/instant/src/redux/reducer.ts
@@ -75,13 +75,14 @@ export const createReducer = (initialState: State) => {
return reduceStateWithAccount(state, account);
}
case ActionTypes.UPDATE_ACCOUNT_ETH_BALANCE: {
- const account = state.providerState.account;
- if (account.state !== AccountState.Ready) {
+ const { address, ethBalanceInWei } = action.data;
+ const currentAccount = state.providerState.account;
+ if (currentAccount.state !== AccountState.Ready || currentAccount.address !== address) {
return state;
} else {
const newAccount: AccountReady = {
- ...account,
- ethBalanceInWei: action.data,
+ ...currentAccount,
+ ethBalanceInWei,
};
return reduceStateWithAccount(state, newAccount);
}