UNPKG

@metamask/snaps-rpc-methods

Version:
60 lines 2.34 kB
import type { JsonRpcEngineEndCallback } from "@metamask/json-rpc-engine"; import type { Messenger } from "@metamask/messenger"; import type { GetFileParams, GetFileResult } from "@metamask/snaps-sdk"; import type { InferMatching } from "@metamask/snaps-utils"; import type { PendingJsonRpcResponse } from "@metamask/utils"; import type { JsonRpcRequestWithOrigin, SnapControllerGetSnapFileAction } from "../types.cjs"; export declare const GetFileArgsStruct: import("@metamask/superstruct").Struct<{ path: string; encoding?: "base64" | "hex" | "utf8" | undefined; }, { path: import("@metamask/superstruct").Struct<string, null>; encoding: import("@metamask/superstruct").Struct<"base64" | "hex" | "utf8" | undefined, null>; }>; export type InferredGetFileParams = InferMatching<typeof GetFileArgsStruct, GetFileParams>; export type GetFileMethodActions = SnapControllerGetSnapFileAction; /** * Gets a static file's content in UTF-8, Base64, or hexadecimal. * * The file must be specified in [the Snap's manifest file](https://docs.metamask.io/snaps/features/static-files/). * * @example * ```json name="Manifest" * { * "source": { * "files": ["./files/my-file.bin"] * } * } * ``` * ```ts name="Usage" * const contents = await snap.request({ * method: 'snap_getFile', * params: { * path: './files/myfile.bin', * encoding: 'hex', * }, * }) * * // '0x...' * console.log(contents) * ``` */ export declare const getFileHandler: { implementation: typeof implementation; actionNames: "SnapController:getSnapFile"[]; }; /** * The `snap_getFile` 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 implementation(req: JsonRpcRequestWithOrigin<InferredGetFileParams>, res: PendingJsonRpcResponse<GetFileResult>, _next: unknown, end: JsonRpcEngineEndCallback, _hooks: never, messenger: Messenger<string, GetFileMethodActions>): Promise<void>; export {}; //# sourceMappingURL=getFile.d.cts.map