Skip to content

Commit

Permalink
refactor: sync mem and persistent store
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesposito committed May 29, 2023
1 parent cd2c9eb commit d2c69f7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/keyring-controller/src/KeyringController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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(),
}));
}
Expand Down

0 comments on commit d2c69f7

Please sign in to comment.