@fairmint/canton-node-sdk 0.0.251 → 0.0.252
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 +34 -7
- package/package.json +14 -15
- package/bin/canton-localnet +0 -213
- package/scripts/localnet-cloud.sh +0 -1178
package/README.md
CHANGED
|
@@ -4,10 +4,10 @@ Low-level TypeScript SDK for Canton Network nodes (Ledger JSON API, Validator AP
|
|
|
4
4
|
|
|
5
5
|
## Developer documentation
|
|
6
6
|
|
|
7
|
-
The public [GitHub wiki](https://github.com/Fairmint/canton-node-sdk/wiki) is the canonical guide
|
|
8
|
-
configuration, API boundaries, external signing, LocalNet, examples, and contribution. The
|
|
9
|
-
[`src/index.ts`](https://github.com/Fairmint/canton-node-sdk/blob/main/src/index.ts) defines
|
|
10
|
-
supported package surface; use the installed declarations and public
|
|
7
|
+
The public [GitHub wiki](https://github.com/Fairmint/canton-node-sdk/wiki) is the canonical guide
|
|
8
|
+
for configuration, API boundaries, external signing, LocalNet, examples, and contribution. The
|
|
9
|
+
public [`src/index.ts`](https://github.com/Fairmint/canton-node-sdk/blob/main/src/index.ts) defines
|
|
10
|
+
the supported package surface; use the installed declarations and public
|
|
11
11
|
[`examples/`](https://github.com/Fairmint/canton-node-sdk/tree/main/examples) and
|
|
12
12
|
[`test/`](https://github.com/Fairmint/canton-node-sdk/tree/main/test) for exact methods, request
|
|
13
13
|
shapes, and error behavior.
|
|
@@ -19,10 +19,10 @@ npm install @fairmint/canton-node-sdk
|
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
```ts
|
|
22
|
-
import { Canton } from
|
|
22
|
+
import { Canton } from '@fairmint/canton-node-sdk';
|
|
23
23
|
|
|
24
24
|
async function main(): Promise<void> {
|
|
25
|
-
const canton = new Canton({ network:
|
|
25
|
+
const canton = new Canton({ network: 'localnet' });
|
|
26
26
|
const version = await canton.ledger.getVersion();
|
|
27
27
|
console.log(version);
|
|
28
28
|
}
|
|
@@ -44,4 +44,31 @@ npm test
|
|
|
44
44
|
npm run build
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
### LocalNet (owned by `@fairmint/canton-dev-tools`)
|
|
48
|
+
|
|
49
|
+
LocalNet lifecycle and shared test helpers live in
|
|
50
|
+
[`@fairmint/canton-dev-tools@0.1.1`](https://www.npmjs.com/package/@fairmint/canton-dev-tools)
|
|
51
|
+
(see its [COMPATIBILITY.md](https://github.com/Fairmint/canton-dev-tools/blob/main/COMPATIBILITY.md)).
|
|
52
|
+
This SDK does not publish a LocalNet CLI or `scripts/localnet-cloud.sh`.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm install # installs @fairmint/canton-dev-tools as an exact-pinned devDependency
|
|
56
|
+
npm run localnet:start
|
|
57
|
+
npm run localnet:smoke
|
|
58
|
+
npm run localnet:stop
|
|
59
|
+
|
|
60
|
+
# Or call the Dev Tools CLI directly:
|
|
61
|
+
npx @fairmint/canton-dev-tools start
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Integration helpers:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import {
|
|
68
|
+
buildIntegrationTestClientConfig,
|
|
69
|
+
getLocalnetParticipantAdminLedgerClient,
|
|
70
|
+
} from '@fairmint/canton-dev-tools/testing';
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
See [docs/package-boundary.md](docs/package-boundary.md) for what the npm package publishes versus
|
|
74
|
+
CI-only surfaces (`npm run check:package-artifacts`).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fairmint/canton-node-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.252",
|
|
4
4
|
"description": "Canton Node SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"canton",
|
|
@@ -21,13 +21,8 @@
|
|
|
21
21
|
"author": "Fairmint",
|
|
22
22
|
"main": "build/src/index.js",
|
|
23
23
|
"types": "build/src/index.d.ts",
|
|
24
|
-
"bin": {
|
|
25
|
-
"canton-localnet": "bin/canton-localnet"
|
|
26
|
-
},
|
|
27
24
|
"files": [
|
|
28
|
-
"
|
|
29
|
-
"scripts/localnet-cloud.sh",
|
|
30
|
-
"build/**"
|
|
25
|
+
"build/src/**"
|
|
31
26
|
],
|
|
32
27
|
"scripts": {
|
|
33
28
|
"artifacts:manifest": "mkdir -p artifacts && npm pack --dry-run --json --ignore-scripts > /tmp/npm-pack.json 2>/dev/null && jq -r '.[0].files[].path' /tmp/npm-pack.json | sort | tsx scripts/collapse-manifest.ts > artifacts/npm-manifest.txt",
|
|
@@ -47,14 +42,17 @@
|
|
|
47
42
|
"lint:fix": "eslint . --fix",
|
|
48
43
|
"lint:npm": "npmPkgJsonLint . --fix",
|
|
49
44
|
"lint:npm:check": "npmPkgJsonLint .",
|
|
50
|
-
"localnet:
|
|
51
|
-
"localnet:
|
|
52
|
-
"localnet:
|
|
53
|
-
"localnet:
|
|
54
|
-
"localnet:
|
|
55
|
-
"localnet:
|
|
56
|
-
"localnet:
|
|
57
|
-
"localnet:
|
|
45
|
+
"localnet:diagnostics": "canton-dev-tools diagnostics",
|
|
46
|
+
"localnet:logs": "canton-dev-tools logs",
|
|
47
|
+
"localnet:quickstart": "canton-dev-tools setup",
|
|
48
|
+
"localnet:readiness": "canton-dev-tools readiness",
|
|
49
|
+
"localnet:setup": "canton-dev-tools setup",
|
|
50
|
+
"localnet:smoke": "canton-dev-tools smoke",
|
|
51
|
+
"localnet:start": "canton-dev-tools start",
|
|
52
|
+
"localnet:status": "canton-dev-tools status",
|
|
53
|
+
"localnet:stop": "canton-dev-tools stop",
|
|
54
|
+
"localnet:teardown": "canton-dev-tools teardown",
|
|
55
|
+
"localnet:verify": "canton-dev-tools verify",
|
|
58
56
|
"prepack": "npm run clean && npm run build:core",
|
|
59
57
|
"prepare-release": "tsx scripts/prepare-release.ts",
|
|
60
58
|
"prepublishOnly": "npm run prepack",
|
|
@@ -81,6 +79,7 @@
|
|
|
81
79
|
"zod": "4.4.3"
|
|
82
80
|
},
|
|
83
81
|
"devDependencies": {
|
|
82
|
+
"@fairmint/canton-dev-tools": "0.1.1",
|
|
84
83
|
"@types/jest": "30.0.0",
|
|
85
84
|
"@types/node": "26.1.0",
|
|
86
85
|
"@types/ws": "8.18.1",
|
package/bin/canton-localnet
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -euo pipefail
|
|
3
|
-
|
|
4
|
-
resolve_script_dir() {
|
|
5
|
-
local source="$1"
|
|
6
|
-
local dir=""
|
|
7
|
-
|
|
8
|
-
while [[ -L "${source}" ]]; do
|
|
9
|
-
dir="$(cd -P "$(dirname "${source}")" && pwd)"
|
|
10
|
-
source="$(readlink "${source}")"
|
|
11
|
-
if [[ "${source}" != /* ]]; then
|
|
12
|
-
source="${dir}/${source}"
|
|
13
|
-
fi
|
|
14
|
-
done
|
|
15
|
-
|
|
16
|
-
cd -P "$(dirname "${source}")" && pwd
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
PACKAGE_ROOT="$(cd "$(resolve_script_dir "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
20
|
-
LOCALNET_SCRIPT="${PACKAGE_ROOT}/scripts/localnet-cloud.sh"
|
|
21
|
-
DEFAULT_QUICKSTART_REPO="https://github.com/digital-asset/cn-quickstart.git"
|
|
22
|
-
DEFAULT_QUICKSTART_REF="2f4edfc17621a7dfb6d44357050c22f4b3914c89"
|
|
23
|
-
DEFAULT_SPLICE_VERSION="0.6.8"
|
|
24
|
-
|
|
25
|
-
log() {
|
|
26
|
-
printf '[canton-localnet] %s\n' "$*"
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
usage() {
|
|
30
|
-
cat <<'USAGE'
|
|
31
|
-
Usage: canton-localnet <command>
|
|
32
|
-
|
|
33
|
-
Commands:
|
|
34
|
-
setup Prepare LocalNet prerequisites
|
|
35
|
-
start Start lean LocalNet + Keycloak and wait for ready endpoints
|
|
36
|
-
stop Stop LocalNet services
|
|
37
|
-
logs Show LocalNet diagnostic logs
|
|
38
|
-
status Show docker + endpoint status
|
|
39
|
-
smoke Run endpoint smoke checks
|
|
40
|
-
test Run project integration tests when configured
|
|
41
|
-
verify Run setup + start + smoke + test
|
|
42
|
-
|
|
43
|
-
One-liners:
|
|
44
|
-
npx @fairmint/canton-node-sdk start
|
|
45
|
-
npx @fairmint/canton-node-sdk verify
|
|
46
|
-
|
|
47
|
-
Environment:
|
|
48
|
-
CANTON_LOCALNET_QUICKSTART_DIR Use an existing cn-quickstart/quickstart directory
|
|
49
|
-
CANTON_LOCALNET_CACHE_DIR Cache root for fetched cn-quickstart assets
|
|
50
|
-
CANTON_LOCALNET_QUICKSTART_REF cn-quickstart git ref to fetch
|
|
51
|
-
CANTON_LOCALNET_SPLICE_VERSION Splice image tag (defaults to the SDK's pinned API version)
|
|
52
|
-
CANTON_LOCALNET_INFRA_ONLY Defaults to true for this package binary
|
|
53
|
-
USAGE
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
require_command() {
|
|
57
|
-
local cmd="$1"
|
|
58
|
-
if ! command -v "${cmd}" >/dev/null 2>&1; then
|
|
59
|
-
log "Missing required command: ${cmd}"
|
|
60
|
-
exit 1
|
|
61
|
-
fi
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
cache_root() {
|
|
65
|
-
if [[ -n "${CANTON_LOCALNET_CACHE_DIR:-}" ]]; then
|
|
66
|
-
printf '%s' "${CANTON_LOCALNET_CACHE_DIR}"
|
|
67
|
-
return
|
|
68
|
-
fi
|
|
69
|
-
|
|
70
|
-
if [[ -n "${XDG_CACHE_HOME:-}" ]]; then
|
|
71
|
-
printf '%s' "${XDG_CACHE_HOME}/fairmint/canton-localnet"
|
|
72
|
-
return
|
|
73
|
-
fi
|
|
74
|
-
|
|
75
|
-
printf '%s' "${HOME}/.cache/fairmint/canton-localnet"
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
quickstart_ref() {
|
|
79
|
-
printf '%s' "${CANTON_LOCALNET_QUICKSTART_REF:-${DEFAULT_QUICKSTART_REF}}"
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
quickstart_repo() {
|
|
83
|
-
printf '%s' "${CANTON_LOCALNET_QUICKSTART_REPO:-${DEFAULT_QUICKSTART_REPO}}"
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
default_splice_version() {
|
|
87
|
-
if [[ -f "${PACKAGE_ROOT}/libs/splice/VERSION" ]]; then
|
|
88
|
-
local version=""
|
|
89
|
-
version="$(tr -d '[:space:]' < "${PACKAGE_ROOT}/libs/splice/VERSION")"
|
|
90
|
-
if [[ -n "${version}" ]]; then
|
|
91
|
-
printf '%s' "${version}"
|
|
92
|
-
return
|
|
93
|
-
fi
|
|
94
|
-
fi
|
|
95
|
-
|
|
96
|
-
printf '%s' "${DEFAULT_SPLICE_VERSION}"
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
default_quickstart_root() {
|
|
100
|
-
printf '%s/cn-quickstart-%s' "$(cache_root)" "$(quickstart_ref)"
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
repo_quickstart_dir() {
|
|
104
|
-
printf '%s/libs/cn-quickstart/quickstart' "${PACKAGE_ROOT}"
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
use_repo_quickstart_default() {
|
|
108
|
-
[[ -z "${CANTON_LOCALNET_QUICKSTART_DIR:-}" \
|
|
109
|
-
&& -f "${PACKAGE_ROOT}/.gitmodules" \
|
|
110
|
-
&& ( -d "${PACKAGE_ROOT}/.git" || -f "${PACKAGE_ROOT}/.git" ) ]]
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
quickstart_dir() {
|
|
114
|
-
if [[ -n "${CANTON_LOCALNET_QUICKSTART_DIR:-}" ]]; then
|
|
115
|
-
printf '%s' "${CANTON_LOCALNET_QUICKSTART_DIR}"
|
|
116
|
-
return
|
|
117
|
-
fi
|
|
118
|
-
|
|
119
|
-
if use_repo_quickstart_default; then
|
|
120
|
-
repo_quickstart_dir
|
|
121
|
-
return
|
|
122
|
-
fi
|
|
123
|
-
|
|
124
|
-
printf '%s/quickstart' "$(default_quickstart_root)"
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
ensure_quickstart_checkout() {
|
|
128
|
-
local dir=""
|
|
129
|
-
local root=""
|
|
130
|
-
local tmp=""
|
|
131
|
-
|
|
132
|
-
if use_repo_quickstart_default; then
|
|
133
|
-
return
|
|
134
|
-
fi
|
|
135
|
-
|
|
136
|
-
dir="$(quickstart_dir)"
|
|
137
|
-
if [[ -d "${dir}/docker/modules/localnet" ]]; then
|
|
138
|
-
return
|
|
139
|
-
fi
|
|
140
|
-
|
|
141
|
-
if [[ -n "${CANTON_LOCALNET_QUICKSTART_DIR:-}" ]]; then
|
|
142
|
-
log "CANTON_LOCALNET_QUICKSTART_DIR is not a cn-quickstart quickstart directory: ${dir}"
|
|
143
|
-
exit 1
|
|
144
|
-
fi
|
|
145
|
-
|
|
146
|
-
require_command git
|
|
147
|
-
|
|
148
|
-
root="$(default_quickstart_root)"
|
|
149
|
-
if [[ -e "${root}" ]]; then
|
|
150
|
-
log "Cached cn-quickstart directory exists but is incomplete: ${root}"
|
|
151
|
-
log "Remove it or set CANTON_LOCALNET_CACHE_DIR to use a fresh cache."
|
|
152
|
-
exit 1
|
|
153
|
-
fi
|
|
154
|
-
|
|
155
|
-
mkdir -p "$(cache_root)"
|
|
156
|
-
tmp="$(mktemp -d "$(cache_root)/cn-quickstart.XXXXXX")"
|
|
157
|
-
trap 'rm -rf "${tmp}"' RETURN
|
|
158
|
-
|
|
159
|
-
log "Fetching cn-quickstart $(quickstart_ref)..."
|
|
160
|
-
git -C "${tmp}" init -q
|
|
161
|
-
git -C "${tmp}" remote add origin "$(quickstart_repo)"
|
|
162
|
-
if git -C "${tmp}" fetch --depth 1 origin "$(quickstart_ref)"; then
|
|
163
|
-
git -C "${tmp}" checkout --detach FETCH_HEAD -q
|
|
164
|
-
else
|
|
165
|
-
log "Direct ref fetch failed; retrying with a blobless repository fetch."
|
|
166
|
-
git -C "${tmp}" fetch --filter=blob:none origin
|
|
167
|
-
git -C "${tmp}" checkout --detach "$(quickstart_ref)" -q
|
|
168
|
-
fi
|
|
169
|
-
|
|
170
|
-
if [[ ! -d "${tmp}/quickstart/docker/modules/localnet" ]]; then
|
|
171
|
-
log "Fetched cn-quickstart does not contain quickstart/docker/modules/localnet."
|
|
172
|
-
exit 1
|
|
173
|
-
fi
|
|
174
|
-
|
|
175
|
-
mv "${tmp}" "${root}"
|
|
176
|
-
trap - RETURN
|
|
177
|
-
log "Cached cn-quickstart at ${root}."
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
main() {
|
|
181
|
-
local command="${1:-}"
|
|
182
|
-
local dir=""
|
|
183
|
-
|
|
184
|
-
case "${command}" in
|
|
185
|
-
"" | -h | --help | help)
|
|
186
|
-
usage
|
|
187
|
-
if [[ -z "${command}" ]]; then
|
|
188
|
-
exit 1
|
|
189
|
-
fi
|
|
190
|
-
exit 0
|
|
191
|
-
;;
|
|
192
|
-
setup | start | verify)
|
|
193
|
-
ensure_quickstart_checkout
|
|
194
|
-
;;
|
|
195
|
-
logs | status | stop | smoke | test)
|
|
196
|
-
;;
|
|
197
|
-
*)
|
|
198
|
-
usage
|
|
199
|
-
exit 1
|
|
200
|
-
;;
|
|
201
|
-
esac
|
|
202
|
-
|
|
203
|
-
dir="$(quickstart_dir)"
|
|
204
|
-
if ! use_repo_quickstart_default; then
|
|
205
|
-
export CANTON_LOCALNET_QUICKSTART_DIR="${dir}"
|
|
206
|
-
fi
|
|
207
|
-
export CANTON_LOCALNET_SPLICE_VERSION="${CANTON_LOCALNET_SPLICE_VERSION:-$(default_splice_version)}"
|
|
208
|
-
export CANTON_LOCALNET_INFRA_ONLY="${CANTON_LOCALNET_INFRA_ONLY:-true}"
|
|
209
|
-
|
|
210
|
-
exec bash "${LOCALNET_SCRIPT}" "$@"
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
main "$@"
|