-
Notifications
You must be signed in to change notification settings - Fork 5k
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
fix: Fix currentNetwork
selector when current network config is missing (#26327)
#26331
Merged
danjm
merged 3 commits into
Version-v12.0.1
from
v12-cherry-pick-fix-current-network-selector
Aug 5, 2024
Merged
fix: Fix currentNetwork
selector when current network config is missing (#26327)
#26331
danjm
merged 3 commits into
Version-v12.0.1
from
v12-cherry-pick-fix-current-network-selector
Aug 5, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gudahtt
force-pushed
the
v12-cherry-pick-fix-current-network-selector
branch
from
August 2, 2024 19:42
35ff1e4
to
fdd517b
Compare
adonesky1
approved these changes
Aug 2, 2024
…sing (#26327) The `providerConfig` state is not guaranteed to match a built-in or custom network. It should in the vast majority of cases, but there are some edge cases where that would not hold true. For example: * If the wallet crashed partway through removing the current network * If the user has had the same network selected since before we introduced the `networkConfigurations` state The `currentNetwork` selector has been updated to handle this case by returning a configuration object constructed from the `providerConfig` state directly. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/26327?quickstart=1) Fixes #26320 * Create a dev build and proceed through onboarding * Run this command in the background console to set `providerConfig` to a custom network that isn't present in the user's tracked network configurations: ``` chrome.storage.local.get( null, (state) => { state.data.NetworkController.providerConfig = { rpcUrl: 'https://mainnet.optimism.io', chainId: '0xa', ticker: 'ETH', type: 'rpc', }; chrome.storage.local.set(state, () => chrome.runtime.reload()); } ); ``` * See that the UI can be opened and does not crash. N/A - [x] 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). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] 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. - [ ] 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.
Gudahtt
force-pushed
the
v12-cherry-pick-fix-current-network-selector
branch
from
August 5, 2024 14:53
4f7bcb2
to
0b62420
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## Version-v12.0.1 #26331 +/- ##
================================================
Coverage 65.66% 65.66%
================================================
Files 1369 1369
Lines 54661 54663 +2
Branches 14223 14225 +2
================================================
+ Hits 35890 35893 +3
+ Misses 18771 18770 -1 ☔ View full report in Codecov by Sentry. |
Builds ready [0b62420]
Page Load Metrics (45 ± 5 ms)
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a cherry-pick of #26327 for v12.0.1. Original description below:
Description
The
providerConfig
state is not guaranteed to match a built-in or custom network. It should in the vast majority of cases, but there are some edge cases where that would not hold true. For example:networkConfigurations
stateThe
currentNetwork
selector has been updated to handle this case by returning a configuration object constructed from theproviderConfig
state directly.Related issues
Fixes #26320
Manual testing steps
providerConfig
to a custom network that isn't present in the user's tracked network configurations:Screenshots/Recordings
N/A
Pre-merge author checklist
Standards.
Pre-merge reviewer checklist