@@ -265,6 +265,9 @@ describe('Batch Utils', () => {
265
265
} ,
266
266
} ,
267
267
] ,
268
+ disable7702 : false ,
269
+ disableHook : false ,
270
+ disableSequential : false ,
268
271
} ,
269
272
updateTransaction : updateTransactionMock ,
270
273
publishTransaction : publishTransactionMock ,
@@ -274,7 +277,7 @@ describe('Batch Utils', () => {
274
277
} ) ;
275
278
276
279
it ( 'returns generated batch ID' , async ( ) => {
277
- doesChainSupportEIP7702Mock . mockReturnValueOnce ( true ) ;
280
+ doesChainSupportEIP7702Mock . mockReturnValue ( true ) ;
278
281
279
282
isAccountUpgradedToEIP7702Mock . mockResolvedValueOnce ( {
280
283
delegationAddress : undefined ,
@@ -298,7 +301,7 @@ describe('Batch Utils', () => {
298
301
} ) ;
299
302
300
303
it ( 'returns provided batch ID' , async ( ) => {
301
- doesChainSupportEIP7702Mock . mockReturnValueOnce ( true ) ;
304
+ doesChainSupportEIP7702Mock . mockReturnValue ( true ) ;
302
305
303
306
isAccountUpgradedToEIP7702Mock . mockResolvedValueOnce ( {
304
307
delegationAddress : undefined ,
@@ -324,7 +327,7 @@ describe('Batch Utils', () => {
324
327
} ) ;
325
328
326
329
it ( 'adds generated EIP-7702 transaction' , async ( ) => {
327
- doesChainSupportEIP7702Mock . mockReturnValueOnce ( true ) ;
330
+ doesChainSupportEIP7702Mock . mockReturnValue ( true ) ;
328
331
329
332
isAccountUpgradedToEIP7702Mock . mockResolvedValueOnce ( {
330
333
delegationAddress : undefined ,
@@ -361,7 +364,7 @@ describe('Batch Utils', () => {
361
364
} ) ;
362
365
363
366
it ( 'uses type 4 transaction if not upgraded' , async ( ) => {
364
- doesChainSupportEIP7702Mock . mockReturnValueOnce ( true ) ;
367
+ doesChainSupportEIP7702Mock . mockReturnValue ( true ) ;
365
368
366
369
isAccountUpgradedToEIP7702Mock . mockResolvedValueOnce ( {
367
370
delegationAddress : undefined ,
@@ -403,7 +406,7 @@ describe('Batch Utils', () => {
403
406
} ) ;
404
407
405
408
it ( 'passes nested transactions to add transaction' , async ( ) => {
406
- doesChainSupportEIP7702Mock . mockReturnValueOnce ( true ) ;
409
+ doesChainSupportEIP7702Mock . mockReturnValue ( true ) ;
407
410
408
411
isAccountUpgradedToEIP7702Mock . mockResolvedValueOnce ( {
409
412
delegationAddress : undefined ,
@@ -444,7 +447,7 @@ describe('Batch Utils', () => {
444
447
} ) ;
445
448
446
449
it ( 'determines transaction type for nested transactions' , async ( ) => {
447
- doesChainSupportEIP7702Mock . mockReturnValueOnce ( true ) ;
450
+ doesChainSupportEIP7702Mock . mockReturnValue ( true ) ;
448
451
449
452
isAccountUpgradedToEIP7702Mock . mockResolvedValueOnce ( {
450
453
delegationAddress : undefined ,
@@ -489,23 +492,23 @@ describe('Batch Utils', () => {
489
492
} ) ;
490
493
491
494
it ( 'throws if chain not supported' , async ( ) => {
492
- doesChainSupportEIP7702Mock . mockReturnValueOnce ( false ) ;
495
+ doesChainSupportEIP7702Mock . mockReturnValue ( false ) ;
493
496
494
497
await expect ( addTransactionBatch ( request ) ) . rejects . toThrow (
495
- rpcErrors . internal ( 'Chain does not support EIP-7702' ) ,
498
+ rpcErrors . internal ( "Can't process batch" ) ,
496
499
) ;
497
500
} ) ;
498
501
499
502
it ( 'throws if no public key' , async ( ) => {
500
- doesChainSupportEIP7702Mock . mockReturnValueOnce ( true ) ;
503
+ doesChainSupportEIP7702Mock . mockReturnValue ( true ) ;
501
504
502
505
await expect (
503
506
addTransactionBatch ( { ...request , publicKeyEIP7702 : undefined } ) ,
504
507
) . rejects . toThrow ( rpcErrors . internal ( ERROR_MESSGE_PUBLIC_KEY ) ) ;
505
508
} ) ;
506
509
507
510
it ( 'throws if account upgraded to unsupported contract' , async ( ) => {
508
- doesChainSupportEIP7702Mock . mockReturnValueOnce ( true ) ;
511
+ doesChainSupportEIP7702Mock . mockReturnValue ( true ) ;
509
512
isAccountUpgradedToEIP7702Mock . mockResolvedValueOnce ( {
510
513
delegationAddress : CONTRACT_ADDRESS_MOCK ,
511
514
isSupported : false ,
@@ -517,7 +520,7 @@ describe('Batch Utils', () => {
517
520
} ) ;
518
521
519
522
it ( 'throws if account not upgraded and no upgrade address' , async ( ) => {
520
- doesChainSupportEIP7702Mock . mockReturnValueOnce ( true ) ;
523
+ doesChainSupportEIP7702Mock . mockReturnValue ( true ) ;
521
524
522
525
isAccountUpgradedToEIP7702Mock . mockResolvedValueOnce ( {
523
526
delegationAddress : undefined ,
@@ -542,7 +545,7 @@ describe('Batch Utils', () => {
542
545
} ) ;
543
546
544
547
it ( 'adds security alert ID to transaction' , async ( ) => {
545
- doesChainSupportEIP7702Mock . mockReturnValueOnce ( true ) ;
548
+ doesChainSupportEIP7702Mock . mockReturnValue ( true ) ;
546
549
547
550
isAccountUpgradedToEIP7702Mock . mockResolvedValueOnce ( {
548
551
delegationAddress : undefined ,
@@ -577,7 +580,7 @@ describe('Batch Utils', () => {
577
580
578
581
describe ( 'validates security' , ( ) => {
579
582
it ( 'using transaction params' , async ( ) => {
580
- doesChainSupportEIP7702Mock . mockReturnValueOnce ( true ) ;
583
+ doesChainSupportEIP7702Mock . mockReturnValue ( true ) ;
581
584
582
585
isAccountUpgradedToEIP7702Mock . mockResolvedValueOnce ( {
583
586
delegationAddress : undefined ,
@@ -624,7 +627,7 @@ describe('Batch Utils', () => {
624
627
} ) ;
625
628
626
629
it ( 'using delegation mock if not upgraded' , async ( ) => {
627
- doesChainSupportEIP7702Mock . mockReturnValueOnce ( true ) ;
630
+ doesChainSupportEIP7702Mock . mockReturnValue ( true ) ;
628
631
629
632
isAccountUpgradedToEIP7702Mock . mockResolvedValueOnce ( {
630
633
delegationAddress : undefined ,
@@ -680,6 +683,7 @@ describe('Batch Utils', () => {
680
683
mockRequestApproval ( MESSENGER_MOCK , {
681
684
state : 'approved' ,
682
685
} ) ;
686
+ doesChainSupportEIP7702Mock . mockReturnValueOnce ( false ) ;
683
687
} ) ;
684
688
685
689
it ( 'adds each nested transaction' , async ( ) => {
@@ -693,7 +697,7 @@ describe('Batch Utils', () => {
693
697
addTransactionBatch ( {
694
698
...request ,
695
699
publishBatchHook,
696
- request : { ...request . request , useHook : true } ,
700
+ request : { ...request . request , disable7702 : true } ,
697
701
} ) . catch ( ( ) => {
698
702
// Intentionally empty
699
703
} ) ;
@@ -745,7 +749,7 @@ describe('Batch Utils', () => {
745
749
addTransactionBatch ( {
746
750
...request ,
747
751
publishBatchHook,
748
- request : { ...request . request , useHook : true , origin } ,
752
+ request : { ...request . request , origin , disable7702 : true } ,
749
753
} ) . catch ( ( ) => {
750
754
// Intentionally empty
751
755
} ) ;
@@ -799,7 +803,7 @@ describe('Batch Utils', () => {
799
803
addTransactionBatch ( {
800
804
...request ,
801
805
publishBatchHook,
802
- request : { ...request . request , useHook : true } ,
806
+ request : { ...request . request , disable7702 : true } ,
803
807
} ) . catch ( ( ) => {
804
808
// Intentionally empty
805
809
} ) ;
@@ -878,7 +882,7 @@ describe('Batch Utils', () => {
878
882
addTransactionBatch ( {
879
883
...request ,
880
884
publishBatchHook,
881
- request : { ...request . request , useHook : true } ,
885
+ request : { ...request . request , disable7702 : true } ,
882
886
} ) . catch ( ( ) => {
883
887
// Intentionally empty
884
888
} ) ;
@@ -960,14 +964,14 @@ describe('Batch Utils', () => {
960
964
publishBatchHook,
961
965
request : {
962
966
...request . request ,
967
+ disable7702 : true ,
963
968
transactions : [
964
969
{
965
970
...request . request . transactions [ 0 ] ,
966
971
existingTransaction : EXISTING_TRANSACTION_MOCK ,
967
972
} ,
968
973
request . request . transactions [ 1 ] ,
969
974
] ,
970
- useHook : true ,
971
975
} ,
972
976
} ) . catch ( ( ) => {
973
977
// Intentionally empty
@@ -1063,6 +1067,7 @@ describe('Batch Utils', () => {
1063
1067
publishBatchHook,
1064
1068
request : {
1065
1069
...request . request ,
1070
+ disable7702 : true ,
1066
1071
transactions : [
1067
1072
{
1068
1073
...request . request . transactions [ 0 ] ,
@@ -1074,7 +1079,6 @@ describe('Batch Utils', () => {
1074
1079
} ,
1075
1080
request . request . transactions [ 1 ] ,
1076
1081
] ,
1077
- useHook : true ,
1078
1082
} ,
1079
1083
} ) . catch ( ( ) => {
1080
1084
// Intentionally empty
@@ -1125,7 +1129,7 @@ describe('Batch Utils', () => {
1125
1129
const resultPromise = addTransactionBatch ( {
1126
1130
...request ,
1127
1131
publishBatchHook,
1128
- request : { ...request . request , useHook : true } ,
1132
+ request : { ...request . request , disable7702 : true } ,
1129
1133
} ) ;
1130
1134
1131
1135
resultPromise . catch ( ( ) => {
@@ -1187,8 +1191,8 @@ describe('Batch Utils', () => {
1187
1191
publishBatchHook,
1188
1192
request : {
1189
1193
...request . request ,
1190
- useHook : true ,
1191
1194
requireApproval : false ,
1195
+ disable7702 : true ,
1192
1196
} ,
1193
1197
} ) . catch ( ( ) => {
1194
1198
// Intentionally empty
@@ -1244,8 +1248,8 @@ describe('Batch Utils', () => {
1244
1248
publishBatchHook,
1245
1249
request : {
1246
1250
...request . request ,
1247
- useHook : true ,
1248
1251
requireApproval : false ,
1252
+ disable7702 : true ,
1249
1253
} ,
1250
1254
} ) . catch ( ( ) => {
1251
1255
// Intentionally empty
@@ -1274,6 +1278,8 @@ describe('Batch Utils', () => {
1274
1278
let sequentialPublishBatchHook : jest . MockedFn < PublishBatchHook > ;
1275
1279
1276
1280
beforeEach ( ( ) => {
1281
+ doesChainSupportEIP7702Mock . mockReturnValue ( false ) ;
1282
+
1277
1283
sequentialPublishBatchHook = jest . fn ( ) ;
1278
1284
1279
1285
addTransactionMock
@@ -1360,9 +1366,7 @@ describe('Batch Utils', () => {
1360
1366
isSimulationEnabled : ( ) => isSimulationSupportedMock ( ) ,
1361
1367
request : { ...request . request , useHook : true } ,
1362
1368
} ) ,
1363
- ) . rejects . toThrow (
1364
- 'Cannot create transaction batch as simulation not supported' ,
1365
- ) ;
1369
+ ) . rejects . toThrow ( `Can't process batch` ) ;
1366
1370
} ) ;
1367
1371
1368
1372
it ( 'invokes sequentialPublishBatchHook when publishBatchHook is undefined' , async ( ) => {
@@ -1374,8 +1378,8 @@ describe('Batch Utils', () => {
1374
1378
publishBatchHook : undefined ,
1375
1379
request : {
1376
1380
...request . request ,
1377
- useHook : true ,
1378
1381
requireApproval : false ,
1382
+ disable7702 : true ,
1379
1383
} ,
1380
1384
} ) . catch ( ( ) => {
1381
1385
// Intentionally empty
@@ -1399,7 +1403,7 @@ describe('Batch Utils', () => {
1399
1403
addTransactionBatch ( {
1400
1404
...request ,
1401
1405
publishBatchHook : undefined ,
1402
- request : { ...request . request , useHook : true } ,
1406
+ request : { ...request . request , disable7702 : true } ,
1403
1407
} ) ,
1404
1408
) . rejects . toThrow ( 'Test error' ) ;
1405
1409
@@ -1417,7 +1421,11 @@ describe('Batch Utils', () => {
1417
1421
...request ,
1418
1422
publishBatchHook : undefined ,
1419
1423
messenger : MESSENGER_MOCK ,
1420
- request : { ...request . request , useHook : true , origin : ORIGIN_MOCK } ,
1424
+ request : {
1425
+ ...request . request ,
1426
+ origin : ORIGIN_MOCK ,
1427
+ disable7702 : true ,
1428
+ } ,
1421
1429
} ) . catch ( ( ) => {
1422
1430
// Intentionally empty
1423
1431
} ) ;
@@ -1457,8 +1465,8 @@ describe('Batch Utils', () => {
1457
1465
messenger : MESSENGER_MOCK ,
1458
1466
request : {
1459
1467
...request . request ,
1460
- useHook : true ,
1461
1468
origin : ORIGIN_MOCK ,
1469
+ disable7702 : true ,
1462
1470
} ,
1463
1471
} ) . catch ( ( ) => {
1464
1472
// Intentionally empty
@@ -1526,6 +1534,10 @@ describe('Batch Utils', () => {
1526
1534
} ) ;
1527
1535
1528
1536
describe ( 'isAtomicBatchSupported' , ( ) => {
1537
+ beforeEach ( ( ) => {
1538
+ jest . resetAllMocks ( ) ;
1539
+ } ) ;
1540
+
1529
1541
it ( 'includes all feature flag chains if chain IDs not specified' , async ( ) => {
1530
1542
getEIP7702SupportedChainsMock . mockReturnValueOnce ( [
1531
1543
CHAIN_ID_MOCK ,
0 commit comments