Skip to content

Commit

Permalink
fix: relax network symbol length validation (#11693)
Browse files Browse the repository at this point in the history
## **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:
MetaMask/metamask-extension#24872
-  #11217

## **Manual testing steps**



## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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.
  • Loading branch information
bergeron authored Nov 7, 2024
1 parent b2c9110 commit 9b5a1e5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/core/RPCMethods/lib/ethereum-chain-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
});
}

Expand Down

0 comments on commit 9b5a1e5

Please sign in to comment.