metamask-mobile
metamask-mobile copied to clipboard
Refactor wallet_addEthereumChain implementation
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
- 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.
- Looks for matching networks by RPC url instead of chainId.
Related issues
Fixes: #9519
Manual testing steps
- Add default RPC for binance smart chain
- Go to 1rpc.io and add their BSC url.
- 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.
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.
I have read the CLA Document and I hereby sign the CLA
Closing as this work is redundant to work currently being done by Assets team on Network Controller.