Skip to main content

NodeOracle class downloads the latest version of the Switchboard oracle for a given ReleaseChannel. The oracle is a NodeJS bundle that can be run in CI.

Usage example:

import { NodeOracle } from '@switchboard-xyz/oracle';

const oracle = await NodeOracle.fromReleaseChannel({
chain: "solana",
releaseChannel: "testnet",
network: "localnet",
rpcUrl: switchboardProgram.connection.rpcEndpoint,
oracleKey: oracleAccount.publicKey.toBase58(),
secretPath: switchboard.walletPath,
silent: false,
envVariables: {
VERBOSE: "1",
DEBUG: "1",
DISABLE_NONCE_QUEUE: "1",
DISABLE_METRICS: "1",
},
});

Hierarchy

  • ISwitchboardOracle
    • NodeOracle

Index

Constructors

constructor

Properties

readonlychain

chain: Chain

readonlyconfig

readonlyenvVariables

envVariables: Record<string, string>

readonlyimageTag

imageTag: string

isActive

isActive: boolean = true

readonlylogFile

logFile: string

logs

logs: string[] = []

readonlynetwork

network: Network

onCloseCallback

onCloseCallback: (code: number, signal: Signals) => void

Type declaration

    • (code: number, signal: Signals): void
    • Parameters

      • code: number
      • signal: Signals

      Returns void

onDataCallback

onDataCallback: (data: any) => void

Type declaration

    • (data: any): void
    • Parameters

      • data: any

      Returns void

onErrorCallback

onErrorCallback: (error: Error) => void

Type declaration

    • (error: Error): void
    • Parameters

      • error: Error

      Returns void

optionaloracleProcess

oracleProcess?: ChildProcess

readonlysecretPath

secretPath: string

readonlysilent

silent: boolean

readonlyswitchboardDirectory

switchboardDirectory: string

readonlytimestamp

timestamp: number = ...

Methods

publicaddLog

  • addLog(log: string): void
  • Parameters

    • log: string

    Returns void

awaitReady

  • awaitReady(timeout?: number): Promise<void>
  • Start the oracle process and await for the oracle to start heartbeating on-chain.

    @throws

    if timeout is exceeded and oracle heartbeat was never detected


    Parameters

    • timeout: number = 60

      the number of seconds to await for the oracle to start successfully heartbeating

    Returns Promise<void>

fetchImage

  • fetchImage(): Promise<string>
  • Returns Promise<string>

getArgs

  • getArgs(): string[]
  • Returns string[]

kill

  • kill(exitCode?: number | Signals): void
  • Force kill the oracle sub process


    Parameters

    • exitCode: number | Signals = "SIGINT"

    Returns void

publicsaveLogs

  • saveLogs(): void
  • Save an array of oracle logs


    Returns void

start

  • start(): Promise<void>
  • Returns Promise<void>

publicstartAndAwait

  • startAndAwait(timeout?: number): Promise<void>
  • Start a Switchboard oracle and await for the oracle to signal readiness.

    @throws

    if timeout is exceeded and oracle heartbeat was never detected


    Parameters

    • timeout: number = 60

      the number of seconds to await for the oracle to start successfully heartbeating

    Returns Promise<void>

stop

  • stop(): boolean
  • Stop the oracle sub process


    Returns boolean

    returns a boolean dictating whether the oracle was successfully stopped

publicstaticfromReleaseChannel

publicstaticparseEnvVariables

  • Parameters

    Returns Record<string, string>