@@ -55,7 +55,6 @@ import { ragequitThunk } from "./thunks/ragequitThunk";
5555import { SyncAspThunkParams } from "./thunks/syncAspThunk" ;
5656import { syncThunk } from "./thunks/syncThunk" ;
5757import { withdrawThunk } from "./thunks/withdrawThunk" ;
58- import { deserialize } from "./utils/serialize.utils" ;
5958
6059export interface StoreFactoryParams
6160 extends BaseSelectorParams , SyncAspThunkParams {
@@ -179,27 +178,14 @@ const getStoreStorageKey = (
179178
180179const storeByChainAndEntrypoint = ( {
181180 storageToSyncTo,
182- initialState,
181+ initialState : initialStateByChainAndEntrypoint = { } ,
183182 ...params
184183} : Omit < StoreFactoryParams , "dataService" > ) => {
185- const initialMapState = Object . entries ( initialState || { } ) . map (
186- ( [ key , state ] ) =>
187- [
188- key ,
189- initializeSelectors ( {
190- ...params ,
191- store : storeFactory ( {
192- entrypointInfo : deserialize ( state ! . entrypointInfo ) ,
193- initialState : state ,
194- } ) ,
195- } ) ,
196- ] as const ,
197- ) ;
198184
199185 const chainStoreMap = new Map <
200186 string ,
201187 ReturnType < typeof initializeSelectors < ReturnType < typeof storeFactory > > >
202- > ( initialMapState ) ;
188+ > ( ) ;
203189
204190 return {
205191 getChainStore : ( getChainStoreParams : GetChainStoreParams ) => {
@@ -210,14 +196,12 @@ const storeByChainAndEntrypoint = ({
210196 const computedChainKey = getStoreKey ( getChainStoreParams ) ;
211197 let storeWithSelectors = chainStoreMap . get ( computedChainKey ) ;
212198
213- const storedState = storageToSyncTo ?. get (
214- getStoreStorageKey ( getChainStoreParams ) ,
215- ) ;
216-
217199 if ( ! storeWithSelectors ) {
218- const initialState : RootState | undefined = storedState
219- ? JSON . parse ( storedState )
220- : undefined ;
200+ const storageKey = getStoreStorageKey ( getChainStoreParams ) ;
201+ const rawStoredState = storageToSyncTo ?. get ( storageKey ) ;
202+ const storedState : RootState | undefined = rawStoredState ? JSON . parse ( rawStoredState ) : undefined ;
203+ const snapshotInitialState = initialStateByChainAndEntrypoint [ storageKey ] ;
204+ const initialState : RootState | undefined = storedState || snapshotInitialState ;
221205 const store = storeFactory ( {
222206 entrypointInfo : {
223207 chainId,
0 commit comments