import { type Abi, type Address, BaseError, type Client, type Hex, type LocalAccount } from "viem" import type { Chain, EncodeDeployDataParameters, Transport } from "viem" import type { UserOperation } from "../types" import type { EntryPoint, GetEntryPointVersion } from "../types/entrypoint" export class SignTransactionNotSupportedBySmartAccount extends BaseError { override name = "SignTransactionNotSupportedBySmartAccount" constructor({ docsPath }: { docsPath?: string } = {}) { super( [ "A smart account cannot sign or send transaction, it can only sign message or userOperation.", "Please send user operation instead." ].join("\n"), { docsPath, docsSlug: "account" } ) } } export type SmartAccount< entryPoint extends EntryPoint, TSource extends string = string, transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, TAbi extends Abi | readonly unknown[] = Abi > = LocalAccount & { client: Client entryPoint: entryPoint getNonce: () => Promise getInitCode: () => Promise getFactory: () => Promise
getFactoryData: () => Promise encodeCallData: ( args: | { to: Address value: bigint data: Hex } | { to: Address value: bigint data: Hex }[] ) => Promise getDummySignature( userOperation: UserOperation> ): Promise encodeDeployCallData: ({ abi, args, bytecode }: EncodeDeployDataParameters) => Promise signUserOperation: ( userOperation: UserOperation> ) => Promise } export type SmartAccountSigner< TSource extends string = string, TAddress extends Address = Address > = Omit, "signTransaction">