import type { PermissionSpecificationBuilder, RestrictedMethodOptions } from '@metamask/permission-controller'; import { PermissionType } from '@metamask/permission-controller'; import type { Component } from '@metamask/snaps-ui'; import type { EnumToUnion } from '@metamask/snaps-utils'; import type { NonEmptyArray } from '@metamask/utils'; import type { Infer, Struct } from 'superstruct'; import type { MethodHooksObject } from '../utils'; declare const methodName = "snap_dialog"; export declare enum DialogType { Alert = "alert", Confirmation = "confirmation", Prompt = "prompt" } declare const PlaceholderStruct: Struct; export declare type Placeholder = Infer; declare type ShowDialog = (snapId: string, type: EnumToUnion, content: Component, placeholder?: Placeholder) => Promise; export declare type DialogMethodHooks = { /** * @param snapId - The ID of the Snap that created the alert. * @param type - The dialog type. * @param content - The dialog custom UI. * @param placeholder - The placeholder for the Prompt dialog input. */ showDialog: ShowDialog; }; declare type DialogSpecificationBuilderOptions = { allowedCaveats?: Readonly> | null; methodHooks: DialogMethodHooks; }; export declare const dialogBuilder: Readonly<{ readonly targetName: "snap_dialog"; readonly specificationBuilder: PermissionSpecificationBuilder; allowedCaveats: Readonly> | null; }>; readonly methodHooks: MethodHooksObject; }>; declare const DialogParametersStruct: Struct<{ type: "alert"; content: import("@metamask/snaps-ui").Panel | { value: string; type: import("@metamask/snaps-ui").NodeType.Copyable; } | { type: import("@metamask/snaps-ui").NodeType.Divider; } | { value: string; type: import("@metamask/snaps-ui").NodeType.Heading; } | { type: import("@metamask/snaps-ui").NodeType.Spinner; } | { value: string; type: import("@metamask/snaps-ui").NodeType.Text; markdown?: boolean | undefined; } | { value: string; type: import("@metamask/snaps-ui").NodeType.Image; }; } | { type: "confirmation"; content: import("@metamask/snaps-ui").Panel | { value: string; type: import("@metamask/snaps-ui").NodeType.Copyable; } | { type: import("@metamask/snaps-ui").NodeType.Divider; } | { value: string; type: import("@metamask/snaps-ui").NodeType.Heading; } | { type: import("@metamask/snaps-ui").NodeType.Spinner; } | { value: string; type: import("@metamask/snaps-ui").NodeType.Text; markdown?: boolean | undefined; } | { value: string; type: import("@metamask/snaps-ui").NodeType.Image; }; } | { type: "prompt"; content: import("@metamask/snaps-ui").Panel | { value: string; type: import("@metamask/snaps-ui").NodeType.Copyable; } | { type: import("@metamask/snaps-ui").NodeType.Divider; } | { value: string; type: import("@metamask/snaps-ui").NodeType.Heading; } | { type: import("@metamask/snaps-ui").NodeType.Spinner; } | { value: string; type: import("@metamask/snaps-ui").NodeType.Text; markdown?: boolean | undefined; } | { value: string; type: import("@metamask/snaps-ui").NodeType.Image; }; placeholder?: string | undefined; }, null>; export declare type DialogParameters = Infer; /** * Builds the method implementation for `snap_dialog`. * * @param hooks - The RPC method hooks. * @param hooks.showDialog - A function that shows the specified dialog in the * MetaMask UI and returns the appropriate value for the dialog type. * @returns The method implementation which return value depends on the dialog * type, valid return types are: string, boolean, null. */ export declare function getDialogImplementation({ showDialog }: DialogMethodHooks): (args: RestrictedMethodOptions) => Promise; export {};