snap_getClientStatus
Description
Get the status of the client running the Snap.
Parameters
This method does not have any parameters.
Returns
object
An object containing information about the client that the Snap is running in.
clientVersion
stringThe semantic version of the client that the Snap is running in.
platformVersion
stringThe Snaps platform version that the client is running.
locked
booleanA boolean flag that indicates whether the client is locked or not.
active
booleanA boolean flag that indicates whether the client is active or not. The client is considered active if the client is visible.
Example
import type { OnCronjobHandler } from "@metamask/snaps-sdk";
import { MethodNotFoundError } from "@metamask/snaps-sdk";
export const onCronjob: OnCronjobHandler = async ({ request }) => {
switch (request.method) {
case "execute":
// Find out if MetaMask is locked.
const { locked } = await snap.request({
method: "snap_getClientStatus",
});
if (!locked) {
// Do something that requires MetaMask to be unlocked, such as
// accessing the encrypted state.
}
default:
throw new MethodNotFoundError();
}
};