UNPKG

@biconomy/abstractjs

Version:

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

30 lines 1.16 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 { accountAddress, instructions, meeVersions } = parameters; const result = []; const batchesByChainId = new Map(); const chainIds = new Set(); for (const instruction of instructions) { const chainId = String(instruction.chainId); chainIds.add(chainId); const batch = batchesByChainId.get(chainId) || []; batch.push(instruction); batchesByChainId.set(chainId, batch); } for (const chainId of [...chainIds]) { const batch = batchesByChainId.get(chainId) || []; if (batch.length > 1) { const [batchedInx] = await (0, buildBatch_1.buildBatch)({ accountAddress, meeVersions }, { instructions: batch }); result.push(batchedInx); } else { result.push(...batch); } } return result; }; exports.batchInstructions = batchInstructions; //# sourceMappingURL=batchInstructions.js.map