import { ILogger } from "../onchain/types/logger.js"; import { CreateTestnetRequest, Testnet, TestnetFiles, TestnetStatus } from "./types.js"; //#region src/testnets/TestnetsAPI.d.ts /** * Options of a {@link TestnetsAPI}. **/ export interface TestnetsAPIOptions { /** * Base URL of anvil-manager. * * @defaultValue `"https://anvil.gearbox.foundation"` **/ baseUrl?: string; /** * API key sent as a bearer token with every request. Without it the private * routes (create, kill) answer 401, which surfaces as a * {@link TestnetStatusError}. **/ apiKey?: string; /** * Timeout of one request, in milliseconds. * * @defaultValue `30_000` **/ timeout?: number; logger?: ILogger; } /** * Options of {@link TestnetsAPI.waitUntilReady}. **/ export interface WaitUntilReadyOptions { /** * How long to wait for the testnet to become ready, in milliseconds. * * @defaultValue `600_000` (10 minutes) **/ timeout?: number; /** * Pause between two status polls, in milliseconds. * * @defaultValue `5_000` **/ interval?: number; } /** * Client for anvil-manager, which runs the anvil forks Gearbox calls * testnets. It manages non-persistent testnets only, addressed by their * execution id. * * ```ts * const testnets = new TestnetsAPI({ apiKey: process.env.ANVIL_MANAGER_API_KEY }); * const { executionId } = await testnets.create({ network: "Mainnet", timeout: "2h" }); * const status = await testnets.waitUntilReady(executionId); * // ... use status.rpcUrl ... * await testnets.kill(executionId); * ``` * * Every method throws a {@link TestnetsError} subclass when it fails, except * when a response body is not JSON: then it rejects with the error of * `response.json()`. **/ export declare class TestnetsAPI { #private; protected readonly logger?: ILogger; constructor(options?: TestnetsAPIOptions); /** * Base URL every request of this client is sent to. **/ get baseUrl(): string; /** * Every testnet anvil-manager knows of, persistent ones included. **/ list(): Promise; /** * Status of one testnet. * * @param id - Execution id of the testnet. * @throws {@link TestnetNotFoundError} when there is no such testnet. **/ get(id: string): Promise; /** * Starts a testnet. It answers as soon as the testnet is created, long * before it is {@link TestnetStatus.ready}. * * @param files - Saved in the testnet's shared dir, where scripts and tasks * can read them. **/ create(request: CreateTestnetRequest, files?: TestnetFiles): Promise; /** * Stops a testnet. Stopping one that is already stopped succeeds. * * @param id - Execution id of the testnet. * @throws {@link TestnetNotFoundError} when there is no such testnet. * @throws {@link TestnetStatusError} with status 400 when the testnet is * persistent. **/ kill(id: string): Promise; /** * Polls a testnet's status until it is {@link TestnetStatus.ready}. * * @param id - Execution id of the testnet. * @returns The first status that is ready. * @throws {@link TestnetWaitTimeoutError} when the testnet is not ready in * time. Any error of a poll is thrown as is, without retrying. **/ waitUntilReady(id: string, options?: WaitUntilReadyOptions): Promise; } //#endregion