Skip to content

Commit 5eaa9d3

Browse files
authored
fix (cherry-pick): Adding patch on eth-json-rpc-middleware to disable verifyContract field validation for cosmos (#27065)
Cherry-picks #27021 (4ee09fc) ## **Description** Adding patch on eth-json-rpc-middleware to disable verifyContract field validation for cosmos ## **Related issues** Fixes: #26980 ## **Manual testing steps** 1. Submit a types signature request with verifyingContract set to `cosmos` 2. Ensure that you are able to sign it ## **Screenshots/Recordings** <img width="360" alt="Screenshot 2024-09-10 at 4 08 00 PM" src="https://github.com/user-attachments/assets/a56bb8bd-abed-4fae-9c50-a3a25addd5b5"> ## **Pre-merge author checklist** - [X] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.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 - [ ] 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-extension/blob/develop/.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.
1 parent 75fed52 commit 5eaa9d3

File tree

3 files changed

+44
-12
lines changed

3 files changed

+44
-12
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/dist/wallet.js b/dist/wallet.js
2+
index fce8272ab926443df4c5971c811664f849791425..9237ffcaaea2260e01182feecec667b10edd35a0 100644
3+
--- a/dist/wallet.js
4+
+++ b/dist/wallet.js
5+
@@ -293,7 +293,7 @@ exports.createWalletMiddleware = createWalletMiddleware;
6+
*/
7+
function validateVerifyingContract(data) {
8+
const { domain: { verifyingContract } = {} } = (0, normalize_1.parseTypedMessage)(data);
9+
- if (verifyingContract && !(0, utils_1.isValidHexAddress)(verifyingContract)) {
10+
+ if (verifyingContract && verifyingContract !== 'cosmos' && !(0, utils_1.isValidHexAddress)(verifyingContract)) {
11+
throw rpc_errors_1.rpcErrors.invalidInput();
12+
}
13+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@
303303
"@metamask/design-tokens": "^4.0.0",
304304
"@metamask/ens-controller": "^10.0.1",
305305
"@metamask/eth-json-rpc-filters": "^7.0.0",
306-
"@metamask/eth-json-rpc-middleware": "^14.0.1",
306+
"@metamask/eth-json-rpc-middleware": "patch:@metamask/eth-json-rpc-middleware@npm%3A14.0.1#~/.yarn/patches/@metamask-eth-json-rpc-middleware-npm-14.0.1-b6c2ccbe8c.patch",
307307
"@metamask/eth-ledger-bridge-keyring": "patch:@metamask/eth-ledger-bridge-keyring@npm%3A2.0.1#~/.yarn/patches/@metamask-eth-ledger-bridge-keyring-npm-2.0.1-7a5d815b2d.patch",
308308
"@metamask/eth-query": "^4.0.0",
309309
"@metamask/eth-sig-util": "^7.0.1",

yarn.lock

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5036,7 +5036,7 @@ __metadata:
50365036
languageName: node
50375037
linkType: hard
50385038

5039-
"@metamask/eth-block-tracker@npm:^9.0.2":
5039+
"@metamask/eth-block-tracker@npm:^9.0.2, @metamask/eth-block-tracker@npm:^9.0.3":
50405040
version: 9.0.3
50415041
resolution: "@metamask/eth-block-tracker@npm:9.0.3"
50425042
dependencies:
@@ -5088,26 +5088,45 @@ __metadata:
50885088
languageName: node
50895089
linkType: hard
50905090

5091+
"@metamask/eth-json-rpc-middleware@npm:14.0.1":
5092+
version: 14.0.1
5093+
resolution: "@metamask/eth-json-rpc-middleware@npm:14.0.1"
5094+
dependencies:
5095+
"@metamask/eth-block-tracker": "npm:^11.0.1"
5096+
"@metamask/eth-json-rpc-provider": "npm:^4.1.1"
5097+
"@metamask/eth-sig-util": "npm:^7.0.3"
5098+
"@metamask/json-rpc-engine": "npm:^9.0.2"
5099+
"@metamask/rpc-errors": "npm:^6.3.1"
5100+
"@metamask/utils": "npm:^9.1.0"
5101+
"@types/bn.js": "npm:^5.1.5"
5102+
bn.js: "npm:^5.2.1"
5103+
klona: "npm:^2.0.6"
5104+
pify: "npm:^5.0.0"
5105+
safe-stable-stringify: "npm:^2.4.3"
5106+
checksum: 10/39beecb0d2be19854b132fd615aee1f29195602d3db902f52755260b26a2c37c0a91cd635a09d4dc16f922d32bb229003b338228ae29577c5151d880fad04637
5107+
languageName: node
5108+
linkType: hard
5109+
50915110
"@metamask/eth-json-rpc-middleware@npm:^12.1.1":
5092-
version: 12.1.1
5093-
resolution: "@metamask/eth-json-rpc-middleware@npm:12.1.1"
5111+
version: 12.1.2
5112+
resolution: "@metamask/eth-json-rpc-middleware@npm:12.1.2"
50945113
dependencies:
5095-
"@metamask/eth-block-tracker": "npm:^9.0.2"
5096-
"@metamask/eth-json-rpc-provider": "npm:^2.1.0"
5114+
"@metamask/eth-block-tracker": "npm:^9.0.3"
5115+
"@metamask/eth-json-rpc-provider": "npm:^3.0.2"
50975116
"@metamask/eth-sig-util": "npm:^7.0.0"
5098-
"@metamask/json-rpc-engine": "npm:^7.1.1"
5117+
"@metamask/json-rpc-engine": "npm:^8.0.2"
50995118
"@metamask/rpc-errors": "npm:^6.0.0"
51005119
"@metamask/utils": "npm:^8.1.0"
51015120
klona: "npm:^2.0.6"
51025121
pify: "npm:^5.0.0"
51035122
safe-stable-stringify: "npm:^2.4.3"
5104-
checksum: 10/0018da198a4f8fbdeab25aa8184377b3215e365b2a631d0f8d7f0577e281c860a1d19fc58ad310afb6d005291c0797dabfe14bdb4adb16300c7f28b11fb26cbc
5123+
checksum: 10/1c0f186a35765394a28695bcade84c636b0c92cf3252219d1e9cbdd31231ad09fea5ec7bff7d31e2c7fe4d2158f15b54a5e42166549b69af1f7e475a1c7ae536
51055124
languageName: node
51065125
linkType: hard
51075126

5108-
"@metamask/eth-json-rpc-middleware@npm:^14.0.1":
5127+
"@metamask/eth-json-rpc-middleware@patch:@metamask/eth-json-rpc-middleware@npm%3A14.0.1#~/.yarn/patches/@metamask-eth-json-rpc-middleware-npm-14.0.1-b6c2ccbe8c.patch":
51095128
version: 14.0.1
5110-
resolution: "@metamask/eth-json-rpc-middleware@npm:14.0.1"
5129+
resolution: "@metamask/eth-json-rpc-middleware@patch:@metamask/eth-json-rpc-middleware@npm%3A14.0.1#~/.yarn/patches/@metamask-eth-json-rpc-middleware-npm-14.0.1-b6c2ccbe8c.patch::version=14.0.1&hash=96e7e0"
51115130
dependencies:
51125131
"@metamask/eth-block-tracker": "npm:^11.0.1"
51135132
"@metamask/eth-json-rpc-provider": "npm:^4.1.1"
@@ -5120,7 +5139,7 @@ __metadata:
51205139
klona: "npm:^2.0.6"
51215140
pify: "npm:^5.0.0"
51225141
safe-stable-stringify: "npm:^2.4.3"
5123-
checksum: 10/39beecb0d2be19854b132fd615aee1f29195602d3db902f52755260b26a2c37c0a91cd635a09d4dc16f922d32bb229003b338228ae29577c5151d880fad04637
5142+
checksum: 10/d1d97a845a8a9a5931c3853c6e2768a97ba289d676a2a8b6111077531943f9647430ef8e3f2a05f4643760ffdab1af0dc72574ca3010feadbdfab3dec345b7c8
51245143
languageName: node
51255144
linkType: hard
51265145

@@ -25272,7 +25291,7 @@ __metadata:
2527225291
"@metamask/eslint-config-typescript": "npm:^9.0.1"
2527325292
"@metamask/eslint-plugin-design-tokens": "npm:^1.1.0"
2527425293
"@metamask/eth-json-rpc-filters": "npm:^7.0.0"
25275-
"@metamask/eth-json-rpc-middleware": "npm:^14.0.1"
25294+
"@metamask/eth-json-rpc-middleware": "patch:@metamask/eth-json-rpc-middleware@npm%3A14.0.1#~/.yarn/patches/@metamask-eth-json-rpc-middleware-npm-14.0.1-b6c2ccbe8c.patch"
2527625295
"@metamask/eth-ledger-bridge-keyring": "patch:@metamask/eth-ledger-bridge-keyring@npm%3A2.0.1#~/.yarn/patches/@metamask-eth-ledger-bridge-keyring-npm-2.0.1-7a5d815b2d.patch"
2527725296
"@metamask/eth-query": "npm:^4.0.0"
2527825297
"@metamask/eth-sig-util": "npm:^7.0.1"

0 commit comments

Comments
 (0)