Skip to content

Commit 519d059

Browse files
feat: update container types (#6014)
## Explanation Support updating `containerTypes` property of `TransactionMeta` via `updateEditableParams` method. ## References ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary - [x] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
1 parent d1c1e05 commit 519d059

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

packages/transaction-controller/CHANGELOG.md

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

1010
### Added
1111

12+
- Support `containerTypes` property in `updateEditableParams` method ([#6014](https://github.com/MetaMask/core/pull/6014))
1213
- Add specific transaction types to outgoing transactions retrieved from accounts API ([#5987](https://github.com/MetaMask/core/pull/5987))
1314
- Add optional `amount` property to `transferInformation` object in `TransactionMeta` type.
1415

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ import {
7979
GasFeeEstimateType,
8080
SimulationErrorCode,
8181
SimulationTokenStandard,
82+
TransactionContainerType,
8283
TransactionEnvelopeType,
8384
TransactionStatus,
8485
TransactionType,
@@ -7157,6 +7158,29 @@ describe('TransactionController', () => {
71577158
);
71587159
});
71597160

7161+
it('updates container types', async () => {
7162+
const { controller } = setupController({
7163+
options: {
7164+
state: {
7165+
transactions: [transactionMeta],
7166+
},
7167+
},
7168+
updateToInitialState: true,
7169+
});
7170+
7171+
const updatedTransaction = await controller.updateEditableParams(
7172+
transactionId,
7173+
{
7174+
...params,
7175+
containerTypes: [TransactionContainerType.EnforcedSimulations],
7176+
},
7177+
);
7178+
7179+
expect(updatedTransaction?.containerTypes).toStrictEqual([
7180+
TransactionContainerType.EnforcedSimulations,
7181+
]);
7182+
});
7183+
71607184
it('throws an error if no transaction metadata is found', async () => {
71617185
const { controller } = setupController();
71627186
await expect(

packages/transaction-controller/src/TransactionController.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ import type {
119119
TransactionBatchMeta,
120120
AfterSimulateHook,
121121
BeforeSignHook,
122+
TransactionContainerType,
122123
} from './types';
123124
import {
124125
GasFeeEstimateLevel,
@@ -2027,6 +2028,7 @@ export class TransactionController extends BaseController<
20272028
*
20282029
* @param txId - The ID of the transaction to update.
20292030
* @param params - The editable parameters to update.
2031+
* @param params.containerTypes - Container types applied to the parameters.
20302032
* @param params.data - Data to pass with the transaction.
20312033
* @param params.from - Address to send the transaction from.
20322034
* @param params.gas - Maximum number of units of gas to use for the transaction.
@@ -2040,6 +2042,7 @@ export class TransactionController extends BaseController<
20402042
async updateEditableParams(
20412043
txId: string,
20422044
{
2045+
containerTypes,
20432046
data,
20442047
from,
20452048
gas,
@@ -2049,6 +2052,7 @@ export class TransactionController extends BaseController<
20492052
to,
20502053
value,
20512054
}: {
2055+
containerTypes?: TransactionContainerType[];
20522056
data?: string;
20532057
from?: string;
20542058
gas?: string;
@@ -2099,6 +2103,10 @@ export class TransactionController extends BaseController<
20992103

21002104
updatedTransaction.type = type;
21012105

2106+
if (containerTypes) {
2107+
updatedTransaction.containerTypes = containerTypes;
2108+
}
2109+
21022110
await updateTransactionLayer1GasFee({
21032111
layer1GasFeeFlows: this.#layer1GasFeeFlows,
21042112
messenger: this.messagingSystem,

0 commit comments

Comments
 (0)