UNPKG

@alchemy/aa-core

Version:

viem based SDK that enables interactions with ERC-4337 Smart Accounts. ABIs are based off the definitions generated in @account-abstraction/contracts

34 lines (33 loc) 4.22 kB
import { type Chain, type Client, type ClientConfig, type CustomTransport, type PublicActions, type PublicRpcSchema, type RpcSchema, type Transport } from "viem"; import { z } from "zod"; import type { SmartContractAccount } from "../account/smartContractAccount.js"; import type { UserOperationContext } from "../actions/smartAccount/types.js"; import type { ClientMiddleware } from "../middleware/types.js"; import type { Prettify } from "../utils/index.js"; import { type BundlerClient } from "./bundlerClient.js"; import { type BundlerActions, type BundlerRpcSchema } from "./decorators/bundlerClient.js"; import { type BaseSmartAccountClientActions } from "./decorators/smartAccountClient.js"; import { SmartAccountClientOptsSchema } from "./schema.js"; import type { ClientMiddlewareConfig } from "./types.js"; type SmartAccountClientOpts = z.output<typeof SmartAccountClientOptsSchema>; export type SmartAccountClientConfig<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends SmartContractAccount | undefined = SmartContractAccount | undefined, context extends UserOperationContext | undefined = UserOperationContext | undefined> = Prettify<Pick<ClientConfig<transport, chain, account>, "cacheTime" | "chain" | "key" | "name" | "pollingInterval" | "transport" | "type"> & { account?: account; opts?: z.input<typeof SmartAccountClientOptsSchema>; } & ClientMiddlewareConfig<context>>; export type SmartAccountClientRpcSchema = [ ...BundlerRpcSchema, ...PublicRpcSchema ]; export type SmartAccountClientActions<chain extends Chain | undefined = Chain | undefined, account extends SmartContractAccount | undefined = SmartContractAccount | undefined, context extends UserOperationContext | undefined = UserOperationContext | undefined> = BaseSmartAccountClientActions<chain, account, context> & BundlerActions & PublicActions; export type SmartAccountClient<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends SmartContractAccount | undefined = SmartContractAccount | undefined, actions extends Record<string, unknown> = Record<string, unknown>, rpcSchema extends RpcSchema = SmartAccountClientRpcSchema, context extends UserOperationContext | undefined = UserOperationContext | undefined> = Prettify<Client<transport, chain, account, rpcSchema, actions & SmartAccountClientActions<chain, account, context>>>; export type BaseSmartAccountClient<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends SmartContractAccount | undefined = SmartContractAccount | undefined, context extends UserOperationContext | undefined = UserOperationContext | undefined> = Prettify<Client<transport, chain, account, [ ...BundlerRpcSchema, ...PublicRpcSchema ], { middleware: ClientMiddleware<context>; } & SmartAccountClientOpts & BundlerActions & PublicActions>>; export declare function createSmartAccountClient<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(config: SmartAccountClientConfig<TTransport, TChain, TAccount, TContext>): SmartAccountClient<TTransport, TChain, TAccount>; export declare function createSmartAccountClientFromExisting<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TClient extends BundlerClient<TTransport> = BundlerClient<TTransport>, TActions extends SmartAccountClientActions<TChain, TAccount, TContext> = SmartAccountClientActions<TChain, TAccount>, TRpcSchema extends SmartAccountClientRpcSchema = SmartAccountClientRpcSchema, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(config: Omit<SmartAccountClientConfig<Transport, TChain, TAccount, TContext>, "transport" | "chain"> & { client: TClient; }): SmartAccountClient<CustomTransport, TChain, TAccount, TActions, TRpcSchema, TContext>; export {};