UNPKG

@metamask/eip-5792-middleware

Version:

Implements the JSON-RPC methods for sending multiple calls from the user's wallet, and checking their status, as referenced in EIP-5792

34 lines 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.walletSendCalls = void 0; const rpc_errors_1 = require("@metamask/rpc-errors"); const types_1 = require("../types.cjs"); const utils_1 = require("../utils.cjs"); /** * The RPC method handler middleware for `wallet_sendCalls` * * @param req - The JSON RPC request's end callback. * @param res - The JSON RPC request's pending response object. * @param hooks - The hooks object. * @param hooks.getAccounts - Function that retrieves available accounts. * @param hooks.processSendCalls - Function that processes a sendCalls request for EIP-5792 transactions. */ async function walletSendCalls(req, res, { getAccounts, processSendCalls, }) { if (!processSendCalls) { throw rpc_errors_1.rpcErrors.methodNotSupported(); } (0, utils_1.validateParams)(req.params, types_1.SendCallsStruct); const params = req.params[0]; const from = params.from ? await (0, utils_1.validateAndNormalizeKeyholder)(params.from, req, { getAccounts, }) : undefined; const sendCalls = { ...params, from, }; res.result = await processSendCalls(sendCalls, req); } exports.walletSendCalls = walletSendCalls; //# sourceMappingURL=wallet_sendCalls.cjs.map