@@ -18,6 +18,7 @@ import { accountsActions } from '@suite-common/wallet-core';
1818import { isCodesignBuild } from '@trezor/env-utils' ;
1919import { mergeDeepObject } from '@trezor/utils' ;
2020import { suiteSyncSlice } from 'src/actions/suiteSync/suiteSyncSlice' ;
21+ import { ExtraDependencies , createStoreWithExtraStoreMiddleware } from '@suite-common/redux-utils' ;
2122
2223import backupMiddlewares from 'src/middlewares/backup' ;
2324import onboardingMiddlewares from 'src/middlewares/onboarding' ;
@@ -32,14 +33,13 @@ import walletReducers from 'src/reducers/wallet';
3233// toastMiddleware can be used only in suite-desktop and suite-web
3334// it's not included into `@suite-middlewares` index
3435import { geolocationReducer } from '@suite-common/geolocation' ;
35- import { ExtraDependencies } from '@suite-common/redux-utils' ;
3636import { prepareLabelingReducer } from '@suite-common/suite-sync' ;
3737import { OPEN_USER_CONTEXT } from 'src/actions/suite/constants/modalConstants' ;
3838import toastMiddleware from 'src/middlewares/suite/toastMiddleware' ;
3939import { globalSendReceiveFilters } from 'src/slices/wallet/globalSendReceiveFilters' ;
4040import type { PreloadStoreAction } from 'src/support/suite/preloadStore' ;
4141import { bluetoothSlice } from '../actions/bluetooth/desktopBluetoothReducer' ;
42- import { extraDependencies } from '../support/extraDependencies' ;
42+ import { extraDependencies , suiteExtraFactory } from '../support/extraDependencies' ;
4343import { prepareBioAuthReducer } from './bioAuth' ;
4444import { desktopReducer } from './desktop' ;
4545
@@ -138,7 +138,9 @@ export const initStore = <E extends Partial<ExtraDependencies>>(
138138 )
139139 : preloadedState ;
140140
141- return configureStore ( {
141+ let extra : ExtraDependencies | null = null ;
142+
143+ const store = configureStore ( {
142144 reducer : rootReducer as Reducer < AppState , InferredAction , PreloadedState > ,
143145 preloadedState : patchedState ,
144146 middleware : getDefaultMiddleware =>
@@ -152,13 +154,27 @@ export const initStore = <E extends Partial<ExtraDependencies>>(
152154 'modal.payload.decision.reject' ,
153155 ] ,
154156 } ,
155- thunk : {
156- extraArgument : {
157- ...extraDependencies ,
158- ...( options . additionalExtraDeps ?? { } ) ,
159- } ,
160- } ,
161- } ) . concat ( getCustomMiddleware ( ) ) ,
157+ } )
158+ . prepend (
159+ createStoreWithExtraStoreMiddleware (
160+ api => ( {
161+ ...extraDependencies ,
162+ ...suiteExtraFactory ( api ) ,
163+ } ) ,
164+ initializedExtra => {
165+ extra = initializedExtra ;
166+ } ,
167+ ) ,
168+ )
169+ . concat ( getCustomMiddleware ( ) ) ,
162170 devTools,
163171 } as const ) ;
172+
173+ if ( ! extra ) {
174+ throw new Error (
175+ "This shouldn't happen: Extra dependencies not initialized, should be done in callback in createEnhancedStoreWithExtraStoreThunk" ,
176+ ) ;
177+ }
178+
179+ return { store, extra } ;
164180} ;
0 commit comments