snap_getClientStatus
Description
Get the status of the client running the Snap.
Returns
object
The result returned by the snap_getClientStatus method.
It returns an object containing useful information about the client.
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.
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();
}
};