Abstraction around the Switchboard-On-Demand State account

This account is used to store the state data for a given program.

Constructors

Properties

program: Program<Idl>

The Anchor program instance.

pubkey: PublicKey

Methods

  • Loads the state data from on chain.

    Returns Promise<any>

    A promise that resolves to the state data.

    Throws

    if the state account does not exist.

  • Register a guardian with the global guardian queue.

    Parameters

    • params: {
          guardian: PublicKey;
      }

      The parameters object.

      • guardian: PublicKey

        The guardian account.

    Returns Promise<TransactionInstruction>

    A promise that resolves to the transaction instruction.

  • Set program-wide configurations.

    Parameters

    • params: {
          addCostWl?: PublicKey;
          denyAdvisory?: number;
          enableStaking?: boolean;
          epochLength?: BN;
          guardianQueue?: PublicKey;
          minQuoteVerifyVotes?: BN;
          newAuthority?: PublicKey;
          permitAdvisory?: number;
          resetEpochs?: boolean;
          rmCostWl?: PublicKey;
          stakePool?: PublicKey;
          stakeProgram?: PublicKey;
          switchMint?: PublicKey;
          testOnlyDisableMrEnclaveCheck?: boolean;
      }

      The configuration parameters.

      • Optional addCostWl?: PublicKey
      • Optional denyAdvisory?: number

        The deny advisory value.

      • Optional enableStaking?: boolean

        A flag to enable staking.

      • Optional epochLength?: BN

        The epoch length.

      • Optional guardianQueue?: PublicKey

        The guardian queue account.

      • Optional minQuoteVerifyVotes?: BN

        The minimum number of votes required to verify a quote.

      • Optional newAuthority?: PublicKey

        The new authority account.

      • Optional permitAdvisory?: number

        The permit advisory value.

      • Optional resetEpochs?: boolean

        A flag to reset epochs.

      • Optional rmCostWl?: PublicKey
      • Optional stakePool?: PublicKey

        The stake pool account.

      • Optional stakeProgram?: PublicKey

        The stake program account.

      • Optional switchMint?: PublicKey

        The switch mint account.

      • Optional testOnlyDisableMrEnclaveCheck?: boolean

        A flag to disable MrEnclave check for testing purposes.

    Returns Promise<TransactionInstruction>

    A promise that resolves to the transaction instruction.

  • Unregister a guardian from the global guardian queue.

    Parameters

    • params: {
          guardian: PublicKey;
      }

      The parameters object.

      • guardian: PublicKey

        The guardian account.

    Returns Promise<TransactionInstruction>

    A promise that resolves to the transaction instruction.

  • Initializes the state account.

    Parameters

    • program: Program<Idl>

      The Anchor program instance.

    Returns Promise<[State, String]>

    A promise that resolves to the state account and the transaction signature.

  • Derives a state PDA (Program Derived Address) from the program.

    Parameters

    • program: Program<Idl>

      The Anchor program instance.

    Returns PublicKey

    The derived state account's public key.

  • Loads the state data from on chain.

    Parameters

    • program: Program<Idl>

    Returns Promise<any>

    A promise that resolves to the state data.

    Throws

    if the state account does not exist.