import type { Account, Address, Block, Chain, Client, Hex, Prettify, PublicClient, TestActions, TestRpcSchema, Transport, WalletClient } from "viem"; export interface AnvilNodeInfo { currentBlockNumber: string; currentBlockTimestamp: number; currentBlockHash: string; hardFork: string; transactionOrder: string; environment: { baseFee: string; chainId: number; gasLimit: string; gasPrice: string; }; forkConfig: { forkUrl: string; forkBlockNumber: string; forkRetryBackoff: number; }; } export type AnvilRPCSchema = [ ...TestRpcSchema<"anvil">, { Method: "anvil_nodeInfo"; Parameters: []; ReturnType: AnvilNodeInfo; }, { Method: "evm_mine_detailed"; Parameters: [Hex]; ReturnType: Block[]; } ]; export interface AnvilDealParameters { /** * ERC20 token address. */ erc20: Address; /** * Account that should receive the tokens. */ account: Account | Address; /** * Token amount in raw units (no decimals applied). */ amount: bigint; } export type AnvilActions = { anvilNodeInfo: () => Promise; isAnvil: () => Promise; evmMineDetailed: ( /** * Block timestamp in seconds */ timestamp: bigint | number) => Promise | undefined>; /** * Deals ERC20 tokens to an account by overriding the storage of * `balanceOf(account)`. Requires `viem-deal` as a peer dependency. */ deal: (params: AnvilDealParameters) => Promise; }; export type AnvilClient = Prettify<{ mode: "anvil"; } & Client> & PublicClient & WalletClient; export interface AnvilClientConfig { transport: transport; chain?: chain; cacheTime?: number; pollingInterval?: number; } /** * Extends an arbitrary viem `PublicClient` with anvil + wallet actions plus * the SDK's bonus actions (`anvilNodeInfo`, `isAnvil`, `evmMineDetailed`, * `deal`). * * Used to lift `sdk.client` into an `AnvilClient` shape on the fly when test * RPCs (impersonateAccount, setBalance, setStorageAt, ...) are needed. */ export declare function extendAnvilClient(client: PublicClient): AnvilClient; export declare function createAnvilClient({ chain, transport, cacheTime, pollingInterval, }: AnvilClientConfig): AnvilClient; /** * View action to detect if client is an anvil client * @param client * @returns */ export declare function isAnvil(client: Client): Promise; /** * Anvil node info * @param client * @returns */ export declare function anvilNodeInfo(client: Client): Promise; /** * Safely tries to mine block with given timestamp * @param client * @param timestamp in seconds * @returns */ export declare function evmMineDetailed(client: Client, timestamp: bigint | number): Promise | undefined>;