aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-11-13 07:28:54 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-11-13 09:09:28 +0800
commit711b307e6c56457647a98c6d76725aa90ac0d53e (patch)
treeb49ec5b525aa22299f05eb8c0a1930cb7d085aa5 /packages
parent1ab19a7c23eb1bb252c50d6dbe323d62aad61154 (diff)
downloaddexon-0x-contracts-711b307e6c56457647a98c6d76725aa90ac0d53e.tar
dexon-0x-contracts-711b307e6c56457647a98c6d76725aa90ac0d53e.tar.gz
dexon-0x-contracts-711b307e6c56457647a98c6d76725aa90ac0d53e.tar.bz2
dexon-0x-contracts-711b307e6c56457647a98c6d76725aa90ac0d53e.tar.lz
dexon-0x-contracts-711b307e6c56457647a98c6d76725aa90ac0d53e.tar.xz
dexon-0x-contracts-711b307e6c56457647a98c6d76725aa90ac0d53e.tar.zst
dexon-0x-contracts-711b307e6c56457647a98c6d76725aa90ac0d53e.zip
feat: prevent eth balance blink
Diffstat (limited to 'packages')
-rw-r--r--packages/instant/src/redux/async_data.ts6
-rw-r--r--packages/instant/src/redux/reducer.ts11
2 files changed, 11 insertions, 6 deletions
diff --git a/packages/instant/src/redux/async_data.ts b/packages/instant/src/redux/async_data.ts
index 8999ef097..2682677b9 100644
--- a/packages/instant/src/redux/async_data.ts
+++ b/packages/instant/src/redux/async_data.ts
@@ -72,9 +72,9 @@ export const asyncData = {
fetchAccountBalanceAndDispatchToStore: async (providerState: ProviderState, dispatch: Dispatch) => {
const web3Wrapper = providerState.web3Wrapper;
const account = providerState.account;
- if (account.state !== AccountState.Ready) {
- return;
- }
+ // if (account.state !== AccountState.Ready) {
+ // return;
+ // }
try {
const address = account.address;
const ethBalanceInWei = await web3Wrapper.getBalanceInWeiAsync(address);
diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts
index 4688250bc..28f094184 100644
--- a/packages/instant/src/redux/reducer.ts
+++ b/packages/instant/src/redux/reducer.ts
@@ -73,11 +73,16 @@ export const createReducer = (initialState: State) => {
case ActionTypes.SET_ACCOUNT_STATE_LOCKED:
return reduceStateWithAccount(state, LOCKED_ACCOUNT);
case ActionTypes.SET_ACCOUNT_STATE_READY: {
- const account: AccountReady = {
+ const address = action.data;
+ const newAccount: AccountReady = {
state: AccountState.Ready,
- address: action.data,
+ address,
};
- return reduceStateWithAccount(state, account);
+ const currentAccount = state.providerState.account;
+ if (currentAccount.state === AccountState.Ready && currentAccount.address === address) {
+ newAccount.ethBalanceInWei = currentAccount.ethBalanceInWei;
+ }
+ return reduceStateWithAccount(state, newAccount);
}
case ActionTypes.UPDATE_ACCOUNT_ETH_BALANCE: {
const { address, ethBalanceInWei } = action.data;