Skip to content

Commit 4678f2f

Browse files
committed
fix(transaction-controller): add isInternal: true to ExtraTransactionsPublishHook batch call
1 parent 7c30d1d commit 4678f2f

4 files changed

Lines changed: 36 additions & 0 deletions

File tree

packages/transaction-controller/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Fix `ExtraTransactionsPublishHook` not passing `isInternal: true` when calling `addTransactionBatch`, causing the duplicate-batch-ID guard to incorrectly throw `DuplicateBundleId` (error 5720) for nested ERC-20 gas-fee-token transfers that share a `batchId` with their parent batch ([#8884](https://github.com/MetaMask/core/pull/8884))
13+
1014
## [66.0.0]
1115

1216
### Changed

packages/transaction-controller/src/TransactionController.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3739,6 +3739,36 @@ describe('TransactionController', () => {
37393739
networkClientId: NETWORK_CLIENT_ID_MOCK,
37403740
});
37413741
});
3742+
3743+
it('does not throw if duplicate and isInternal is true', async () => {
3744+
const { controller } = setupController({
3745+
options: {
3746+
state: {
3747+
transactions: [
3748+
{
3749+
batchId: BATCH_ID_MOCK,
3750+
} as unknown as TransactionMeta,
3751+
],
3752+
},
3753+
},
3754+
updateToInitialState: true,
3755+
});
3756+
3757+
const txParams = {
3758+
from: ACCOUNT_MOCK,
3759+
to: ACCOUNT_MOCK,
3760+
};
3761+
3762+
const { result } = await controller.addTransaction(txParams, {
3763+
batchId: BATCH_ID_MOCK,
3764+
isInternal: true,
3765+
networkClientId: NETWORK_CLIENT_ID_MOCK,
3766+
origin: ORIGIN_MOCK,
3767+
requireApproval: false,
3768+
});
3769+
3770+
await result.catch(() => {});
3771+
});
37423772
});
37433773
});
37443774

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ describe('ExtraTransactionsPublishHook', () => {
121121
disable7702: true,
122122
disableHook: false,
123123
disableSequential: true,
124+
isInternal: true,
124125
requireApproval: false,
125126
});
126127
});

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ export class ExtraTransactionsPublishHook {
164164

165165
await this.#addTransactionBatch({
166166
from,
167+
isInternal: true,
167168
networkClientId,
168169
requireApproval: false,
169170
transactions,

0 commit comments

Comments
 (0)