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

Properties

readonlyaddress

address: string

address of the EnclaveAccount

publicdata

data: any

readonlyswitchboard

switchboard: ISwitchboardProgram

the instance of Switchboard program

Accessors

publicaccount

publicauthority

  • get authority(): string
  • Returns string

publicbalance

  • get balance(): BigNumber
  • Returns BigNumber

publiccid

  • get cid(): string
  • Returns string

publicisOnQueue

  • get isOnQueue(): boolean
  • Returns boolean

publiclastHeartbeat

  • get lastHeartbeat(): number
  • Returns number

publicmrEnclave

  • get mrEnclave(): string
  • Returns string

publicqueueId

  • get queueId(): string
  • Returns string

publicsigner

  • get signer(): string
  • Returns string

publicvalidUntil

  • get validUntil(): number
  • Returns number

publicverificationStatus

  • get verificationStatus(): PENDING | FAILURE | SUCCESS | OVERRIDE
  • Returns PENDING | FAILURE | SUCCESS | OVERRIDE

publicverificationTimestamp

  • get verificationTimestamp(): number
  • Returns number

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>
  • Load Function Account data and update LoadedFunctionAccount state.


    Returns Promise<any>

    Promise that resolves to EnclaveData

    const functionData = await functionAccount.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);

publictoJSON

  • toJSON(): { address: string; authority: string; balance: BigNumber; cid: string; isOnQueue: boolean; lastHeartbeat: number; mrEnclave: string; queueId: string; signer: string; validUntil: number; verificationStatus: PENDING | FAILURE | SUCCESS | OVERRIDE; verificationTimestamp: number }
  • Returns { address: string; authority: string; balance: BigNumber; cid: string; isOnQueue: boolean; lastHeartbeat: number; mrEnclave: string; queueId: string; signer: string; validUntil: number; verificationStatus: PENDING | FAILURE | SUCCESS | OVERRIDE; verificationTimestamp: number }

    • address: string
    • authority: string
    • balance: BigNumber
    • cid: string
    • isOnQueue: boolean
    • lastHeartbeat: number
    • mrEnclave: string
    • queueId: string
    • signer: string
    • validUntil: number
    • verificationStatus: PENDING | FAILURE | SUCCESS | OVERRIDE
    • verificationTimestamp: number

publictoObj

  • toObj(): { address: string; authority: string; balance: BigNumber; cid: string; isOnQueue: boolean; lastHeartbeat: number; mrEnclave: string; queueId: string; signer: string; validUntil: number; verificationStatus: PENDING | FAILURE | SUCCESS | OVERRIDE; verificationTimestamp: number }
  • Returns { address: string; authority: string; balance: BigNumber; cid: string; isOnQueue: boolean; lastHeartbeat: number; mrEnclave: string; queueId: string; signer: string; validUntil: number; verificationStatus: PENDING | FAILURE | SUCCESS | OVERRIDE; verificationTimestamp: number }

    • address: string
    • authority: string
    • balance: BigNumber
    • cid: string
    • isOnQueue: boolean
    • lastHeartbeat: number
    • mrEnclave: string
    • queueId: string
    • signer: string
    • validUntil: number
    • verificationStatus: PENDING | FAILURE | SUCCESS | OVERRIDE
    • verificationTimestamp: number

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);