UNPKG

@biconomy/abstractjs

Version:

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

57 lines 2.35 kB
import buildBridgeInstructions from "../buildBridgeInstructions.js"; /** * Builds bridge intent instructions by checking unified token balance and creating necessary bridge operations * * @param baseParams - {@link BaseInstructionsParams} Base configuration * @param baseParams.account - {@link BaseMultichainSmartAccount} The smart account to execute the bridging * @param baseParams.currentInstructions - Array of existing instructions to append to * @param parameters - {@link BuildIntentParameters} Bridge configuration * @param parameters.depositor - The account address initiating the bridge on the source chain * @param parameters.recipient - The account address receiving the bridged tokens on the destination chain * @param parameters.amount - The amount to bridge * @param parameters.token - Object containing: * @param parameters.token.mcToken - The multichain token contract * @param parameters.token.unifiedBalance - The unified token balance across chains * @param parameters.toChainId - The destination chain id * @param parameters.mode - (Optional) "DEBIT" or "OPTIMISTIC" bridging mode * * @returns Promise resolving to an array of {@link Instruction} * * @example * const bridgeIntentInstructions = await buildIntent( * { * account: myMultichainAccount, * currentInstructions: [] * }, * { * depositor: "0x...", * recipient: "0x...", * amount: BigInt("1000000"), // 1 USDC * token: { * mcToken: mcUSDC, * unifiedBalance: myUnifiedBalance * }, * toChainId: 10 * } * ); */ export const buildIntent = async (baseParams, parameters) => { const { currentInstructions = [] } = baseParams; const { amount, token: { unifiedBalance }, toChainId, depositor, recipient, mode, metadata, lowerBoundTimestamp, upperBoundTimestamp, executionSimulationRetryDelay, simulationOverrides } = parameters; const { instructions } = await buildBridgeInstructions({ depositor, recipient, amount: amount, toChainId, unifiedBalance, mode, metadata, lowerBoundTimestamp, upperBoundTimestamp, executionSimulationRetryDelay, simulationOverrides }); return [...currentInstructions, ...instructions]; }; export default buildIntent; //# sourceMappingURL=buildIntent.js.map