From 1441829e5f35bdd637b81c8963b1ac057f6b0e02 Mon Sep 17 00:00:00 2001 From: jiexi Date: Fri, 8 Mar 2024 09:04:46 -0800 Subject: [PATCH] fix: Fix `wallet_switchEthereumChain` chainId validation (#8883) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** This PR makes `wallet_switchEthereumChain` chainId validation better ## **Related issues** ## **Manual testing steps** ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've clearly explained what problem this PR is solving and how it is solved. - [x] I've linked related issues - [x] I've included manual testing steps - [x] I've included screenshots/recordings if applicable - [ ] 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. - [ ] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [ ] In case it's "ready for review", I've changed it from "draft" to "non-draft". ## **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. --- app/util/regex/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/util/regex/index.ts b/app/util/regex/index.ts index c8ea480b955..1612a2f02e1 100644 --- a/app/util/regex/index.ts +++ b/app/util/regex/index.ts @@ -36,7 +36,7 @@ export const regex: RegexTypes = { nonNumber: /[^0-9.]/g, number: /^(\d+(\.\d+)?)$/, portfolioUrl: new RegExp(`${AppConstants.PORTFOLIO_URL}/(?![a-z])`), - prefixedFormattedHexString: /^0x[1-9a-f]+[0-9a-f]*$/iu, + prefixedFormattedHexString: /^0x[1-9a-f][0-9a-f]*$/iu, privateCredentials: /"/g, protocol: /^[a-z]*:\/\//, replaceNetworkErrorSentry: /0x[A-Fa-f0-9]{40}/u,