UNPKG

opstack-kit-chains

Version:
44 lines 1.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.sendCalls = void 0; const parseAccount_js_1 = require("../../../accounts/utils/parseAccount.js"); const account_js_1 = require("../../../errors/account.js"); const chain_js_1 = require("../../../errors/chain.js"); const toHex_js_1 = require("../../../utils/encoding/toHex.js"); const getTransactionError_js_1 = require("../../../utils/errors/getTransactionError.js"); async function sendCalls(client, parameters) { const { account: account_ = client.account, calls, capabilities, chain = client.chain, version = '1.0', } = parameters; if (!account_) throw new account_js_1.AccountNotFoundError({ docsPath: '/experimental/eip5792/sendCalls', }); const account = (0, parseAccount_js_1.parseAccount)(account_); if (!chain) throw new chain_js_1.ChainNotFoundError(); try { return await client.request({ method: 'wallet_sendCalls', params: [ { calls: calls.map((call) => ({ ...call, value: call.value ? (0, toHex_js_1.numberToHex)(call.value) : undefined, })), capabilities, chainId: (0, toHex_js_1.numberToHex)(chain.id), from: account.address, version, }, ], }, { retryCount: 0 }); } catch (err) { throw (0, getTransactionError_js_1.getTransactionError)(err, { ...parameters, account, chain: parameters.chain, }); } } exports.sendCalls = sendCalls; //# sourceMappingURL=sendCalls.js.map