import { combineReducers , Reducer } from 'redux' ; import { TxReducer } from '../txs/reducers' ; import { VtxconfigReducer } from '../vtxconfig/reducers' ; import { VtxeventsReducer } from '../vtxevents/reducers' ; import { VtxpollReducer } from '../vtxpoll/reducers' ; import { ContractsReducer } from '../contracts/reducers' ; import { BlocksReducer } from '../blocks/reducers' ; import { VtxcacheReducer } from '../vtxcache/reducers' ; import { AccountsReducer } from '../accounts/reducers' ; import { EventsReducer } from '../events/reducers' ; const VTX_REDUCERS_LIST = [ 'txs' , 'vtxconfig' , 'vtxevents' , 'vtxpoll' , 'contracts' , 'blocks' , 'vtxcache' , 'accounts' ] ; interface IReducerMap { [ key ] : Reducer ; } export const getReducers = ( custom_reducers ? ) : Reducer => { let final_reducers = { txs : TxReducer , contracts : ContractsReducer , blocks : BlocksReducer , accounts : AccountsReducer , events : EventsReducer , vtxconfig : VtxconfigReducer , vtxevents : VtxeventsReducer , vtxpoll : VtxpollReducer , vtxcache : VtxcacheReducer } ; if ( ! custom_reducers ) { custom_reducers = { } ; } for ( const reducer of Object . keys ( custom_reducers ) ) { if ( VTX_REDUCERS_LIST . indexOf ( reducer ) !== - 1 ) { throw new Error ( `Invalid reducer ${ reducer }. This reducer name is already used by ethvtx.` ) ; } } final_reducers = { ... final_reducers , ... custom_reducers } ; return combineReducers ( final_reducers ) ; } ;