UNPKG

@coinbase/agentkit

Version:

Coinbase AgentKit core primitives

148 lines (147 loc) 4.98 kB
import { KernelSmartAccountImplementation } from "@zerodev/sdk"; import { createIntentClient, type GetCABParameters, type GetCABResult } from "@zerodev/intent"; import { Abi, Address, ContractFunctionArgs, ContractFunctionName, ReadContractParameters, ReadContractReturnType, TransactionRequest, Hex, Hash, Account } from "viem"; import { SmartAccount } from "viem/account-abstraction"; import { EvmWalletProvider } from "./evmWalletProvider"; import { type Network } from "../network"; /** * Configuration options for the ZeroDev Wallet Provider. */ export interface ZeroDevWalletProviderConfig { /** * The underlying EVM wallet provider to use as a signer. */ signer: Account; /** * The ZeroDev project ID. */ projectId: string; /** * The EntryPoint version ("0.6" or "0.7"). * Defaults to "0.7". */ entryPointVersion?: "0.6" | "0.7"; /** * The network ID of the wallet. */ networkId?: string; /** * The address of the wallet. * If not provided, it will be computed from the signer. */ address?: Address; } /** * A wallet provider that uses ZeroDev's account abstraction. */ export declare class ZeroDevWalletProvider extends EvmWalletProvider { #private; /** * Constructs a new ZeroDevWalletProvider. * * @param config - The configuration options for the ZeroDevWalletProvider. * @param kernelAccount - The kernel account. * @param intentClient - The intent client. */ private constructor(); /** * Configures a new ZeroDevWalletProvider with an existing wallet provider as the signer. * * @param config - The configuration options for the ZeroDevWalletProvider. * @returns A Promise that resolves to a new ZeroDevWalletProvider instance. */ static configureWithWallet(config: ZeroDevWalletProviderConfig): Promise<ZeroDevWalletProvider>; /** * Signs a message using the Kernel account. * * @param message - The message to sign. * @returns The signed message. */ signMessage(message: string | Uint8Array): Promise<Hex>; /** * Signs a typed data object using the Kernel account. * * @param typedData - The typed data object to sign. * @returns The signed typed data object. */ signTypedData(typedData: any): Promise<Hex>; /** * Signs a transaction using the Kernel account. * * @param _transaction - The transaction to sign. * @returns The signed transaction. */ signTransaction(_transaction: TransactionRequest): Promise<Hex>; /** * Sends a transaction using ZeroDev's Intent system. * * @param transaction - The transaction to send. * @returns The hash of the transaction. */ sendTransaction(transaction: TransactionRequest): Promise<Hex>; /** * Waits for a transaction receipt. * * @param txHash - The hash of the transaction to wait for. * @returns The transaction receipt. */ waitForTransactionReceipt(txHash: Hash): Promise<unknown>; /** * Reads a contract. * * @param params - The parameters to read the contract. * @returns The response from the contract. */ readContract<const abi extends Abi | readonly unknown[], functionName extends ContractFunctionName<abi, "pure" | "view">, const args extends ContractFunctionArgs<abi, "pure" | "view", functionName>>(params: ReadContractParameters<abi, functionName, args>): Promise<ReadContractReturnType<abi, functionName, args>>; /** * Gets the address of the wallet. * * @returns The address of the wallet. */ getAddress(): Address; /** * Gets the network of the wallet. * * @returns The network of the wallet. */ getNetwork(): Network; /** * Gets the name of the wallet provider. * * @returns The name of the wallet provider. */ getName(): string; /** * Gets the balance of the wallet. * * @returns The balance of the wallet in wei. */ getBalance(): Promise<bigint>; /** * Transfer the native asset of the network. * * @param to - The destination address. * @param value - The amount to transfer in whole units (e.g. ETH). * @returns The transaction hash. */ nativeTransfer(to: string, value: string): Promise<string>; /** * Gets the ZeroDev Kernel account. * * @returns The ZeroDev Kernel account. */ getKernelAccount(): SmartAccount<KernelSmartAccountImplementation>; /** * Gets the ZeroDev Intent client. * * @returns The ZeroDev Intent client. */ getIntentClient(): Awaited<ReturnType<typeof createIntentClient>>; /** * Gets chain abstracted balance. * * @param options - The options for the get CAB. * @returns The chain abstracted balance. */ getCAB(options: GetCABParameters): Promise<GetCABResult>; }