@fairmint/wrapped-assets-sdk

中文文档
0.0.5发布于 2026/08/22Apache-2.0TypeScriptES Module近 30 天下载 1.1万

Opinionated Canton Network Token Standard registry over the WrappedAssets-v01 DAML contracts: factories, choice contexts and instrument reads, assembled from a narrow ledger port.

原始使用文档
文档目录3 节
  1. Install
  2. What to reach for
  3. Develop

@fairmint/wrapped-assets-sdk

The Canton Network Token Standard registry for the WrappedAssets-v01 DAML contracts: the registry reads a wallet asks for, and a command builder for every choice the contracts define. Nothing here submits — a builder returns a Ledger JSON API command plus the disclosures the submission carries, and handing that to a ledger client is the caller's step.

Not the generated Daml bindings. Those are @fairmint/wrapped-assets-daml-js, published from this repository and versioned separately — and a dependency of this package rather than an alternative to it. Every template id, interface id, choice name and choice-argument shape here is read off those bindings, pinned to 0.0.2, so this SDK tracks exactly the DAR that version was generated from: registry factories, instrument pause and compliance enforcement included. A choice a later DAR renames or drops stops this package compiling instead of failing at submission time.

This package is not opinionated about which ledger client you use. Inject a RegistryLedger, or a duck-typed JSON API reader (getActiveContracts + getEventsByContractId). To read CIP-56 results, use @fairmint/canton-node-sdk (or another client) with this package's CHOICES / TEMPLATE_IDS.

Install

npm install @fairmint/wrapped-assets-sdk
import { createWrappedAssetsRegistry } from '@fairmint/wrapped-assets-sdk';

// `ledger` is a RegistryLedger, or any JSON API reader with
// getActiveContracts + getEventsByContractId.
const registry = createWrappedAssetsRegistry({
  ledger: client,
  adminId: 'OTA::1220aaaa',
  instruments: [{ id: 'FMT-A', name: 'Fairmint Wrapped A', symbol: 'FMTA', decimals: 6 }],
});

await registry.listInstruments();

What to reach for

IntentStart at
Serve the registry API: instruments, factories, choice contextscreateWrappedAssetsRegistry, createWrappedAssetsRegistryFromJsonApiClient
Issue or rewrap units (pause-gated)getBurnMintFactory, buildMintCommand, buildBurnMintCommand
Retire units (pause-blind)getBurnFactory, buildBurnCommand
Redeem: the owner consents, the transfer agent burns laterbuildBurnOfferCreateCommand, and the Accept/Reject/Withdraw/Expire builders beside it
Send units, or settle one leg of a tradebuildTransferCommand, buildAllocateCommand, and the accept, reject, withdraw and cancel builders
Compliance: freeze, release, confiscate, pausebuildEnforceHoldingsCommand, buildBurnHoldingEnforcementCommand, buildEnforceInstrumentsCommand
Stand up or retire a factory or an instrumentbuild*ProposalCreateCommand and the accept, reject and withdraw builders for each
Name or match a template, interface or choiceTEMPLATE_IDS (commands), TEMPLATES + matchesTemplate (create events), CHOICES, *_INTERFACE_ID
Handle failureNotFoundError (404), BadRequestError (400), UnavailableError (503)
Implement the ledger yourself, or read from something elseRegistryLedger, and test/support/fixtures.ts as a worked example
Validate a request or a response against the standard@fairmint/wrapped-assets-sdk/schemas

The ./schemas entry point is Zod schemas for every request and response the standard defines, generated during npm run build from the four OpenAPI documents Splice publishes and pinned by openapi/specs.lock.json, so a server validating against the standard does not run a generator of its own. zod is an optional peer dependency, needed only by a consumer that imports that entry point; the devDependency is pinned to the oldest version the peer range accepts, so a consumer pinning that version shares one copy of Zod with these schemas rather than comparing two.

Minting is pause-gated and instrument-scoped as of 0.0.4, and a burn-mint caller that passed an empty context has to fetch one now. CHANGELOG.md has the migration.

Every export carries its contract in a doc comment at its definition, including who controls each choice, which builders are pause-gated, and what each reader refuses to guess at. How the pieces fit together — the registry's place in the OTA architecture, and which DAR is deployed where — is in Fairmint/dev-docs.

Develop

npm install    # from the repository root
npm run build:sdk
npm run test:sdk

Tests are node:test over tsx and never reach a participant node: builders are asserted against expected JSON, registry reads against the fixture ledger, and test/schemas.test.ts parses every registry read with the generated schema for the operation that serves it.

src/generated/ is not committed. Build, test and typecheck all run npm run generate first, which fetches each pinned document if it is absent, refuses one that does not hash to what openapi/specs.lock.json records, and writes the schemas — so the first run of any of them needs network access.

Every template this SDK names is now in the WrappedAssets-v01 DAR, and test/templates.test.ts holds it to that: the choices come off the published bindings, and one of its tests fails if the DAR declares a choice no builder reaches. What is still unit-tested only is the behaviour of those commands on a ledger — test/localnet/ reaches a live participant for the factory bootstrap alone, so the transfer, allocation and enforcement builders are asserted against expected JSON rather than submitted.

版本与发布记录

@fairmint/wrapped-assets-sdk 共发布 5 个版本,首次发布于 2026/08/19;过去 12 个月发布了 5 个版本。

版本发布日期距今
0.0.5latest2026/08/222 个月前
0.0.42026/08/212 个月前
0.0.32026/08/192 个月前
0.0.22026/08/192 个月前
0.0.12026/08/192 个月前

关于 @fairmint/wrapped-assets-sdk 的常见问题

@fairmint/wrapped-assets-sdk 是什么?

Opinionated Canton Network Token Standard registry over the WrappedAssets-v01 DAML contracts: factories, choice contexts and instrument reads, assembled from a narrow ledger port.

如何安装 @fairmint/wrapped-assets-sdk?

在项目目录运行 npm install @fairmint/wrapped-assets-sdk,或使用 pnpm add / yarn add / bun add。

@fairmint/wrapped-assets-sdk 支持 TypeScript 吗?

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

@fairmint/wrapped-assets-sdk 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@fairmint/wrapped-assets-sdk 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@fairmint/wrapped-assets-sdk 可以商用吗?

@fairmint/wrapped-assets-sdk 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@fairmint/wrapped-assets-sdk 的下载量有多少?

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

@fairmint/wrapped-assets-sdk 还在维护吗?

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