UNPKG

@biconomy/abstractjs

Version:

SDK for Biconomy integration with support for account abstraction, smart accounts, ERC-4337.

33 lines 1.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildBatch = void 0; const utils_1 = require("../../utils/index.js"); const buildBatch = async (baseParams, parameters) => { const { currentInstructions = [] } = baseParams; const { instructions } = parameters; if (instructions.length < 2) { throw new Error("A Batch must contain at least 2 instructions"); } const resolvedInstructions = await (0, utils_1.resolveInstructions)(instructions); if (resolvedInstructions.some(({ chainId }) => Number(chainId) !== Number(resolvedInstructions[0].chainId))) { throw new Error("All instructions must be on the same chain"); } const isComposable = resolvedInstructions.some(({ isComposable }) => isComposable === true); if (!resolvedInstructions.every((inx) => !!inx.isComposable === !!isComposable)) { throw new Error(`${isComposable ? "All the instructions must be built with buildComposable in order to support the runtime time parameters." : "All the instructions must be non composable when there are no runtime parameters"}`); } const calls = resolvedInstructions.flatMap(({ calls }) => calls); return [ ...currentInstructions, { calls: isComposable ? calls : calls, chainId: resolvedInstructions[0].chainId, isComposable } ]; }; exports.buildBatch = buildBatch; exports.default = exports.buildBatch; //# sourceMappingURL=buildBatch.js.map