@biconomy/abstractjs
Version:
SDK for Biconomy integration with support for account abstraction, smart accounts, ERC-4337.
55 lines • 2.23 kB
JavaScript
import { erc7579Calls } from "../../../clients/decorators/erc7579/index.js";
import { smartAccountCalls } from "../../../clients/decorators/smartAccount/index.js";
import { functionNameToLabel } from "../../../modules/index.js";
import { ownableCalls } from "../../../modules/validators/ownable/decorators/index.js";
import { smartSessionCalls } from "../../../modules/validators/smartSessions/index.js";
export const GLOBAL_COMPOSABLE_CALLS = {
...erc7579Calls,
...smartAccountCalls,
...ownableCalls,
...smartSessionCalls
};
export 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: `${functionNameToLabel(type)} on-chain action`
}
];
callsPerChain = (await GLOBAL_COMPOSABLE_CALLS[type](account, parametersForType));
}
return {
calls: callsPerChain,
chainId,
metadata: metadataOverride || metadata,
lowerBoundTimestamp,
upperBoundTimestamp,
executionSimulationRetryDelay,
simulationOverrides
};
}));
return [...currentInstructions, ...instructions];
};
export default buildMultichainInstructions;
//# sourceMappingURL=buildMultichainInstructions.js.map