UNPKG

permissionless

Version:

A utility library for working with ERC-4337

76 lines 2.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.encodeCallData = void 0; const viem_1 = require("viem"); const encodeCallData = async (calls) => { if (calls.length > 1) { return (0, viem_1.encodeFunctionData)({ abi: [ { inputs: [ { internalType: "address[]", name: "dest", type: "address[]" }, { internalType: "uint256[]", name: "value", type: "uint256[]" }, { internalType: "bytes[]", name: "func", type: "bytes[]" } ], name: "executeBatch", outputs: [], stateMutability: "nonpayable", type: "function" } ], functionName: "executeBatch", args: [ calls.map((a) => a.to), calls.map((a) => a.value ?? 0n), calls.map((a) => a.data ?? "0x") ] }); } const call = calls.length === 0 ? undefined : calls[0]; if (!call) { throw new Error("No calls to encode"); } return (0, viem_1.encodeFunctionData)({ abi: [ { inputs: [ { internalType: "address", name: "dest", type: "address" }, { internalType: "uint256", name: "value", type: "uint256" }, { internalType: "bytes", name: "func", type: "bytes" } ], name: "execute", outputs: [], stateMutability: "nonpayable", type: "function" } ], functionName: "execute", args: [call.to, call.value ?? 0n, call.data ?? "0x"] }); }; exports.encodeCallData = encodeCallData; //# sourceMappingURL=encodeCallData.js.map