Uh oh!
There was an error while loading. Please reload this page.
fix: SelectedNetworkController network stateChange listener - #4638
Merged
mikesposito merged 5 commits intoSep 2, 2024
Conversation
mikesposito
changed the base branch from
main
to
group-network-configurations-by-chainAugust 26, 2024 10:27
SelectedNetworkController expected network stateChange patchSelectedNetworkController network stateChange listenermikespositoforce-pushed
the
fix/selected-network-controller-chainid-networks
branch
from
August 26, 2024 14:10
290f23a to
e0fda92CompareContributor
product change looks good, ive tested it via extension. Would be good to merge this to the main PR so we can publish a new preview release. Edit: I committed it to the main PR for that reason |
mikesposito
commented
Aug 28, 2024
MemberAuthor
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
mikesposito
commented
Aug 28, 2024
Comment on lines
195
to
207
MemberAuthor
There was a problem hiding this comment.
The usage of immer patches has been removed since it strictly depends on how state changes are made on the controller that originates the event.
We can reduce the number of events received by this listener using a selector
mikesposito
commented
Aug 28, 2024
Uh oh!
There was an error while loading. Please reload this page.
mikesposito
marked this pull request as ready for review
August 28, 2024 15:22
mikespositoforce-pushed
the
fix/selected-network-controller-chainid-networks
branch
from
September 2, 2024 10:01
aa8d6f7 to
e050d07Compare3 tasks
mikesposito
deleted the
fix/selected-network-controller-chainid-networks
branch
September 2, 2024 10:25
This file contains hidden or 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
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Explanation
Currently,
SelectedNetworkControllersubscribes to theNetworkController:stateChangeevent to make sure that network client ids associated with managed domains stay valid. Though, we are currently checking on the specific immer patch applied to the NetworkController state: this means that based on how the state draft was manipulated on the origin controller, we may or may not capture the change and react to it.To fix it, now
SelectedNetworkControllerwill look at the actual content of the updated state, instead of relying on immer patches. To reduce the amount of event instances received by the controller, a selector is applied to the subscription, filtering out irrelevant instances.References
Changelog
@metamask/network-controllergetNetworkConfigurations,getAvailableNetworkClientIdsandselectAvailableNetworkClientIdsselectors@metamask/selected-network-controllerNo consumer-faced changes
Checklist