Open Cap Table Protocol Canton SDK - v0.2.224
    Preparing search index...

    Function getEntityAsOcf

    • Generic function to retrieve and convert a contract to OCF format.

      This function combines contract fetching, data extraction, and OCF conversion into a single operation, eliminating the duplicated pattern across get*AsOcf functions.

      Type Parameters

      Parameters

      • client: LedgerJsonApiClient

        The LedgerJsonApiClient instance

      • entityType: T

        The OCF entity type

      • contractId: string

        The contract ID to fetch

      Returns Promise<GetEntityAsOcfResult<T>>

      The entity data in native OCF format along with the contract ID

      OcpParseError if the contract data is invalid or conversion fails

      // Generic read using dispatcher
      const result = await getEntityAsOcf(client, 'stockAcceptance', contractId);
      // result.data is typed as OcfStockAcceptance

      // Can be used in place of specific get*AsOcf functions
      const acceptance = await getEntityAsOcf(client, 'convertibleAcceptance', id);