From 412282299b97b0a073e08bc6dee489bad1004e89 Mon Sep 17 00:00:00 2001 From: Hassan Malik Date: Thu, 23 Apr 2026 13:37:57 -0400 Subject: [PATCH 1/2] feat: add isUnlocked action --- packages/keyring-controller/CHANGELOG.md | 2 ++ .../src/KeyringController-method-action-types.ts | 11 +++++++++++ packages/keyring-controller/src/KeyringController.ts | 1 + packages/keyring-controller/src/index.ts | 1 + 4 files changed, 15 insertions(+) diff --git a/packages/keyring-controller/CHANGELOG.md b/packages/keyring-controller/CHANGELOG.md index 2c94b6cbea2..e5dcf355074 100644 --- a/packages/keyring-controller/CHANGELOG.md +++ b/packages/keyring-controller/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Expose `KeyringController:isUnlocked` method through `KeyringController` messenger + - Returns `true` when the vault is unlocked, `false` otherwise. Mirrors `state.isUnlocked` and the `isUnlocked()` instance method, allowing consumers to check lock status via the messenger without holding a controller reference. - Add `withController` action to run atomic operations on multiple keyrings (within a single transaction) ([#8416](https://github.com/MetaMask/core/pull/8416)) - This action uses a `RestrictedController` object that exposes `addNewKeyring` and `removeKeyring` methods to add and remove keyring during the transaction (atomic) call. - Expose `KeyringController:signTransaction` method through `KeyringController` messenger ([#8408](https://github.com/MetaMask/core/pull/8408)) diff --git a/packages/keyring-controller/src/KeyringController-method-action-types.ts b/packages/keyring-controller/src/KeyringController-method-action-types.ts index 3f1bd62fee4..e5799d22cb0 100644 --- a/packages/keyring-controller/src/KeyringController-method-action-types.ts +++ b/packages/keyring-controller/src/KeyringController-method-action-types.ts @@ -58,6 +58,16 @@ export type KeyringControllerAddNewKeyringAction = { handler: KeyringController['addNewKeyring']; }; +/** + * Returns the status of the vault. + * + * @returns Boolean returning true if the vault is unlocked. + */ +export type KeyringControllerIsUnlockedAction = { + type: `KeyringController:isUnlocked`; + handler: KeyringController['isUnlocked']; +}; + /** * Returns the public addresses of all accounts from every keyring. * @@ -401,6 +411,7 @@ export type KeyringControllerMethodActions = | KeyringControllerCreateNewVaultAndRestoreAction | KeyringControllerCreateNewVaultAndKeychainAction | KeyringControllerAddNewKeyringAction + | KeyringControllerIsUnlockedAction | KeyringControllerGetAccountsAction | KeyringControllerGetEncryptionPublicKeyAction | KeyringControllerDecryptMessageAction diff --git a/packages/keyring-controller/src/KeyringController.ts b/packages/keyring-controller/src/KeyringController.ts index 3b8ef6aa691..f989e277586 100644 --- a/packages/keyring-controller/src/KeyringController.ts +++ b/packages/keyring-controller/src/KeyringController.ts @@ -76,6 +76,7 @@ const MESSENGER_EXPOSED_METHODS = [ 'createNewVaultAndKeychain', 'createNewVaultAndRestore', 'removeAccount', + 'isUnlocked', ] as const; /** diff --git a/packages/keyring-controller/src/index.ts b/packages/keyring-controller/src/index.ts index 4d570f0c98e..7da62e7fbdd 100644 --- a/packages/keyring-controller/src/index.ts +++ b/packages/keyring-controller/src/index.ts @@ -4,6 +4,7 @@ export type { KeyringControllerCreateNewVaultAndRestoreAction, KeyringControllerCreateNewVaultAndKeychainAction, KeyringControllerAddNewKeyringAction, + KeyringControllerIsUnlockedAction, KeyringControllerGetAccountsAction, KeyringControllerGetEncryptionPublicKeyAction, KeyringControllerDecryptMessageAction, From 83fffcb42c99c1d4583b9e031c8f47bc5452faa0 Mon Sep 17 00:00:00 2001 From: Hassan Malik Date: Thu, 23 Apr 2026 13:43:03 -0400 Subject: [PATCH 2/2] chore: update changelog --- packages/keyring-controller/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/keyring-controller/CHANGELOG.md b/packages/keyring-controller/CHANGELOG.md index e5dcf355074..84e4b860693 100644 --- a/packages/keyring-controller/CHANGELOG.md +++ b/packages/keyring-controller/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Expose `KeyringController:isUnlocked` method through `KeyringController` messenger +- Expose `KeyringController:isUnlocked` method through `KeyringController` messenger ([#8573](https://github.com/MetaMask/core/pull/8573)) - Returns `true` when the vault is unlocked, `false` otherwise. Mirrors `state.isUnlocked` and the `isUnlocked()` instance method, allowing consumers to check lock status via the messenger without holding a controller reference. - Add `withController` action to run atomic operations on multiple keyrings (within a single transaction) ([#8416](https://github.com/MetaMask/core/pull/8416)) - This action uses a `RestrictedController` object that exposes `addNewKeyring` and `removeKeyring` methods to add and remove keyring during the transaction (atomic) call.