From d2c69f7eb28d3714c8549fcf467275670046cfed Mon Sep 17 00:00:00 2001 From: Michele Esposito Date: Thu, 25 May 2023 10:08:41 +0200 Subject: [PATCH] refactor: sync mem and persistent store --- packages/keyring-controller/src/KeyringController.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/keyring-controller/src/KeyringController.ts b/packages/keyring-controller/src/KeyringController.ts index e3e1d455825..4eadd27da73 100644 --- a/packages/keyring-controller/src/KeyringController.ts +++ b/packages/keyring-controller/src/KeyringController.ts @@ -236,6 +236,7 @@ export class KeyringController extends BaseControllerV2< Object.assign({ initState: state }, config), ); this.#keyring.memStore.subscribe(this.#fullUpdate.bind(this)); + this.#keyring.store.subscribe(this.#fullUpdate.bind(this)); this.#keyring.on('lock', this.#handleLock.bind(this)); this.#keyring.on('unlock', this.#handleUnlock.bind(this)); @@ -814,12 +815,14 @@ export class KeyringController extends BaseControllerV2< } /** - * Sync controller state with current keyring memStore state. + * Sync controller state with current keyring store + * and memStore states. * * @fires KeyringController:stateChange */ #fullUpdate() { this.update(() => ({ + ...this.#keyring.store.getState(), ...this.#keyring.memStore.getState(), })); }