WA-238 adding transactions property to redux store

This commit is contained in:
apanizo 2018-05-22 11:23:41 +02:00
parent 63cb857b7b
commit 89b1b5ffe0
6 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,6 @@
// @flow
import { createAction } from 'redux-actions'
export const ADD_TRANSACTIONS = 'ADD_TRANSACTIONS'
export default createAction(ADD_TRANSACTIONS)

View File

@ -0,0 +1,17 @@
// @flow
import { List, Map } from 'immutable'
import { handleActions, type ActionType } from 'redux-actions'
import addTransactions, { ADD_TRANSACTIONS } from '~/routes/safe/store/actions/addTransactions'
import { type Transaction } from '~/routes/safe/store/model/transaction'
import { loadSafeTransactions } from '~/routes/safe/component/Transactions/transactions'
export const TRANSACTIONS_REDUCER_ID = 'transactions'
export type State = Map<string, List<Transaction>>
export const transactionsInitialState = () => loadSafeTransactions()
export default handleActions({
[ADD_TRANSACTIONS]: (state: State, action: ActionType<typeof addTransactions>): State =>
action.payload,
}, Map())

View File

@ -27,6 +27,7 @@ const grantedSelectorTests = () => {
[SAFE_REDUCER_ID]: map,
providers: makeProvider(provider),
balances: undefined,
transactions: undefined,
}
// WHEN
@ -47,6 +48,7 @@ const grantedSelectorTests = () => {
[SAFE_REDUCER_ID]: map,
providers: makeProvider(provider),
balances: undefined,
transactions: undefined,
}
// WHEN

View File

@ -15,6 +15,7 @@ const safeSelectorTests = () => {
[SAFE_REDUCER_ID]: Map(),
providers: undefined,
balances: undefined,
transactions: undefined,
}
const match: Match = buildMathPropsFrom('fooAddress')
@ -38,6 +39,7 @@ const safeSelectorTests = () => {
[SAFE_REDUCER_ID]: map,
providers: undefined,
balances: undefined,
transactions: undefined,
}
// WHEN

View File

@ -22,6 +22,7 @@ const safesListSelectorTests = () => {
[PROVIDER_REDUCER_ID]: walletRecord,
[SAFE_REDUCER_ID]: Map(),
balances: undefined,
transactions: undefined,
}
const emptyList = List([])
@ -42,6 +43,7 @@ const safesListSelectorTests = () => {
[PROVIDER_REDUCER_ID]: walletRecord,
[SAFE_REDUCER_ID]: map,
balances: undefined,
transactions: undefined,
}
// WHEN
@ -61,6 +63,7 @@ const safesListSelectorTests = () => {
[PROVIDER_REDUCER_ID]: walletRecord,
[SAFE_REDUCER_ID]: map,
balances: undefined,
transactions: undefined,
}
// WHEN
@ -81,6 +84,7 @@ const safesListSelectorTests = () => {
[SAFE_REDUCER_ID]: map,
[PROVIDER_REDUCER_ID]: walletRecord,
balances: undefined,
transactions: undefined,
}
// WHEN
@ -102,6 +106,7 @@ const safesListSelectorTests = () => {
[SAFE_REDUCER_ID]: map,
[PROVIDER_REDUCER_ID]: walletRecord,
balances: undefined,
transactions: undefined,
}
// WHEN

View File

@ -6,6 +6,7 @@ import thunk from 'redux-thunk'
import provider, { PROVIDER_REDUCER_ID, type State as ProviderState } from '~/wallets/store/reducer/provider'
import safe, { SAFE_REDUCER_ID, safeInitialState, type State as SafeState } from '~/routes/safe/store/reducer/safe'
import balances, { BALANCE_REDUCER_ID, type State as BalancesState } from '~/routes/safe/store/reducer/balances'
import transactions, { type State as TransactionsState, transactionsInitialState, TRANSACTIONS_REDUCER_ID } from '~/routes/safe/store/reducer/transactions'
export const history = createBrowserHistory()
@ -20,6 +21,7 @@ export type GlobalState = {
providers: ProviderState,
safes: SafeState,
balances: BalancesState,
transactions: TransactionsState,
}
const reducers: Reducer<GlobalState> = combineReducers({
@ -27,10 +29,12 @@ const reducers: Reducer<GlobalState> = combineReducers({
[PROVIDER_REDUCER_ID]: provider,
[SAFE_REDUCER_ID]: safe,
[BALANCE_REDUCER_ID]: balances,
[TRANSACTIONS_REDUCER_ID]: transactions,
})
const initialState = {
[SAFE_REDUCER_ID]: safeInitialState(),
[TRANSACTIONS_REDUCER_ID]: transactionsInitialState(),
}
export const store: Store<GlobalState> = createStore(reducers, initialState, finalCreateStore)