You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Keep PreferencesController in sync with keyring state (#3799)
## Explanation
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.
## References
Closes#3794
## Changelog
### `@metamask/keyring-controller`
#### Added
- Add `getDefaultKeyringState` function
#### Removed
- Remove `peerDependency` and `devDependency` upon
`@metamask/preferences-controller`
- This dependency was just used to access the types of four methods.
Those types are now inlined instead.
### `@metamask/preferences-controller`
#### Changed
- **BREAKING:** Keep `PreferencesController` state synchronized with
`KeyringController` state
- The `KeyringController:stateChange` event is now required by the
`PreferencesController` messenger, which is a breaking change.
- The package `@metamask/keyring-controller` has been added as a
`peerDependency` and as a `devDependency`, which is a breaking change.
- Previously the state was synchronized manually by calling
`syncIdentities` or `updateIdentities`. Calling these methods is no
longer required.
## Checklist
- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
0 commit comments