UNPKG

@metamask/snaps-rpc-methods

Version:
43 lines 1.32 kB
/** * Get permitted and installed Snaps for the requesting origin. * * @example * ```ts * const snaps = await snap.request({ * method: 'wallet_getSnaps', * }); * console.log(snaps); * // { * // 'npm:example-snap': { * // id: 'npm:example-snap', * // version: '1.0.0', * // initialPermissions: { ... }, * // blocked: false, * // enabled: true, * // }, * // ..., * // } * ``` */ export const getSnapsHandler = { implementation: getSnapsImplementation, actionNames: ['SnapController:getPermittedSnaps'], }; /** * The `wallet_getSnaps` method implementation. * Fetches available snaps for the requesting origin and adds them to the JSON-RPC response. * * @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. */ async function getSnapsImplementation(req, res, _next, end, _hooks, messenger) { res.result = messenger.call('SnapController:getPermittedSnaps', req.origin); return end(); } //# sourceMappingURL=getSnaps.mjs.map