From 19c43fc312226f669814336dc62d4976c43c75c8 Mon Sep 17 00:00:00 2001 From: Abbas Ali Date: Tue, 26 Nov 2024 20:57:36 +0530 Subject: [PATCH] fix: keyring issue --- packages/background/src/keyring/keyring.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/background/src/keyring/keyring.ts b/packages/background/src/keyring/keyring.ts index b9f26b34c5..0fb50ab344 100644 --- a/packages/background/src/keyring/keyring.ts +++ b/packages/background/src/keyring/keyring.ts @@ -1155,6 +1155,10 @@ export class KeyRing { ): Promise<{ multiKeyStoreInfo: MultiKeyStoreInfoWithSelected; }> { + if (this.password !== "" && this.status !== KeyRingStatus.UNLOCKED) { + await this.unlock(this.password); + } + if (this.status !== KeyRingStatus.UNLOCKED || this.password == "") { throw new Error("Key ring is locked or not initialized"); } @@ -1184,6 +1188,10 @@ export class KeyRing { ): Promise<{ multiKeyStoreInfo: MultiKeyStoreInfoWithSelected; }> { + if (this.password !== "" && this.status !== KeyRingStatus.UNLOCKED) { + await this.unlock(this.password); + } + if (this.status !== KeyRingStatus.UNLOCKED || this.password == "") { throw new Error("Key ring is locked or not initialized"); } @@ -1212,6 +1220,10 @@ export class KeyRing { ): Promise<{ multiKeyStoreInfo: MultiKeyStoreInfoWithSelected; }> { + if (this.password !== "" && this.status !== KeyRingStatus.UNLOCKED) { + await this.unlock(this.password); + } + if (this.status !== KeyRingStatus.UNLOCKED || this.password == "") { throw new Error("Key ring is locked or not initialized"); } @@ -1249,6 +1261,10 @@ export class KeyRing { ): Promise<{ multiKeyStoreInfo: MultiKeyStoreInfoWithSelected; }> { + if (this.password !== "" && this.status !== KeyRingStatus.UNLOCKED) { + await this.unlock(this.password); + } + if (this.status !== KeyRingStatus.UNLOCKED || this.password == "") { throw new Error("Key ring is locked or not initialized"); }