@biconomy/sdk
Version:
SDK for Biconomy integration with support for account abstraction, smart accounts, ERC-4337.
56 lines • 1.79 kB
JavaScript
import { buildDefaultInstructions } from "./instructions/buildDefaultInstructions.js";
import { buildIntent } from "./instructions/buildIntent.js";
/**
* Builds transaction instructions based on the provided action type and parameters
*
* @param baseParams - {@link BaseInstructionsParams} Base configuration for instructions
* @param baseParams.account - The multichain smart account to check balances for
* @param baseParams.currentInstructions - Optional array of existing instructions to append to
* @param parameters - {@link BuildInstructionTypes} The build action configuration
* @param parameters.type - The type of build action ("default" | "intent")
* @param parameters.data - Action-specific parameters based on the type
*
* @returns Promise resolving to an array of {@link Instruction}
*
* @example
* // Bridge tokens example
* const bridgeInstructions = await build(
* { account: myMultichainAccount },
* {
* type: "intent",
* data: {
* amount: BigInt(1000000),
* mcToken: mcUSDC,
* chain: optimism
* }
* }
* );
*
* @example
* // Default action example
* const defaultInstructions = await build(
* { account: myMultichainAccount },
* {
* type: "default",
* data: {
* instructions: myExistingInstruction
* }
* }
* );
*/
export const build = async (baseParams, parameters) => {
const { type, data } = parameters;
switch (type) {
case "intent": {
return buildIntent(baseParams, data);
}
case "default": {
return buildDefaultInstructions(baseParams, data);
}
default: {
throw new Error(`Unknown build action type: ${type}`);
}
}
};
export default build;
//# sourceMappingURL=build.js.map