-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
Update controllers that rely on provider to listen to NetworkController:networkDidChange
instead of NetworkController:stateChange
#3610
Conversation
NetworkController:networkDidChange
instead of NetworkController:stateChange
NOTE: the |
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.
Looks good, should get a great performance improvement from this approach. Let's make sure to test the 'infura blocked' (or anything other network change errors) - These controllers will no longer have event handlers called when there is an error in switching the network. |
State updates from the network metadata flow would follow soon after a |
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.
Makes sense to me!
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
Explanation
Listening to
NetworkController:stateChange
to catch network changes doesn't guarantee that the provider proxy has also been updated to point to the new network.NetworkController:networkDidChange
does however. This PR updates several controllers that rely on the provider proxy to listen toNetworkController:networkDidChange
rather thanNetworkController:stateChange
. GasFeeController and AssetsContractController are already listening toNetworkController:networkDidChange
on the extension side despite their constructor param hook names still beingonNetworkStateChange
(which this PR also renames to be correct)References
Changelog
@metamask/assets-controllers
TokensController
constructor paramsonNetworkStateChange
replaced withonNetworkDidChange
AssetsContractController
constructor paramsonNetworkStateChange
replaced withonNetworkDidChange
@metamask/ens-controller
EnsController
constructor paramsonNetworkStateChange
replaced withonNetworkDidChange
@metamask/gas-fee-controller
GasFeeController
will subscribe toNetworkController:networkDidChange
now instead ofNetworkController:stateChange
using the passed inmessenger
param whenonNetworkDidChange
is not providedGasFeeController
constructor params optionalonNetworkStateChange
replaced with optionalonNetworkDidChange
Checklist