UNPKG

@metamask/snaps-rpc-methods

Version:
75 lines 2.98 kB
import type { JsonRpcEngineEndCallback } from "@metamask/json-rpc-engine"; import type { Messenger } from "@metamask/messenger"; import type { PermissionControllerHasPermissionAction } from "@metamask/permission-controller"; import type { ListEntropySourcesParams, ListEntropySourcesResult } from "@metamask/snaps-sdk"; import type { PendingJsonRpcResponse } from "@metamask/utils"; import type { JsonRpcRequestWithOrigin, KeyringControllerGetStateAction } from "../types.mjs"; import type { MethodHooksObject } from "../utils.mjs"; export type ListEntropySourcesMethodHooks = { /** * Wait for the extension to be unlocked. * * @returns A promise that resolves once the extension is unlocked. */ getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>; }; export type ListEntropySourcesMethodActions = PermissionControllerHasPermissionAction | KeyringControllerGetStateAction; /** * Get a list of entropy sources available to the Snap. The requesting origin * must have at least one of the following permissions to access entropy source * metadata: * * - `snap_getBip32Entropy` * - `snap_getBip32PublicKey` * - `snap_getBip44Entropy` * - `snap_getEntropy` * * @example * ```json name="Manifest" * { * "initialPermissions": { * "snap_getBip32Entropy": {} * } * } * ``` * ```ts name="Usage" * const entropySources = await snap.request({ method: 'snap_listEntropySources' }); * console.log(entropySources); * // Example output: * // [ * // { * // name: 'Mnemonic 1', * // id: 'mnemonic-1', * // type: 'mnemonic', * // primary: true, * // }, * // { * // name: 'Mnemonic 2', * // id: 'mnemonic-2', * // type: 'mnemonic', * // primary: false, * // }, * // ] * ``` */ export declare const listEntropySourcesHandler: { implementation: typeof listEntropySourcesImplementation; hookNames: MethodHooksObject<ListEntropySourcesMethodHooks>; actionNames: ("KeyringController:getState" | "PermissionController:hasPermission")[]; }; /** * The `snap_listEntropySources` 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 - The function to get the unlock promise. * @param messenger - The messenger used to call controller actions. * @returns Nothing. */ declare function listEntropySourcesImplementation(request: JsonRpcRequestWithOrigin<ListEntropySourcesParams>, response: PendingJsonRpcResponse<ListEntropySourcesResult>, _next: unknown, end: JsonRpcEngineEndCallback, { getUnlockPromise }: ListEntropySourcesMethodHooks, messenger: Messenger<string, ListEntropySourcesMethodActions>): Promise<void>; export {}; //# sourceMappingURL=listEntropySources.d.mts.map