@fairmint/daml-js

中文文档
0.1.61发布于 2026/11/06GPL-3.0-onlyTypeScriptCommonJS近 30 天下载 1.5万

Fairmint DAML packages with generated JavaScript bindings (CantonPayments, NFT, Reports, Equity, CouponMinter, TradeSettlement and TradeSettlementHolder). The OpenCapTable-v35 register is published from open-captable-protocol-daml.

原始使用文档
文档目录6 节
  1. Developer documentation
  2. Install
  3. Package surface
  4. Trade desk and holder packages
  5. Repository layout
  6. Build and validate

Fairmint DAML contracts

This repository contains Fairmint's DAML contract packages and publishes their generated JavaScript bindings as @fairmint/daml-js.

The package covers:

  • Canton payment streams
  • OCF reporting contracts
  • CIP-0112 equity tokens, OTC settlement, and clearing
  • TA trade settlement on the OpenCapTable-v35 register: the transfer agent's trade desk (TradeSettlement-v01) and the holder-facing templates of its trades (TradeSettlementHolder-v01: terms, the holders' approvals and the Token Standard V2 cash leg)
  • the equity certificate, keyed by cap table, stakeholder and stock class (EquityCertificate)
  • NFT API and reference contracts
  • test-token helpers used by integrations

The Open Cap Table Protocol contracts are published separately. Install @fairmint/open-captable-protocol-daml-js for Fairmint.OpenCapTable and OCP_TEMPLATES; their source is in Fairmint/open-captable-protocol-daml. @fairmint/daml-js carries only a private copy of the OpenCapTable-v35 and OpenCapTableApi-v01 types that TradeSettlement-v01's bindings name (and of the equity certificate types the desk's reserve and settle name), pinned to the OpenCapTable version it was built against. That copy is not exported and registers no templates with @daml/types, so OpenCapTable templates always resolve through @fairmint/open-captable-protocol-daml-js.

Developer documentation

The GitHub wiki is retired (disabled). Those hubs are canonical.

Install

npm install @fairmint/daml-js

The package declares the DAML JavaScript runtime versions that its generated bindings use. Keep @daml/ledger and @daml/types compatible with the peer dependency versions reported by npm.

Package surface

The browser-safe root entry point exports generated namespaces including:

import { CantonPayments, Fairmint, Nft } from '@fairmint/daml-js';

const registryTemplate = Fairmint.EquityTokens.EquityRegistry.EquityRegistry;
const paymentFactoryTemplate =
  CantonPayments.PaymentStream.PaymentStreamFactory.PaymentStreamFactory;
const nftInterface = Nft.Api.V1.Nft.Nft;

The exact module names are generated from the DAML source. Let TypeScript discover the available templates from the installed package instead of copying package IDs into application code.

Deployed singleton IDs are available through stable JSON subpaths:

import paymentStreamsFactory from '@fairmint/daml-js/paymentStreams-factory-contract-id.json';
import reportsFactory from '@fairmint/daml-js/reports-factory-contract-id.json';

Check package.json for the complete export map. The generated package surface is also enforced by scripts/test-imports.ts and scripts/verify-merged-lib-runtime.ts.

Trade desk and holder packages

The transfer agent's trade desk settles secondary trades on the OpenCapTable-v35 register, per ADR-041 and the OCP register product doc. The module headers under TradeSettlement/, TradeSettlementHolder/ and EquityCertificate/ are the exact contract; the shape is:

  • TradeSettlementHolder-v01 holds the contracts a holder signs or observes (Types, Cash, AllocationRequest, Seller, Buyer) and depends on no OpenCapTable package, so a holder vets no register DAR and sees no register node. TradeSettlement-v01 holds the desk (TradeDesk, DeskChecks). npm run check:holder-packages, which build and test run first, fails if the holder package, the equity certificate packages or the NFT packages name OpenCapTable.
  • TradeSettlement.TestPrivacy checks what holders see: no desk or register contract among their active contracts and, walking the transaction trees of reserve, settle and release, every register node only under desk nodes. Follow-up, not yet written: the per-party projection test of those transactions on LocalNet, which Daml Script cannot run, pinning that no holder's projection holds an OpenCapTable-v35 node (the design's visibility section asks for it), for example in ta-service's LocalNet tests.
  • The desk is signed by the cap table's three keys (the issuer, the system operator and the transfer agent) and created through TradeDeskAuthorization: the system operator creates it, the transfer agent accepts, then the issuer. The authorization names the desk it replaces and lapses at its acceptBefore.
  • ta_cash is a transfer agent party separate from the three keys. With the buyer it is the cash leg's executor, so the transfer agent alone can never move the cash.
  • Acceptance_Settle on the buyer's BuyerAcceptance is controlled by the issuer, the system operator, the transfer agent and ta_cash together. TradeDesk_Settle is the only code that exercises it: after CapTable_Settle it checks the returned SettleResult field by field against the accepted terms, and a mismatch rolls back shares and cash together.
  • TradeDesk_Reserve consumes the seller's stakeholder-and-class instruction beside CapTable_PlaceHolds and keeps the hold IDs on a TradeHoldRecord no holder sees; TradeDesk_Release ends a trade through CapTable_CancelHolds.
  • EquityCertificate is keyed by cap table, stakeholder and stock class, signed by the same three keys, observed by its holder and minted only through the cap table's EquityCertificateFactory.

In @fairmint/daml-js the modules of both trade packages merge into one Fairmint.TradeSettlement namespace, while template IDs name the defining package: #TradeSettlementHolder-v01:… for the holder modules and #TradeSettlement-v01:… for TradeDesk.

Repository layout

  • multi-package.yaml declares the active package build graph.
  • Each package's daml.yaml is the source of truth for its current name, version, SDK, and DAML dependencies.
  • scripts/ contains code generation, package verification, DAR policy, and deployment tooling.
  • dars/ and dars/dars.lock retain backed-up DARs and their integrity metadata.
  • generated/ and lib/ are produced by the build and packaging pipeline; do not treat them as hand-maintained documentation.

Build and validate

Install dependencies and the DAML SDK versions selected by the package manifests:

npm install
npx canton-dev-tools install-dpm-sdks

TradeSettlement-v01 data-depends on the two OpenCapTable DARs pinned in ocp-dars.json, the reader interfaces (OpenCapTableApi-v01) and the register (OpenCapTable-v35), at one open-captable-protocol-daml commit. npm run sync-ocp-dars (run before build, test, lint:daml and check-upgrade-compat) fetches both from that repository and verifies their SHA-256. To build against local OpenCapTable DARs instead, for example ones not backed up in that repository yet, set OCP_DAR_PATH to a comma-separated list of them. Each is matched to the pin whose file is its basename (<package>-<version>.dar, as dpm names it), and a hash that differs from the pin is reported as a warning.

The TradeSettlement-v01 DAR embeds both OpenCapTable DARs, so uploading it also uploads and vets them. Release OpenCapTable through open-captable-protocol-daml on a network first, the reader interfaces and then the register: npm run upload-dar refuses TradeSettlement until that repository has the dar-deploy/<network>/<package>/v<version> tag of each of the two DARs. The desk also embeds TradeSettlementHolder-v01 and the equity certificate and NFT packages, and upload-dar refuses any package that embeds another package of this repository until that package has its own dar-deploy/<network>/<package>/v<version> tag here. Upload them first, each through its own run of the upload workflow; the refusal lists them in dependency order.

Other repositories that need these DARs (for example ta-service's LocalNet suites) install them from the private @fairmint/daml-dars package (npm-dars/) at a pinned version instead of vendoring them or cloning this repository. It carries the backed-up DARs of the settlement packages, verified against dars/dars.lock. npm run stage:npm-dars regenerates its manifest when a DAR changes and npm run check:npm-dars (CI) enforces it, with a version bump. Merging a bump to main publishes it through npm trusted publishing (publish-dars.yml). @fairmint/daml-js itself still ships no DARs.

The normal local validation path is:

npm run build
npm test

When generated bindings or the published npm surface are affected, also run:

npm run codegen
npm run verify-package

See package.json and the selected script's source for specialized checks and the exact command interface.

版本与发布记录

@fairmint/daml-js 共发布 60 个版本,首次发布于 2026/05/04;过去 12 个月发布了 60 个版本。

版本发布日期距今
0.1.61latest2026/11/068 天前
0.1.602026/10/2816 天前
0.1.592026/10/2817 天前
0.1.582026/10/2817 天前
0.1.572026/10/2717 天前
0.1.562026/10/091 个月前

关于 @fairmint/daml-js 的常见问题

@fairmint/daml-js 是什么?

Fairmint DAML packages with generated JavaScript bindings (CantonPayments, NFT, Reports, Equity, CouponMinter, TradeSettlement and TradeSettlementHolder). The OpenCapTable-v35 register is published from open-captable-protocol-daml.

如何安装 @fairmint/daml-js?

在项目目录运行 npm install @fairmint/daml-js,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@daml/types(3.5.2)、@daml/ledger(2.10.4)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@fairmint/daml-js 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fairmint/daml-js 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@fairmint/daml-js 可以商用吗?

@fairmint/daml-js 使用 GPL-3.0-only 许可。强 Copyleft:分发包含该代码的软件时,整个作品需以 GPL-3.0 兼容许可开源,并附带专利与反锁定条款。仅内部使用不触发此义务。以上为概括,不构成法律意见,请以许可原文为准。

@fairmint/daml-js 的下载量有多少?

根据 npm 官方下载统计,@fairmint/daml-js 在 2026/10/14 – 2026/11/12 这 30 天内被下载 15,231 次,日均约 508 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fairmint/daml-js 还在维护吗?

最新版本 0.1.61 发布于 2026/11/06(8 天前);至今共发布 60 个版本,其中过去 12 个月发布了 60 个;首次发布于 2026/05/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。