@open-captable-protocol/canton 0.2.278 → 0.2.279
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -156
- package/package.json +1 -1
- package/README.docs.md +0 -42
package/README.md
CHANGED
|
@@ -1,158 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Implementation guidance for contributors and AI assistants
|
|
3
|
-
- Use strict TypeScript (enable "strict": true)
|
|
4
|
-
- Never use `any` or `unknown`; model precise types or augment upstream
|
|
5
|
-
- Fail fast on invalid inputs; validate early and throw meaningful errors
|
|
6
|
-
- Prefer explicit names and return types in all public APIs
|
|
7
|
-
- Keep modules small, pure, and composable; avoid side effects
|
|
8
|
-
-->
|
|
1
|
+
# ocp-canton-sdk
|
|
9
2
|
|
|
10
|
-
|
|
3
|
+
High-level TypeScript SDK for Open Cap Table Protocol contracts on Canton Network.
|
|
11
4
|
|
|
12
|
-
|
|
13
|
-
[
|
|
14
|
-
|
|
15
|
-
### Principles
|
|
16
|
-
|
|
17
|
-
- **Strict types**: `"strict": true` across the repo; no unsound assertions
|
|
18
|
-
- **No `any`/`unknown`**: prefer unions, discriminated unions, and narrow interfaces
|
|
19
|
-
- **Fail fast**: validate inputs, throw early with actionable messages
|
|
20
|
-
- **Explicit APIs**: always annotate exported function return types
|
|
21
|
-
- **Deterministic**: avoid hidden state; keep functions pure when possible
|
|
22
|
-
|
|
23
|
-
### Directory conventions
|
|
24
|
-
|
|
25
|
-
- `src/functions/<domain>/...`: one operation per file; export `Params`/`Result`
|
|
26
|
-
- `src/OcpClient.ts`: grouped facade that wires functions to a `LedgerJsonApiClient`
|
|
27
|
-
- `src/types/native.ts`: ergonomic OCF-native types for inputs/outputs
|
|
28
|
-
- `src/types/contractDetails.ts`: `ContractDetails` for disclosed cross-domain references
|
|
29
|
-
- `src/utils/typeConversions.ts`: conversions between DAML types and native OCF types
|
|
30
|
-
- `src/utils/TransactionBatch.ts`: typed batch submission helper
|
|
31
|
-
|
|
32
|
-
### Function design
|
|
33
|
-
|
|
34
|
-
- Name operations with verbs: `createX`, `getXAsOcf`, `archiveXByIssuer`
|
|
35
|
-
- Define `XParams` and `XResult` in the operation file; export them
|
|
36
|
-
- Validate all required fields in `XParams` and return precise `XResult`
|
|
37
|
-
- Provide `buildXCommand` for batch support when relevant (returns Command + disclosures)
|
|
38
|
-
|
|
39
|
-
### Disclosed contracts
|
|
40
|
-
|
|
41
|
-
- Use `ContractDetails` with all fields required: `contractId`, `createdEventBlob`,
|
|
42
|
-
`synchronizerId`, `templateId`
|
|
43
|
-
- Include only the minimum set of disclosed contracts required for the transaction
|
|
44
|
-
|
|
45
|
-
### Ledger client and config
|
|
46
|
-
|
|
47
|
-
- Construct with `ClientConfig` from `@fairmint/canton-node-sdk`
|
|
48
|
-
- Ensure LEDGER_JSON_API is configured with auth and party/user identifiers
|
|
49
|
-
|
|
50
|
-
### Data conversion
|
|
51
|
-
|
|
52
|
-
- Map inputs using native OCF types from `types/native`
|
|
53
|
-
- Perform conversions in `utils/typeConversions.ts`; reject invalid shapes immediately
|
|
54
|
-
- **Never hide data issues with defensive checks or fallback values**
|
|
55
|
-
- If DAML defines a field as an array, trust it's an array—don't check with `Array.isArray()` and
|
|
56
|
-
provide empty array fallbacks
|
|
57
|
-
- DAML arrays are never null or undefined, so don't check for that either (e.g.,
|
|
58
|
-
`arr && arr.length` → just `arr.length`)
|
|
59
|
-
- If data is malformed, let it throw naturally so issues surface immediately
|
|
60
|
-
- This applies to all conversions: fail fast rather than silently handling unexpected data
|
|
61
|
-
- Example of what NOT to do: `Array.isArray(data) ? data : []` ❌ or `data && data.length` ❌
|
|
62
|
-
- Example of what to do: `data as ExpectedType[]` ✅ and `data.length` ✅
|
|
63
|
-
|
|
64
|
-
### Batching
|
|
65
|
-
|
|
66
|
-
- Use `TransactionBatch` for multi-command submissions; prefer `buildXCommand` helpers to ensure
|
|
67
|
-
types are correct
|
|
68
|
-
|
|
69
|
-
### Error handling & logging
|
|
70
|
-
|
|
71
|
-
- Throw `Error` (or domain-specific subclasses) with clear messages; never swallow errors
|
|
72
|
-
- Prefer adding context (contract/template ids, party id) to error messages
|
|
73
|
-
- Use the shared logger from the node SDK when available
|
|
74
|
-
|
|
75
|
-
### Testing
|
|
76
|
-
|
|
77
|
-
- Unit-test conversions and param validation
|
|
78
|
-
- Prefer deterministic fixtures and golden samples for OCF objects
|
|
79
|
-
- All OCF fixtures are validated against the official OCF JSON schemas (see
|
|
80
|
-
`test/utils/ocfSchemaValidator.ts`)
|
|
81
|
-
- The OCF schemas are maintained as a git submodule at `libs/Open-Cap-Format-OCF/`
|
|
82
|
-
|
|
83
|
-
### Documentation
|
|
84
|
-
|
|
85
|
-
- Contributor guidance lives here
|
|
86
|
-
- End-user/API docs: [Open Cap Table Protocol Canton SDK](https://ocp.canton.fairmint.com/)
|
|
87
|
-
- Internal API docs can be generated locally with `npm run docs` into `docs/`
|
|
88
|
-
- AI context (single source of truth): `CLAUDE.md` (agent entrypoints: `CLAUDE.md`, `AGENTS.md`,
|
|
89
|
-
`GEMINI.md`)
|
|
90
|
-
|
|
91
|
-
### Contribution checklist
|
|
92
|
-
|
|
93
|
-
- Types are precise; no `any`/`unknown`
|
|
94
|
-
- Public APIs annotated; parameters validated
|
|
95
|
-
- Errors are actionable; no silent fallbacks
|
|
96
|
-
- Functions added to the relevant `index.ts` barrels and `OcpClient`
|
|
97
|
-
- Add `buildXCommand` variant where batching is expected
|
|
98
|
-
|
|
99
|
-
### LocalNet (cn-quickstart)
|
|
100
|
-
|
|
101
|
-
Local Canton Network for integration testing:
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
npm run localnet:start # Start (fast path when artifacts exist)
|
|
105
|
-
npm run localnet:stop # Stop services
|
|
106
|
-
npm run localnet:status # Docker + endpoint status
|
|
107
|
-
npm run localnet:smoke # Endpoint smoke checks
|
|
108
|
-
npm run localnet:test # Run integration tests
|
|
109
|
-
npm run localnet:verify # Setup + start + smoke + test
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
Environment toggles: `CANTON_LOCALNET_FAST_START` (default: true),
|
|
113
|
-
`CANTON_LOCALNET_FORCE_FULL_START` (default: false).
|
|
114
|
-
|
|
115
|
-
> **Note:** The orchestrator requires Linux with passwordless `sudo` and `apt-get` (designed for
|
|
116
|
-
> CI/cloud environments). For local development on macOS, use the cn-quickstart `Makefile` directly.
|
|
117
|
-
|
|
118
|
-
### OCF Schema Validation
|
|
119
|
-
|
|
120
|
-
The SDK enforces schema alignment and validation through dedicated test suites and an auditable
|
|
121
|
-
report flow:
|
|
122
|
-
|
|
123
|
-
- `test/schemaAlignment/*` guards SDK type/interface + enum alignment with OCF schemas, including
|
|
124
|
-
converter coverage for mapped enums.
|
|
125
|
-
- `test/validation/*` verifies fail-fast required-field validation and converter output validity.
|
|
126
|
-
- `scripts/audit-ocf-schema-alignment.ts` regenerates `audit-field-report.md` from current SDK types
|
|
127
|
-
vs OCF schema definitions.
|
|
128
|
-
|
|
129
|
-
**Schema-alignment workflow:**
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
git submodule update --init --recursive
|
|
133
|
-
npx jest test/schemaAlignment --runInBand
|
|
134
|
-
npx jest test/validation --runInBand
|
|
135
|
-
npx ts-node scripts/audit-ocf-schema-alignment.ts
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
**Validation guarantee:**
|
|
139
|
-
|
|
140
|
-
- Invalid or incomplete payloads should fail with explicit validation errors.
|
|
141
|
-
- OCF-facing outputs are continuously checked against official OCF schemas in test suites.
|
|
142
|
-
|
|
143
|
-
### LocalNet
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
npm run localnet:start # Start (fast path when artifacts exist)
|
|
147
|
-
npm run localnet:stop # Stop services
|
|
148
|
-
npm run localnet:status # Docker + endpoint status
|
|
149
|
-
npm run localnet:smoke # Endpoint smoke checks
|
|
150
|
-
npm run localnet:verify # Setup + start + smoke + test
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
`localnet:start` uses a fast startup path when quickstart build artifacts already exist. To force a
|
|
154
|
-
full rebuild start, run `CANTON_LOCALNET_FORCE_FULL_START=true npm run localnet:start`.
|
|
155
|
-
|
|
156
|
-
### License
|
|
157
|
-
|
|
158
|
-
MIT
|
|
5
|
+
See the [wiki](https://github.com/fairmint/ocp-canton-sdk/wiki) for full documentation. For the full
|
|
6
|
+
API reference, see [ocp.canton.fairmint.com](https://ocp.canton.fairmint.com/).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-captable-protocol/canton",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.279",
|
|
4
4
|
"description": "A TypeScript SDK for interacting with the Open CapTable Protocol (OCP) Factory contract on Canton blockchain",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
package/README.docs.md
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# OCP Canton SDK - Documentation
|
|
2
|
-
|
|
3
|
-
This package publishes API docs to GitHub Pages using TypeDoc.
|
|
4
|
-
|
|
5
|
-
## Local setup
|
|
6
|
-
|
|
7
|
-
- Node 18+
|
|
8
|
-
- Install deps:
|
|
9
|
-
|
|
10
|
-
```bash
|
|
11
|
-
npm i
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
- Generate docs locally:
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
npm run docs
|
|
18
|
-
open docs/index.html
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## CI publishing
|
|
22
|
-
|
|
23
|
-
A workflow at `.github/workflows/docs.yml` builds docs on pushes to `main` and deploys to GitHub
|
|
24
|
-
Pages.
|
|
25
|
-
|
|
26
|
-
### One-time repo setup
|
|
27
|
-
|
|
28
|
-
- In repository Settings → Pages, set:
|
|
29
|
-
- Build and deployment: "GitHub Actions"
|
|
30
|
-
- Ensure Actions permissions allow GitHub Pages deployments.
|
|
31
|
-
|
|
32
|
-
No secrets are required; it uses `GITHUB_TOKEN` with pages:write.
|
|
33
|
-
|
|
34
|
-
## Customizing
|
|
35
|
-
|
|
36
|
-
- Edit `typedoc.json` to change entry points, output dir, and visibility filters.
|
|
37
|
-
- By default, `src/index.ts` is the entry point and output goes to `docs/`.
|
|
38
|
-
|
|
39
|
-
## Troubleshooting
|
|
40
|
-
|
|
41
|
-
- If docs are empty, ensure `src/index.ts` re-exports public symbols.
|
|
42
|
-
- If CI fails on `npm ci`, ensure `package-lock.json` is up to date.
|