All files / app/store index.ts

0% Statements 0/14
100% Branches 0/0
0% Functions 0/1
0% Lines 0/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60                                                                                                                       
import { addressReducer, AddressState } from './address';
import { configureStore } from './configureStore';
import { HomeState, homeSlice } from './home';
import { KeysState, createKeysReducer } from './keys';
import { pendingTransactionReducer, PendingTransactionState } from './pending-transaction';
import { reduxPersistElectronStore } from './persist-middleware';
import { settingsReducer, SettingsState } from './settings';
import { StackingState, stackingSlice } from './stacking';
import { stacksNodeReducer, StacksNodeState } from './stacks-node';
import { TransactionState, transactionReducer } from './transaction';
import { combineReducers } from '@reduxjs/toolkit';
import { connectRouter } from 'connected-react-router';
import { Store as ReduxStore, Action } from 'redux';
import { PersistConfig } from 'redux-persist';
 
export interface RootState {
  router: any;
  keys: KeysState;
  transaction: TransactionState;
  pendingTransaction: PendingTransactionState;
  address: AddressState;
  home: HomeState;
  stacksNode: StacksNodeState;
  stacking: StackingState;
  settings: SettingsState;
  _persist: any;
}
 
export type GetState = () => RootState;
 
export type Store = ReduxStore<RootState, Action<string>>;
 
export const persistConfig: PersistConfig<RootState> = {
  key: 'root',
  storage: reduxPersistElectronStore(),
  whitelist: ['stacksNode', 'settings'],
};
 
interface RootReducerArgs {
  history: any;
  keys: Partial<KeysState>;
}
 
export function createRootReducer({ history, keys }: RootReducerArgs) {
  return combineReducers({
    // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
    router: connectRouter(history),
    keys: createKeysReducer(keys),
    transaction: transactionReducer,
    pendingTransaction: pendingTransactionReducer,
    address: addressReducer,
    home: homeSlice.reducer,
    stacksNode: stacksNodeReducer,
    stacking: stackingSlice.reducer,
    settings: settingsReducer,
  });
}
 
export type Dispatch = ReturnType<typeof configureStore>['store']['dispatch'];