UNPKG

@metamask/snaps-rpc-methods

Version:
33 lines 1.22 kB
import { rpcErrors } from "@metamask/rpc-errors"; /** * `wallet_getAllSnaps` gets all installed Snaps. Currently, this can only be * called from `https://snaps.metamask.io`. * * @internal */ export const getAllSnapsHandler = { implementation: getAllSnapsImplementation, actionNames: ['SnapController:getAllSnaps'], }; /** * The `wallet_getAllSnaps` method implementation. * Fetches all installed snaps and adds them to the JSON-RPC response. * * @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. Not used by this function. * @param messenger - The messenger used to call controller actions. * @returns Nothing. */ async function getAllSnapsImplementation(request, response, _next, end, _hooks, messenger) { const { origin } = request; if (origin !== 'https://snaps.metamask.io') { return end(rpcErrors.methodNotFound()); } response.result = messenger.call('SnapController:getAllSnaps'); return end(); } //# sourceMappingURL=getAllSnaps.mjs.map