diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-11-13 09:30:28 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-11-13 09:30:28 +0800 |
commit | 01b36b494996c641a3cb5bd3fd894624a8dad210 (patch) | |
tree | eb7ab9dc21faf515807f1be29839f6cc3580961d /packages/instant/src/redux | |
parent | 711b307e6c56457647a98c6d76725aa90ac0d53e (diff) | |
download | dexon-sol-tools-01b36b494996c641a3cb5bd3fd894624a8dad210.tar.gz dexon-sol-tools-01b36b494996c641a3cb5bd3fd894624a8dad210.tar.zst dexon-sol-tools-01b36b494996c641a3cb5bd3fd894624a8dad210.zip |
fix: remove requirement of default case in all switch statements
Diffstat (limited to 'packages/instant/src/redux')
-rw-r--r-- | packages/instant/src/redux/async_data.ts | 11 | ||||
-rw-r--r-- | packages/instant/src/redux/reducer.ts | 7 |
2 files changed, 8 insertions, 10 deletions
diff --git a/packages/instant/src/redux/async_data.ts b/packages/instant/src/redux/async_data.ts index 2682677b9..15ac31a5a 100644 --- a/packages/instant/src/redux/async_data.ts +++ b/packages/instant/src/redux/async_data.ts @@ -1,4 +1,5 @@ import { AssetProxyId } from '@0x/types'; +import { Web3Wrapper } from '@0x/web3-wrapper'; import * as _ from 'lodash'; import { Dispatch } from 'redux'; @@ -64,19 +65,13 @@ export const asyncData = { const activeAddress = availableAddresses[0]; dispatch(actions.setAccountStateReady(activeAddress)); // tslint:disable-next-line:no-floating-promises - asyncData.fetchAccountBalanceAndDispatchToStore(providerState, dispatch); + asyncData.fetchAccountBalanceAndDispatchToStore(activeAddress, providerState.web3Wrapper, dispatch); } else { dispatch(actions.setAccountStateLocked()); } }, - fetchAccountBalanceAndDispatchToStore: async (providerState: ProviderState, dispatch: Dispatch) => { - const web3Wrapper = providerState.web3Wrapper; - const account = providerState.account; - // if (account.state !== AccountState.Ready) { - // return; - // } + fetchAccountBalanceAndDispatchToStore: async (address: string, web3Wrapper: Web3Wrapper, dispatch: Dispatch) => { try { - const address = account.address; const ethBalanceInWei = await web3Wrapper.getBalanceInWeiAsync(address); dispatch(actions.updateAccountEthBalance({ address, ethBalanceInWei })); } catch (e) { diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts index 28f094184..3d7c3f483 100644 --- a/packages/instant/src/redux/reducer.ts +++ b/packages/instant/src/redux/reducer.ts @@ -74,13 +74,16 @@ export const createReducer = (initialState: State) => { return reduceStateWithAccount(state, LOCKED_ACCOUNT); case ActionTypes.SET_ACCOUNT_STATE_READY: { const address = action.data; - const newAccount: AccountReady = { + let newAccount: AccountReady = { state: AccountState.Ready, address, }; const currentAccount = state.providerState.account; if (currentAccount.state === AccountState.Ready && currentAccount.address === address) { - newAccount.ethBalanceInWei = currentAccount.ethBalanceInWei; + newAccount = { + ...newAccount, + ethBalanceInWei: currentAccount.ethBalanceInWei, + }; } return reduceStateWithAccount(state, newAccount); } |