Skip to content

Reference

Utils — Canton OCF manifest extraction & transaction sort

extractCantonOcfManifest walks CapTableState contract ids into an OcfManifest; countManifestObjects tallies entities; sortTransactions and buildTransactionSortKey provide DB-parity ordering.

These exports support bulk export / verification: turn a CapTableState from getCapTableState into an OcfManifest shaped like fairmint API buildCaptableInput / processCapTable consumers. The module also exposes deterministic transaction ordering (sortTransactions, buildTransactionSortKey, txWeight, getTimestampOrNull) aligned with historical DB loaders.

Import

import {
  extractCantonOcfManifest,
  countManifestObjects,
  sortTransactions,
  buildTransactionSortKey,
  txWeight,
  getTimestampOrNull,
} from '@open-captable-protocol/canton';

extractCantonOcfManifest(client, cantonState, options?)

  • clientLedgerJsonApiClient
  • cantonStateCapTableState from getCapTableState
  • optionsExtractCantonOcfOptions:
    • verbose, logger — progress logging
    • readAs — forwarded via ledgerReadScope for issuer-visible reads
    • failOnReadErrors — default true; when false, non-benign classified failures log and continue (partial manifest)

Returns: OcfManifest with sorted transactions (via sortTransactions).

Throws: May throw OcpValidationError (e.g. missing object_type mapping), OcpContractError via createDiagnosedContractReadError for hard read failures when failOnReadErrors is true, and errors from underlying readers.

countManifestObjects(manifest)

Counts issuer (0/1) + array lengths for stakeholders, classes, plans, vesting terms, transactions, valuations, documents, legend templates. Accepts Partial<OcfManifest>.

Sort helpers

  • getTimestampOrNull — coerces numbers / ISO strings to ms or null.
  • txWeight — domain weight for same-day ordering by object_type.
  • buildTransactionSortKey — composite key day|weight|group|created|id; throws OcpValidationError if tx.date invalid.
  • sortTransactions — decorate-sort-undecorate using buildTransactionSortKey.

See also

Source