UNPKG

@metamask/snaps-rpc-methods

Version:
35 lines 1.61 kB
import type { JsonRpcMiddleware } from "@metamask/json-rpc-engine"; import type { PermissionConstraint, RequestedPermissions } from "@metamask/permission-controller"; import { type Json, type JsonRpcParams } from "@metamask/utils"; export type PreinstalledSnapsMiddlewareHooks = { /** * Get all accounts with the eip155 scope. * * @returns A list of all account addresses from the eip155 scope. */ getAllEvmAccounts: () => string[]; /** * Get the current permissions for the requesting origin. * * @returns An object containing the metadata about each permission. */ getPermissions: () => Record<string, PermissionConstraint> | undefined; /** * Grant the passed permissions to the origin. * * @param permissions */ grantPermissions: (permissions: RequestedPermissions) => void; }; /** * Create a middleware that automatically grants account permissions to preinstalled Snaps * that want to use the Ethereum provider endowment. * * @param hooks - The hooks used by the middleware. * @param hooks.getAllEvmAccounts - Hook for retriveing all available EVM addresses. * @param hooks.getPermissions - Hook for retrieving the permissions of the requesting origin. * @param hooks.grantPermissions - Hook for granting permissions to the requesting origin. * @returns The middleware. */ export declare function createPreinstalledSnapsMiddleware({ getAllEvmAccounts, getPermissions, grantPermissions, }: PreinstalledSnapsMiddlewareHooks): JsonRpcMiddleware<JsonRpcParams, Json>; //# sourceMappingURL=preinstalled-snaps.d.cts.map