UNPKG

@biconomy/sdk

Version:

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

82 lines 3.34 kB
import { type Account, type Address, type Chain, type ClientConfig, type Hex, type LocalAccount, type OneOf, type Prettify, type PublicClient, type RpcSchema, type Transport, type WalletClient } from "viem"; import { type SmartAccount, type SmartAccountImplementation, type UserOperation } from "viem/account-abstraction"; import { EntrypointAbi } from "../constants/abi"; import type { Module } from "../modules/utils/Types"; import type { Call } from "./utils/Types"; import { type EthersWallet } from "./utils/Utils"; import { type EthereumProvider, type Signer } from "./utils/toSigner"; /** * Parameters for creating a Nexus Smart Account */ export type ToNexusSmartAccountParameters = { /** The blockchain network */ chain: Chain; /** The transport configuration */ transport: ClientConfig["transport"]; /** The signer account or address */ signer: OneOf<EthereumProvider | WalletClient<Transport, Chain | undefined, Account> | LocalAccount | EthersWallet>; /** Optional index for the account */ index?: bigint | undefined; /** Optional active validation module */ module?: Module; /** Optional factory address */ factoryAddress?: Address; /** Optional K1 validator address */ validatorAddress?: Address; /** Optional account address override */ accountAddress?: Address; /** Attester addresses to apply to the account */ attesters?: Address[]; /** Optional attestors threshold for the account */ attesterThreshold?: number; /** Optional boot strap address */ bootStrapAddress?: Address; /** Optional registry address */ registryAddress?: Address; /** Optional use test bundler */ useTestBundler?: boolean; } & Prettify<Pick<ClientConfig<Transport, Chain, Account, RpcSchema>, "account" | "cacheTime" | "chain" | "key" | "name" | "pollingInterval" | "rpcSchema">>; /** * Nexus Smart Account type */ export type NexusAccount = Prettify<SmartAccount<NexusSmartAccountImplementation>>; /** * Nexus Smart Account Implementation */ export type NexusSmartAccountImplementation = SmartAccountImplementation<typeof EntrypointAbi, "0.7", { getCounterFactualAddress: () => Promise<Address>; isDeployed: () => Promise<boolean>; getInitCode: () => Hex; encodeExecute: (call: Call) => Promise<Hex>; encodeExecuteBatch: (calls: readonly Call[]) => Promise<Hex>; getUserOpHash: (userOp: UserOperation) => Hex; setModule: (validationModule: Module) => void; getModule: () => Module; factoryData: Hex; factoryAddress: Address; validatorAddress: Address; attesters: Address[]; signer: Signer; publicClient: PublicClient; walletClient: WalletClient; useTestBundler: boolean; }>; /** * @description Create a Nexus Smart Account. * * @param parameters - {@link ToNexusSmartAccountParameters} * @returns Nexus Smart Account. {@link NexusAccount} * * @example * import { toNexusAccount } from '@biconomy/sdk' * import { createWalletClient, http } from 'viem' * import { mainnet } from 'viem/chains' * * const account = await toNexusAccount({ * chain: mainnet, * transport: http(), * signer: '0x...', * }) */ export declare const toNexusAccount: (parameters: ToNexusSmartAccountParameters) => Promise<NexusAccount>; //# sourceMappingURL=toNexusAccount.d.ts.map