-
-
Notifications
You must be signed in to change notification settings - Fork 200
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: Keep PreferencesController
in sync with keyring state
#3799
feat: Keep PreferencesController
in sync with keyring state
#3799
Conversation
f628c6e
to
656be76
Compare
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.
LGTM
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.
One question, but otherwise looks good.
packages/preferences-controller/src/PreferencesController.test.ts
Outdated
Show resolved
Hide resolved
The `PreferencesController` now listens for `KeyringController` state changes, and updates its own state in response to account removals or additions. New accounts are added to the `identities` state and given default labels. Removed accounts are removed from the `identities` state, and the `selectedAddress` is updated if it was removed. The dependency between these two packages has been flipped; the `@metamask/preferences-controller` package now depends upon `@metamask/keyring-controller` rather than the other away around, so that the `KeyringController` state type and state change event can be accessed. The dependency the other way was just to get the types for the four `PreferencesController` methods that are passed into the `KeyringController` constructor. These types were easily inlined, and these methods will soon be removed anyway. A `getDefaultKeyringState` export was added to the `@metamask/keyring-controller` package to make it easier to write the necessary `PreferencesController` tests. Closes #3794
bd4819d
to
f8b7715
Compare
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.
LGTM!
…roller-in-sync-with-keyrings * origin/main: chore(deps): bump @metamask/eth-keyring-controller from 17.0.0 to 17.0.1 (#3805) fix: custody keyring name (#3803) chore: update dependencies for `@metamask/accounts-controller` (#3747) fix: quick succession of submit password causing Accounts Controller state to be cleared (#3802) feat: add methods to support ERC-4337 accounts (#3602) feat: add getAccount action to AccountsController (#1892)
Merged in |
abdaeea
to
ee153a6
Compare
ee153a6
to
1ee4f74
Compare
Updated to use new latest keyring-controller version and bump lockfile |
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!
Explanation
The
PreferencesController
now listens forKeyringController
state changes, and updates its own state in response to account removals or additions. New accounts are added to theidentities
state and given default labels. Removed accounts are removed from theidentities
state, and theselectedAddress
is updated if it was removed.The dependency between these two packages has been flipped; the
@metamask/preferences-controller
package now depends upon@metamask/keyring-controller
rather than the other away around, so that theKeyringController
state type and state change event can be accessed. The dependency the other way was just to get the types for the fourPreferencesController
methods that are passed into theKeyringController
constructor. These types were easily inlined, and these methods will soon be removed anyway.A
getDefaultKeyringState
export was added to the@metamask/keyring-controller
package to make it easier to write the necessaryPreferencesController
tests.References
Closes #3794
Changelog
@metamask/keyring-controller
Added
getDefaultKeyringState
functionRemoved
peerDependency
anddevDependency
upon@metamask/preferences-controller
@metamask/preferences-controller
Changed
PreferencesController
state synchronized withKeyringController
stateKeyringController:stateChange
event is now required by thePreferencesController
messenger, which is a breaking change.@metamask/keyring-controller
has been added as apeerDependency
and as adevDependency
, which is a breaking change.syncIdentities
orupdateIdentities
. Calling these methods is no longer required.Checklist