Skip to content

Commit c2a4312

Browse files
feat: support type 4 transactions (#5285)
## Explanation Support EIP-7702 / type 4 transactions including `authorizationList` via the `TransactionController`. Specifically: - Upgrade `ethereumjs/tx` and `ethereumjs/common`. - Add `setCode` to `TransactionEnvelopeType`. - Add `authorizationList` to `TransactionParams`. - Complete and sign all authorizations using `KeyringController` before signing transaction. - Prevent type 4 transactions if origin is not `ORIGIN_METAMASK`. - Validate `authorizationList` property before approval request. - Centralise prepare and serialization logic into `prepare.ts` utils. - Encapsulate all EIP-7702 specific logic in new `eip7702.ts` util. _Currently using a local messenger action type for the signing. To be replaced once available in the `KeyringController`._ ## References Fixes [#4095](MetaMask/MetaMask-planning#4095) ## Changelog ### `@metamask/transaction-controller` - **ADDED**: Add `setCode` to `TransactionEnvelopeType`. - **ADDED**: Add `authorizationList` to `TransactionParams`. - **CHANGED**: Bump `ethereumjs/tx` to `^5.4.0`. - **CHANGED**: Bump `ethereumjs/common` to `^4.4.0`. ## 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 highlighted breaking changes using the "BREAKING" category above as appropriate - [x] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
1 parent 1fbade9 commit c2a4312

16 files changed

+1075
-282
lines changed

eslint-warning-thresholds.json

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -575,12 +575,8 @@
575575
"promise/always-return": 2
576576
},
577577
"packages/transaction-controller/src/TransactionController.ts": {
578-
"@typescript-eslint/prefer-readonly": 11,
579578
"jsdoc/check-tag-names": 35,
580-
"jsdoc/require-returns": 5,
581-
"jsdoc/tag-lines": 1,
582-
"prettier/prettier": 1,
583-
"no-unused-private-class-members": 1
579+
"jsdoc/require-returns": 5
584580
},
585581
"packages/transaction-controller/src/TransactionControllerIntegration.test.ts": {
586582
"import-x/order": 4,
@@ -612,9 +608,6 @@
612608
"import-x/order": 1,
613609
"jsdoc/tag-lines": 1
614610
},
615-
"packages/transaction-controller/src/gas-flows/OracleLayer1GasFeeFlow.ts": {
616-
"@typescript-eslint/prefer-readonly": 2
617-
},
618611
"packages/transaction-controller/src/gas-flows/ScrollLayer1GasFeeFlow.test.ts": {
619612
"import-x/order": 1
620613
},
@@ -673,9 +666,6 @@
673666
"@typescript-eslint/prefer-readonly": 1,
674667
"jsdoc/tag-lines": 2
675668
},
676-
"packages/transaction-controller/src/types.ts": {
677-
"jsdoc/tag-lines": 4
678-
},
679669
"packages/transaction-controller/src/utils/external-transactions.test.ts": {
680670
"import-x/order": 1
681671
},
@@ -764,13 +754,6 @@
764754
"packages/transaction-controller/src/utils/utils.test.ts": {
765755
"import-x/order": 1
766756
},
767-
"packages/transaction-controller/src/utils/validation.test.ts": {
768-
"import-x/order": 1
769-
},
770-
"packages/transaction-controller/src/utils/validation.ts": {
771-
"@typescript-eslint/no-unsafe-enum-comparison": 2,
772-
"import-x/order": 1
773-
},
774757
"packages/user-operation-controller/src/UserOperationController.test.ts": {
775758
"jsdoc/tag-lines": 4
776759
},

packages/transaction-controller/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = merge(baseConfig, {
1818
coverageThreshold: {
1919
global: {
2020
branches: 91.76,
21-
functions: 94.76,
21+
functions: 94.62,
2222
lines: 96.83,
2323
statements: 96.82,
2424
},

packages/transaction-controller/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
4848
},
4949
"dependencies": {
50-
"@ethereumjs/common": "^3.2.0",
51-
"@ethereumjs/tx": "^4.2.0",
50+
"@ethereumjs/common": "^4.4.0",
51+
"@ethereumjs/tx": "^5.4.0",
5252
"@ethereumjs/util": "^8.1.0",
5353
"@ethersproject/abi": "^5.7.0",
5454
"@ethersproject/contracts": "^5.7.0",

0 commit comments

Comments
 (0)