UNPKG

@biconomy/abstractjs

Version:

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

38 lines 1.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.batchInstructions = void 0; const buildBatch_1 = require("../decorators/instructions/buildBatch.js"); const batchInstructions = async (parameters) => { const { account, instructions } = parameters; const result = []; let currentBatch = []; let currentChainId = null; for (const instruction of instructions) { const chainId = String(instruction.chainId); if (currentChainId === null || chainId === currentChainId) { currentBatch.push(instruction); currentChainId = chainId; } else { if (currentBatch.length > 1) { const [batchedOp] = await (0, buildBatch_1.buildBatch)({ account }, { instructions: currentBatch }); result.push(batchedOp); } else if (currentBatch.length === 1) { result.push(currentBatch[0]); } currentBatch = [instruction]; currentChainId = chainId; } } if (currentBatch.length > 1) { const [batchedOp] = await (0, buildBatch_1.buildBatch)({ account }, { instructions: currentBatch }); result.push(batchedOp); } else if (currentBatch.length === 1) { result.push(currentBatch[0]); } return result; }; exports.batchInstructions = batchInstructions; //# sourceMappingURL=batchInstructions.js.map