Options
All
  • Public
  • Public/Protected
  • All
Menu

@switchboard-xyz/switchboard-api

Index

Variables

Const SWITCHBOARD_DEVNET_PID

SWITCHBOARD_DEVNET_PID: PublicKey = ...

Const SWITCHBOARD_MAINNET_PID

SWITCHBOARD_MAINNET_PID: PublicKey = ...

Const SWITCHBOARD_TESTNET_PID

SWITCHBOARD_TESTNET_PID: PublicKey = ...

Functions

addFeedBundle

  • addFeedBundle(connection: Connection, payerAccount: Account, dataFeedAccount: Account, bundleAuth: PublicKey): Promise<void>
  • Parameters

    • connection: Connection
    • payerAccount: Account
    • dataFeedAccount: Account
    • bundleAuth: PublicKey

    Returns Promise<void>

addFeedJob

  • addFeedJob(connection: Connection, payerAccount: Account, dataFeedAccount: Account, jobTasks: Task[]): Promise<Account>
  • Adds a new task list to be performed when the provided data feed is updated.

    Parameters

    • connection: Connection

      Solana network connection object.

    • payerAccount: Account

      Transaction funder account.

    • dataFeedAccount: Account

      The account holding the data feed being mutated.

    • jobTasks: Task[]

    Returns Promise<Account>

    the Account holding the newly created job.

addFeedParseOptimizedAccount

  • addFeedParseOptimizedAccount(connection: Connection, payerAccount: Account, dataFeedAccount: Account, accountSize?: number): Promise<Account>
  • Adds a zero-copy mirror account that holds information surrounding the last confirmed aggregator result.

    Parameters

    • connection: Connection

      Solana network connection object.

    • payerAccount: Account

      Transaction funder account.

    • dataFeedAccount: Account

      The account holding the data feed being mutated.

    • accountSize: number = 1_000

      Size of the parseOptimizedAcccount to be created.

    Returns Promise<Account>

    the AggregatorParseOptimized account

createBundle

  • createBundle(connection: Connection, payerAccount: Account, switchboardPid: PublicKey, accountSize?: number): Promise<Account>
  • Parameters

    • connection: Connection
    • payerAccount: Account
    • switchboardPid: PublicKey
    • accountSize: number = 10_000_000

    Returns Promise<Account>

createBundleAuth

  • createBundleAuth(connection: Connection, payerAccount: Account, switchboardPid: PublicKey, accountSize?: number): Promise<Account>
  • Creates an account which controls permissions access to write to a bundle.

    Parameters

    • connection: Connection

      Solana network connection object.

    • payerAccount: Account

      Transaction funder account.

    • switchboardPid: PublicKey

      Switchboard program ID.

    • accountSize: number = 500

    Returns Promise<Account>

    Account The account holding the new authorization config.

createDataFeed

  • createDataFeed(connection: Connection, payerAccount: Account, switchboardPid: PublicKey, accountSize?: number): Promise<Account>
  • Creates an account and permanently sets the account type to an Aggregator account.

    Parameters

    • connection: Connection

      Solana network connection object.

    • payerAccount: Account

      Transaction funder account.

    • switchboardPid: PublicKey

      The Switchboard Program pubkey that will own the account.

    • accountSize: number = 5_000

    Returns Promise<Account>

    Account The new switchboard account that can hold a data feed.

createFulfillmentManager

  • createFulfillmentManager(connection: Connection, payerAccount: Account, switchboardPid: PublicKey, accountSize?: number): Promise<Account>
  • Creates an account and permanently sets the account type to a FulfillmentManagerAuth account.

    Parameters

    • connection: Connection

      Solana network connection object.

    • payerAccount: Account

      Transaction funder account.

    • switchboardPid: PublicKey

      The Switchboard Program pubkey.

    • accountSize: number = 3_000

    Returns Promise<Account>

    Account New switchboard account that can hold a fulfillment manager.

createFulfillmentManagerAuth

  • createFulfillmentManagerAuth(connection: Connection, payerAccount: Account, fulfillmentManagerAccount: Account, nomineePubkey: PublicKey, configs: any, accountSize?: number): Promise<Account>
  • Creates an account which controls permissions access to a fulfillment manager.

    Parameters

    • connection: Connection

      Solana network connection object.

    • payerAccount: Account

      Transaction funder account.

    • fulfillmentManagerAccount: Account

      The FulfillmentManagerState account that this authorization will attach to.

    • nomineePubkey: PublicKey

      The public key for which authorization is being linked to the fulfillment manager account.

    • configs: any

      Denotes the settings to initalize the authorization account with.
      authorizeHeartbeat: Set to true to let this account authorize heartbeats from the nomineePubkey to the provided FulfillmentManagerState.
      authorizeUsage: Set to true to let the nominee use the provided Fulfillment manager to fulfill updateFeed requests.

    • accountSize: number = 300

    Returns Promise<Account>

    Account The account holding the new authorization config.

createOwnedStateAccount

  • createOwnedStateAccount(connection: Connection, payerAccount: Account, size: number, parent: PublicKey, programStateAccount?: Account | null): Promise<Account>
  • Helper for creating rent exempted accounts.

    Parameters

    • connection: Connection

      Solana network connection object.

    • payerAccount: Account

      Transaction funder account.

    • size: number

      Data size this account will be able to hold

    • parent: PublicKey

      The public key of the program that will own this account.

    • programStateAccount: Account | null = null

    Returns Promise<Account>

createVrfAccount

  • createVrfAccount(connection: Connection, payerAccount: Account, switchboardPid: PublicKey, accountSize?: number): Promise<Account>
  • Creates an account and permanently sets the account type to a VRF account.

    Parameters

    • connection: Connection

      Solana network connection object.

    • payerAccount: Account

      Transaction funder account.

    • switchboardPid: PublicKey

      The Switchboard Program pubkey.

    • accountSize: number = 1000

    Returns Promise<Account>

    Account New VRF Account

initAccount

  • initAccount(connection: Connection, payerAccount: Account, account: Account, type: SwitchboardAccountType): Promise<void>

initDataFeedAccount

  • initDataFeedAccount(connection: Connection, payerAccount: Account, dataFeedAccount: Account): Promise<void>
  • Permanently sets the account type to an Aggregator account.

    Parameters

    • connection: Connection

      Solana network connection object.

    • payerAccount: Account

      Transaction funder account.

    • dataFeedAccount: Account

      The account for which type will be set.

    Returns Promise<void>

initFulfillmentManagerAccount

  • initFulfillmentManagerAccount(connection: Connection, payerAccount: Account, fulfillmentManagerAccount: Account): Promise<void>
  • Permanently sets the account type to a FulfillmentManager account.

    Parameters

    • connection: Connection

      Solana network connection object.

    • payerAccount: Account

      Transaction funder account.

    • fulfillmentManagerAccount: Account

      The account for which type will be set.

    Returns Promise<void>

initFulfillmentManagerAuthAccount

  • initFulfillmentManagerAuthAccount(connection: Connection, payerAccount: Account, fulfillmentManagerAuthAccount: Account): Promise<void>
  • Permanently sets the account type to a FulfillmentManagerAuth account.

    Parameters

    • connection: Connection

      Solana network connection object.

    • payerAccount: Account

      Transaction funder account.

    • fulfillmentManagerAuthAccount: Account

      The account for which type will be set.

    Returns Promise<void>

parseAggregatorAccountData

  • parseAggregatorAccountData(connection: Connection, address: PublicKey): Promise<AggregatorState>
  • Pull accountInfo from a provided account address and attempt to parse the state.

    Parameters

    • connection: Connection

      Solana network connection object.

    • address: PublicKey

      The address of the aggregator account to parse.

    Returns Promise<AggregatorState>

    AggregatorState

parseBundleAuthAccountData

  • parseBundleAuthAccountData(connection: Connection, address: PublicKey): Promise<BundleAuth>
  • Pull accountInfo from a provided account address and attempt to parse the state.

    Parameters

    • connection: Connection

      Solana network connection object.

    • address: PublicKey

      The address of the bundle auth account to parse.

    Returns Promise<BundleAuth>

    BundleAuth

parseFulfillmentAccountData

  • Pull accountInfo from a provided account address and attempt to parse the state.

    Parameters

    • connection: Connection

      Solana network connection object.

    • address: PublicKey

      The address of the Fulfillment Manager account to parse.

    Returns Promise<FulfillmentManagerState>

    FulfillmentManagerState

parseOracleJobAccountData

  • parseOracleJobAccountData(connection: Connection, address: PublicKey): Promise<OracleJob>
  • Pull accountInfo from a provided account address and attempt to parse the state.

    Parameters

    • connection: Connection

      Solana network connection object.

    • address: PublicKey

      The address of the Oracle Job account to parse.

    Returns Promise<OracleJob>

    OracleJob

parseVrfAccountData

  • parseVrfAccountData(connection: Connection, address: PublicKey): Promise<VrfAccountData>
  • Pull accountInfo from a provided account address and attempt to parse the state.

    Parameters

    • connection: Connection

      Solana network connection object.

    • address: PublicKey

      The address of the VRF account to parse.

    Returns Promise<VrfAccountData>

    VrfAccountData

publishSwitchboardAccount

  • publishSwitchboardAccount(connection: Connection, account: Account, payerAccount: Account, switchboardPid: PublicKey, type: SwitchboardAccountType, accountSize?: number): Promise<Account>
  • Publishes a premade account on chain, initialized as the provided account type.

    Parameters

    • connection: Connection

      Solana network connection object.

    • account: Account

      The account which will be published and type will be set.

    • payerAccount: Account

      Transaction funder account.

    • switchboardPid: PublicKey

      Switchboard program ID.

    • type: SwitchboardAccountType

      The type to set the account to.

    • accountSize: number = 5_000

      The size to initialize the account to.

    Returns Promise<Account>

removeFeedBundle

  • removeFeedBundle(connection: Connection, payerAccount: Account, dataFeedAccount: Account, bundleAuth: PublicKey): Promise<null>
  • Parameters

    • connection: Connection
    • payerAccount: Account
    • dataFeedAccount: Account
    • bundleAuth: PublicKey

    Returns Promise<null>

removeFeedJob

  • removeFeedJob(connection: Connection, payerAccount: Account, dataFeedAccount: Account, job: PublicKey): Promise<void>
  • Adds a new task list to be performed when the provided data feed is updated.

    Parameters

    • connection: Connection

      Solana network connection object.

    • payerAccount: Account

      Transaction funder account.

    • dataFeedAccount: Account

      The account holding the data feed being mutated.

    • job: PublicKey

      The public key of the job account to remove from this aggregator.

    Returns Promise<void>

requestRandomness

  • requestRandomness(connection: Connection, payerAccount: Account, vrfAccount: Account, vrfProducerPermit: PublicKey, fmPermit: PublicKey): Promise<void>
  • Requests new randomness for a provided VRF account

    Parameters

    • connection: Connection

      Solana network connection object.

    • payerAccount: Account

      Transaction funder account.

    • vrfAccount: Account

      The VRF account for which randomness is being requested.

    • vrfProducerPermit: PublicKey

      The permit pubkey authorizing this VRF to request randomness.

    • fmPermit: PublicKey

      The permit pubkey authorizing use of a specific fulfillment group to verify proofs.

    Returns Promise<void>

setAuthConfigs

  • setAuthConfigs(connection: Connection, payerAccount: Account, fulfillmentManagerAccount: Account, fulfillmentManagerAuthPubkey: PublicKey, nomineePubkey: PublicKey, configs: any): Promise<void>
  • Modifies an authorization account for a fulfillment manager. This can be used to disable or enable authorization for an account to interact with a FulfillmentManagerState.

    Parameters

    • connection: Connection

      Solana network connection object.

    • payerAccount: Account

      Transaction funder account.

    • fulfillmentManagerAccount: Account

      The FulfillmentManagerState account for which usage is being authorized.

    • fulfillmentManagerAuthPubkey: PublicKey

      The FulfillmentManagerAuth account for which auth settings are being modified.

    • nomineePubkey: PublicKey

      The public key for which authorization is being linked to the fulfillment manager account.

    • configs: any

      Denotes the parameters of the FulfillmentManagerAuth that are being modified.
      authorizeHeartbeat: Set to true to let this account authorize heartbeats from the nomineePubkey to the provided FulfillmentManager.
      authorizeUsage: Set to true to let the nominee use the provided Fulfillment manager to fulfill updateFeed requests.

    Returns Promise<void>

setBundleAuthConfigs

  • setBundleAuthConfigs(connection: Connection, payerAccount: Account, bundleAuthAccount: Account, bundleAccount: Account, aggregatorPubkey: PublicKey, auth_idx: number): Promise<void>
  • Parameters

    • connection: Connection
    • payerAccount: Account
    • bundleAuthAccount: Account
    • bundleAccount: Account
    • aggregatorPubkey: PublicKey
    • auth_idx: number

    Returns Promise<void>

setDataFeedConfigs

  • setDataFeedConfigs(connection: Connection, payerAccount: Account, dataFeedAccount: Account, configs: any): Promise<void>
  • setDataFeedConfigs allows settings changes to an owned data feed account

    Parameters

    • connection: Connection

      Solana network connection object.

    • payerAccount: Account

      Transaction funder account.

    • dataFeedAccount: Account

      The account of the data feed being configured.

    • configs: any

      A dictonary object specifying the configurations to be updated.
      minConfirmations: Number of results required to accept a new round.
      minUpdateDelaySeconds: How often this feed is permitted to be updated.
      fulfillmentManagerPubkey: The public key of the fulfillment manager to attach to.
      lock: Once a data feed is locked, all future configuration updates are forbidden.

    Returns Promise<void>

setFulfillmentManagerConfigs

  • setFulfillmentManagerConfigs(connection: Connection, payerAccount: Account, fulfillmentManagerAccount: Account, configs: any): Promise<void>
  • setDataFeedConfigs allows settings changes to an owned data feed account

    Parameters

    • connection: Connection

      Solana network connection object.

    • payerAccount: Account

      Transaction funder account.

    • fulfillmentManagerAccount: Account

      The account of the fulfillment manager to being configured.

    • configs: any

      A dictionary object specifying the configurations to be updated.
      heartbeatAuthRequired: Authorization is required for nodes to join this fulfiller.
      usageAuthRequired: Authorization is required for data feeds to use this fulfiller.
      lock: Once the account is locked, all future configuration updates are forbidden.

    Returns Promise<void>

updateFeed

  • updateFeed(connection: Connection, payerAccount: Account, dataFeedPubkey: PublicKey, authKey?: PublicKey): Promise<string>
  • updateFeed will request a new fulfillment agreement for the aggregator and notify nodes to fulfill the aggregator jobs.

    throws

    Error If authorization fails or if the data feed is not allowed to be updated at the time of calling.

    Parameters

    • connection: Connection

      Solana network connection object.

    • payerAccount: Account

      Transaction funder account.

    • dataFeedPubkey: PublicKey

      The public key of the data feed being updated.

    • Optional authKey: PublicKey

      The public key of the authorization account allowing this data feed to use the linked fulfillment manager.

    Returns Promise<string>

    TransactionSignature of the update transaction.

Generated using TypeDoc