Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sentry] feat: network controller upgrade + network editing UI #26433

Merged
merged 521 commits into from
Sep 20, 2024

Conversation

bergeron
Copy link
Contributor

@bergeron bergeron commented Aug 15, 2024

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

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

Before

After

Screen.Recording.2024-08-20.at.10.42.23.AM.mov

Pre-merge author checklist

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.

Copy link
Contributor

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.

Copy link

socket-security bot commented Aug 15, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@metamask/[email protected] None 0 133 kB metamaskbot

🚮 Removed packages: npm/@metamask/[email protected]

View full report↗︎

Copy link

socket-security bot commented Aug 15, 2024

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report↗︎

@bergeron
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated

@bergeron
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated

@salimtb
Copy link
Contributor

salimtb commented Aug 22, 2024

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated

@bergeron
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

No policy changes

ui/store/actions.ts Outdated Show resolved Hide resolved
Base automatically changed from brian/network-controller-v20 to develop August 23, 2024 15:30
@bergeron
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated

@salimtb
Copy link
Contributor

salimtb commented Aug 26, 2024

@metamaskbot update-policies

@darkwing darkwing removed the request for review from kumavis September 19, 2024 20:01
Copy link

sonarcloud bot commented Sep 19, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
74.7% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@bergeron
Copy link
Contributor Author

e2e ci is flakier today despite no real changes here. Some failures have happened recently on develop and I don't think are related, like Cannot destructure property 'metamask' of 'notificationWindowState' as it is null and New hosts found: user-storage.api.cx.metamask.io

@metamaskbot
Copy link
Collaborator

Builds ready [9107a7b]
Page Load Metrics (1626 ± 102 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint144624011631226108
domContentLoaded14102278160320498
load145423201626212102
domInteractive14134332612
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -1.63 KiB (-0.04%)
  • ui: 15.42 KiB (0.21%)
  • common: 9.2 KiB (0.11%)

@bergeron bergeron merged commit 555d42b into develop Sep 20, 2024
76 of 77 checks passed
@bergeron bergeron deleted the brian/network-controller-v20-merging-in-v21 branch September 20, 2024 08:35
@github-actions github-actions bot locked and limited conversation to collaborators Sep 20, 2024
@metamaskbot metamaskbot added the release-12.6.0 Issue or pull request that will be included in release 12.6.0 label Sep 20, 2024
@metamaskbot metamaskbot added release-12.5.0 Issue or pull request that will be included in release 12.5.0 and removed release-12.6.0 Issue or pull request that will be included in release 12.6.0 labels Sep 29, 2024
@metamaskbot
Copy link
Collaborator

Missing release label release-12.5.0 on PR. Adding release label release-12.5.0 on PR and removing other release labels(release-12.6.0), as PR was added to branch 12.5.0 when release was cut.

@metamaskbot metamaskbot changed the title feat: network controller upgrade + network editing UI [Sentry] feat: network controller upgrade + network editing UI Oct 24, 2024
@metamaskbot metamaskbot added type-bug area-Sentry error reporting to sentry regression-prod-12.5.0 Regression bug that was found in production in release 12.5.0 labels Oct 24, 2024
@bergeron bergeron restored the brian/network-controller-v20-merging-in-v21 branch October 24, 2024 15:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Sentry error reporting to sentry regression-prod-12.5.0 Regression bug that was found in production in release 12.5.0 release-12.5.0 Issue or pull request that will be included in release 12.5.0 team-assets type-bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.