@@ -13,7 +13,7 @@ import {
13
13
TouchableOpacity ,
14
14
InteractionManager ,
15
15
} from 'react-native' ;
16
- import { connect } from 'react-redux' ;
16
+ import { connect , useSelector } from 'react-redux' ;
17
17
import { useNavigation , useRoute } from '@react-navigation/native' ;
18
18
import { View as AnimatableView } from 'react-native-animatable' ;
19
19
import IonicIcon from 'react-native-vector-icons/Ionicons' ;
@@ -27,7 +27,7 @@ import {
27
27
safeNumberToBN ,
28
28
} from '../../../util/number' ;
29
29
import { safeToChecksumAddress } from '../../../util/address' ;
30
- import { swapsUtils } from '@metamask/swaps-controller' ;
30
+ import { swapsUtils } from '@metamask-previews /swaps-controller' ;
31
31
import { MetaMetricsEvents } from '../../../core/Analytics' ;
32
32
33
33
import {
@@ -70,6 +70,7 @@ import {
70
70
selectChainId ,
71
71
selectNetworkConfigurations ,
72
72
selectProviderConfig ,
73
+ selectSelectedNetworkClientId ,
73
74
} from '../../../selectors/networkController' ;
74
75
import {
75
76
selectConversionRate ,
@@ -247,6 +248,8 @@ function SwapsAmountView({
247
248
hideTokenVerificationModal ,
248
249
] = useModalHandler ( false ) ;
249
250
251
+ const selectedNetworkClientId = useSelector ( selectSelectedNetworkClientId ) ;
252
+
250
253
useEffect ( ( ) => {
251
254
navigation . setOptions ( getSwapsAmountNavbar ( navigation , route , colors ) ) ;
252
255
} , [ navigation , route , colors ] ) ;
@@ -295,16 +298,20 @@ function SwapsAmountView({
295
298
( async ( ) => {
296
299
const { SwapsController } = Engine . context ;
297
300
try {
298
- await SwapsController . fetchAggregatorMetadataWithCache ( ) ;
299
- await SwapsController . fetchTopAssetsWithCache ( ) ;
301
+ await SwapsController . fetchAggregatorMetadataWithCache ( {
302
+ networkClientId : selectSelectedNetworkClientId ,
303
+ } ) ;
304
+ await SwapsController . fetchTopAssetsWithCache ( {
305
+ networkClientId : selectSelectedNetworkClientId ,
306
+ } ) ;
300
307
} catch ( error ) {
301
308
Logger . error (
302
309
error ,
303
310
'Swaps: Error while updating agg metadata and top assets in amount view' ,
304
311
) ;
305
312
}
306
313
} ) ( ) ;
307
- } , [ ] ) ;
314
+ } , [ selectedNetworkClientId ] ) ;
308
315
309
316
useEffect ( ( ) => {
310
317
( async ( ) => {
@@ -318,7 +325,7 @@ function SwapsAmountView({
318
325
setInitialLoadingTokens ( true ) ;
319
326
}
320
327
setLoadingTokens ( true ) ;
321
- await SwapsController . fetchTokenWithCache ( ) ;
328
+ await SwapsController . fetchTokenWithCache ( { networkClientId } ) ;
322
329
setLoadingTokens ( false ) ;
323
330
setInitialLoadingTokens ( false ) ;
324
331
} catch ( error ) {
@@ -331,7 +338,7 @@ function SwapsAmountView({
331
338
setInitialLoadingTokens ( false ) ;
332
339
}
333
340
} ) ( ) ;
334
- } , [ swapsControllerTokens , swapsTokens ] ) ;
341
+ } , [ swapsControllerTokens , swapsTokens , networkClientId ] ) ;
335
342
336
343
const canSetAnInitialSourceToken =
337
344
! isSourceSet &&
0 commit comments