Skip to content

Reference

OCF data & conversion utils

Type guards, metadata, comparisons, and DAML/OCF conversions.

Utilities for inspecting OCF objects, converting between OCF and Canton DAML types, and comparing entities.


Type guards

typeGuards — runtime narrowing for unknown JSON into OCF shapes.

import { isOcfIssuer, isOcfStakeholder, detectOcfObjectType } from '@open-captable-protocol/canton';

Key exports: isNonEmptyString, isMonetary, isIsoDateString, per-entity guards (isOcfIssuer, isOcfStakeholder, etc.), detectOcfObjectType, assertOcf* assertion helpers


OCF metadata

ocfMetadata / ocfHelpers — canonical type registry and display metadata.

import { OCF_METADATA, getAllOcfTypes, isValidOcfType } from '@open-captable-protocol/canton';

Key exports: OcfObjectType (union), OCF_METADATA (label/plural map), getAllOcfTypes, isValidOcfType, getOcfMetadata, getOcfDataFieldName, getOcfTypeLabel, extractOcfIdFromCreateArgs


OCF comparison

ocfComparison — deep equality and structured diffs for OCF objects.

import { ocfDeepEqual, diffOcfObjects } from '@open-captable-protocol/canton';

Key exports: ocfDeepEqual, ocfCompare, diffOcfObjects, stripInternalFields, createOcfMismatchError, isOcfMismatchError, DEFAULT_INTERNAL_FIELDS, DEFAULT_DEPRECATED_FIELDS


Type conversions

typeConversions — DAML/OCF value conversions for time, monetary, and other field types.

import { dateStringToDAMLTime, monetaryToDaml } from '@open-captable-protocol/canton';

Key exports: dateStringToDAMLTime, damlTimeToDateString, relTimeToDAML, monetaryToDaml, damlMonetaryToNative, addressToDaml, parseDamlMap, quantityTransferToNative, mapDamlTriggerTypeToOcf, normalizeNumericString, optionalNumberToString


Enum conversions

enumConversions — bidirectional mappers between OCF enums and DAML-generated types.

import { stakeholderTypeToDaml, damlEmailTypeToNative } from '@open-captable-protocol/canton';

Covers email/phone types, stakeholder types, stock class types, stakeholder relationship and status types.


Read scope

ledgerReadScope — normalize optional readAs into ledger call spread.

import { ledgerReadScope } from '@open-captable-protocol/canton';

// spreads { readAs } if provided, else {}
const scope = ledgerReadScope({ readAs: ['observer::party'] });

Source