From d1ea1a727b42d1a7fa0330f611ae676e9286beaf Mon Sep 17 00:00:00 2001 From: Salah-Eddine Saakoun Date: Fri, 4 Sep 2026 15:34:53 +0200 Subject: [PATCH] chore: bump @ethereumjs/tx to v5 @ethereumjs/tx ^4.2.0 -> ^5.4.0 The bump compiles with no source change, which is exactly the trap here. @ethereumjs/tx@5 reuses the name TxData for something entirely different: v4 TxData = a legacy transaction data object v5 TxData = { [TransactionType.Legacy]: LegacyTxData, [AccessListEIP2930]: ..., ... } v4's meaning is now called LegacyTxData. Since keyring.ts declares signTransaction as returning Promise, the bump alone would silently change that public type from "a signed legacy transaction" to "an object carrying every transaction type at once", and still build clean. Confirmed by typechecking a v4 era consumer against the unpatched build: Type '{ nonce, gasPrice, gasLimit, to, value, data, v, r, s }' is missing the following properties from type 'TxData': [TransactionType.Legacy], [TransactionType.AccessListEIP2930], ... Mapping TxData to LegacyTxData restores the original contract exactly, so the same consumer typechecks again and the bump is not breaking. TypedTxData would also accept it, but it is a union, so callers would have to narrow the result. LegacyTxData keeps the API identical to v4. --- CHANGELOG.md | 2 + package.json | 2 +- src/keyring.ts | 4 +- yarn.lock | 115 +++++++++++++++++++++++-------------------------- 4 files changed, 58 insertions(+), 65 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91d518e4e..6817943e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Bump `@ethereumjs/tx` from `^4.2.0` to `^5.4.0` ([#321](https://github.com/MetaMask/utils/pull/321)) + - The deprecated `Keyring.signTransaction` now returns `LegacyTxData` rather than `TxData`. These describe the same shape: `@ethereumjs/tx@5` repurposed the name `TxData` for a map keyed by transaction type and renamed the old meaning to `LegacyTxData`. Implementations do not need changing. - Bump `@metamask/scure-bip39` from `^2.0.3` to `^2.1.1` ([#311](https://github.com/MetaMask/utils/pull/311)) - Bump `@metamask/superstruct` from `^3.1.0` to `^3.4.1` ([#311](https://github.com/MetaMask/utils/pull/311)) - Bump `@noble/hashes` from `^1.3.1` to `^1.8.0` ([#311](https://github.com/MetaMask/utils/pull/311)) diff --git a/package.json b/package.json index 32e2f685d..f9bfbb4ab 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "test:watch": "jest --watch" }, "dependencies": { - "@ethereumjs/tx": "^4.2.0", + "@ethereumjs/tx": "^5.4.0", "@metamask/scure-bip39": "^2.1.1", "@metamask/superstruct": "^3.4.1", "@noble/hashes": "^1.8.0", diff --git a/src/keyring.ts b/src/keyring.ts index a669d0a83..30b422d21 100644 --- a/src/keyring.ts +++ b/src/keyring.ts @@ -1,4 +1,4 @@ -import type { TypedTransaction, TxData } from '@ethereumjs/tx'; +import type { TypedTransaction, LegacyTxData } from '@ethereumjs/tx'; import type { Eip1024EncryptedData } from './encryption-types'; import type { Hex } from './hex'; @@ -149,7 +149,7 @@ export type Keyring = { address: Hex, transaction: TypedTransaction, options?: Record, - ): Promise; + ): Promise; /** * Sign a message. This is equivalent to an older version of the the diff --git a/yarn.lock b/yarn.lock index 3845b61b6..659676d4a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -533,13 +533,12 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/common@npm:^3.2.0": - version: 3.2.0 - resolution: "@ethereumjs/common@npm:3.2.0" +"@ethereumjs/common@npm:^4.4.0": + version: 4.4.0 + resolution: "@ethereumjs/common@npm:4.4.0" dependencies: - "@ethereumjs/util": "npm:^8.1.0" - crc-32: "npm:^1.2.0" - checksum: 10/b3f612406b6bcefaf9117ceb42eff58d311e2b50205e3d55b4c793d803de517efbc84075e058dc0e2ec27a2bff11dfc279dda1fa2b249ed6ab3973be045898f4 + "@ethereumjs/util": "npm:^9.1.0" + checksum: 10/dd5cc78575a762b367601f94d6af7e36cb3a5ecab45eec0c1259c433e755a16c867753aa88f331e3963791a18424ad0549682a3a6a0a160640fe846db6ce8014 languageName: node linkType: hard @@ -561,26 +560,25 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/tx@npm:^4.2.0": - version: 4.2.0 - resolution: "@ethereumjs/tx@npm:4.2.0" +"@ethereumjs/tx@npm:^5.4.0": + version: 5.4.0 + resolution: "@ethereumjs/tx@npm:5.4.0" dependencies: - "@ethereumjs/common": "npm:^3.2.0" - "@ethereumjs/rlp": "npm:^4.0.1" - "@ethereumjs/util": "npm:^8.1.0" - ethereum-cryptography: "npm:^2.0.0" - checksum: 10/cbd2ffc3ef76ca5416d58f2f694858d9fcac946e6a107fef44cf3f308a7c9fcc996a6847868609354d72d5b356faee68408e9d5601c4c4f7dad8e18cb2c24a95 + "@ethereumjs/common": "npm:^4.4.0" + "@ethereumjs/rlp": "npm:^5.0.2" + "@ethereumjs/util": "npm:^9.1.0" + ethereum-cryptography: "npm:^2.2.1" + checksum: 10/8d2c0a69ab37015f945f9de065cfb9f05e8e79179efeed725ea0a14760c3eb8ff900bcf915bb71ec29fe2f753db35d1b78a15ac4ddec489e87c995dec1ba6e85 languageName: node linkType: hard -"@ethereumjs/util@npm:^8.1.0": - version: 8.1.0 - resolution: "@ethereumjs/util@npm:8.1.0" +"@ethereumjs/util@npm:^9.1.0": + version: 9.1.0 + resolution: "@ethereumjs/util@npm:9.1.0" dependencies: - "@ethereumjs/rlp": "npm:^4.0.1" - ethereum-cryptography: "npm:^2.0.0" - micro-ftch: "npm:^0.3.1" - checksum: 10/cc35338932e49b15e54ca6e548b32a1f48eed7d7e1d34ee743e4d3600dd616668bd50f70139e86c5c35f55aac35fba3b6cc4e6f679cf650aeba66bf93016200c + "@ethereumjs/rlp": "npm:^5.0.2" + ethereum-cryptography: "npm:^2.2.1" + checksum: 10/4e22c4081c63eebb808eccd54f7f91cd3407f4cac192da5f30a0d6983fe07d51f25e6a9d08624f1376e604bb7dce574aafcf0fbf0becf42f62687c11e710ac41 languageName: node linkType: hard @@ -1187,7 +1185,7 @@ __metadata: version: 0.0.0-use.local resolution: "@metamask/utils@workspace:." dependencies: - "@ethereumjs/tx": "npm:^4.2.0" + "@ethereumjs/tx": "npm:^5.4.0" "@lavamoat/allow-scripts": "npm:^3.0.4" "@lavamoat/preinstall-always-fail": "npm:^2.1.0" "@metamask/auto-changelog": "npm:^6.1.0" @@ -1250,19 +1248,19 @@ __metadata: languageName: node linkType: hard -"@noble/curves@npm:1.1.0, @noble/curves@npm:~1.1.0": - version: 1.1.0 - resolution: "@noble/curves@npm:1.1.0" +"@noble/curves@npm:1.4.2, @noble/curves@npm:~1.4.0": + version: 1.4.2 + resolution: "@noble/curves@npm:1.4.2" dependencies: - "@noble/hashes": "npm:1.3.1" - checksum: 10/7028e3f19a4a2a601f9159e5423f51ae86ab231bed79a6e40649b063e1ed7f55f5da0475f1377bd2c5a8e5fc485af9ce0549ad89da6b983d6af48e5d0a2041ca + "@noble/hashes": "npm:1.4.0" + checksum: 10/f433a2e8811ae345109388eadfa18ef2b0004c1f79417553241db4f0ad0d59550be6298a4f43d989c627e9f7551ffae6e402a4edf0173981e6da95fc7cab5123 languageName: node linkType: hard -"@noble/hashes@npm:1.3.1": - version: 1.3.1 - resolution: "@noble/hashes@npm:1.3.1" - checksum: 10/39474bab7e7813dbbfd8750476f48046d3004984e161fcd4333e40ca823f07b069010b35a20246e5b4ac20858e29913172a4d69720fd1e93620f7bedb70f9b72 +"@noble/hashes@npm:1.4.0, @noble/hashes@npm:~1.4.0": + version: 1.4.0 + resolution: "@noble/hashes@npm:1.4.0" + checksum: 10/e156e65794c473794c52fa9d06baf1eb20903d0d96719530f523cc4450f6c721a957c544796e6efd0197b2296e7cd70efeb312f861465e17940a3e3c7e0febc6 languageName: node linkType: hard @@ -1273,7 +1271,7 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:~1.3.0, @noble/hashes@npm:~1.3.1, @noble/hashes@npm:~1.3.2": +"@noble/hashes@npm:~1.3.2": version: 1.3.3 resolution: "@noble/hashes@npm:1.3.3" checksum: 10/1025ddde4d24630e95c0818e63d2d54ee131b980fe113312d17ed7468bc18f54486ac86c907685759f8a7e13c2f9b9e83ec7b67d1cc20836f36b5e4a65bb102d @@ -1829,31 +1827,31 @@ __metadata: languageName: node linkType: hard -"@scure/base@npm:~1.1.0, @scure/base@npm:~1.1.3": +"@scure/base@npm:~1.1.3, @scure/base@npm:~1.1.6": version: 1.1.9 resolution: "@scure/base@npm:1.1.9" checksum: 10/f0ab7f687bbcdee2a01377fe3cd808bf63977999672751295b6a92625d5322f4754a96d40f6bd579bc367aad48ecf8a4e6d0390e70296e6ded1076f52adb16bb languageName: node linkType: hard -"@scure/bip32@npm:1.3.1": - version: 1.3.1 - resolution: "@scure/bip32@npm:1.3.1" +"@scure/bip32@npm:1.4.0": + version: 1.4.0 + resolution: "@scure/bip32@npm:1.4.0" dependencies: - "@noble/curves": "npm:~1.1.0" - "@noble/hashes": "npm:~1.3.1" - "@scure/base": "npm:~1.1.0" - checksum: 10/0595955374dfa54a60adfa33d4793fd8b27230e962aaceb5bb5fcf8ccbb935184aa2c45154ec9bdfb26a1877b2ae0a8e4808c9a5464d4ffd971120740b816def + "@noble/curves": "npm:~1.4.0" + "@noble/hashes": "npm:~1.4.0" + "@scure/base": "npm:~1.1.6" + checksum: 10/6cd5062d902564d9e970597ec8b1adacb415b2eadfbb95aee1a1a0480a52eb0de4d294d3753aa8b48548064c9795ed108d348a31a8ce3fc88785377bb12c63b9 languageName: node linkType: hard -"@scure/bip39@npm:1.2.1": - version: 1.2.1 - resolution: "@scure/bip39@npm:1.2.1" +"@scure/bip39@npm:1.3.0": + version: 1.3.0 + resolution: "@scure/bip39@npm:1.3.0" dependencies: - "@noble/hashes": "npm:~1.3.0" - "@scure/base": "npm:~1.1.0" - checksum: 10/2ea368bbed34d6b1701c20683bf465e147f231a9e37e639b8c82f585d6f978bb0f3855fca7ceff04954ae248b3e313f5d322d0210614fb7acb402739415aaf31 + "@noble/hashes": "npm:~1.4.0" + "@scure/base": "npm:~1.1.6" + checksum: 10/7d71fd58153de22fe8cd65b525f6958a80487bc9d0fbc32c71c328aeafe41fa259f989d2f1e0fa4fdfeaf83b8fcf9310d52ed9862987e46c2f2bfb9dd8cf9fc1 languageName: node linkType: hard @@ -3323,7 +3321,7 @@ __metadata: languageName: node linkType: hard -"crc-32@npm:^1.2.0, crc-32@npm:^1.2.2": +"crc-32@npm:^1.2.2": version: 1.2.2 resolution: "crc-32@npm:1.2.2" bin: @@ -4027,15 +4025,15 @@ __metadata: languageName: node linkType: hard -"ethereum-cryptography@npm:^2.0.0": - version: 2.1.0 - resolution: "ethereum-cryptography@npm:2.1.0" +"ethereum-cryptography@npm:^2.0.0, ethereum-cryptography@npm:^2.2.1": + version: 2.2.1 + resolution: "ethereum-cryptography@npm:2.2.1" dependencies: - "@noble/curves": "npm:1.1.0" - "@noble/hashes": "npm:1.3.1" - "@scure/bip32": "npm:1.3.1" - "@scure/bip39": "npm:1.2.1" - checksum: 10/a8ad32d464729588ca29037ad1281020ee683677f82c16ad889607733b363a3a3595e4325e4920881a43a679f5adc300378edb3b431a887c8b275911ee9cbad5 + "@noble/curves": "npm:1.4.2" + "@noble/hashes": "npm:1.4.0" + "@scure/bip32": "npm:1.4.0" + "@scure/bip39": "npm:1.3.0" + checksum: 10/ab123bbfe843500ac2d645ce9edc4bc814962ffb598db6bf8bf01fbecac656e6c81ff4cf2472f1734844bbcbad2bf658d8b699cb7248d768e0f06ae13ecf43b8 languageName: node linkType: hard @@ -5872,13 +5870,6 @@ __metadata: languageName: node linkType: hard -"micro-ftch@npm:^0.3.1": - version: 0.3.1 - resolution: "micro-ftch@npm:0.3.1" - checksum: 10/a7ab07d25e28ec4ae492ce4542ea9b06eee85538742b3b1263b247366ee8872f2c5ce9c8651138b2f1d22c8212f691a7b8b5384fe86ead5aff1852e211f1c035 - languageName: node - linkType: hard - "micromatch@npm:^4.0.4": version: 4.0.8 resolution: "micromatch@npm:4.0.8"