Skip to content

chore: allow deletion of selected network #6163

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Teng-Web3
Copy link
Contributor

@Teng-Web3 Teng-Web3 commented Jul 22, 2025

Explanation

The Global Network Selector is being removed In the new version of extension, we can select muti active networks, so we can remove any of them including the current(selected) one.

References

Fix : #6162
Related to: MetaMask/metamask-extension#34457

Changelog

After change

after_change.mp4

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@Teng-Web3 Teng-Web3 requested review from a team as code owners July 22, 2025 14:21
@Teng-Web3 Teng-Web3 marked this pull request as draft July 22, 2025 14:28
@Teng-Web3 Teng-Web3 marked this pull request as ready for review July 28, 2025 13:30
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Network Deletion Bug Causes Inconsistent State

Removing the check that prevented deletion of the currently selected network causes selectedNetworkClientId to point to a non-existent network, leading to an inconsistent state. The subsequent logic, designed for deleting an EVM network when a non-EVM network is selected, now incorrectly executes when deleting any currently selected network (including EVM), potentially causing unintended behavior like an automatic switch to EVM mainnet. The associated comment is also misleading.

packages/multichain-network-controller/src/MultichainNetworkController/MultichainNetworkController.ts#L202-L206

if (selectedChainId === hexChainId) {
// If a non-EVM network is selected, we can delete the currently EVM selected network, but
// we automatically switch to EVM mainnet.
const ethereumMainnetHexChainId = '0x1'; // TODO: Should probably be a constant.

packages/network-controller/src/NetworkController.ts#L2353-L2363

const autoManagedNetworkClientRegistry =
this.#ensureAutoManagedNetworkClientRegistryPopulated();
const networkClientOperations =
existingNetworkConfiguration.rpcEndpoints.map((rpcEndpoint) => {
return {
type: 'remove' as const,
rpcEndpoint,
};
});

Fix in Cursor Fix in Web


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow deletion of selected network
1 participant