@metamask/snaps-rpc-methods
Version:
MetaMask Snaps JSON-RPC method implementations
53 lines • 2.21 kB
text/typescript
import type { PermittedHandlerExport } from "@metamask/permission-controller";
import type { GetStateParams, GetStateResult } from "@metamask/snaps-sdk";
import { type InferMatching } from "@metamask/snaps-utils";
import type { Json } from "@metamask/utils";
/**
* `snap_getState` gets the state of the Snap.
*/
export declare const getStateHandler: PermittedHandlerExport<GetStateHooks, GetStateParameters, GetStateResult>;
export type GetStateHooks = {
/**
* Check if the requesting origin has a given permission.
*
* @param permissionName - The name of the permission to check.
* @returns Whether the origin has the permission.
*/
hasPermission: (permissionName: string) => boolean;
/**
* Get the state of the requesting Snap.
*
* @returns The current state of the Snap.
*/
getSnapState: (encrypted: boolean) => Promise<Record<string, Json>>;
/**
* Wait for the extension to be unlocked.
*
* @returns A promise that resolves once the extension is unlocked.
*/
getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;
};
declare const GetStateParametersStruct: import("@metamask/superstruct").Struct<{
encrypted?: boolean | undefined;
key?: string | undefined;
}, {
key: import("@metamask/superstruct").Struct<string | undefined, null>;
encrypted: import("@metamask/superstruct").Struct<boolean | undefined, null>;
}>;
export type GetStateParameters = InferMatching<typeof GetStateParametersStruct, GetStateParams>;
/**
* Get the value of a key in an object. The key may contain Lodash-style path
* syntax, e.g., `a.b.c` (with the exception of array syntax). If the key does
* not exist, `null` is returned.
*
* This is a simplified version of Lodash's `get` function, but Lodash doesn't
* seem to be maintained anymore, so we're using our own implementation.
*
* @param value - The object to get the key from.
* @param key - The key to get.
* @returns The value of the key in the object, or `null` if the key does not
* exist.
*/
export declare function get(value: Record<string, Json> | null, key?: string | undefined): Json;
export {};
//# sourceMappingURL=getState.d.cts.map