-
-
Notifications
You must be signed in to change notification settings - Fork 198
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
feat: decouple account sync logic from UserStorageController
#5078
base: main
Are you sure you want to change the base?
feat: decouple account sync logic from UserStorageController
#5078
Conversation
@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.
|
const mappedAccount = | ||
mapInternalAccountToUserStorageAccount(internalAccount); | ||
|
||
await getUserStorageControllerInstance().performSetStorage( |
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.
(not actionable, just a comment) Oooh... I just realised, that if we have the messenger, then you don't need the controller instance..
const messenger = options.getMessenger();
await messenger.call('UserStorageController:performSetStorage', ..., ....)
Hmm need to weigh pros/cons.
Pro:
- 1 less dependency to manage
- We technically don't need the entire controller instance, just methods, which this has.
Cons:
- I think tests (the messenger mock) may need to support this.
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.
Yeah no need to action this. Can be a future refactor if we want it.
But maybe we can store the instance as a variable so it can be reused (only if we call this alot).
const messenger = options.getMessenger()
const controller - options.getUserStorageControllerInstance();
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.
meh its fine
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.
This is exactly the type of thing the messenger is intended for! it's also intended to be very easy to mock (much easier than a controller).
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.
Nice cleanup and great test coverage.
Explanation
This PR moves the logic related to account syncing from
UserStorageController
to separated files in theaccount-syncing
folder.It also improves test coverage related to account syncing to 100%.
References
Related to #4923
isAccountSyncingInProgress
state key at various places to make it pass CI (as expected)NetworkController
and itsNetworkController:networkDidChange
event. This latest version is requested by our controller as part of the upcoming network syncing feature.NetworkController
tov22.1.1
(or another incriminated dependency TBD)Changelog
@metamask/profile-sync-controller
isAccountSyncingInProgress
state keyChecklist