add selector for all active tokens
This commit is contained in:
parent
e3d7984486
commit
81fbb3b662
|
@ -1,5 +1,5 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { Map, List } from 'immutable'
|
import { Map, List, Set } from 'immutable'
|
||||||
import { type Match } from 'react-router-dom'
|
import { type Match } from 'react-router-dom'
|
||||||
import { createSelector, createStructuredSelector, type Selector } from 'reselect'
|
import { createSelector, createStructuredSelector, type Selector } from 'reselect'
|
||||||
import { type GlobalState } from '~/store/index'
|
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 State as TransactionsState, TRANSACTIONS_REDUCER_ID } from '~/routes/safe/store/reducer/transactions'
|
||||||
import { type Transaction } from '~/routes/safe/store/models/transaction'
|
import { type Transaction } from '~/routes/safe/store/models/transaction'
|
||||||
import { type Confirmation } from '~/routes/safe/store/models/confirmation'
|
import { type Confirmation } from '~/routes/safe/store/models/confirmation'
|
||||||
|
import { safesListSelector } from '~/routes/safeList/store/selectors/'
|
||||||
|
|
||||||
export type RouterProps = {
|
export type RouterProps = {
|
||||||
match: Match,
|
match: Match,
|
||||||
|
@ -100,6 +101,21 @@ export const safeBalancesSelector: Selector<GlobalState, RouterProps, Map<string
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
export const getActiveTokensAddressesForAllSafes: Selector<GlobalState, any, Set<string>> = createSelector(
|
||||||
|
safesListSelector,
|
||||||
|
(safes: List<Safe>) => {
|
||||||
|
const addresses = Set().withMutations((set) => {
|
||||||
|
safes.forEach((safe: Safe) => {
|
||||||
|
safe.activeTokens.forEach((tokenAddress) => {
|
||||||
|
set.add(tokenAddress)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return addresses
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
export default createStructuredSelector<Object, *>({
|
export default createStructuredSelector<Object, *>({
|
||||||
safe: safeSelector,
|
safe: safeSelector,
|
||||||
tokens: safeActiveTokensSelector,
|
tokens: safeActiveTokensSelector,
|
||||||
|
|
Loading…
Reference in New Issue