metamask-mobile icon indicating copy to clipboard operation
metamask-mobile copied to clipboard

Refactor wallet_addEthereumChain implementation

Open saefstroem opened this issue 1 year ago • 2 comments

This commit updates the wallet_addEthereumChain function to check for the existence of a network configuration based on the RPC URL rather than the chain ID. By doing so, we prevent allow multiple networks to have the same chainId but be from different providers.

Description

  1. On Mobile, the current implementation of checking for matching network entries is done by checking chainId. This is incorrect because it prevents users to add additional RPC url's of the same chain in their Metamask app.
  2. Looks for matching networks by RPC url instead of chainId.

Related issues

Fixes: #9519

Manual testing steps

  1. Add default RPC for binance smart chain
  2. Go to 1rpc.io and add their BSC url.
  3. Metamask shall add the new BSC chain configuration from 1rpc to Metamask.

Screenshots/Recordings

N/A

Pre-merge author checklist

  • [x] I’ve followed MetaMask Coding Standards.
  • [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 format if applicable
  • [x] I’ve applied the right labels on the PR (see labeling guidelines). 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.

saefstroem avatar May 04 '24 15:05 saefstroem

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

github-actions[bot] avatar May 04 '24 15:05 github-actions[bot]

I have read the CLA Document and I hereby sign the CLA

saefstroem avatar May 04 '24 15:05 saefstroem

Closing as this work is redundant to work currently being done by Assets team on Network Controller.

smilingkylan avatar Sep 16 '24 21:09 smilingkylan