diff --git a/packages/keyring-controller/CHANGELOG.md b/packages/keyring-controller/CHANGELOG.md index 2c94b6cbea2..84e4b860693 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 ([#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. - 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,