-
Notifications
You must be signed in to change notification settings - Fork 5.5k
fix: fix network switch from dapp permission popover #39064
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
base: main
Are you sure you want to change the base?
fix: fix network switch from dapp permission popover #39064
Conversation
|
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. |
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/core-extension-ux (1 files, +4 -3)
|
|
|
||
| dispatch( | ||
| setNetworkClientIdForDomain(selectedTabOrigin, finalNetworkClientId), | ||
| await setNetworkClientIdForDomain( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setNetworkClientIdForDomain returns a Promise, not a Redux thunk. The code was incorrectly wrapping this function call with dispatch():
This caused the execution to fail silently, preventing setActiveNetwork from being reached.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great find! That does look like it's fixed it. Though I think the part that filters the global network menu is setEnabledNetworks not setActiveNetwork, right? Not totally sure what setActiveNetwork is supposed to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the setActiveNetwork is what switches the network; it calls the networkController.
The setEnabledNetworks; controls which networks appear in the network list UI
Just updates enabledNetworkMap state and it calls the networkEnablementController
Builds ready [9880904]
UI Startup Metrics (1273 ± 107 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Description
When clicking on an EVM network from the dapp connected site popover (the network button shown when a dapp is connected), the network would not switch on the home page. However, selecting a non-EVM network from the same menu would correctly switch the network.
Looking at the code, the intention was clearly for EVM networks to switch when selected - the
handleEvmNetworkChangefunction callssetActiveNetwork(finalNetworkClientId)which should update the globally selected network. However, this was silently failing.Non-EVM networks worked correctly because handleNonEvmNetworkChange does not have the dapp-specific code block that calls setNetworkClientIdForDomain. It simply calls setActiveNetwork(chainId) directly without going through the problematic code path
Changelog
CHANGELOG entry: Fixing a bug to allow switching evm networks on main page when selected from dapp connected site popover.
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist