edge-core-js
Version:
Edge account & wallet management library
35 lines (22 loc) • 643 B
JavaScript
import { buildReducer, mapReducer } from 'redux-keto'
import {
currencyWalletReducer,
} from './wallet/currency-wallet-reducer'
export const currency = buildReducer({
currencyWalletIds(state, action, next) {
// Optimize the common case:
if (next.accountIds.length === 1) {
const id = next.accountIds[0]
return next.accounts[id].activeWalletIds
}
const out = []
for (const accountId of next.accountIds) {
out.push(...next.accounts[accountId].activeWalletIds)
}
return out
},
wallets: mapReducer(
currencyWalletReducer,
(props) => props.currency.currencyWalletIds
)
})