/// import type { CreateAnvilOptions } from "../anvil/createAnvil.js"; import { type Pool } from "../pool/createPool.js"; import { type InstanceRequestContext } from "./parseRequest.js"; import { IncomingMessage, ServerResponse } from "node:http"; import type { Awaitable } from "vitest"; export type ProxyResponseSuccess = { success: true; } & TResponse; export type ProxyResponseFailure = { success: false; reason: string; }; export type ProxyResponse = ProxyResponseSuccess | ProxyResponseFailure; export type ProxyRequestHandler = (req: IncomingMessage, res: ServerResponse, context: ProxyRequestContext) => Awaitable; export type ProxyRequestContext = { pool: Pool; options?: AnvilProxyOptions | undefined; } & (InstanceRequestContext | {}); /** * A function callback to dynamically derive the options based on the request. */ export type AnvilProxyOptionsFn = (id: number, request: IncomingMessage) => Awaitable; export type AnvilProxyOptions = CreateAnvilOptions | AnvilProxyOptionsFn; export type CreateProxyOptions = { /** * The pool of anvil instances. */ pool: Pool; /** * The options to pass to each anvil instance. */ options?: AnvilProxyOptions | undefined; /** * A function callback to handle custom proxy requests. */ fallback?: ProxyRequestHandler | undefined; }; /** * Creates a proxy server that spawns anvil instance on demand. * * @example * ``` * import { createProxy, createPool } from "@viem/anvil"; * * const server = createProxy({ * pool: createPool(), * options: { * forkUrl: "https://eth-mainnet.alchemyapi.io/v2/", * blockNumber: 12345678, * }, * }); * * server.listen(8545, "::", () => { * console.log("Proxy server listening on http://0.0.0.0:8545"); * }); * ``` */ export declare function createProxy({ pool, options, fallback, }: CreateProxyOptions): Promise>; //# sourceMappingURL=createProxy.d.ts.map