diff --git a/src/redux/slices/settingsSlice/index.ts b/src/redux/slices/settingsSlice/index.ts index f34a9f701..c647eb80a 100644 --- a/src/redux/slices/settingsSlice/index.ts +++ b/src/redux/slices/settingsSlice/index.ts @@ -335,13 +335,15 @@ const initialState: SettingsSlice = { usedBitcoinAddresses: {}, } +const createInitialState = () => ({ + ...initialState, + chainId: getCurrentChainId(), + chainType: chainTypesById[getCurrentChainId()], +}) + const settingsSlice = createSlice({ name: 'settings', - initialState: () => ({ - ...initialState, - chainId: getCurrentChainId(), - chainType: chainTypesById[getCurrentChainId()], - }), + initialState: createInitialState, reducers: { setKeysExist: (state, { payload }: PayloadAction) => { state.keysExist = payload @@ -440,7 +442,7 @@ const settingsSlice = createSlice({ deleteKeys() deleteDomains() deleteCache() - return initialState + return createInitialState() }, setFullscreen: (state, { payload }: PayloadAction) => { state.fullscreen = payload diff --git a/src/storage/ChainStorage.ts b/src/storage/ChainStorage.ts index b419ffd01..06d1ccd0f 100644 --- a/src/storage/ChainStorage.ts +++ b/src/storage/ChainStorage.ts @@ -1,9 +1,10 @@ import { ChainTypesByIdType } from 'shared/constants/chainConstants' +import { MMKVStorage } from 'storage/MMKVStorage' -import { MainStorage } from './MainStorage' +const ChainStorage = new MMKVStorage('chainStorage') export const getCurrentChainId: () => ChainTypesByIdType = () => - MainStorage.get('chainId') || 31 + ChainStorage.get('chainId') || 31 export const setCurrentChainId = (chainId: ChainTypesByIdType) => - MainStorage.set('chainId', chainId) + ChainStorage.set('chainId', chainId)