import type { GasConfig, WriteReportReply, WriteReportReplyJson } from '../../generated/capabilities/blockchain/evm/v1alpha/client_pb'; import type { ReportResponse } from '../../generated/sdk/v1alpha/sdk_pb'; import { type Abi, type AbiFunction, type Address } from 'viem'; import type { EvmMock } from './generated'; type ViewFunction = AbiFunction & { stateMutability: 'view' | 'pure'; }; type ExtractViewFunctionNames = Extract['name']; /** * Strict version of {@link WriteReportRequest} where `report` and `gasConfig` * are guaranteed to be present. Used by mock handlers so tests don't need * to check for undefined. */ export interface WriteReportMockInput { receiver: Uint8Array; report: ReportResponse; gasConfig: GasConfig; } /** * A contract mock returned by {@link addContractMock}. * * Each view/pure function in the ABI becomes an optional property whose value * is a handler function. When set, calls to that function on the mock EVM * client are automatically routed, decoded, and re-encoded. * * A special `writeReport` property handles write-report calls to this * contract's address. Its handler receives a {@link WriteReportMockInput} * where `report` and `gasConfig` are guaranteed to be present. */ export type ContractMock = { [K in ExtractViewFunctionNames]?: (...args: readonly unknown[]) => unknown; } & { writeReport?: (input: WriteReportMockInput) => WriteReportReply | WriteReportReplyJson; }; export interface AddContractMockOptions { address: Address; abi: TAbi; } /** * Registers a typed contract mock on an {@link EvmMock} instance. * * This is the TypeScript equivalent of Go's `evmmock.AddContractMock`. * It intercepts `callContract` and `writeReport` on the provided mock, * routing calls by contract address and ABI method selector. * * Multiple contracts can be mocked on the same `EvmMock` — each call to * `addContractMock` chains with the previous handler. * * @example * ```ts * const evmMock = EvmMock.testInstance(chainSelector); * * const balanceMock = addContractMock(evmMock, { * address: "0x1234...", * abi: BalanceReader, * }); * * balanceMock.getNativeBalances = (addresses) => { * return [500000000000000000n]; * }; * ``` * * @param evmMock - The `EvmMock` instance to attach to. * @param options - Contract address and viem-compatible ABI. * @returns A mock object with settable handler properties for each view/pure function. */ export declare function addContractMock(evmMock: EvmMock, options: AddContractMockOptions): ContractMock; export {};