import { createSlice , PayloadAction } from "@reduxjs/toolkit" ; import { ChainNetwork } from "picklefinance-core/lib/chain/Chains" ; import { RootState } from "." ; interface ConnectionState { blockNumber : number | undefined ; network : ChainNetwork | undefined ; isManuallyDeactivated : boolean ; isModalOpen : boolean ; } const initialState = { blockNumber : undefined , network : undefined , isManuallyDeactivated : false , isModalOpen : false , } ; const connectionSlice = createSlice ( { name : "connection" , initialState , reducers : { updateBlockNumber : ( state , action ) => { state . blockNumber = action . payload ; } , setIsManuallyDeactivated : ( state ) => { state . isManuallyDeactivated = true ; } , setIsModalOpen : ( state , action ) => { state . isModalOpen = action . payload ; } , } , } ) ; export const { updateBlockNumber , setIsManuallyDeactivated , setIsModalOpen , } = connectionSlice . actions ; /**
 * Selectors
 */ const selectBlockNumber = ( state ) => state . connection . blockNumber ; const selectIsManuallyDeactivated = ( state ) => state . connection . isManuallyDeactivated ; const selectIsModalOpen = ( state ) => state . connection . isModalOpen ; export const ConnectionSelectors = { selectBlockNumber , selectIsManuallyDeactivated , selectIsModalOpen , } ; export default connectionSlice . reducer ;