Skip to main content

Class for interacting with Enclave Accounts in the SwitchboardAttestationService.sol contract.

// Instantiate an EnclaveAccount
const enclaveAccount = new EnclaveAccount(switchboardProgram, '0xYourEnclaveAccountAddress');

// Load the data
const enclave = await enclaveAccount.loadData();
const name = enclave.name;

Hierarchy

Index

Constructors

constructor

  • Constructor of EnclaveAccount


    Parameters

    • switchboard: ISwitchboardProgram

      the instance of Switchboard program

    • address: string

      address of the EnclaveAccount

    Returns EnclaveAccount

Properties

readonlyaddress

address: string

address of the EnclaveAccount

readonlyswitchboard

switchboard: ISwitchboardProgram

the instance of Switchboard program

Methods

publicforceOverrideVerify

  • forceOverrideVerify(options?: any): Promise<ContractTransaction>
  • Method to force an override verification


    Parameters

    • optionaloptions: any

      Transaction options

    Returns Promise<ContractTransaction>

    Promise that resolves to ContractTransaction

    const contractTransaction = await enclaveAccount.forceOverrideVerify(options);

publicheartbeat

  • heartbeat(options?: any): Promise<ContractTransaction>
  • Parameters

    • optionaloptions: any

    Returns Promise<ContractTransaction>

publicisEnclaveValid

  • isEnclaveValid(): Promise<boolean>
  • Method to check if the enclave is valid


    Returns Promise<boolean>

    Promise that resolves to boolean value indicating whether the enclave is valid

    const isValid = await enclaveAccount.isEnclaveValid();

publicloadData

  • loadData(): Promise<any>
  • Method to load the data of the EnclaveAccount


    Returns Promise<any>

    Promise that resolves to EnclaveData

    const enclaveData = await enclaveAccount.loadData();

publicpollVerification

  • pollVerification(retryCount?: number): Promise<any>
  • Method to poll for the enclave verification


    Parameters

    • optionalretryCount: number = 3

      Number of retries for the operation

    Returns Promise<any>

    Promise that resolves to EnclaveData

    const enclaveData = await enclaveAccount.pollVerification(retryCount);

publicupdateEnclave

  • updateEnclave(enclaveBuffer: RawMrEnclave, options?: any): Promise<ContractTransaction>
  • Method to update the enclave


    Parameters

    • enclaveBuffer: RawMrEnclave

      RawMrEnclave data

    • optionaloptions: any

      Transaction options

    Returns Promise<ContractTransaction>

    Promise that resolves to ContractTransaction

    const contractTransaction = await enclaveAccount.updateEnclave(enclaveBuffer, options);

publicverifyEnclave

  • verifyEnclave(verifierAddress: string, mrEnclave: RawMrEnclave, enclaveIdx?: number, options?: any): Promise<ContractTransaction>
  • Method to verify the enclave


    Parameters

    • verifierAddress: string

      Address of the verifier

    • mrEnclave: RawMrEnclave

      RawMrEnclave data

    • optionalenclaveIdx: number

      Enclave index

    • optionaloptions: any

      Transaction options

    Returns Promise<ContractTransaction>

    Promise that resolves to ContractTransaction

    const contractTransaction = await enclaveAccount.verifyEnclave(verifierAddress, mrEnclave, enclaveIdx, options);

publicstaticcreate

  • Static method to initialize a Enclave


    Parameters

    • switchboard: ISwitchboardProgram

      Instance of the SwitchboardProgram class

    • params: EnclaveInitParams & { attestationQueue: string }

      Enclave initialization parameters

    • optionaloptions: any

      Transaction options

    Returns Promise<[EnclaveAccount, ContractTransaction]>

    Promise that resolves to tuple of EnclaveAccount and ContractTransaction

    const [enclaveAccount, contractTransaction] = await EnclaveAccount.create(switchboard, params, options);

publicstaticinitAndAwaitVerification

  • Static method to initialize and await for the enclave verification


    Parameters

    • switchboard: ISwitchboardProgram

      Instance of the Switchboard Program class

    • authority: string

      Address of the authority

    • attestationQueueAddress: string

      Attestation Queue Address

    • enclaveBuffer: RawMrEnclave

      RawMrEnclave data

    • optionaloptions: any

      Transaction options

    • optionalretryCount: number = 3

      Number of retries for the operation

    Returns Promise<EnclaveAccount>

    Promise that resolves to EnclaveAccount

    const enclaveAccount = await EnclaveAccount.initAndAwaitVerification(switchboard, authority, attestationQueueAddress, enclaveBuffer, options, retryCount);

publicstaticload

  • Static method to load and fetch the account data


    Parameters

    Returns Promise<LoadedEnclaveAccount>

    Promise that resolves to tuple of EnclaveAccount and EnclaveData

    const enclaveAccount = await EnclaveAccount.load(switchboard, address);

publicstaticsignerToAddress

  • Static method to get the EnclaveAccount for the given authority


    Parameters

    • switchboard: ISwitchboardProgram

      Instance of the Switchboard Program class

    • authority: string

      Address of the authority

    Returns Promise<EnclaveAccount>

    Promise that resolves to EnclaveAccount

    const enclaveAccount = await EnclaveAccount.signerToAddress(switchboard, authority);