Skip to content

Commit b46ad98

Browse files
wip
1 parent a5384b9 commit b46ad98

File tree

5 files changed

+26
-38
lines changed

5 files changed

+26
-38
lines changed

packages/transaction-controller/src/hooks/ExtraTransactionsPublishHook.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ describe('ExtraTransactionsPublishHook', () => {
8888
params: BATCH_TRANSACTION_PARAMS_2_MOCK,
8989
},
9090
],
91-
useHook: true,
9291
});
9392
});
9493

packages/transaction-controller/src/hooks/ExtraTransactionsPublishHook.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ export class ExtraTransactionsPublishHook {
107107
from,
108108
networkClientId,
109109
transactions,
110-
useHook: true,
111110
});
112111

113112
return resultPromise.promise;

packages/transaction-controller/src/types.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,12 +1569,6 @@ export type TransactionBatchRequest = {
15691569
/** Transactions to be submitted as part of the batch. */
15701570
transactions: TransactionBatchSingleRequest[];
15711571

1572-
/**
1573-
* Whether to use the publish batch hook to submit the batch.
1574-
* Defaults to false.
1575-
*/
1576-
useHook?: boolean;
1577-
15781572
/**
15791573
* Callback to trigger security validation in the client.
15801574
*

packages/transaction-controller/src/utils/batch.test.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -384,14 +384,6 @@ describe('Batch Utils', () => {
384384
);
385385
});
386386

387-
it('throws if chain not supported', async () => {
388-
doesChainSupportEIP7702Mock.mockReturnValueOnce(false);
389-
390-
await expect(addTransactionBatch(request)).rejects.toThrow(
391-
rpcErrors.internal('Chain does not support EIP-7702'),
392-
);
393-
});
394-
395387
it('throws if no public key', async () => {
396388
doesChainSupportEIP7702Mock.mockReturnValueOnce(true);
397389

@@ -570,6 +562,10 @@ describe('Batch Utils', () => {
570562
});
571563

572564
describe('with publish batch hook', () => {
565+
beforeEach(() => {
566+
doesChainSupportEIP7702Mock.mockReturnValueOnce(false);
567+
});
568+
573569
it('adds each nested transaction', async () => {
574570
const publishBatchHook = jest.fn();
575571

@@ -581,7 +577,7 @@ describe('Batch Utils', () => {
581577
addTransactionBatch({
582578
...request,
583579
publishBatchHook,
584-
request: { ...request.request, useHook: true },
580+
request: { ...request.request },
585581
}).catch(() => {
586582
// Intentionally empty
587583
});
@@ -639,7 +635,7 @@ describe('Batch Utils', () => {
639635
addTransactionBatch({
640636
...request,
641637
publishBatchHook,
642-
request: { ...request.request, useHook: true },
638+
request: { ...request.request },
643639
}).catch(() => {
644640
// Intentionally empty
645641
});
@@ -718,7 +714,7 @@ describe('Batch Utils', () => {
718714
addTransactionBatch({
719715
...request,
720716
publishBatchHook,
721-
request: { ...request.request, useHook: true },
717+
request: { ...request.request },
722718
}).catch(() => {
723719
// Intentionally empty
724720
});
@@ -801,7 +797,6 @@ describe('Batch Utils', () => {
801797
},
802798
request.request.transactions[1],
803799
],
804-
useHook: true,
805800
},
806801
}).catch(() => {
807802
// Intentionally empty
@@ -900,7 +895,6 @@ describe('Batch Utils', () => {
900895
},
901896
request.request.transactions[1],
902897
],
903-
useHook: true,
904898
},
905899
}).catch(() => {
906900
// Intentionally empty
@@ -951,7 +945,7 @@ describe('Batch Utils', () => {
951945
const resultPromise = addTransactionBatch({
952946
...request,
953947
publishBatchHook,
954-
request: { ...request.request, useHook: true },
948+
request: { ...request.request },
955949
});
956950

957951
resultPromise.catch(() => {
@@ -1011,7 +1005,7 @@ describe('Batch Utils', () => {
10111005
addTransactionBatch({
10121006
...request,
10131007
publishBatchHook,
1014-
request: { ...request.request, useHook: true },
1008+
request: { ...request.request },
10151009
}).catch(() => {
10161010
// Intentionally empty
10171011
});
@@ -1064,7 +1058,7 @@ describe('Batch Utils', () => {
10641058
addTransactionBatch({
10651059
...request,
10661060
publishBatchHook,
1067-
request: { ...request.request, useHook: true },
1061+
request: { ...request.request },
10681062
}).catch(() => {
10691063
// Intentionally empty
10701064
});
@@ -1089,6 +1083,10 @@ describe('Batch Utils', () => {
10891083
});
10901084

10911085
describe('with sequential publish batch hook', () => {
1086+
beforeEach(() => {
1087+
doesChainSupportEIP7702Mock.mockReturnValueOnce(false);
1088+
});
1089+
10921090
let sequentialPublishBatchHook: jest.MockedFn<PublishBatchHook>;
10931091

10941092
beforeEach(() => {
@@ -1158,7 +1156,7 @@ describe('Batch Utils', () => {
11581156
addTransactionBatch({
11591157
...request,
11601158
publishBatchHook: undefined,
1161-
request: { ...request.request, useHook: true },
1159+
request: { ...request.request },
11621160
}).catch(() => {
11631161
// Intentionally empty
11641162
});
@@ -1194,7 +1192,7 @@ describe('Batch Utils', () => {
11941192
const resultPromise = addTransactionBatch({
11951193
...request,
11961194
publishBatchHook: undefined,
1197-
request: { ...request.request, useHook: true },
1195+
request: { ...request.request },
11981196
});
11991197

12001198
resultPromise.catch(() => {
@@ -1220,7 +1218,7 @@ describe('Batch Utils', () => {
12201218
addTransactionBatch({
12211219
...request,
12221220
publishBatchHook: undefined,
1223-
request: { ...request.request, useHook: true },
1221+
request: { ...request.request },
12241222
}),
12251223
).rejects.toThrow('Test error');
12261224

@@ -1230,6 +1228,10 @@ describe('Batch Utils', () => {
12301228
});
12311229

12321230
describe('isAtomicBatchSupported', () => {
1231+
beforeEach(() => {
1232+
jest.resetAllMocks();
1233+
});
1234+
12331235
it('includes all feature flag chains if chain IDs not specified', async () => {
12341236
getEIP7702SupportedChainsMock.mockReturnValueOnce([
12351237
CHAIN_ID_MOCK,

packages/transaction-controller/src/utils/batch.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ export async function addTransactionBatch(
100100
sizeLimit,
101101
});
102102

103-
const { useHook } = userRequest;
104-
105103
log('Adding', userRequest);
106104

107-
if (useHook) {
108-
return await addTransactionBatchWithHook(request);
105+
const chainId = request.getChainId(request.request.networkClientId);
106+
const isChainSupportingEIP7702 = doesChainSupportEIP7702(chainId, messenger);
107+
if (isChainSupportingEIP7702) {
108+
return await addTransactionBatchWith7702(request);
109109
}
110110

111-
return await addTransactionBatchWith7702(request);
111+
return await addTransactionBatchWithHook(request);
112112
}
113113

114114
/**
@@ -249,12 +249,6 @@ async function addTransactionBatchWith7702(
249249

250250
const chainId = getChainId(networkClientId);
251251
const ethQuery = request.getEthQuery(networkClientId);
252-
const isChainSupported = doesChainSupportEIP7702(chainId, messenger);
253-
254-
if (!isChainSupported) {
255-
log('Chain does not support EIP-7702', chainId);
256-
throw rpcErrors.internal('Chain does not support EIP-7702');
257-
}
258252

259253
if (!publicKeyEIP7702) {
260254
throw rpcErrors.internal(ERROR_MESSGE_PUBLIC_KEY);

0 commit comments

Comments
 (0)