@metamask/snaps-rpc-methods
Version:
MetaMask Snaps JSON-RPC method implementations
36 lines • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAllSnapsHandler = void 0;
const rpc_errors_1 = require("@metamask/rpc-errors");
/**
* `wallet_getAllSnaps` gets all installed Snaps. Currently, this can only be
* called from `https://snaps.metamask.io`.
*
* @internal
*/
exports.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(rpc_errors_1.rpcErrors.methodNotFound());
}
response.result = messenger.call('SnapController:getAllSnaps');
return end();
}
//# sourceMappingURL=getAllSnaps.cjs.map