The PreferencesController should listen for KeyringController state changes, and react to them appropriately. Specifically it should listen for account additions and removals, and ensure the selected address always points at an address that exists.
Today it doesn't react to these event changes because it relies upon the KeyringController calling the PreferencesController methods to update state. This is error prone and makes the KeyringController more complex than we'd like, and introduces a circular dependency between the controllers that would be nice to avoid.
The
PreferencesControllershould listen forKeyringControllerstate changes, and react to them appropriately. Specifically it should listen for account additions and removals, and ensure the selected address always points at an address that exists.Today it doesn't react to these event changes because it relies upon the
KeyringControllercalling thePreferencesControllermethods to update state. This is error prone and makes theKeyringControllermore complex than we'd like, and introduces a circular dependency between the controllers that would be nice to avoid.