Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: network controller upgrade + network editing UI (#26433)
## **Description** This PR upgrades the network controller, and enables a new UI for adding and editing networks. The network controller changes are described in full in MetaMask/core#4286 In short, there's now a single network per chain id. Multiple RPC endpoints for a chain are now represented as an array under the single network configuration, instead of being separate networks. Each network has some RPC endpoint chosen as the default. Also the built in Infura networks are now represented in state, where they were not before. A migration is added to transform the network controller state to this new format. For the UI, networks are now added, edited, and deleted directly in the network list. Networks are no longer edited via the settings page. Users with multiple RPC endpoints per chain are shown a modal upon upgrade, allowing them to select a different endpoint as the default. The UI for `wallet_addEthereumChain` is changed, to message that users may be adding an additional endpoint to an existing network, rather than adding a new network. This PR contains both the controller upgrade and UI, because it's not possible to perfectly recrate the old UI with the new state or vice versa. To minimize changes, some selectors are shimmed to return equivalent data. This includes `getProviderConfig` and `getCurrentNetwork`. Other selectors have been removed in favor of selecting the new state, as there was no behavior that satisfied every caller. This includes `getNetworkConfigurations` and its dependents like `getNonTestNetworks` `getTestNetworks`. Places listing networks now go through the new `getNetworkConfigurationsByChainId`. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/26433?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** 1. Upgrade from an older build with custom networks 2. Verify they all still appear in the network dropdown - Verify multiple endpoints for the same chain have been merged into 1 network with multiple RPC endponits 3. Click the network dropdown 4. Try: - Adding popular networks - Adding a custom network - Editing an existing network - Deleting an existing network 5. Try adding a new network via a dapp 6. Try adding a new RPC endpoint to an existing network via a dapp ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** https://github.com/user-attachments/assets/dd215f30-9c83-4490-83c3-8aaf39412763 ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.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-extension/blob/develop/.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. --------- Co-authored-by: salimtb <[email protected]> Co-authored-by: MetaMask Bot <[email protected]> Co-authored-by: David Walsh <[email protected]> Co-authored-by: Howard Braham <[email protected]> Co-authored-by: Maarten Zuidhoorn <[email protected]>
- Loading branch information