import type { JsonRpcEngineEndCallback } from "@metamask/json-rpc-engine"; import type { Messenger } from "@metamask/messenger"; import type { PermissionControllerHasPermissionAction } from "@metamask/permission-controller"; import { type GetStateParams, type GetStateResult } from "@metamask/snaps-sdk"; import { type InferMatching } from "@metamask/snaps-utils"; import type { PendingJsonRpcResponse, Json } from "@metamask/utils"; import type { JsonRpcRequestWithOrigin, SnapControllerGetSnapStateAction } from "../types.mjs"; import type { MethodHooksObject } from "../utils.mjs"; export type GetStateMethodHooks = { /** * Wait for the extension to be unlocked. * * @returns A promise that resolves once the extension is unlocked. */ getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise; }; export type GetStateMethodActions = PermissionControllerHasPermissionAction | SnapControllerGetSnapStateAction; /** * Get the state of the Snap, or a specific value within the state. By default, * the data is automatically encrypted using a Snap-specific key and * automatically decrypted when retrieved. You can set `encrypted` to `false` to * use unencrypted storage (available when the client is locked). * * @example * ```json name="Manifest" * { * "initialPermissions": { * "snap_manageState": {} * } * } * ``` * ```ts name="Usage" * const state = await snap.request({ * method: 'snap_getState', * params: { * key: 'some.nested.value', // Optional, defaults to entire state * encrypted: true, // Optional, defaults to `true` * }, * }); * ``` */ export declare const getStateHandler: { implementation: typeof getStateImplementation; hookNames: MethodHooksObject; actionNames: ("SnapController:getSnapState" | "PermissionController:hasPermission")[]; }; declare const GetStateParametersStruct: import("@metamask/superstruct").Struct<{ encrypted?: boolean | undefined; key?: string | string[] | undefined; }, { key: import("@metamask/superstruct").Struct; encrypted: import("@metamask/superstruct").Struct; }>; export type GetStateParameters = InferMatching; /** * The `snap_getState` method implementation. * * @param request - The JSON-RPC request object. * @param response - The JSON-RPC response object. * @param _next - The `json-rpc-engine` "next" callback. Not used by this * function. * @param end - The `json-rpc-engine` "end" callback. * @param hooks - The RPC method hooks. * @param hooks.getUnlockPromise - Wait for the extension to be unlocked. * @param messenger - The messenger used to call controller actions. * @returns Nothing. */ declare function getStateImplementation(request: JsonRpcRequestWithOrigin, response: PendingJsonRpcResponse, _next: unknown, end: JsonRpcEngineEndCallback, { getUnlockPromise }: GetStateMethodHooks, messenger: Messenger): Promise; /** * 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. If an array of keys is provided, the result * is an object mapping each key to its value. * * 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 or keys to get. * @returns The value of the key in the object, or `null` if the key does not * exist. If an array of keys is provided, returns a `Record` mapping each key * to its value. */ export declare function get(value: Record | null, key?: string | string[] | undefined): Json; export {}; //# sourceMappingURL=getState.d.mts.map