@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
1 lines • 1.14 kB
Source Map (JSON)
{"version":3,"file":"protocol.cjs","sourceRoot":"","sources":["../../../src/types/handlers/protocol.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n CaipChainId,\n Json,\n JsonRpcParams,\n JsonRpcRequest,\n} from '@metamask/utils';\n\n/**\n * The `onProtocolRequest` handler, which is called when a Snap receives a\n * protocol request.\n *\n * Note that using this handler requires the `endowment:protocol` permission.\n *\n * @param args - The request arguments.\n * @param args.origin - The origin of the request. This can be the ID of another\n * Snap, or the URL of a website.\n * @param args.scope - The scope of the request.\n * @param args.request - The protocol request sent to the Snap. This includes\n * the method name and parameters.\n * @returns The response to the protocol request. This must be a\n * JSON-serializable value. In order to return an error, throw a `SnapError`\n * instead.\n */\nexport type OnProtocolRequestHandler<\n Params extends JsonRpcParams = JsonRpcParams,\n> = (args: {\n origin: string;\n scope: CaipChainId;\n request: JsonRpcRequest<Params>;\n}) => Promise<Json>;\n"]}