UNPKG

@metamask/snaps-rpc-methods

Version:
61 lines 2.8 kB
import type { JsonRpcEngineEndCallback } from "@metamask/json-rpc-engine"; import type { Messenger } from "@metamask/messenger"; import type { PermissionControllerHasPermissionAction } from "@metamask/permission-controller"; import type { ResolveInterfaceParams, ResolveInterfaceResult } from "@metamask/snaps-sdk"; import type { InferMatching } from "@metamask/snaps-utils"; import type { PendingJsonRpcResponse } from "@metamask/utils"; import type { JsonRpcRequestWithOrigin, SnapInterfaceControllerResolveInterfaceAction } from "../types.mjs"; export type ResolveInterfaceMethodActions = PermissionControllerHasPermissionAction | SnapInterfaceControllerResolveInterfaceAction; /** * Resolve an interactive interface. For use in * [custom dialogs](https://docs.metamask.io/snaps/features/custom-ui/dialogs/#display-a-custom-dialog). * * @example * ```ts * const id = await snap.request({ * method: 'snap_createInterface', * params: { * // The parameters to create the interface with. * }, * }); * * // Later, when the user has interacted with the interface, and you want to * // resolve it: * await snap.request({ * method: 'snap_resolveInterface', * params: { * id: interfaceId, * value: { * // The value to resolve the interface with. * }, * }, * }); * ``` */ export declare const resolveInterfaceHandler: { implementation: typeof getResolveInterfaceImplementation; actionNames: ("SnapInterfaceController:resolveInterface" | "PermissionController:hasPermission")[]; }; declare const ResolveInterfaceParametersStruct: import("@metamask/superstruct").Struct<{ id: string; value: import("@metamask/snaps-sdk").Json; }, { id: import("@metamask/superstruct").Struct<string, null>; value: import("@metamask/superstruct").Struct<import("@metamask/snaps-sdk").Json, unknown>; }>; export type ResolveInterfaceParameters = InferMatching<typeof ResolveInterfaceParametersStruct, ResolveInterfaceParams>; /** * The `snap_resolveInterface` method implementation. * * @param req - The JSON-RPC request object. * @param res - 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. Not used by this function. * @param messenger - The messenger used to call controller actions. * @returns Nothing. */ declare function getResolveInterfaceImplementation(req: JsonRpcRequestWithOrigin<ResolveInterfaceParameters>, res: PendingJsonRpcResponse<ResolveInterfaceResult>, _next: unknown, end: JsonRpcEngineEndCallback, _hooks: never, messenger: Messenger<string, ResolveInterfaceMethodActions>): Promise<void>; export {}; //# sourceMappingURL=resolveInterface.d.mts.map