A private local instance of a network.

Hierarchy

  • Devnet

Implements

Constructors

  • Create an object representing a devnet. Must call the respawn method to get it running.

    Parameters

    • options: Partial<Devnet> = {}

    Returns Devnet

Properties

accounts: string[] = ...

List of genesis accounts that will be given an initial balance when creating the devnet container for the first time.

chainId: string

The chain ID that will be passed to the devnet node.

containerId?: string

ID of container if exists

deleteOnExit: boolean

Whether to destroy this devnet on exit.

dockerfile?: string

Path to Dockerfile to build image

dontMountState: boolean

Whether to skip mounting a local state directory into/out of the container.

engine?: Engine

Containerization engine (Docker or Podman).

exitHandlerSet: boolean = false

Kludge.

host: string

The hostname of the API URL.

imageTag?: string

Name or tag of image if set

initScript?: string

If set, overrides the script that launches the devnet in the container.

keepRunning: boolean

Whether the devnet should remain running after the command ends.

launchTimeout: number

After how many seconds to throw if container is not ready.

platform: "scrt_1.2" | "scrt_1.3" | "scrt_1.4" | "scrt_1.8" | "scrt_1.5" | "scrt_1.6" | "scrt_1.7" | "scrt_1.9"

Which kind of devnet to launch

podman: boolean

Whether to use Podman instead of Docker to run the devnet container.

port?: string | number

The port of the API URL.

portMode: DevnetPortMode

Which service does the API URL port correspond to.

postLaunchWait: number = 7

Seconds to wait after first block. Overridable for testing.

protocol: string

The protocol of the API URL without the trailing colon.

readyPhrase: string

Once this phrase is encountered in the log output from the container, the devnet is ready to accept requests.

running: boolean = false

Is this thing on?

stateDir: string

This directory is created to remember the state of the devnet setup.

verbose: boolean

Whether more detailed output is preferred.

waitPort: ((__namedParameters) => Promise<void>) = waitPort

Type declaration

    • (__namedParameters): Promise<void>
    • Overridable for testing.

      Parameters

      • __namedParameters: {
            host: string;
            interval?: number;
            port: number;
            retries?: number;
        }
        • host: string
        • Optional interval?: number
        • port: number
        • Optional retries?: number

      Returns Promise<void>

RE_NON_PRINTABLE: RegExp = ...

Regexp for non-printable characters.

dockerTags: Record<"scrt_1.2" | "scrt_1.3" | "scrt_1.4" | "scrt_1.8" | "scrt_1.5" | "scrt_1.6" | "scrt_1.7" | "scrt_1.9", string> = ...
dockerfiles: Record<"scrt_1.2" | "scrt_1.3" | "scrt_1.4" | "scrt_1.8" | "scrt_1.5" | "scrt_1.6" | "scrt_1.7" | "scrt_1.9", string> = ...
initScriptMount: string = 'devnet.init.mjs'
portModes: Record<"scrt_1.2" | "scrt_1.3" | "scrt_1.4" | "scrt_1.8" | "scrt_1.5" | "scrt_1.6" | "scrt_1.7" | "scrt_1.9", DevnetPortMode> = ...

Default connection type to expose on each devnet variant.

readyMessage: Record<"scrt_1.2" | "scrt_1.3" | "scrt_1.4" | "scrt_1.8" | "scrt_1.5" | "scrt_1.6" | "scrt_1.7" | "scrt_1.9", string> = ...
stateFile: string = 'devnet.json'

Accessors

  • get container(): undefined | Promise<Container>
  • Handle to created devnet container

    Returns undefined | Promise<Container>

  • get image(): undefined | Promise<Image>
  • This should point to the standard production docker image for the network.

    Returns undefined | Promise<Image>

  • get initScriptMount(): string
  • Virtual path inside the container where the init script is mounted.

    Returns string

  • get spawnEnv(): Record<string, string>
  • Environment variables in the container.

    Returns Record<string, string>

  • get spawnOptions(): {
        env: Record<string, string>;
        exposed: string[];
        extra: {
            AttachStderr: boolean;
            AttachStdin: boolean;
            AttachStdout: boolean;
            Domainname: string;
            HostConfig: {
                Binds: string[];
                NetworkMode: string;
                PortBindings: {};
            };
            Hostname: string;
            Tty: boolean;
        };
    }
  • Options for the container.

    Returns {
        env: Record<string, string>;
        exposed: string[];
        extra: {
            AttachStderr: boolean;
            AttachStdin: boolean;
            AttachStdout: boolean;
            Domainname: string;
            HostConfig: {
                Binds: string[];
                NetworkMode: string;
                PortBindings: {};
            };
            Hostname: string;
            Tty: boolean;
        };
    }

    • env: Record<string, string>
    • exposed: string[]
    • extra: {
          AttachStderr: boolean;
          AttachStdin: boolean;
          AttachStdout: boolean;
          Domainname: string;
          HostConfig: {
              Binds: string[];
              NetworkMode: string;
              PortBindings: {};
          };
          Hostname: string;
          Tty: boolean;
      }
      • AttachStderr: boolean
      • AttachStdin: boolean
      • AttachStdout: boolean
      • Domainname: string
      • HostConfig: {
            Binds: string[];
            NetworkMode: string;
            PortBindings: {};
        }
        • Binds: string[]
        • NetworkMode: string
        • PortBindings: {}
        • Hostname: string
        • Tty: boolean
    • get stateFile(): JSONFile<Partial<this>>
    • This file contains the id of the current devnet container. TODO store multiple containers

      Returns JSONFile<Partial<this>>

    Methods

    • Create the devnet container and save state.

      Returns Promise<this>

    • Export the state of the devnet as a container image.

      Parameters

      • Optional repository: string
      • Optional tag: string

      Returns Promise<string>

    • Write the state of the devnet to a file. This saves the info needed to respawn the node

      Parameters

      • extra: {} = {}

        Returns Promise<this>

      • Restore a Devnet from the info stored in the state file

        Parameters

        • dir: string | Path
        • allowInvalid: boolean = false

        Returns Devnet

      • Filter logs when waiting for the ready phrase.

        Parameters

        • data: string

        Returns boolean

      Generated using TypeDoc