-
Notifications
You must be signed in to change notification settings - Fork 5.4k
release(runway): cherry-pick fix: cp-13.6.0 adding network does not update balance #37141
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
release(runway): cherry-pick fix: cp-13.6.0 adding network does not update balance #37141
Conversation
…nce (#37062) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** When adding a network the `selectedNetworkClientId` was not being updated and many of our components still depend on it. That is why a refresh was needed after adding a network <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> [](https://codespaces.new/MetaMask/metamask-extension/pull/37062?quickstart=1) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: when adding a network the `selectedNetworkClientId` was not being updated and many of our components still depend on it ## **Related issues** Fixes: #36845 & #36752 Maybe also fixes: #36806 ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **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/main/.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/main/.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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adding a network now automatically becomes the active network; UI no longer manually sets it active. > > - **Background (controller)**: > - Add `_addNetworkAndSetActive(networkConfiguration)` to add a network then set it active via its default RPC endpoint `networkClientId`. > - Replace exposed `addNetwork` API usages to call `_addNetworkAndSetActive` (both general UI API and multichain provider API paths). > - **UI (networks form)**: > - Remove manual `setActiveNetwork` after `addNetwork`; rely on background to activate the new network. > - Clean up related imports/types; still enables the network post-add. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 3b5c1cd. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: davidrentc <[email protected]> Co-authored-by: Salim TOUBAL <[email protected]>
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Results generated automatically by MetaMask CI |
Builds ready [95cf931]
UI Startup Metrics (1231 ± 90 ms)
|
|
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. |
| addedNetwork?.rpcEndpoints?.[addedNetwork.defaultRpcEndpointIndex] ?? {}; | ||
| await this.networkController.setActiveNetwork(networkClientId); | ||
| return addedNetwork; | ||
| } |
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.
Bug: Network Controller State Corruption
The _addNetworkAndSetActive method can pass undefined to setActiveNetwork. This happens when destructuring networkClientId from addedNetwork?.rpcEndpoints?.[addedNetwork.defaultRpcEndpointIndex] ?? {} if the RPC endpoint is missing or malformed, potentially leading to an invalid network controller state or errors.
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Results generated automatically by MetaMask CI |
Builds ready [3854b91]
UI Startup Metrics (1317 ± 85 ms)
|
|
No release label on PR. Adding release label release-13.6.0 on PR, as PR was cherry-picked in branch 13.6.0. |
Description
When adding a network the
selectedNetworkClientIdwas not beingupdated and many of our components still depend on it. That is why a
refresh was needed after adding a network
Changelog
CHANGELOG entry: when adding a network the
selectedNetworkClientIdwasnot being updated and many of our components still depend on it
Related issues
Fixes: #36845 &
#36752
Maybe also fixes:
#36806
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Docs and MetaMask
Extension Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
Pre-merge reviewer checklist
app, test code being changed).
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Note
Ensure newly added networks are immediately set active (updating
selectedNetworkClientId) and simplify UI flow to rely on this behavior._addNetworkAndSetActiveto add a network and set itsnetworkClientIdactive.addNetworkAPI bindings to use_addNetworkAndSetActiveingetApi()and EIP-1193 provider setup.networks-formadd flow: remove manualsetActiveNetworkand rely onaddNetworkto activate; minor type/import cleanup.selectedNetworkClientId.Written by Cursor Bugbot for commit 3854b91. This will update automatically on new commits. Configure here.
Co-authored-by: davidrentc [email protected]
Co-authored-by: Salim TOUBAL [email protected] 6e9ff43