starknet-devnet
Version:
Starknet Devnet provider
59 lines (58 loc) • 2.72 kB
TypeScript
import { DevnetProvider } from "./devnet-provider";
import { Stream } from "stream";
export type DevnetOutput = "inherit" | "ignore" | Stream | number;
export interface DevnetConfig {
/** The CLI args you would pass to a Devnet run in terminal. */
args?: string[];
stdout?: DevnetOutput;
stderr?: DevnetOutput;
/** The maximum amount of time waited for Devnet to start. Defaults to 5000 ms. */
maxStartupMillis?: number;
/**
* If `false` (default), automatically closes the spawned Devnet on program exit.
* Otherwise keeps it alive.
*/
keepAlive?: boolean;
}
export declare class Devnet {
private process;
provider: DevnetProvider;
static instances: Devnet[];
private static CLEANUP_REGISTERED;
private constructor();
/**
* Assumes `starknet-devnet` is installed and present in the environment PATH and executes it, using the args provided in `config`.
* @param config an object for configuring Devnet
* @returns a newly spawned Devnet instance
*/
static spawnInstalled(config?: DevnetConfig): Promise<Devnet>;
/**
* Spawns a new Devnet using the provided command and optional args in `config`.
* The `command` can be an absolute or a relative path, or a command in your environment's PATH.
* @param command the command used for starting Devnet; can be a path
* @param config configuration object
* @returns a newly spawned Devnet instance
*/
static spawnCommand(command: string, config?: DevnetConfig): Promise<Devnet>;
/**
* Spawns a Devnet of the provided `version` using the parameters provided in `config`.
* If not present locally, a precompiled version is fetched, extracted and executed.
* If you already have a local Devnet you would like to run, use {@link spawnCommand}.
* @param version if set to `"latest"`, uses the latest Devnet version compatible with this library;
* otherwise needs to be a semver string with a prepended "v" (e.g. "v1.2.3") and
* should be available in https://github.com/0xSpaceShard/starknet-devnet/releases
* @param config configuration object
* @returns a newly spawned Devnet instance
*/
static spawnVersion(version: string, config?: DevnetConfig): Promise<Devnet>;
private ensureAlive;
/**
* Sends the provided signal to the underlying Devnet process. Keep in mind
* that the process is killed automatically on program exit.
* @param signal the signal to be sent; deaults to `SIGTERM`
* @returns `true` if successful; `false` otherwise
*/
kill(signal?: NodeJS.Signals): boolean;
private static cleanup;
private static registerCleanup;
}