From 81fbb3b662ed4a545bffef52dd0977145d45927e Mon Sep 17 00:00:00 2001 From: mmv Date: Wed, 17 Apr 2019 15:35:35 +0400 Subject: [PATCH] add selector for all active tokens --- src/routes/safe/store/selectors/index.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/routes/safe/store/selectors/index.js b/src/routes/safe/store/selectors/index.js index 100e3cbd..948a0d06 100644 --- a/src/routes/safe/store/selectors/index.js +++ b/src/routes/safe/store/selectors/index.js @@ -1,5 +1,5 @@ // @flow -import { Map, List } from 'immutable' +import { Map, List, Set } from 'immutable' import { type Match } from 'react-router-dom' import { createSelector, createStructuredSelector, type Selector } from 'reselect' import { type GlobalState } from '~/store/index' @@ -9,6 +9,7 @@ import { safesMapSelector } from '~/routes/safeList/store/selectors' import { type State as TransactionsState, TRANSACTIONS_REDUCER_ID } from '~/routes/safe/store/reducer/transactions' import { type Transaction } from '~/routes/safe/store/models/transaction' import { type Confirmation } from '~/routes/safe/store/models/confirmation' +import { safesListSelector } from '~/routes/safeList/store/selectors/' export type RouterProps = { match: Match, @@ -100,6 +101,21 @@ export const safeBalancesSelector: Selector> = createSelector( + safesListSelector, + (safes: List) => { + const addresses = Set().withMutations((set) => { + safes.forEach((safe: Safe) => { + safe.activeTokens.forEach((tokenAddress) => { + set.add(tokenAddress) + }) + }) + }) + + return addresses + }, +) + export default createStructuredSelector({ safe: safeSelector, tokens: safeActiveTokensSelector,