UNPKG

@biconomy/abstractjs

Version:

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

41 lines 1.64 kB
import { sendUserOperation } from "viem/account-abstraction"; import { getAction, parseAccount } from "viem/utils"; import { AccountNotFoundError } from "../../../account/utils/AccountNotFound.js"; import { toInstallWithSafeSenderCalls } from "./installModule.js"; /** * Installs multiple modules on a given smart account. * * @param client - The client instance. * @param parameters - Parameters including the smart account, modules to install, and optional gas settings. * @returns The hash of the user operation as a hexadecimal string. * @throws {AccountNotFoundError} If the account is not found. * * @example * import { installModules } from '@biconomy/abstractjs' * * const userOpHash = await installModules(nexusClient, { * modules: [ * { type: 'executor', address: '0x...', context: '0x' }, * { type: 'validator', address: '0x...', context: '0x' } * ] * }) * console.log(userOpHash) // '0x...' */ export async function installModules(client, parameters) { const { account: account_ = client.account, maxFeePerGas, maxPriorityFeePerGas, nonce, modules } = parameters; if (!account_) { throw new AccountNotFoundError({ docsPath: "/nexus-client/methods#sendtransaction" }); } const account = parseAccount(account_); const calls = (await Promise.all(modules.flatMap((module) => toInstallWithSafeSenderCalls(account, module)))).flat(); return getAction(client, sendUserOperation, "sendUserOperation")({ calls, maxFeePerGas, maxPriorityFeePerGas, nonce, account }); } //# sourceMappingURL=installModules.js.map