From 5ff0b2e24609d721c2993e08103c02cdc1c03952 Mon Sep 17 00:00:00 2001 From: Xiaoming Wang <7315988+dawnseeker8@users.noreply.github.com> Date: Wed, 13 Nov 2024 17:49:15 +0800 Subject: [PATCH 1/2] feat: upgrade @metamask/eth-ledger-bridge-keyring (#11836) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** This PR contain the upgrade of `@metamask/eth-ledger-bridge-keyring` library to latest `6.0.0`, which contain the latest `@ledgerhq/hw-eth-app` from ledger team, the latest `@ledgerhq/hw-eth-app` will provide following: 1. `clear-signing` feature support 2. replace `@ledgerhq/cryptoassets` with lighter package `@ledgerhq/cryptoassets-evm-signature` Regarding the package size anlysis from requirement https://github.com/MetaMask/accounts-planning/issues/567 after the upgrade of @ledgerhq/hw-eth-app to 6.39.0, the whole @ledgerhq library bundle did increase a little bit than before. (due to some new features support), but for `clear-signing` support, we may need to take the hit. ## **Related issues** Fixes: https://github.com/MetaMask/accounts-planning/issues/567 ## **Manual testing steps** Need a full regression on all ledger features to make sure all ledger features not broken by this library upgrade. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com> --- package.json | 2 +- patches/@ledgerhq+evm-tools+1.2.3.patch | 15 ++ patches/@ledgerhq+hw-app-eth+6.39.0.patch | 65 +++++++++ yarn.lock | 170 ++++++++++++++++------ 4 files changed, 204 insertions(+), 48 deletions(-) create mode 100644 patches/@ledgerhq+evm-tools+1.2.3.patch create mode 100644 patches/@ledgerhq+hw-app-eth+6.39.0.patch diff --git a/package.json b/package.json index 8ac2ebb7606..b48b67ac241 100644 --- a/package.json +++ b/package.json @@ -146,9 +146,9 @@ "@metamask/contract-metadata": "^2.1.0", "@metamask/controller-utils": "^11.3.0", "@metamask/design-tokens": "^4.0.0", + "@metamask/eth-ledger-bridge-keyring": "^6.0.0", "@metamask/eth-json-rpc-filters": "^8.0.0", "@metamask/eth-json-rpc-middleware": "^11.0.2", - "@metamask/eth-ledger-bridge-keyring": "^4.1.0", "@metamask/eth-query": "^4.0.0", "@metamask/eth-sig-util": "^7.0.2", "@metamask/eth-snap-keyring": "^4.3.3", diff --git a/patches/@ledgerhq+evm-tools+1.2.3.patch b/patches/@ledgerhq+evm-tools+1.2.3.patch new file mode 100644 index 00000000000..8cde5f4498a --- /dev/null +++ b/patches/@ledgerhq+evm-tools+1.2.3.patch @@ -0,0 +1,15 @@ +diff --git a/node_modules/@ledgerhq/evm-tools/lib/message/EIP712/index.js b/node_modules/@ledgerhq/evm-tools/lib/message/EIP712/index.js +index 5443ac0..57ec861 100644 +--- a/node_modules/@ledgerhq/evm-tools/lib/message/EIP712/index.js ++++ b/node_modules/@ledgerhq/evm-tools/lib/message/EIP712/index.js +@@ -28,8 +28,8 @@ const ethers_1 = require("ethers"); + const axios_1 = __importDefault(require("axios")); + const sha224_1 = __importDefault(require("crypto-js/sha224")); + const live_env_1 = require("@ledgerhq/live-env"); +-const eip712_1 = __importDefault(require("@ledgerhq/cryptoassets-evm-signatures/data/eip712")); +-const eip712_v2_1 = __importDefault(require("@ledgerhq/cryptoassets-evm-signatures/data/eip712_v2")); ++const eip712_1 = __importDefault(require("@ledgerhq/cryptoassets-evm-signatures/lib/data/eip712")); ++const eip712_v2_1 = __importDefault(require("@ledgerhq/cryptoassets-evm-signatures/lib/data/eip712_v2")); + // As defined in [spec](https://eips.ethereum.org/EIPS/eip-712), the properties below are all required. + function isEIP712Message(message) { + return (!!message && diff --git a/patches/@ledgerhq+hw-app-eth+6.39.0.patch b/patches/@ledgerhq+hw-app-eth+6.39.0.patch new file mode 100644 index 00000000000..a817ada8eb3 --- /dev/null +++ b/patches/@ledgerhq+hw-app-eth+6.39.0.patch @@ -0,0 +1,65 @@ +diff --git a/node_modules/@ledgerhq/hw-app-eth/lib/modules/EIP712/index.js b/node_modules/@ledgerhq/hw-app-eth/lib/modules/EIP712/index.js +index bbca23c..c85cb18 100644 +--- a/node_modules/@ledgerhq/hw-app-eth/lib/modules/EIP712/index.js ++++ b/node_modules/@ledgerhq/hw-app-eth/lib/modules/EIP712/index.js +@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); + exports.signEIP712HashedMessage = exports.signEIP712Message = void 0; + /* eslint-disable @typescript-eslint/no-duplicate-enum-values */ + const semver_1 = __importDefault(require("semver")); +-const index_1 = require("@ledgerhq/evm-tools/message/EIP712/index"); ++const index_1 = require("@ledgerhq/evm-tools/lib/message/EIP712/index"); + const erc20_1 = require("../../services/ledger/erc20"); + const utils_1 = require("../../utils"); + const loadConfig_1 = require("../../services/ledger/loadConfig"); +diff --git a/node_modules/@ledgerhq/hw-app-eth/lib/modules/EIP712/utils.js b/node_modules/@ledgerhq/hw-app-eth/lib/modules/EIP712/utils.js +index 4f09ea8..1cc7de0 100644 +--- a/node_modules/@ledgerhq/hw-app-eth/lib/modules/EIP712/utils.js ++++ b/node_modules/@ledgerhq/hw-app-eth/lib/modules/EIP712/utils.js +@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { + Object.defineProperty(exports, "__esModule", { value: true }); + exports.getPayloadForFilterV2 = exports.getFilterDisplayNameAndSigBuffers = exports.getAppAndVersion = exports.getCoinRefTokensMap = exports.makeTypeEntryStructBuffer = exports.constructTypeDescByteString = exports.destructTypeFromString = exports.EIP712_TYPE_ENCODERS = exports.EIP712_TYPE_PROPERTIES = void 0; + const bignumber_js_1 = __importDefault(require("bignumber.js")); +-const index_1 = require("@ledgerhq/evm-tools/message/index"); ++const index_1 = require("@ledgerhq/evm-tools/lib/message/index"); + const utils_1 = require("../../utils"); + /** + * @ignore for the README +diff --git a/node_modules/@ledgerhq/hw-app-eth/lib/services/ledger/erc20.js b/node_modules/@ledgerhq/hw-app-eth/lib/services/ledger/erc20.js +index 8fdedf8..c10cea2 100644 +--- a/node_modules/@ledgerhq/hw-app-eth/lib/services/ledger/erc20.js ++++ b/node_modules/@ledgerhq/hw-app-eth/lib/services/ledger/erc20.js +@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); + exports.byContractAddressAndChainId = exports.findERC20SignaturesInfo = void 0; + const axios_1 = __importDefault(require("axios")); + const logs_1 = require("@ledgerhq/logs"); +-const index_1 = require("@ledgerhq/cryptoassets-evm-signatures/data/evm/index"); ++const index_1 = require("@ledgerhq/cryptoassets-evm-signatures/lib/data/evm/index"); + const loadConfig_1 = require("./loadConfig"); + const asContractAddress = (addr) => { + const a = addr.toLowerCase(); +diff --git a/node_modules/@ledgerhq/hw-app-eth/lib/services/ledger/index.js b/node_modules/@ledgerhq/hw-app-eth/lib/services/ledger/index.js +index 8385537..6641b95 100644 +--- a/node_modules/@ledgerhq/hw-app-eth/lib/services/ledger/index.js ++++ b/node_modules/@ledgerhq/hw-app-eth/lib/services/ledger/index.js +@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); + // This implements the resolution of a Transaction using Ledger's own API + const logs_1 = require("@ledgerhq/logs"); + const abi_1 = require("@ethersproject/abi"); +-const index_1 = require("@ledgerhq/domain-service/signers/index"); ++const index_1 = require("@ledgerhq/domain-service/lib/signers/index"); + const erc20_1 = require("./erc20"); + const contracts_1 = require("./contracts"); + const nfts_1 = require("./nfts"); +diff --git a/node_modules/@ledgerhq/hw-app-eth/lib/utils.js b/node_modules/@ledgerhq/hw-app-eth/lib/utils.js +index 027089b..1c5da62 100644 +--- a/node_modules/@ledgerhq/hw-app-eth/lib/utils.js ++++ b/node_modules/@ledgerhq/hw-app-eth/lib/utils.js +@@ -2,7 +2,7 @@ + Object.defineProperty(exports, "__esModule", { value: true }); + exports.mergeResolutions = exports.nftSelectors = exports.tokenSelectors = exports.intAsHexBytes = exports.decodeTxInfo = exports.maybeHexBuffer = exports.hexBuffer = exports.splitPath = exports.padHexString = exports.ERC1155_CLEAR_SIGNED_SELECTORS = exports.ERC721_CLEAR_SIGNED_SELECTORS = exports.ERC20_CLEAR_SIGNED_SELECTORS = void 0; + const bignumber_js_1 = require("bignumber.js"); +-const index_1 = require("@ledgerhq/evm-tools/selectors/index"); ++const index_1 = require("@ledgerhq/evm-tools/lib/selectors/index"); + Object.defineProperty(exports, "ERC20_CLEAR_SIGNED_SELECTORS", { enumerable: true, get: function () { return index_1.ERC20_CLEAR_SIGNED_SELECTORS; } }); + Object.defineProperty(exports, "ERC721_CLEAR_SIGNED_SELECTORS", { enumerable: true, get: function () { return index_1.ERC721_CLEAR_SIGNED_SELECTORS; } }); + Object.defineProperty(exports, "ERC1155_CLEAR_SIGNED_SELECTORS", { enumerable: true, get: function () { return index_1.ERC1155_CLEAR_SIGNED_SELECTORS; } }); diff --git a/yarn.lock b/yarn.lock index 2878012d153..96154ff184b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1829,7 +1829,7 @@ dependencies: "@ethereumjs/util" "^9.0.3" -"@ethereumjs/rlp@^4.0.0", "@ethereumjs/rlp@^4.0.1": +"@ethereumjs/rlp@^4.0.1": version "4.0.1" resolved "https://registry.yarnpkg.com/@ethereumjs/rlp/-/rlp-4.0.1.tgz#626fabfd9081baab3d0a3074b0c7ecaf674aaa41" integrity sha512-tqsQiBQDQdmPWE1xkkBq4rlSW5QZpLOUJ5RJh2/9fug+q9tnUhuZoVLk7s0scUIKTOzEtR72DFBXI4WiZcMpvw== @@ -4200,53 +4200,100 @@ npm-normalize-package-bin "3.0.1" yargs "17.7.2" -"@ledgerhq/cryptoassets@^6.26.1": - version "6.37.0" - resolved "https://registry.yarnpkg.com/@ledgerhq/cryptoassets/-/cryptoassets-6.37.0.tgz#302833777bcd210809ca7820afb82cff8da5c296" - integrity sha512-xwrDKTS9koQBNNzc7CqgV6zfGHvNFWJjlIL0Kc4O4DVWYR2vUdztUHcvwHD1KPjxNYhVnsgIopmtq47fHt3nMg== +"@ledgerhq/cryptoassets-evm-signatures@^13.5.0": + version "13.5.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/cryptoassets-evm-signatures/-/cryptoassets-evm-signatures-13.5.0.tgz#19ad9c567fe40efa822b9f5a8d3968210024e704" + integrity sha512-lEz+orFtMVGysZ303n7C/aDrkYpKSHpuifJTt4/Bj4S9OwUv8ExnfazYL/fYMXMUmb1vwzfQ6nKBW01hiY5pBQ== dependencies: - invariant "2" + "@ledgerhq/live-env" "^2.3.0" + axios "1.7.7" -"@ledgerhq/devices@^8.4.2": - version "8.4.2" - resolved "https://registry.yarnpkg.com/@ledgerhq/devices/-/devices-8.4.2.tgz#f1c56194cf1343d56cad49c8feba92ad93432e14" - integrity sha512-oWNTp3jCMaEvRHsXNYE/yo+PFMgXAJGFHLOU1UdE4/fYkniHbD9wdxwyZrZvrxr9hNw4/9wHiThyITwPtMzG7g== +"@ledgerhq/devices@^8.4.2", "@ledgerhq/devices@^8.4.4": + version "8.4.4" + resolved "https://registry.yarnpkg.com/@ledgerhq/devices/-/devices-8.4.4.tgz#0d195c1650fe57da2fad7f0d9074a0190947cd6f" + integrity sha512-sz/ryhe/R687RHtevIE9RlKaV8kkKykUV4k29e7GAVwzHX1gqG+O75cu1NCJUHLbp3eABV5FdvZejqRUlLis9A== dependencies: - "@ledgerhq/errors" "^6.18.0" + "@ledgerhq/errors" "^6.19.1" "@ledgerhq/logs" "^6.12.0" rxjs "^7.8.1" semver "^7.3.5" -"@ledgerhq/errors@^6.10.0", "@ledgerhq/errors@^6.18.0": - version "6.18.0" - resolved "https://registry.yarnpkg.com/@ledgerhq/errors/-/errors-6.18.0.tgz#d55d6a57430d7a86532a9033ce0b45103264c620" - integrity sha512-L3jQWAGyooxRDk/MRlW2v4Ji9+kloBtdmz9wBkHaj2j0n+05rweJSV3GHw9oye1BYMbVFqFffmT4H3hlXlCasw== +"@ledgerhq/domain-service@^1.2.6": + version "1.2.6" + resolved "https://registry.yarnpkg.com/@ledgerhq/domain-service/-/domain-service-1.2.6.tgz#d8a38db38f44914ccb4fe9a12784730829fcbadb" + integrity sha512-tT1PFm71w2VFHJfCEoQ8znA8f1WRWGJJGEt8xql2YP0JFJygDe7PPbHTHHywLlZqo8GBqAGZzjTOmdyDcPPP1w== + dependencies: + "@ledgerhq/errors" "^6.19.1" + "@ledgerhq/logs" "^6.12.0" + "@ledgerhq/types-live" "^6.52.0" + axios "1.7.7" + eip55 "^2.1.1" + react "^18.2.0" + react-dom "^18.2.0" + +"@ledgerhq/errors@^6.18.0", "@ledgerhq/errors@^6.19.1": + version "6.19.1" + resolved "https://registry.yarnpkg.com/@ledgerhq/errors/-/errors-6.19.1.tgz#d9ac45ad4ff839e468b8f63766e665537aaede58" + integrity sha512-75yK7Nnit/Gp7gdrJAz0ipp31CCgncRp+evWt6QawQEtQKYEDfGo10QywgrrBBixeRxwnMy1DP6g2oCWRf1bjw== + +"@ledgerhq/evm-tools@^1.2.3": + version "1.2.3" + resolved "https://registry.yarnpkg.com/@ledgerhq/evm-tools/-/evm-tools-1.2.3.tgz#f5c9dec99cc36f73f6a6a6408ef78d8d6659633f" + integrity sha512-uQGygvpR1QAJ8hadpx/86GHrhyAz7xJN22GRUDQeYF8b1/i9TSzGXs1crjfFU2aF1+vUhIxv+s3wvbDR5v3/QA== + dependencies: + "@ledgerhq/cryptoassets-evm-signatures" "^13.5.0" + "@ledgerhq/live-env" "^2.3.0" + axios "1.7.7" + crypto-js "4.2.0" + ethers "5.7.2" -"@ledgerhq/hw-app-eth@6.26.1": - version "6.26.1" - resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-eth/-/hw-app-eth-6.26.1.tgz#c807087a563c4e1fb539116344ce114f5c84286b" - integrity sha512-maA5h+i92uoB+LXhkix1ZZWqI1qAxLBI5vEncuAbJubIQaJVv/BIlR3oAlZ+slNcq+9QUZ8vnzjRksn67kvoYA== +"@ledgerhq/hw-app-eth@^6.39.0": + version "6.39.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-eth/-/hw-app-eth-6.39.0.tgz#b4b1588d4adeddc1b4488f3d7d23e80170cb764c" + integrity sha512-T/lLwrY1cpXmAyjfSlSUt9lVdCmO1h2pigONtiTWysiwpCu2s4L1Bfk0qZoc5K68ohTahNVxviRJl1xqFg+fXA== dependencies: "@ethersproject/abi" "^5.5.0" "@ethersproject/rlp" "^5.5.0" - "@ledgerhq/cryptoassets" "^6.26.1" - "@ledgerhq/errors" "^6.10.0" - "@ledgerhq/hw-transport" "^6.24.1" - "@ledgerhq/logs" "^6.10.0" - axios "^0.26.0" - bignumber.js "^9.0.2" - -"@ledgerhq/hw-transport@^6.24.1", "@ledgerhq/hw-transport@^6.31.2": - version "6.31.2" - resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-6.31.2.tgz#79c95f7928a64a0e3b5bc4ea7b5be04b9f738322" - integrity sha512-B27UIzMzm2IXPGYnEB95R7eHxpXBkTBHh6MUJJQZVknt8LilEz1tfpTYUdzAKDGQ+Z5MZyYb01Eh3Zqm3kn3uw== + "@ledgerhq/cryptoassets-evm-signatures" "^13.5.0" + "@ledgerhq/domain-service" "^1.2.6" + "@ledgerhq/errors" "^6.19.1" + "@ledgerhq/evm-tools" "^1.2.3" + "@ledgerhq/hw-transport" "^6.31.4" + "@ledgerhq/hw-transport-mocker" "^6.29.4" + "@ledgerhq/logs" "^6.12.0" + "@ledgerhq/types-live" "^6.52.0" + axios "1.7.7" + bignumber.js "^9.1.2" + semver "^7.3.5" + +"@ledgerhq/hw-transport-mocker@^6.29.4": + version "6.29.4" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-mocker/-/hw-transport-mocker-6.29.4.tgz#c7828cbab304648f9d01643736b0c2e5040ca8cc" + integrity sha512-CLDIpQ/eqU8qrCYGY9MyHa+oMgqs6PuNkWtqbcaS4AzNx8L/9bv7y8CZwCjxX6oB/2ZEq42RlL6oZ6Ou3oHnoQ== dependencies: - "@ledgerhq/devices" "^8.4.2" - "@ledgerhq/errors" "^6.18.0" + "@ledgerhq/hw-transport" "^6.31.4" + "@ledgerhq/logs" "^6.12.0" + rxjs "^7.8.1" + +"@ledgerhq/hw-transport@^6.31.2", "@ledgerhq/hw-transport@^6.31.4": + version "6.31.4" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-6.31.4.tgz#9b23a6de4a4caaa5c24b149c2dea8adde46f0eb1" + integrity sha512-6c1ir/cXWJm5dCWdq55NPgCJ3UuKuuxRvf//Xs36Bq9BwkV2YaRQhZITAkads83l07NAdR16hkTWqqpwFMaI6A== + dependencies: + "@ledgerhq/devices" "^8.4.4" + "@ledgerhq/errors" "^6.19.1" "@ledgerhq/logs" "^6.12.0" events "^3.3.0" -"@ledgerhq/logs@^6.10.0", "@ledgerhq/logs@^6.12.0": +"@ledgerhq/live-env@^2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/live-env/-/live-env-2.3.0.tgz#8a5b9ead9269f0ac167434e6d5601da6b3e836f9" + integrity sha512-VWZso7/LdxxlaQqJ1tI44yrAadiJ78VUyQomlg7YY1eNI12+3xzWK8Rfs/aZEIQYp5q6ZBgbbDe7hmTtcAd4KQ== + dependencies: + rxjs "^7.8.1" + utility-types "^3.10.0" + +"@ledgerhq/logs@^6.12.0": version "6.12.0" resolved "https://registry.yarnpkg.com/@ledgerhq/logs/-/logs-6.12.0.tgz#ad903528bf3687a44da435d7b2479d724d374f5d" integrity sha512-ExDoj1QV5eC6TEbMdLUMMk9cfvNKhhv5gXol4SmULRVCx/3iyCPhJ74nsb3S0Vb+/f+XujBEj3vQn5+cwS0fNA== @@ -4264,6 +4311,14 @@ rxjs "^7.8.1" uuid "^9.0.1" +"@ledgerhq/types-live@^6.52.0": + version "6.52.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/types-live/-/types-live-6.52.0.tgz#71a6631ed5498104211f0b1c3dbaf2e2cc2407fd" + integrity sha512-3ZMUGGkeb0kLWr16SCS8cZRudVLafoYWBDyeBn0cqVtX8T5iUNmC+ICICsJZrn5KJcM0JsOs6DBuuFmSVJ1Q5Q== + dependencies: + bignumber.js "^9.1.2" + rxjs "^7.8.1" + "@log4js-node/log4js-api@^1.0.2": version "1.0.2" resolved "https://registry.yarnpkg.com/@log4js-node/log4js-api/-/log4js-api-1.0.2.tgz#7a8143fb33f077df3e579dca7f18fea74a02ec8b" @@ -4636,16 +4691,16 @@ "@metamask/utils" "^9.1.0" uuid "^8.3.2" -"@metamask/eth-ledger-bridge-keyring@^4.1.0": - version "4.1.0" - resolved "https://registry.yarnpkg.com/@metamask/eth-ledger-bridge-keyring/-/eth-ledger-bridge-keyring-4.1.0.tgz#90bb94b931ecba5c8ed9f0023b35f32f4ed8ac5a" - integrity sha512-ZNNV6zLwyEbzIAN8WHdTA372xst7/ajX/lvafbZDrSiiA+UuC0CfRSDOS+NOyCNnP+3NRBcJlo1ilDRYRe3ZZg== +"@metamask/eth-ledger-bridge-keyring@^6.0.0": + version "6.0.0" + resolved "https://registry.yarnpkg.com/@metamask/eth-ledger-bridge-keyring/-/eth-ledger-bridge-keyring-6.0.0.tgz#f62b6f3e286bdd3369c9360aa14300f86a24427c" + integrity sha512-xPNE/ZpmzwILnZ3a1JrcScSMdIL650fFPtrmf/7ZJRCyUlOoVWETpqUdSesLROC5WZBs8Ao1lus6YfTTqIsu6w== dependencies: - "@ethereumjs/rlp" "^4.0.0" + "@ethereumjs/rlp" "^5.0.2" "@ethereumjs/tx" "^4.2.0" - "@ethereumjs/util" "^8.0.0" - "@ledgerhq/hw-app-eth" "6.26.1" - "@metamask/eth-sig-util" "^7.0.1" + "@ethereumjs/util" "^8.1.0" + "@ledgerhq/hw-app-eth" "^6.39.0" + "@metamask/eth-sig-util" "^8.0.0" hdkey "^2.1.0" "@metamask/eth-query@^4.0.0": @@ -4669,7 +4724,7 @@ tweetnacl "^1.0.3" tweetnacl-util "^0.15.1" -"@metamask/eth-sig-util@^7.0.0", "@metamask/eth-sig-util@^7.0.1", "@metamask/eth-sig-util@^7.0.2", "@metamask/eth-sig-util@^7.0.3": +"@metamask/eth-sig-util@^7.0.0", "@metamask/eth-sig-util@^7.0.2", "@metamask/eth-sig-util@^7.0.3": version "7.0.3" resolved "https://registry.yarnpkg.com/@metamask/eth-sig-util/-/eth-sig-util-7.0.3.tgz#be9e444fe0b8474c04e2ff42fd983173767f6ac0" integrity sha512-PAtGnOkYvh90k2lEZldq/FK7GTLF6WxE+2bV85PoA3pqlJnmJCAY62tuvxHSwnVngSKlc4mcNvjnUg2eYO6JGg== @@ -13003,7 +13058,7 @@ axios-retry@^3.1.2: "@babel/runtime" "^7.15.4" is-retry-allowed "^2.2.0" -axios@1.4.0, axios@^0.26.0, axios@^0.28.0, axios@^0.x, axios@^1.6.7, axios@^1.6.8, axios@^1.7.4, axios@~1.6.8: +axios@1.4.0, axios@1.7.7, axios@^0.28.0, axios@^0.x, axios@^1.6.7, axios@^1.6.8, axios@^1.7.4, axios@~1.6.8: version "1.7.4" resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.4.tgz#4c8ded1b43683c8dd362973c393f3ede24052aa2" integrity sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw== @@ -13319,7 +13374,7 @@ bignumber.js@^7.2.1: resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-7.2.1.tgz#80c048759d826800807c4bfd521e50edbba57a5f" integrity sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ== -bignumber.js@^9.0.1, bignumber.js@^9.0.2, bignumber.js@^9.1.2: +bignumber.js@^9.0.1, bignumber.js@^9.1.2: version "9.1.2" resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.2.tgz#b7c4242259c008903b13707983b5f4bbd31eda0c" integrity sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug== @@ -16101,6 +16156,13 @@ ee-first@1.1.1: resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= +eip55@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/eip55/-/eip55-2.1.1.tgz#28b743c4701ac3c811b1e9fe67e39cf1d0781b96" + integrity sha512-WcagVAmNu2Ww2cDUfzuWVntYwFxbvZ5MvIyLZpMjTTkjD6sCvkGOiS86jTppzu9/gWsc8isLHAeMBWK02OnZmA== + dependencies: + keccak "^3.0.3" + ejs@^3.0.1: version "3.1.10" resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.10.tgz#69ab8358b14e896f80cc39e62087b88500c3ac3b" @@ -17131,7 +17193,7 @@ ethereumjs-wallet@^1.0.1: utf8 "^3.0.0" uuid "^8.3.2" -ethers@^5.0.14: +ethers@5.7.2, ethers@^5.0.14: version "5.7.2" resolved "https://registry.yarnpkg.com/ethers/-/ethers-5.7.2.tgz#3a7deeabbb8c030d4126b24f84e525466145872e" integrity sha512-wswUsmWo1aOK8rR7DIKiWSw9DbLWe6x98Jrn8wcTflTVvaXhAMaB5zGAXy0GYQEQp9iO1iSHWVyARQm11zUtyg== @@ -19493,7 +19555,7 @@ interpret@^3.1.1: resolved "https://registry.yarnpkg.com/interpret/-/interpret-3.1.1.tgz#5be0ceed67ca79c6c4bc5cf0d7ee843dcea110c4" integrity sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ== -invariant@*, invariant@2, invariant@2.2.4, invariant@^2.2.2, invariant@^2.2.3, invariant@^2.2.4: +invariant@*, invariant@2.2.4, invariant@^2.2.2, invariant@^2.2.3, invariant@^2.2.4: version "2.2.4" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA== @@ -21030,7 +21092,7 @@ junit-report-builder@^3.0.0: make-dir "^3.1.0" xmlbuilder "^15.1.1" -keccak@3.0.2, keccak@^3.0.0: +keccak@3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.2.tgz#4c2c6e8c54e04f2670ee49fa734eb9da152206e0" integrity sha512-PyKKjkH53wDMLGrvmRGSNWgmSxZOUqbnXwKL9tmgbFYA1iAYqW21kfR7mZXV0MlESiefxQQE9X9fTa3X+2MPDQ== @@ -21049,6 +21111,15 @@ keccak@^1.0.2: nan "^2.2.1" safe-buffer "^5.1.0" +keccak@^3.0.0, keccak@^3.0.3: + version "3.0.4" + resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.4.tgz#edc09b89e633c0549da444432ecf062ffadee86d" + integrity sha512-3vKuW0jV8J3XNTzvfyicFR5qvxrSAGl7KIhvgOu5cmWwM7tZRj3fMbj/pfIf4be7aznbc+prBWGjywox/g2Y6Q== + dependencies: + node-addon-api "^2.0.0" + node-gyp-build "^4.2.0" + readable-stream "^3.6.0" + keygrip@~1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/keygrip/-/keygrip-1.1.0.tgz#871b1681d5e159c62a445b0c74b615e0917e7226" @@ -28866,6 +28937,11 @@ utila@~0.4: resolved "https://registry.yarnpkg.com/utila/-/utila-0.4.0.tgz#8a16a05d445657a3aea5eecc5b12a4fa5379772c" integrity sha512-Z0DbgELS9/L/75wZbro8xAnT50pBVFQZ+hUEueGDU5FN51YSCYM+jdxsfCiHjwNP/4LCDD0i/graKpeBnOXKRA== +utility-types@^3.10.0: + version "3.11.0" + resolved "https://registry.yarnpkg.com/utility-types/-/utility-types-3.11.0.tgz#607c40edb4f258915e901ea7995607fdf319424c" + integrity sha512-6Z7Ma2aVEWisaL6TvBCy7P8rm2LQoPv6dJ7ecIaIixHcwfbJ0x7mWdbcwlIM5IGQxPZSFYeqRCqlOOeKoJYMkw== + utils-merge@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" From 09fa44a5ec3ad8584c8c56dc7345b5c7b182a2c6 Mon Sep 17 00:00:00 2001 From: cryptodev-2s <109512101+cryptodev-2s@users.noreply.github.com> Date: Wed, 13 Nov 2024 03:39:40 -0700 Subject: [PATCH 2/2] chore: bump `@metamask/ppom-validator` to `0.35.1` (#12225) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** This PR bumps `@metamask/ppom-validator` to `0.35.1` ## **Related issues** Fixes: https://github.com/MetaMask/metamask-mobile/issues/11134 ## **Manual testing steps** ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. Co-authored-by: Michele Esposito <34438276+mikesposito@users.noreply.github.com> --- app/core/Engine.ts | 5 +- package.json | 2 +- patches/@metamask+ppom-validator+0.32.0.patch | 69 ------------------- yarn.lock | 19 +++-- 4 files changed, 13 insertions(+), 82 deletions(-) delete mode 100644 patches/@metamask+ppom-validator+0.32.0.patch diff --git a/app/core/Engine.ts b/app/core/Engine.ts index 976ecc5a198..f166cc73782 100644 --- a/app/core/Engine.ts +++ b/app/core/Engine.ts @@ -118,6 +118,7 @@ import { import SwapsController, { swapsUtils } from '@metamask/swaps-controller'; import { PPOMController, + PPOMControllerActions, PPOMControllerEvents, PPOMState, } from '@metamask/ppom-validator'; @@ -317,6 +318,7 @@ type GlobalActions = | KeyringControllerActions | AccountsControllerActions | PreferencesControllerActions + | PPOMControllerActions | TokensControllerActions | TokenListControllerActions | SelectedNetworkControllerActions @@ -1674,11 +1676,10 @@ export class Engine { ).configuration.chainId, blockaidPublicKey: process.env.BLOCKAID_PUBLIC_KEY as string, cdnBaseUrl: process.env.BLOCKAID_FILE_CDN as string, - // @ts-expect-error TODO: Resolve/patch mismatch between base-controller versions. Before: never, never. Now: string, string, which expects 3rd and 4th args to be informed for restrictedControllerMessengers messenger: this.controllerMessenger.getRestricted({ name: 'PPOMController', allowedActions: ['NetworkController:getNetworkClientById'], - allowedEvents: [`${networkController.name}:stateChange`], + allowedEvents: [`${networkController.name}:networkDidChange`], }), onPreferencesChange: (listener) => this.controllerMessenger.subscribe( diff --git a/package.json b/package.json index b48b67ac241..a92eeba5f85 100644 --- a/package.json +++ b/package.json @@ -168,7 +168,7 @@ "@metamask/permission-controller": "^11.0.0", "@metamask/phishing-controller": "^12.0.3", "@metamask/post-message-stream": "^8.0.0", - "@metamask/ppom-validator": "0.32.0", + "@metamask/ppom-validator": "0.35.1", "@metamask/preferences-controller": "^13.1.0", "@metamask/profile-sync-controller": "^0.9.7", "@metamask/react-native-actionsheet": "2.4.2", diff --git a/patches/@metamask+ppom-validator+0.32.0.patch b/patches/@metamask+ppom-validator+0.32.0.patch deleted file mode 100644 index ce261de8e56..00000000000 --- a/patches/@metamask+ppom-validator+0.32.0.patch +++ /dev/null @@ -1,69 +0,0 @@ -diff --git a/node_modules/@metamask/ppom-validator/dist/ppom-controller.js b/node_modules/@metamask/ppom-validator/dist/ppom-controller.js -index 9cf1502..b74a350 100644 ---- a/node_modules/@metamask/ppom-validator/dist/ppom-controller.js -+++ b/node_modules/@metamask/ppom-validator/dist/ppom-controller.js -@@ -84,7 +84,7 @@ class PPOMController extends base_controller_1.BaseControllerV2 { - * This is useful to leverage faster native crypto implementation on devices. - * @returns The PPOMController instance. - */ -- constructor({ chainId, messenger, provider, storageBackend, securityAlertsEnabled, onPreferencesChange, ppomProvider, cdnBaseUrl, providerRequestLimit, state, blockaidPublicKey, nativeCrypto, }) { -+ constructor({ chainId, messenger, provider, storageBackend, securityAlertsEnabled, onPreferencesChange, ppomProvider, cdnBaseUrl, providerRequestLimit, state, blockaidPublicKey, nativeCrypto, getNetworkClientById}) { - const initialState = { - versionInfo: state?.versionInfo ?? [], - storageMetadata: state?.storageMetadata ?? [], -@@ -120,6 +120,10 @@ class PPOMController extends base_controller_1.BaseControllerV2 { - _PPOMController_blockaidPublicKey.set(this, void 0); - _PPOMController_ppomInitialised.set(this, false); - _PPOMController_nativeCrypto.set(this, undefined); -+ -+ // _PPOMController_getNetworkClientById.set(this, undefined); -+ -+ - __classPrivateFieldSet(this, _PPOMController_chainId, (0, util_1.addHexPrefix)(chainId), "f"); - __classPrivateFieldSet(this, _PPOMController_provider, provider, "f"); - __classPrivateFieldSet(this, _PPOMController_ppomProvider, ppomProvider, "f"); -@@ -140,6 +144,13 @@ class PPOMController extends base_controller_1.BaseControllerV2 { - __classPrivateFieldSet(this, _PPOMController_securityAlertsEnabled, securityAlertsEnabled, "f"); - __classPrivateFieldSet(this, _PPOMController_blockaidPublicKey, blockaidPublicKey, "f"); - __classPrivateFieldSet(this, _PPOMController_nativeCrypto, nativeCrypto, "f"); -+ -+ -+ -+ // __classPrivateFieldSet(this, _PPOMController_getNetworkClientById, getNetworkClientById, "f"); -+ -+ -+ - // enable / disable PPOM validations as user changes preferences - onPreferencesChange(__classPrivateFieldGet(this, _PPOMController_instances, "m", _PPOMController_onPreferenceChange).bind(this)); - // register message handlers -@@ -177,6 +188,18 @@ class PPOMController extends base_controller_1.BaseControllerV2 { - } - } - exports.PPOMController = PPOMController; -+const getCurrentNetwork = (networkControllerState) => { -+ const configurations = Object.values(networkControllerState.networkConfigurations); -+ if (configurations.length === 0) { -+ console.warn("No network configurations available."); -+ } else { -+ const currentNetwork = getCurrentNetwork(networkControllerState); -+ if (currentNetwork && currentNetwork.chainId) { -+ } else { -+ console.error("Current network or chainId is undefined."); -+ } -+ } -+ }; - _PPOMController_ppom = new WeakMap(), _PPOMController_provider = new WeakMap(), _PPOMController_storage = new WeakMap(), _PPOMController_ppomMutex = new WeakMap(), _PPOMController_ppomProvider = new WeakMap(), _PPOMController_cdnBaseUrl = new WeakMap(), _PPOMController_providerRequestLimit = new WeakMap(), _PPOMController_providerRequests = new WeakMap(), _PPOMController_chainId = new WeakMap(), _PPOMController_securityAlertsEnabled = new WeakMap(), _PPOMController_providerRequestsCount = new WeakMap(), _PPOMController_blockaidPublicKey = new WeakMap(), _PPOMController_ppomInitialised = new WeakMap(), _PPOMController_nativeCrypto = new WeakMap(), _PPOMController_instances = new WeakSet(), _PPOMController_initialisePPOM = - /* - * Initialise PPOM loading wasm file. -@@ -203,7 +226,10 @@ async function _PPOMController_initialisePPOM() { - console.error(`Error in deleting files: ${error.message}`); - }); - }, _PPOMController_onNetworkChange = function _PPOMController_onNetworkChange(networkControllerState) { -- const id = (0, util_1.addHexPrefix)(networkControllerState.providerConfig.chainId); -+ const selectedNetworkClient = this.messagingSystem.call('NetworkController:getNetworkClientById', networkControllerState.selectedNetworkClientId); -+ const { chainId } = selectedNetworkClient.configuration; -+ -+ const id = (0, util_1.addHexPrefix)(chainId); - if (id === __classPrivateFieldGet(this, _PPOMController_chainId, "f")) { - return; - } diff --git a/yarn.lock b/yarn.lock index 96154ff184b..e78d681dea2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4441,7 +4441,7 @@ single-call-balance-checker-abi "^1.0.0" uuid "^8.3.2" -"@metamask/base-controller@^3.0.0", "@metamask/base-controller@^3.2.3": +"@metamask/base-controller@^3.2.3": version "3.2.3" resolved "https://registry.yarnpkg.com/@metamask/base-controller/-/base-controller-3.2.3.tgz#7436a14f6789acf0814952dabaa70ee4fb7d473c" integrity sha512-k66oZe7BOEx0D5N5X8feE/32QlrUTmiEHHAZU/yCac2+VHllJOCEQV/cTeaAtgepnEf8O7SskvYZN+eIjgS99w== @@ -5014,7 +5014,7 @@ resolved "https://registry.yarnpkg.com/@metamask/mobile-provider/-/mobile-provider-3.0.0.tgz#8a6a5a0874c8cbe4b468f63dfc57117d207f9595" integrity sha512-XwFJk0rd9lAZR5xS3VC7ypEhD7DvZR2gi2Ch6PHnODIqeS9Te3OdVKK5+jHI4his8v/zs6LWdFdlRtx5/jL96w== -"@metamask/network-controller@^17.0.0", "@metamask/network-controller@^17.1.0": +"@metamask/network-controller@^17.1.0": version "17.2.1" resolved "https://registry.yarnpkg.com/@metamask/network-controller/-/network-controller-17.2.1.tgz#55d846e9e6000f3264e9ac1cc9c5b1493bac335a" integrity sha512-+cWbnqJyuLO+a3c9Rmdr10onNXv03J2Knl+IAR8QztAczqegtXB0pwTYlclU+j73Rsi9XWrUxS6fMGK1Vb3r9g== @@ -5259,15 +5259,14 @@ "@metamask/utils" "^9.0.0" readable-stream "3.6.2" -"@metamask/ppom-validator@0.32.0": - version "0.32.0" - resolved "https://registry.yarnpkg.com/@metamask/ppom-validator/-/ppom-validator-0.32.0.tgz#e732cd946605c3abb0e11f175013dab879166004" - integrity sha512-BHfKp2wZRhyamQ8YooD+r24wKrYb+ORO6zvwqOva3niWo/5iTNgFt/iQ6CS5dPeklCvyVH8RAxS6Fgk7Mu7XKA== +"@metamask/ppom-validator@0.35.1": + version "0.35.1" + resolved "https://registry.yarnpkg.com/@metamask/ppom-validator/-/ppom-validator-0.35.1.tgz#9ccece28f9f8947caef575849ef41f2ca15baa13" + integrity sha512-iaJRIFUXNBeuQwy+6B10mkPJDAmhvSyu5PAehSNSj+J2Q7Vy3AJe9GWI5t62j3IeDnwuny+Av+x/T+iI5D/b8w== dependencies: - "@metamask/base-controller" "^3.0.0" - "@metamask/controller-utils" "^8.0.1" - "@metamask/network-controller" "^17.0.0" - "@metamask/utils" "^8.3.0" + "@metamask/base-controller" "^7.0.1" + "@metamask/controller-utils" "^11.3.0" + "@metamask/utils" "^9.2.1" await-semaphore "^0.1.3" crypto-js "^4.2.0" elliptic "^6.5.4"