@@ -195,6 +195,7 @@ const createStateAfterPending = () => {
195
195
uuid : 'uuid1' ,
196
196
status : 'pending' ,
197
197
cancellable : true ,
198
+ chainId : '0x1' ,
198
199
statusMetadata : {
199
200
cancellationFeeWei : 0 ,
200
201
cancellationReason : 'not_cancelled' ,
@@ -223,6 +224,7 @@ const createStateAfterSuccess = () => {
223
224
uuid : 'uuid2' ,
224
225
status : 'success' ,
225
226
cancellable : false ,
227
+ chainId : '0x1' ,
226
228
statusMetadata : {
227
229
cancellationFeeWei : 36777567771000 ,
228
230
cancellationReason : 'not_cancelled' ,
@@ -269,6 +271,7 @@ describe('SmartTransactionsController', () => {
269
271
provider : jest . fn ( ) ,
270
272
confirmExternalTransaction : confirmExternalMock ,
271
273
trackMetaMetricsEvent : trackMetaMetricsEventSpy ,
274
+ getNetworkClientById : jest . fn ( ) ,
272
275
} ) ;
273
276
// eslint-disable-next-line jest/prefer-spy-on
274
277
smartTransactionsController . subscribe = jest . fn ( ) ;
@@ -283,7 +286,7 @@ describe('SmartTransactionsController', () => {
283
286
it ( 'initializes with default config' , ( ) => {
284
287
expect ( smartTransactionsController . config ) . toStrictEqual ( {
285
288
interval : DEFAULT_INTERVAL ,
286
- supportedChainIds : [ CHAIN_IDS . ETHEREUM , CHAIN_IDS . RINKEBY ] ,
289
+ supportedChainIds : [ CHAIN_IDS . ETHEREUM , CHAIN_IDS . GOERLI ] ,
287
290
chainId : CHAIN_IDS . ETHEREUM ,
288
291
clientId : 'default' ,
289
292
} ) ;
@@ -300,20 +303,44 @@ describe('SmartTransactionsController', () => {
300
303
approvalTxFees : undefined ,
301
304
tradeTxFees : undefined ,
302
305
} ,
306
+ feesByChainId : {
307
+ [ CHAIN_IDS . ETHEREUM ] : {
308
+ approvalTxFees : undefined ,
309
+ tradeTxFees : undefined ,
310
+ } ,
311
+ [ CHAIN_IDS . GOERLI ] : {
312
+ approvalTxFees : undefined ,
313
+ tradeTxFees : undefined ,
314
+ } ,
315
+ } ,
303
316
liveness : true ,
317
+ livenessByChainId : {
318
+ [ CHAIN_IDS . ETHEREUM ] : true ,
319
+ [ CHAIN_IDS . GOERLI ] : true ,
320
+ } ,
304
321
} ,
305
322
} ) ;
306
323
} ) ;
307
324
308
325
describe ( 'onNetworkChange' , ( ) => {
309
326
it ( 'is triggered' , ( ) => {
310
- networkListener ( { providerConfig : { chainId : '52' } } as NetworkState ) ;
311
- expect ( smartTransactionsController . config . chainId ) . toBe ( '52' ) ;
327
+ networkListener ( {
328
+ providerConfig : { chainId : '0x32' , type : 'rpc' , ticker : 'CET' } ,
329
+ selectedNetworkClientId : 'networkClientId' ,
330
+ networkConfigurations : { } ,
331
+ networksMetadata : { } ,
332
+ } as NetworkState ) ;
333
+ expect ( smartTransactionsController . config . chainId ) . toBe ( '0x32' ) ;
312
334
} ) ;
313
335
314
336
it ( 'calls poll' , ( ) => {
315
337
const checkPollSpy = jest . spyOn ( smartTransactionsController , 'checkPoll' ) ;
316
- networkListener ( { providerConfig : { chainId : '2' } } as NetworkState ) ;
338
+ networkListener ( {
339
+ providerConfig : { chainId : '0x32' , type : 'rpc' , ticker : 'CET' } ,
340
+ selectedNetworkClientId : 'networkClientId' ,
341
+ networkConfigurations : { } ,
342
+ networksMetadata : { } ,
343
+ } as NetworkState ) ;
317
344
expect ( checkPollSpy ) . toHaveBeenCalled ( ) ;
318
345
} ) ;
319
346
} ) ;
@@ -354,7 +381,12 @@ describe('SmartTransactionsController', () => {
354
381
'updateSmartTransactions' ,
355
382
) ;
356
383
expect ( updateSmartTransactionsSpy ) . not . toHaveBeenCalled ( ) ;
357
- networkListener ( { providerConfig : { chainId : '56' } } as NetworkState ) ;
384
+ networkListener ( {
385
+ providerConfig : { chainId : '0x32' , type : 'rpc' , ticker : 'CET' } ,
386
+ selectedNetworkClientId : 'networkClientId' ,
387
+ networkConfigurations : { } ,
388
+ networksMetadata : { } ,
389
+ } as NetworkState ) ;
358
390
expect ( updateSmartTransactionsSpy ) . not . toHaveBeenCalled ( ) ;
359
391
} ) ;
360
392
} ) ;
@@ -489,7 +521,11 @@ describe('SmartTransactionsController', () => {
489
521
nock ( API_BASE_URL )
490
522
. get ( `/networks/${ ethereumChainIdDec } /batchStatus?uuids=uuid1` )
491
523
. reply ( 200 , pendingBatchStatusApiResponse ) ;
492
- await smartTransactionsController . fetchSmartTransactionsStatus ( uuids ) ;
524
+
525
+ await smartTransactionsController . fetchSmartTransactionsStatus (
526
+ uuids ,
527
+ CHAIN_IDS . ETHEREUM ,
528
+ ) ;
493
529
const pendingState = createStateAfterPending ( ) [ 0 ] ;
494
530
const pendingTransaction = { ...pendingState , history : [ pendingState ] } ;
495
531
expect ( smartTransactionsController . state ) . toStrictEqual ( {
@@ -502,7 +538,21 @@ describe('SmartTransactionsController', () => {
502
538
approvalTxFees : undefined ,
503
539
tradeTxFees : undefined ,
504
540
} ,
541
+ feesByChainId : {
542
+ [ CHAIN_IDS . ETHEREUM ] : {
543
+ approvalTxFees : undefined ,
544
+ tradeTxFees : undefined ,
545
+ } ,
546
+ [ CHAIN_IDS . GOERLI ] : {
547
+ approvalTxFees : undefined ,
548
+ tradeTxFees : undefined ,
549
+ } ,
550
+ } ,
505
551
liveness : true ,
552
+ livenessByChainId : {
553
+ [ CHAIN_IDS . ETHEREUM ] : true ,
554
+ [ CHAIN_IDS . GOERLI ] : true ,
555
+ } ,
506
556
} ,
507
557
} ) ;
508
558
} ) ;
@@ -524,7 +574,11 @@ describe('SmartTransactionsController', () => {
524
574
nock ( API_BASE_URL )
525
575
. get ( `/networks/${ ethereumChainIdDec } /batchStatus?uuids=uuid2` )
526
576
. reply ( 200 , successBatchStatusApiResponse ) ;
527
- await smartTransactionsController . fetchSmartTransactionsStatus ( uuids ) ;
577
+
578
+ await smartTransactionsController . fetchSmartTransactionsStatus (
579
+ uuids ,
580
+ CHAIN_IDS . ETHEREUM ,
581
+ ) ;
528
582
const successState = createStateAfterSuccess ( ) [ 0 ] ;
529
583
const successTransaction = { ...successState , history : [ successState ] } ;
530
584
expect ( smartTransactionsController . state ) . toStrictEqual ( {
@@ -541,6 +595,20 @@ describe('SmartTransactionsController', () => {
541
595
tradeTxFees : undefined ,
542
596
} ,
543
597
liveness : true ,
598
+ feesByChainId : {
599
+ '0x1' : {
600
+ approvalTxFees : undefined ,
601
+ tradeTxFees : undefined ,
602
+ } ,
603
+ '0x5' : {
604
+ approvalTxFees : undefined ,
605
+ tradeTxFees : undefined ,
606
+ } ,
607
+ } ,
608
+ livenessByChainId : {
609
+ '0x1' : true ,
610
+ '0x5' : true ,
611
+ } ,
544
612
} ,
545
613
} ) ;
546
614
} ) ;
0 commit comments