UNPKG

@biconomy/abstractjs

Version:

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

59 lines 2.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildMultichainInstructions = exports.GLOBAL_COMPOSABLE_CALLS = void 0; const erc7579_1 = require("../../../clients/decorators/erc7579/index.js"); const smartAccount_1 = require("../../../clients/decorators/smartAccount/index.js"); const modules_1 = require("../../../modules/index.js"); const decorators_1 = require("../../../modules/validators/ownable/decorators/index.js"); const smartSessions_1 = require("../../../modules/validators/smartSessions/index.js"); exports.GLOBAL_COMPOSABLE_CALLS = { ...erc7579_1.erc7579Calls, ...smartAccount_1.smartAccountCalls, ...decorators_1.ownableCalls, ...smartSessions_1.smartSessionCalls }; const buildMultichainInstructions = async (baseParams, parameters) => { const { currentInstructions = [] } = baseParams; const { calls: calls_, type, parameters: parametersForType, account, metadata: metadataOverride, lowerBoundTimestamp, upperBoundTimestamp, executionSimulationRetryDelay, simulationOverrides } = parameters; const instructions = await Promise.all(account.deployments.map(async (account) => { let callsPerChain = []; const chainId = account.client.chain?.id; if (!chainId) { throw new Error("Chain ID is not set"); } let metadata = []; if (calls_) { metadata = [ { type: "CUSTOM", chainId, description: "Custom on-chain action" } ]; callsPerChain = calls_; } else if (type) { metadata = [ { type: "CUSTOM", chainId, description: `${(0, modules_1.functionNameToLabel)(type)} on-chain action` } ]; callsPerChain = (await exports.GLOBAL_COMPOSABLE_CALLS[type](account, parametersForType)); } return { calls: callsPerChain, chainId, metadata: metadataOverride || metadata, lowerBoundTimestamp, upperBoundTimestamp, executionSimulationRetryDelay, simulationOverrides }; })); return [...currentInstructions, ...instructions]; }; exports.buildMultichainInstructions = buildMultichainInstructions; exports.default = exports.buildMultichainInstructions; //# sourceMappingURL=buildMultichainInstructions.js.map