diff --git a/src/logic/tokens/store/reducer/tokens.ts b/src/logic/tokens/store/reducer/tokens.ts index 50dc1def..39a8c4f1 100644 --- a/src/logic/tokens/store/reducer/tokens.ts +++ b/src/logic/tokens/store/reducer/tokens.ts @@ -3,24 +3,24 @@ import { handleActions } from 'redux-actions' import { ADD_TOKEN } from 'src/logic/tokens/store/actions/addToken' import { ADD_TOKENS } from 'src/logic/tokens/store/actions/saveTokens' -import { makeToken } from 'src/logic/tokens/store/model/token' +import { makeToken, Token } from 'src/logic/tokens/store/model/token' export const TOKEN_REDUCER_ID = 'tokens' +export type TokenState = Map + export default handleActions( { - [ADD_TOKENS]: (state, action) => { + [ADD_TOKENS]: (state: TokenState, action) => { const { tokens } = action.payload - const newState = state.withMutations((map) => { - tokens.forEach((token) => { + return state.withMutations((map) => { + tokens.forEach((token: Token) => { map.set(token.address, token) }) }) - - return newState }, - [ADD_TOKEN]: (state, action) => { + [ADD_TOKEN]: (state: TokenState, action) => { const { token } = action.payload const { address: tokenAddress } = token diff --git a/src/logic/tokens/store/selectors/index.ts b/src/logic/tokens/store/selectors/index.ts index e5543689..2017bd88 100644 --- a/src/logic/tokens/store/selectors/index.ts +++ b/src/logic/tokens/store/selectors/index.ts @@ -1,11 +1,9 @@ -import { Map } from 'immutable' import { createSelector } from 'reselect' -import { TOKEN_REDUCER_ID } from 'src/logic/tokens/store/reducer/tokens' -import { Token } from 'src/logic/tokens/store/model/token' +import { TOKEN_REDUCER_ID, TokenState } from 'src/logic/tokens/store/reducer/tokens' import { AppReduxState } from 'src/store' -export const tokensSelector = (state: AppReduxState): Map => state[TOKEN_REDUCER_ID] +export const tokensSelector = (state: AppReduxState): TokenState => state[TOKEN_REDUCER_ID] export const tokenListSelector = createSelector(tokensSelector, (tokens) => tokens.toList())