@@ -33,13 +33,6 @@ import { createDeferredPromise } from '@metamask/utils';
33
33
import assert from 'assert' ;
34
34
import * as uuidModule from 'uuid' ;
35
35
36
- import { FakeBlockTracker } from '../../../tests/fake-block-tracker' ;
37
- import { FakeProvider } from '../../../tests/fake-provider' ;
38
- import { flushPromises } from '../../../tests/helpers' ;
39
- import {
40
- buildCustomNetworkClientConfiguration ,
41
- buildMockGetNetworkClientById ,
42
- } from '../../network-controller/tests/helpers' ;
43
36
import { getAccountAddressRelationship } from './api/accounts-api' ;
44
37
import { CHAIN_IDS } from './constants' ;
45
38
import { DefaultGasFeeFlow } from './gas-flows/DefaultGasFeeFlow' ;
@@ -80,6 +73,7 @@ import {
80
73
TransactionType ,
81
74
WalletDevice ,
82
75
} from './types' ;
76
+ import { addTransactionBatch } from './utils/batch' ;
83
77
import { addGasBuffer , estimateGas , updateGas } from './utils/gas' ;
84
78
import { updateGasFees } from './utils/gas-fees' ;
85
79
import { getGasFeeFlow } from './utils/gas-flow' ;
@@ -92,6 +86,13 @@ import {
92
86
updatePostTransactionBalance ,
93
87
updateSwapsTransaction ,
94
88
} from './utils/swaps' ;
89
+ import { FakeBlockTracker } from '../../../tests/fake-block-tracker' ;
90
+ import { FakeProvider } from '../../../tests/fake-provider' ;
91
+ import { flushPromises } from '../../../tests/helpers' ;
92
+ import {
93
+ buildCustomNetworkClientConfiguration ,
94
+ buildMockGetNetworkClientById ,
95
+ } from '../../network-controller/tests/helpers' ;
95
96
96
97
type UnrestrictedMessenger = Messenger <
97
98
TransactionControllerActions | AllowedActions ,
@@ -111,6 +112,7 @@ jest.mock('./helpers/IncomingTransactionHelper');
111
112
jest . mock ( './helpers/MethodDataHelper' ) ;
112
113
jest . mock ( './helpers/MultichainTrackingHelper' ) ;
113
114
jest . mock ( './helpers/PendingTransactionTracker' ) ;
115
+ jest . mock ( './utils/batch' ) ;
114
116
jest . mock ( './utils/gas' ) ;
115
117
jest . mock ( './utils/gas-fees' ) ;
116
118
jest . mock ( './utils/gas-flow' ) ;
@@ -276,6 +278,7 @@ function buildMockBlockTracker(
276
278
277
279
/**
278
280
* Builds a mock gas fee flow.
281
+ *
279
282
* @returns The mocked gas fee flow.
280
283
*/
281
284
function buildMockGasFeeFlow ( ) : jest . Mocked < GasFeeFlow > {
@@ -488,6 +491,7 @@ describe('TransactionController', () => {
488
491
const getAccountAddressRelationshipMock = jest . mocked (
489
492
getAccountAddressRelationship ,
490
493
) ;
494
+ const addTransactionBatchMock = jest . mocked ( addTransactionBatch ) ;
491
495
const methodDataHelperClassMock = jest . mocked ( MethodDataHelper ) ;
492
496
493
497
let mockEthQuery : EthQuery ;
@@ -638,6 +642,7 @@ describe('TransactionController', () => {
638
642
'NetworkController:getNetworkClientById' ,
639
643
'NetworkController:findNetworkClientIdByChainId' ,
640
644
'AccountsController:getSelectedAccount' ,
645
+ 'AccountsController:getState' ,
641
646
] ,
642
647
allowedEvents : [ ] ,
643
648
} ) ;
@@ -648,6 +653,11 @@ describe('TransactionController', () => {
648
653
mockGetSelectedAccount ,
649
654
) ;
650
655
656
+ unrestrictedMessenger . registerActionHandler (
657
+ 'AccountsController:getState' ,
658
+ ( ) => ( { } ) as never ,
659
+ ) ;
660
+
651
661
const controller = new TransactionController ( {
652
662
...otherOptions ,
653
663
messenger : restrictedMessenger ,
@@ -1371,8 +1381,6 @@ describe('TransactionController', () => {
1371
1381
const mockDeviceConfirmedOn = WalletDevice . OTHER ;
1372
1382
const mockOrigin = 'origin' ;
1373
1383
const mockSecurityAlertResponse = {
1374
- // TODO: Either fix this lint violation or explain why it's necessary to ignore.
1375
- // eslint-disable-next-line @typescript-eslint/naming-convention
1376
1384
result_type : 'Malicious' ,
1377
1385
reason : 'blur_farming' ,
1378
1386
description :
@@ -1571,6 +1579,7 @@ describe('TransactionController', () => {
1571
1579
deviceConfirmedOn : undefined ,
1572
1580
id : expect . any ( String ) ,
1573
1581
isFirstTimeInteraction : undefined ,
1582
+ nestedTransactions : undefined ,
1574
1583
networkClientId : NETWORK_CLIENT_ID_MOCK ,
1575
1584
origin : undefined ,
1576
1585
securityAlertResponse : undefined ,
@@ -4166,8 +4175,6 @@ describe('TransactionController', () => {
4166
4175
const key = 'testKey' ;
4167
4176
const value = 123 ;
4168
4177
4169
- // TODO: Replace `any` with type
4170
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4171
4178
incomingTransactionHelperClassMock . mock . calls [ 0 ] [ 0 ] . updateCache (
4172
4179
( cache ) => {
4173
4180
cache [ key ] = value ;
@@ -4467,24 +4474,18 @@ describe('TransactionController', () => {
4467
4474
txParams : { ...TRANSACTION_META_MOCK . txParams , nonce : '0x1' } ,
4468
4475
} ;
4469
4476
4470
- // TODO: Either fix this lint violation or explain why it's necessary to ignore.
4471
- // eslint-disable-next-line @typescript-eslint/naming-convention
4472
4477
const duplicate_1 = {
4473
4478
...confirmed ,
4474
4479
id : 'testId2' ,
4475
4480
status : TransactionStatus . submitted ,
4476
4481
} ;
4477
4482
4478
- // TODO: Either fix this lint violation or explain why it's necessary to ignore.
4479
- // eslint-disable-next-line @typescript-eslint/naming-convention
4480
4483
const duplicate_2 = {
4481
4484
...duplicate_1 ,
4482
4485
id : 'testId3' ,
4483
4486
status : TransactionStatus . approved ,
4484
4487
} ;
4485
4488
4486
- // TODO: Either fix this lint violation or explain why it's necessary to ignore.
4487
- // eslint-disable-next-line @typescript-eslint/naming-convention
4488
4489
const duplicate_3 = {
4489
4490
...duplicate_1 ,
4490
4491
id : 'testId4' ,
@@ -5106,8 +5107,6 @@ describe('TransactionController', () => {
5106
5107
5107
5108
controller . updateSecurityAlertResponse ( transactionMeta . id , {
5108
5109
reason : 'NA' ,
5109
- // TODO: Either fix this lint violation or explain why it's necessary to ignore.
5110
- // eslint-disable-next-line @typescript-eslint/naming-convention
5111
5110
result_type : 'Benign' ,
5112
5111
} ) ;
5113
5112
@@ -5129,8 +5128,6 @@ describe('TransactionController', () => {
5129
5128
// @ts -expect-error Intentionally passing invalid input
5130
5129
controller . updateSecurityAlertResponse ( undefined , {
5131
5130
reason : 'NA' ,
5132
- // TODO: Either fix this lint violation or explain why it's necessary to ignore.
5133
- // eslint-disable-next-line @typescript-eslint/naming-convention
5134
5131
result_type : 'Benign' ,
5135
5132
} ) ,
5136
5133
) . toThrow (
@@ -5197,8 +5194,6 @@ describe('TransactionController', () => {
5197
5194
expect ( ( ) =>
5198
5195
controller . updateSecurityAlertResponse ( '456' , {
5199
5196
reason : 'NA' ,
5200
- // TODO: Either fix this lint violation or explain why it's necessary to ignore.
5201
- // eslint-disable-next-line @typescript-eslint/naming-convention
5202
5197
result_type : 'Benign' ,
5203
5198
} ) ,
5204
5199
) . toThrow (
@@ -6115,4 +6110,26 @@ describe('TransactionController', () => {
6115
6110
expect ( transaction ?. isActive ) . toBe ( true ) ;
6116
6111
} ) ;
6117
6112
} ) ;
6113
+
6114
+ describe ( 'addTransactionBatch' , ( ) => {
6115
+ it ( 'invokes util' , async ( ) => {
6116
+ const { controller } = setupController ( ) ;
6117
+
6118
+ await controller . addTransactionBatch ( {
6119
+ from : ACCOUNT_MOCK ,
6120
+ networkClientId : NETWORK_CLIENT_ID_MOCK ,
6121
+ transactions : [
6122
+ {
6123
+ params : {
6124
+ to : ACCOUNT_2_MOCK ,
6125
+ data : '0x123456' ,
6126
+ value : '0x123' ,
6127
+ } ,
6128
+ } ,
6129
+ ] ,
6130
+ } ) ;
6131
+
6132
+ expect ( addTransactionBatchMock ) . toHaveBeenCalledTimes ( 1 ) ;
6133
+ } ) ;
6134
+ } ) ;
6118
6135
} ) ;
0 commit comments