import { configureStore , PreloadedState } from '@reduxjs/toolkit' ; import { createLogger } from 'redux-logger' ; import { persistStore } from 'redux-persist' ; import createSagaMiddleware from 'redux-saga' ; import { connectHDWallet , getAccounts , processAccountsQueue , requestConnectionSuccess } from '@features/AddAccount/components/hdWallet.slice' ; import { messageUpdate , signMessage } from '@features/SignAndVerifyMessage' ; import { analyticsMiddleware } from '@services/Analytics' ; import { startBalancesPolling , startRatesPolling , updateAccounts } from '@store' ; import { IS_DEV } from '@utils' ; import { REDUX_PERSIST_ACTION_TYPES } from './persist.config' ; import rootReducer , { AppState } from './root.reducer' ; import rootSaga from './sagas' ; import { serializeLegacyMiddleware } from './serialize.middleware' ; export default function createStore ( initialState ? ) { const sagaMiddleware = createSagaMiddleware ( ) ; const store = configureStore ( { reducer : rootReducer , preloadedState : initialState , middleware : ( getDefaultMiddleware ) => [ serializeLegacyMiddleware , ... getDefaultMiddleware ( { immutableCheck : IS_DEV , thunk : false , serializableCheck : { ignoredActions : [ ... REDUX_PERSIST_ACTION_TYPES , updateAccounts . type , startRatesPolling . type , startBalancesPolling . type , connectHDWallet . type , requestConnectionSuccess . type , getAccounts . type , processAccountsQueue . type , signMessage . type , messageUpdate . type ] } } ) , sagaMiddleware , analyticsMiddleware , ... ( IS_DEV ? [ createLogger ( { collapsed : true } ) ] : [ ] ) ] } ) ; const persistor = persistStore ( store ) ; if ( module . hot && IS_DEV ) { module . hot . accept ( './root.reducer' , ( ) => { import ( './root.reducer' ) . then ( ( { default : nextReducer } ) => store . replaceReducer ( nextReducer ) ) ; } ) ; } sagaMiddleware . run ( rootSaga ) ; return { store , persistor } ; }