@biconomy/sdk
Version:
SDK for Biconomy integration with support for account abstraction, smart accounts, ERC-4337.
42 lines • 1.64 kB
JavaScript
import buildBridgeInstructions from "../buildBridgeInstructions.js";
import { getUnifiedERC20Balance } from "../getUnifiedERC20Balance.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.amount - The amount to bridge
* @param parameters.mcToken - The multichain token contract
* @param parameters.chain - The destination chain
*
* @returns Promise resolving to an array of {@link Instruction}
*
* @example
* const bridgeIntentInstructions = await buildIntent(
* {
* account: myMultichainAccount,
* currentInstructions: []
* },
* {
* amount: BigInt("1000000"), // 1 USDC
* mcToken: mcUSDC,
* chain: optimism
* }
* );
*/
export const buildIntent = async (baseParams, parameters) => {
const { account, currentInstructions = [] } = baseParams;
const { amount, mcToken, chain } = parameters;
const unifiedBalance = await getUnifiedERC20Balance({ mcToken, account });
const { instructions } = await buildBridgeInstructions({
account,
amount: amount,
toChain: chain,
unifiedBalance
});
return [...currentInstructions, ...instructions];
};
export default buildIntent;
//# sourceMappingURL=buildIntent.js.map