From 9b5a1e5293c9698d8cc5ed44ba86003f816aafa0 Mon Sep 17 00:00:00 2001 From: Brian Bergeron Date: Thu, 7 Nov 2024 07:41:21 -0800 Subject: [PATCH] fix: relax network symbol length validation (#11693) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** When adding a network with wallet_addEthereumChain, MetaMask was requiring the chain's symbol to be minimum of 2 characters. But there are networks with single character symbols. ## **Related issues** - Equivalent PR on extension: https://github.com/MetaMask/metamask-extension/pull/24872 - https://github.com/MetaMask/metamask-mobile/issues/11217 ## **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. --- app/core/RPCMethods/lib/ethereum-chain-utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/core/RPCMethods/lib/ethereum-chain-utils.js b/app/core/RPCMethods/lib/ethereum-chain-utils.js index 44fe63c1d33..cb71659205f 100644 --- a/app/core/RPCMethods/lib/ethereum-chain-utils.js +++ b/app/core/RPCMethods/lib/ethereum-chain-utils.js @@ -155,9 +155,9 @@ function validateNativeCurrency(nativeCurrency) { } const ticker = nativeCurrency?.symbol || 'ETH'; - if (typeof ticker !== 'string' || ticker.length < 2 || ticker.length > 6) { + if (typeof ticker !== 'string' || ticker.length < 1 || ticker.length > 6) { throw rpcErrors.invalidParams({ - message: `Expected 2-6 character string 'nativeCurrency.symbol'. Received:\n${ticker}`, + message: `Expected 1-6 character string 'nativeCurrency.symbol'. Received:\n${ticker}`, }); }