@fairmint/canton-node-sdk 0.0.269 → 0.0.271

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 CHANGED
@@ -57,7 +57,7 @@ npm run build
57
57
  ### LocalNet (owned by `@fairmint/canton-dev-tools`)
58
58
 
59
59
  LocalNet lifecycle and shared test helpers live in
60
- [`@fairmint/canton-dev-tools@0.1.11`](https://www.npmjs.com/package/@fairmint/canton-dev-tools) (see
60
+ [`@fairmint/canton-dev-tools@0.1.13`](https://www.npmjs.com/package/@fairmint/canton-dev-tools) (see
61
61
  its [COMPATIBILITY.md](https://github.com/Fairmint/canton-dev-tools/blob/main/COMPATIBILITY.md)).
62
62
  This SDK does not publish a LocalNet CLI or `scripts/localnet-cloud.sh`.
63
63
 
@@ -4,5 +4,6 @@ export * from './commands';
4
4
  export * from './ledger';
5
5
  export * from './packages';
6
6
  export * from './readers';
7
+ export * from './setup';
7
8
  export * from './templates';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/da-registry/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/da-registry/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
@@ -20,5 +20,6 @@ __exportStar(require("./commands"), exports);
20
20
  __exportStar(require("./ledger"), exports);
21
21
  __exportStar(require("./packages"), exports);
22
22
  __exportStar(require("./readers"), exports);
23
+ __exportStar(require("./setup"), exports);
23
24
  __exportStar(require("./templates"), exports);
24
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/da-registry/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,mDAAiC;AACjC,6CAA2B;AAC3B,2CAAyB;AACzB,6CAA2B;AAC3B,4CAA0B;AAC1B,8CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/da-registry/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,mDAAiC;AACjC,6CAA2B;AAC3B,2CAAyB;AACzB,6CAA2B;AAC3B,4CAA0B;AAC1B,0CAAwB;AACxB,8CAA4B"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Exact decimal arithmetic for registry amounts (Daml `Decimal`, 10 fractional digits), on scaled `bigint`s so sums and
3
+ * deficits never lose precision.
4
+ */
5
+ /** An amount scaled by 10^10. */
6
+ export type ScaledDecimal = bigint;
7
+ /** Parses a decimal string (as the ledger and configs encode amounts); throws on anything else or on lost precision. */
8
+ export declare function parseDecimal(value: string): ScaledDecimal;
9
+ /** Plain notation with no trailing zeros: `10.50` → `10.5`, `1000.0000000000` → `1000`. */
10
+ export declare function formatDecimal(value: ScaledDecimal): string;
11
+ export declare function sumDecimals(values: readonly ScaledDecimal[]): ScaledDecimal;
12
+ //# sourceMappingURL=decimal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../../src/da-registry/setup/decimal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,iCAAiC;AACjC,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AAEnC,wHAAwH;AACxH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAQzD;AAED,2FAA2F;AAC3F,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAM1D;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,GAAG,aAAa,CAE3E"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ /**
3
+ * Exact decimal arithmetic for registry amounts (Daml `Decimal`, 10 fractional digits), on scaled `bigint`s so sums and
4
+ * deficits never lose precision.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.parseDecimal = parseDecimal;
8
+ exports.formatDecimal = formatDecimal;
9
+ exports.sumDecimals = sumDecimals;
10
+ const SCALE = 10;
11
+ const FACTOR = 10n ** BigInt(SCALE);
12
+ const DECIMAL_PATTERN = /^([+-]?)(\d+)(?:\.(\d+))?$/;
13
+ /** Drops trailing `0`s with a scan, not a regex, so input with long runs of zeros stays linear. */
14
+ function trimTrailingZeros(digits) {
15
+ let end = digits.length;
16
+ while (end > 0 && digits[end - 1] === '0')
17
+ end--;
18
+ return digits.slice(0, end);
19
+ }
20
+ /** Parses a decimal string (as the ledger and configs encode amounts); throws on anything else or on lost precision. */
21
+ function parseDecimal(value) {
22
+ const match = DECIMAL_PATTERN.exec(value.trim());
23
+ if (!match)
24
+ throw new Error(`not a decimal: ${JSON.stringify(value)}`);
25
+ const [, sign = '', whole = '0', fraction = ''] = match;
26
+ const significant = trimTrailingZeros(fraction);
27
+ if (significant.length > SCALE)
28
+ throw new Error(`more than ${SCALE} decimal places: ${value}`);
29
+ const scaled = BigInt(whole) * FACTOR + BigInt(significant.padEnd(SCALE, '0'));
30
+ return sign === '-' ? -scaled : scaled;
31
+ }
32
+ /** Plain notation with no trailing zeros: `10.50` → `10.5`, `1000.0000000000` → `1000`. */
33
+ function formatDecimal(value) {
34
+ const negative = value < 0n;
35
+ const magnitude = negative ? -value : value;
36
+ const whole = (magnitude / FACTOR).toString();
37
+ const fraction = trimTrailingZeros((magnitude % FACTOR).toString().padStart(SCALE, '0'));
38
+ return `${negative ? '-' : ''}${whole}${fraction ? `.${fraction}` : ''}`;
39
+ }
40
+ function sumDecimals(values) {
41
+ return values.reduce((total, v) => total + v, 0n);
42
+ }
43
+ //# sourceMappingURL=decimal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decimal.js","sourceRoot":"","sources":["../../../../src/da-registry/setup/decimal.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AAEH,MAAM,KAAK,GAAG,EAAE,CAAC;AACjB,MAAM,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;AACpC,MAAM,eAAe,GAAG,4BAA4B,CAAC;AAErD,mGAAmG;AACnG,SAAS,iBAAiB,CAAC,MAAc;IACvC,IAAI,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,OAAO,GAAG,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,GAAG;QAAE,GAAG,EAAE,CAAC;IACjD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC;AAKD,wHAAwH;AACxH,sBAA6B,KAAa;IACxC,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACjD,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACvE,MAAM,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,KAAK,GAAG,GAAG,EAAE,QAAQ,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC;IACxD,MAAM,WAAW,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAChD,IAAI,WAAW,CAAC,MAAM,GAAG,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,aAAa,KAAK,oBAAoB,KAAK,EAAE,CAAC,CAAC;IAC/F,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IAC/E,OAAO,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;AACzC,CAAC;AAED,2FAA2F;AAC3F,uBAA8B,KAAoB;IAChD,MAAM,QAAQ,GAAG,KAAK,GAAG,EAAE,CAAC;IAC5B,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5C,MAAM,KAAK,GAAG,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC9C,MAAM,QAAQ,GAAG,iBAAiB,CAAC,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IACzF,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAC3E,CAAC;AAED,qBAA4B,MAAgC;IAC1D,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './runner';
2
+ export * from './steps';
3
+ export * from './types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/da-registry/setup/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./runner"), exports);
18
+ __exportStar(require("./steps"), exports);
19
+ __exportStar(require("./types"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/da-registry/setup/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,0CAAwB;AACxB,0CAAwB"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Runs the DA Registry setup steps in order.
3
+ *
4
+ * - `plan` assesses every step and prints its status, evidence and the exact commands `apply` would submit. It never
5
+ * writes.
6
+ * - `apply` assesses each step; while it is pending, submits its actions and re-assesses, and while it is waiting on
7
+ * another party, polls for as long as the step allows. It stops at the first step that is not done afterwards.
8
+ *
9
+ * A step that builds on an earlier one reports `blocked` (a dependency) until that one is done; steps that stand alone,
10
+ * such as the allowlist, can be pending while earlier ones are. A step that throws, or whose submission the ledger
11
+ * rejects, is reported as `blocked` with the error, so every run ends with a summary.
12
+ */
13
+ import { type LedgerSubmission } from '../../utils/ledger';
14
+ import { type DaRegistrySetupStep, type DaRegistrySetupStepStatus } from './types';
15
+ /** `plan` reads and prints every step; `apply` also submits the pending ones. */
16
+ export type DaRegistrySetupRunMode = 'plan' | 'apply';
17
+ /** What one step ended as, and what `apply` submitted for it. */
18
+ export interface DaRegistrySetupStepResult {
19
+ id: string;
20
+ title: string;
21
+ status: DaRegistrySetupStepStatus;
22
+ summary: string;
23
+ dependency: boolean;
24
+ evidence: Record<string, string>;
25
+ notes: string[];
26
+ /** Descriptions of the actions `apply` submitted, with their update ids. */
27
+ applied: string[];
28
+ }
29
+ /** One run: each step's result, the overall outcome, and whether a person must act. */
30
+ export interface DaRegistrySetupRunResult {
31
+ mode: DaRegistrySetupRunMode;
32
+ steps: DaRegistrySetupStepResult[];
33
+ /** `done` when every step is done; otherwise the status of the first step that is not. */
34
+ outcome: DaRegistrySetupStepStatus;
35
+ /** Some step is blocked on something a person must fix, not merely on an earlier step. */
36
+ needsAttention: boolean;
37
+ }
38
+ /** Side effects the runner needs, injected so a run is testable with a fake clock and ledger. */
39
+ export interface DaRegistrySetupRunnerDeps {
40
+ submit: (submission: LedgerSubmission) => Promise<{
41
+ updateId: string;
42
+ }>;
43
+ log: (line: string) => void;
44
+ sleep: (ms: number) => Promise<void>;
45
+ now: () => number;
46
+ }
47
+ /** Guards against a step whose actions never change what it reads; the step is left pending for the next run. */
48
+ export declare const DA_REGISTRY_SETUP_MAX_ROUNDS_PER_STEP = 25;
49
+ /** JSON for the plan output, with disclosed-contract blobs shortened so the plan stays readable. */
50
+ export declare function formatDaRegistrySetupSubmission(submission: LedgerSubmission): string;
51
+ /** Runs `steps` in order in `mode`; see the module documentation for how `plan` and `apply` differ. */
52
+ export declare function runDaRegistrySetupSteps(steps: DaRegistrySetupStep[], mode: DaRegistrySetupRunMode, deps: DaRegistrySetupRunnerDeps): Promise<DaRegistrySetupRunResult>;
53
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../../src/da-registry/setup/runner.ts"],"names":[],"mappings":"AAAA;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BAAgB,GAAG,MAAM,CASpF;AAkFD,uGAAuG;AACvG,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,mBAAmB,EAAE,EAC5B,IAAI,EAAE,sBAAsB,EAC5B,IAAI,EAAE,yBAAyB,GAC9B,OAAO,CAAC,wBAAwB,CAAC,CA+FnC"}
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DA_REGISTRY_SETUP_MAX_ROUNDS_PER_STEP = void 0;
4
+ exports.formatDaRegistrySetupSubmission = formatDaRegistrySetupSubmission;
5
+ exports.runDaRegistrySetupSteps = runDaRegistrySetupSteps;
6
+ const types_1 = require("./types");
7
+ const STATUS_ICON = {
8
+ done: '✅ done',
9
+ pending: '⏳ pending',
10
+ waiting: '🕒 waiting',
11
+ blocked: '⛔ blocked',
12
+ };
13
+ const WAIT_POLL_MS = 10000;
14
+ /** Guards against a step whose actions never change what it reads; the step is left pending for the next run. */
15
+ exports.DA_REGISTRY_SETUP_MAX_ROUNDS_PER_STEP = 25;
16
+ const MAX_BLOB_CHARS = 48;
17
+ /** JSON for the plan output, with disclosed-contract blobs shortened so the plan stays readable. */
18
+ function formatDaRegistrySetupSubmission(submission) {
19
+ return JSON.stringify(submission, (key, value) => key === 'createdEventBlob' && typeof value === 'string' && value.length > MAX_BLOB_CHARS
20
+ ? `${value.slice(0, MAX_BLOB_CHARS)}…(${value.length} chars)`
21
+ : value, 2);
22
+ }
23
+ function indent(text, prefix) {
24
+ return text
25
+ .split('\n')
26
+ .map((line) => `${prefix}${line}`)
27
+ .join('\n');
28
+ }
29
+ /** What a command acts on: the contract and choice it exercises, or the template it creates. */
30
+ function commandTarget(command) {
31
+ if ('ExerciseCommand' in command) {
32
+ return ['exercise', command.ExerciseCommand.contractId, command.ExerciseCommand.choice];
33
+ }
34
+ if ('CreateAndExerciseCommand' in command) {
35
+ return [
36
+ 'create-and-exercise',
37
+ command.CreateAndExerciseCommand.templateId,
38
+ command.CreateAndExerciseCommand.choice,
39
+ ];
40
+ }
41
+ return ['create', command.CreateCommand.templateId];
42
+ }
43
+ /** A round's identity: each action's description and the contracts and templates its commands act on. */
44
+ function roundFingerprint(actions) {
45
+ return JSON.stringify(actions.map((a) => [a.description, a.submission.commands.map(commandTarget)]));
46
+ }
47
+ function errorMessage(error) {
48
+ return error instanceof Error ? error.message : String(error);
49
+ }
50
+ function printAssessment(log, assessment, showActions) {
51
+ log(` ${STATUS_ICON[assessment.status]} ${assessment.summary}`);
52
+ for (const [key, value] of Object.entries(assessment.evidence ?? {})) {
53
+ log(` · ${key}: ${value}`);
54
+ }
55
+ for (const note of assessment.notes ?? []) {
56
+ log(` ! ${note}`);
57
+ }
58
+ if (!showActions)
59
+ return;
60
+ for (const action of assessment.actions ?? []) {
61
+ log(` → ${action.description}`);
62
+ log(indent(formatDaRegistrySetupSubmission(action.submission), ' '));
63
+ }
64
+ }
65
+ async function safeAssess(step) {
66
+ try {
67
+ return await step.assess();
68
+ }
69
+ catch (error) {
70
+ if (error instanceof types_1.DaRegistrySetupDependencyError) {
71
+ return { status: 'blocked', summary: `needs ${error.stepId}`, dependency: true, notes: [error.message] };
72
+ }
73
+ return { status: 'blocked', summary: 'the step failed to read its state', notes: [errorMessage(error)] };
74
+ }
75
+ }
76
+ /** Submits a pending step's actions; returns an error message instead of throwing, so the run still summarises. */
77
+ async function applyActions(assessment, deps, applied) {
78
+ for (const action of assessment.actions ?? []) {
79
+ deps.log(` ▶ ${action.description}`);
80
+ try {
81
+ const { updateId } = await deps.submit(action.submission);
82
+ applied.push(`${action.description} (update ${updateId})`);
83
+ deps.log(` submitted, update ${updateId}`);
84
+ }
85
+ catch (error) {
86
+ return `${action.description} failed: ${errorMessage(error)}`;
87
+ }
88
+ }
89
+ return null;
90
+ }
91
+ /** Runs `steps` in order in `mode`; see the module documentation for how `plan` and `apply` differ. */
92
+ async function runDaRegistrySetupSteps(steps, mode, deps) {
93
+ const results = [];
94
+ let outcome = 'done';
95
+ for (const [index, step] of steps.entries()) {
96
+ deps.log('');
97
+ deps.log(`[${index + 1}/${steps.length}] ${step.id} — ${step.title}`);
98
+ deps.log(indent(step.why, ' '));
99
+ let assessment = await safeAssess(step);
100
+ const applied = [];
101
+ if (mode === 'apply') {
102
+ // Some steps take several rounds: a mint is an offer then an accept, and each delivery spends the change of
103
+ // the one before. Each round re-reads the ledger, so a round only ever acts on current state.
104
+ let rounds = 0;
105
+ let waitDeadline;
106
+ // A round that plans exactly what the round before it just submitted means the step does not read back its own
107
+ // write (for example a reader that does not match the ledger's encoding); repeating it would only churn. Rounds
108
+ // are compared by what they act on, not by their timestamps, which every round regenerates.
109
+ let lastRound;
110
+ for (;;) {
111
+ if (assessment.status === 'pending' && rounds < exports.DA_REGISTRY_SETUP_MAX_ROUNDS_PER_STEP) {
112
+ const descriptions = (assessment.actions ?? []).map((a) => a.description);
113
+ const round = roundFingerprint(assessment.actions ?? []);
114
+ if (round === lastRound) {
115
+ assessment = {
116
+ status: 'blocked',
117
+ summary: 'the step does not read back its own write',
118
+ ...(assessment.evidence ? { evidence: assessment.evidence } : {}),
119
+ notes: [`planned again after it was applied: ${descriptions.join('; ')}`],
120
+ };
121
+ break;
122
+ }
123
+ lastRound = round;
124
+ rounds++;
125
+ printAssessment(deps.log, assessment, true);
126
+ const failure = await applyActions(assessment, deps, applied);
127
+ if (failure) {
128
+ assessment = { status: 'blocked', summary: 'a submission failed', notes: [failure] };
129
+ break;
130
+ }
131
+ waitDeadline = undefined;
132
+ }
133
+ else if (assessment.status === 'waiting' && step.awaitMs && assessment.poll !== false) {
134
+ if (waitDeadline === undefined) {
135
+ waitDeadline = deps.now() + step.awaitMs;
136
+ deps.log(` 🕒 polling up to ${Math.ceil(step.awaitMs / 60000)} min: ${assessment.summary}`);
137
+ }
138
+ const left = waitDeadline - deps.now();
139
+ if (left <= 0)
140
+ break;
141
+ lastRound = undefined;
142
+ // The last poll waits only until the deadline, so polling never outlasts awaitMs.
143
+ await deps.sleep(Math.min(WAIT_POLL_MS, left));
144
+ }
145
+ else {
146
+ break;
147
+ }
148
+ assessment = await safeAssess(step);
149
+ }
150
+ if (assessment.status === 'pending' && rounds === exports.DA_REGISTRY_SETUP_MAX_ROUNDS_PER_STEP) {
151
+ assessment = {
152
+ ...assessment,
153
+ notes: [
154
+ ...(assessment.notes ?? []),
155
+ `still pending after ${exports.DA_REGISTRY_SETUP_MAX_ROUNDS_PER_STEP} rounds; run again`,
156
+ ],
157
+ };
158
+ }
159
+ }
160
+ // Plan prints the commands for every pending step; apply prints them for whatever is left undone.
161
+ printAssessment(deps.log, assessment, mode === 'plan' || assessment.status !== 'done');
162
+ results.push({
163
+ id: step.id,
164
+ title: step.title,
165
+ status: assessment.status,
166
+ summary: assessment.summary,
167
+ dependency: assessment.status === 'blocked' && assessment.dependency === true,
168
+ evidence: assessment.evidence ?? {},
169
+ notes: assessment.notes ?? [],
170
+ applied,
171
+ });
172
+ if (assessment.status !== 'done' && outcome === 'done') {
173
+ outcome = assessment.status;
174
+ // apply stops here: later steps build on this one. plan keeps going to show the whole picture.
175
+ if (mode === 'apply')
176
+ break;
177
+ }
178
+ }
179
+ return {
180
+ mode,
181
+ steps: results,
182
+ outcome,
183
+ needsAttention: results.some((r) => r.status === 'blocked' && !r.dependency),
184
+ };
185
+ }
186
+ //# sourceMappingURL=runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../../src/da-registry/setup/runner.ts"],"names":[],"mappings":";;;;;AAaA,mCAMiB;AAoCjB,MAAM,WAAW,GAA8C;IAC7D,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,WAAW;IACpB,OAAO,EAAE,YAAY;IACrB,OAAO,EAAE,WAAW;CACrB,CAAC;AAEF,MAAM,YAAY,GAAG,KAAM,CAAC;AAC5B,iHAAiH;AACpG,QAAA,qCAAqC,GAAG,EAAE,CAAC;AACxD,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,oGAAoG;AACpG,yCAAg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import { type InstrumentConfigurationPayload } from '../commands';
2
+ import { type DaRegistrySetupConfig, type DaRegistrySetupContext, type DaRegistrySetupStep } from './types';
3
+ /** Mint offers the setup creates carry this prefix in `reference`; it never touches anyone else's. */
4
+ export declare const DA_REGISTRY_SETUP_MINT_REFERENCE_PREFIX = "da-registry-setup";
5
+ /** The instrument configuration the declared state requires: the registrar's two claims, and the blocklist setting. */
6
+ export declare function desiredDaRegistryInstrumentConfiguration(config: DaRegistrySetupConfig): InstrumentConfigurationPayload;
7
+ /**
8
+ * The ordered steps that converge a ledger to `ctx.config`: ledger access, DA packages, provider service and
9
+ * configuration, registrar service, instrument configuration, credentials (the allowlist), transfer preapprovals, test
10
+ * supply, DA's API, and test deliveries. Run them with {@link runDaRegistrySetupSteps}.
11
+ */
12
+ export declare function buildDaRegistrySetupSteps(ctx: DaRegistrySetupContext): DaRegistrySetupStep[];
13
+ //# sourceMappingURL=steps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"steps.d.ts","sourceRoot":"","sources":["../../../../src/da-registry/setup/steps.ts"],"names":[],"mappings":"AAUA,OAAO,EAoBL,KAAK,8BAA8B,EACpC,MAAM,aAAa,CAAC;AAarB,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EAEzB,MAAM,SAAS,CAAC;AAwBjB,sGAAsG;AACtG,eAAO,MAAM,uCAAuC,sBAAsB,CAAC;AAgY3E,uHAAuH;AACvH,wBAAgB,wCAAwC,CACtD,MAAM,EAAE,qBAAqB,GAC5B,8BAA8B,CAWhC;AAm1BD;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,sBAAsB,GAAG,mBAAmB,EAAE,CAc5F"}