@hazbase/simplicity 0.0.5 → 0.2.0
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 +140 -1038
- package/dist/cli.js +3341 -269
- package/dist/client/SimplicityClient.d.ts +91 -290
- package/dist/client/SimplicityClient.js +93 -23
- package/dist/core/executor.js +67 -92
- package/dist/core/lineage.d.ts +18 -0
- package/dist/core/lineage.js +30 -0
- package/dist/core/outputBinding.d.ts +61 -0
- package/dist/core/outputBinding.js +552 -0
- package/dist/core/reporting.d.ts +22 -0
- package/dist/core/reporting.js +40 -0
- package/dist/core/schnorr.d.ts +5 -0
- package/dist/core/schnorr.js +46 -0
- package/dist/core/types.d.ts +799 -1
- package/dist/docs/definitions/bond-anchor.simf +19 -0
- package/dist/docs/definitions/bond-definition.json +10 -0
- package/dist/docs/definitions/bond-descriptor-bound-settlement-machine.simf +144 -0
- package/dist/docs/definitions/bond-issuance-anchor.simf +26 -0
- package/dist/docs/definitions/bond-issuance-state-partial-redemption.json +18 -0
- package/dist/docs/definitions/bond-issuance-state-redeemed.json +18 -0
- package/dist/docs/definitions/bond-issuance-state.json +12 -0
- package/dist/docs/definitions/bond-redemption-state-machine.simf +118 -0
- package/dist/docs/definitions/bond-redemption-transition.simf +41 -0
- package/dist/docs/definitions/bond-script-bound-settlement-machine.simf +142 -0
- package/dist/docs/definitions/fund-capital-call-open.simf +82 -0
- package/dist/docs/definitions/fund-capital-call-refund-only.simf +67 -0
- package/dist/docs/definitions/fund-capital-call-state.json +11 -0
- package/dist/docs/definitions/fund-definition.json +8 -0
- package/dist/docs/definitions/fund-distribution-claim.simf +57 -0
- package/dist/docs/definitions/receivable-definition.json +9 -0
- package/dist/docs/definitions/receivable-funding-claim.json +13 -0
- package/dist/docs/definitions/receivable-funding-claim.simf +58 -0
- package/dist/docs/definitions/receivable-repayment-claim.json +13 -0
- package/dist/docs/definitions/receivable-repayment-claim.simf +59 -0
- package/dist/docs/definitions/receivable-state-funded.json +20 -0
- package/dist/docs/definitions/receivable-state-originated.json +19 -0
- package/dist/docs/definitions/receivable-state-repaid.json +20 -0
- package/dist/docs/definitions/recursive-delay-direct-next.simf +60 -0
- package/dist/docs/definitions/recursive-delay-optional.simf +88 -0
- package/dist/docs/definitions/recursive-delay-required.simf +72 -0
- package/dist/docs/definitions/recursive-delay.simf +83 -0
- package/dist/docs/definitions/recursive-policy-transfer-machine.simf +65 -0
- package/dist/domain/bond.d.ts +8649 -720
- package/dist/domain/bond.js +1398 -8
- package/dist/domain/bondSettlementValidation.d.ts +2 -0
- package/dist/domain/bondSettlementValidation.js +28 -0
- package/dist/domain/bondValidation.d.ts +37 -1
- package/dist/domain/bondValidation.js +137 -11
- package/dist/domain/fund.d.ts +2452 -0
- package/dist/domain/fund.js +1756 -0
- package/dist/domain/fundValidation.d.ts +152 -0
- package/dist/domain/fundValidation.js +767 -0
- package/dist/domain/policies.d.ts +1064 -0
- package/dist/domain/policies.js +1625 -0
- package/dist/domain/receivable.d.ts +824 -0
- package/dist/domain/receivable.js +1375 -0
- package/dist/domain/receivableValidation.d.ts +147 -0
- package/dist/domain/receivableValidation.js +831 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.js +137 -21
- package/package.json +20 -2
package/dist/cli.js
CHANGED
|
@@ -35,6 +35,13 @@ function getMultiArgs(name) {
|
|
|
35
35
|
function hasFlag(name) {
|
|
36
36
|
return process.argv.includes(`--${name}`);
|
|
37
37
|
}
|
|
38
|
+
function parseJsonArg(name) {
|
|
39
|
+
const value = getArg(name);
|
|
40
|
+
return value ? JSON.parse(value) : undefined;
|
|
41
|
+
}
|
|
42
|
+
function parseJsonArgs(name) {
|
|
43
|
+
return getMultiArgs(name).map((value) => JSON.parse(value));
|
|
44
|
+
}
|
|
38
45
|
function requireArg(name) {
|
|
39
46
|
const value = getArg(name);
|
|
40
47
|
if (!value)
|
|
@@ -44,10 +51,85 @@ function requireArg(name) {
|
|
|
44
51
|
function parseAssignments(values) {
|
|
45
52
|
return Object.fromEntries(values.map((entry) => {
|
|
46
53
|
const [key, raw] = entry.split("=", 2);
|
|
54
|
+
if (raw === "true")
|
|
55
|
+
return [key, true];
|
|
56
|
+
if (raw === "false")
|
|
57
|
+
return [key, false];
|
|
47
58
|
const asNumber = Number(raw);
|
|
48
59
|
return [key, Number.isFinite(asNumber) && String(asNumber) === raw ? asNumber : raw];
|
|
49
60
|
}));
|
|
50
61
|
}
|
|
62
|
+
function parsePolicyReceiver(prefix) {
|
|
63
|
+
const mode = getArg(`${prefix}-mode`) ?? (getArg(`${prefix}-address`) ? "plain" : "policy");
|
|
64
|
+
if (mode === "plain") {
|
|
65
|
+
return { mode: "plain", address: requireArg(`${prefix}-address`) };
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
mode: "policy",
|
|
69
|
+
recipientXonly: requireArg(`${prefix}-recipient-xonly`),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function parsePolicyOutputForm() {
|
|
73
|
+
const assetForm = getArg("asset-form");
|
|
74
|
+
const amountForm = getArg("amount-form");
|
|
75
|
+
const nonceForm = getArg("nonce-form");
|
|
76
|
+
const rangeProofForm = getArg("range-proof-form");
|
|
77
|
+
if (!assetForm && !amountForm && !nonceForm && !rangeProofForm) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
...(assetForm ? { assetForm } : {}),
|
|
82
|
+
...(amountForm ? { amountForm } : {}),
|
|
83
|
+
...(nonceForm ? { nonceForm } : {}),
|
|
84
|
+
...(rangeProofForm ? { rangeProofForm } : {}),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function parseRawOutputFields() {
|
|
88
|
+
const assetBytesHex = getArg("asset-bytes-hex");
|
|
89
|
+
const amountBytesHex = getArg("amount-bytes-hex");
|
|
90
|
+
const nonceBytesHex = getArg("nonce-bytes-hex");
|
|
91
|
+
const scriptPubKeyHex = getArg("script-pubkey-hex");
|
|
92
|
+
const scriptPubKeyHashHex = getArg("script-pubkey-hash-hex");
|
|
93
|
+
const rangeProofHex = getArg("range-proof-hex-raw");
|
|
94
|
+
const rangeProofHashHex = getArg("range-proof-hash-hex");
|
|
95
|
+
if (!assetBytesHex
|
|
96
|
+
&& !amountBytesHex
|
|
97
|
+
&& !nonceBytesHex
|
|
98
|
+
&& !scriptPubKeyHex
|
|
99
|
+
&& !scriptPubKeyHashHex
|
|
100
|
+
&& !rangeProofHex
|
|
101
|
+
&& !rangeProofHashHex) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
...(assetBytesHex ? { assetBytesHex } : {}),
|
|
106
|
+
...(amountBytesHex ? { amountBytesHex } : {}),
|
|
107
|
+
...(nonceBytesHex ? { nonceBytesHex } : {}),
|
|
108
|
+
...(scriptPubKeyHex !== undefined ? { scriptPubKeyHex } : {}),
|
|
109
|
+
...(scriptPubKeyHashHex ? { scriptPubKeyHashHex } : {}),
|
|
110
|
+
...(rangeProofHex !== undefined ? { rangeProofHex } : {}),
|
|
111
|
+
...(rangeProofHashHex ? { rangeProofHashHex } : {}),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function parsePolicyTemplateInput() {
|
|
115
|
+
const templateId = getArg("template-id");
|
|
116
|
+
const templateManifest = getArg("template-manifest");
|
|
117
|
+
const templateManifestValue = getArg("template-manifest-value");
|
|
118
|
+
if (!templateId && !templateManifest && !templateManifestValue) {
|
|
119
|
+
throw new Error("Missing required arg: --template-id or --template-manifest or --template-manifest-value");
|
|
120
|
+
}
|
|
121
|
+
const templateJson = getArg("template-json");
|
|
122
|
+
const parsedManifestValue = templateManifestValue ? JSON.parse(templateManifestValue) : undefined;
|
|
123
|
+
return {
|
|
124
|
+
...(templateId ? { templateId } : {}),
|
|
125
|
+
...(templateManifest ? { manifestPath: templateManifest } : {}),
|
|
126
|
+
...(parsedManifestValue ? { manifestValue: parsedManifestValue } : {}),
|
|
127
|
+
...(templateJson ? { jsonPath: templateJson } : templateId ? { value: { policyTemplateId: templateId } } : {}),
|
|
128
|
+
...(getArg("state-simf") ? { stateSimfPath: getArg("state-simf") } : {}),
|
|
129
|
+
...(getArg("direct-state-simf") ? { directStateSimfPath: getArg("direct-state-simf") } : {}),
|
|
130
|
+
...(getArg("machine-simf") ? { transferMachineSimfPath: getArg("machine-simf") } : {}),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
51
133
|
function parseWitnessAssignments(values) {
|
|
52
134
|
return Object.fromEntries(values.map((entry) => {
|
|
53
135
|
const [left, value] = entry.split("=", 2);
|
|
@@ -130,6 +212,687 @@ function resolveConfig() {
|
|
|
130
212
|
function printJson(value) {
|
|
131
213
|
process.stdout.write(`${JSON.stringify(value, null, 2)}\n`);
|
|
132
214
|
}
|
|
215
|
+
function formatPolicyOutputBindingSummary(outputBinding) {
|
|
216
|
+
const lines = [
|
|
217
|
+
`mode=${outputBinding.mode}`,
|
|
218
|
+
`committed=${outputBinding.committed}`,
|
|
219
|
+
`runtimeBound=${outputBinding.runtimeBound}`,
|
|
220
|
+
`sdkVerified=${outputBinding.sdkVerified}`,
|
|
221
|
+
`amountRuntimeBound=${outputBinding.amountRuntimeBound}`,
|
|
222
|
+
`nextOutputHashRuntimeBound=${outputBinding.nextOutputHashRuntimeBound}`,
|
|
223
|
+
`nextOutputScriptRuntimeBound=${outputBinding.nextOutputScriptRuntimeBound}`,
|
|
224
|
+
];
|
|
225
|
+
if (outputBinding.supportedForm)
|
|
226
|
+
lines.push(`supportedForm=${outputBinding.supportedForm}`);
|
|
227
|
+
if (outputBinding.reasonCode)
|
|
228
|
+
lines.push(`reasonCode=${outputBinding.reasonCode}`);
|
|
229
|
+
if (outputBinding.nextOutputHash)
|
|
230
|
+
lines.push(`nextOutputHash=${outputBinding.nextOutputHash}`);
|
|
231
|
+
if (outputBinding.autoDerived !== undefined)
|
|
232
|
+
lines.push(`autoDerived=${outputBinding.autoDerived}`);
|
|
233
|
+
if (outputBinding.fallbackReason)
|
|
234
|
+
lines.push(`fallbackReason=${outputBinding.fallbackReason}`);
|
|
235
|
+
if (outputBinding.bindingInputs) {
|
|
236
|
+
lines.push(`bindingInputs(asset=${outputBinding.bindingInputs.assetId}, amountSat=${outputBinding.bindingInputs.nextAmountSat}, nextOutputIndex=${outputBinding.bindingInputs.nextOutputIndex}, feeIndex=${outputBinding.bindingInputs.feeIndex}, maxFeeSat=${outputBinding.bindingInputs.maxFeeSat})`, `bindingInputForms(assetForm=${outputBinding.bindingInputs.assetForm}, amountForm=${outputBinding.bindingInputs.amountForm}, nonceForm=${outputBinding.bindingInputs.nonceForm}, rangeProofForm=${outputBinding.bindingInputs.rangeProofForm})`);
|
|
237
|
+
if (outputBinding.bindingInputs.rawOutputComponents) {
|
|
238
|
+
lines.push(`rawOutputComponents(scriptPubKey=${outputBinding.bindingInputs.rawOutputComponents.scriptPubKey}, rangeProof=${outputBinding.bindingInputs.rawOutputComponents.rangeProof})`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return lines.join("\n");
|
|
242
|
+
}
|
|
243
|
+
function formatPolicyVerificationSummary(input) {
|
|
244
|
+
const lines = [
|
|
245
|
+
`ok=${input.ok ?? true}`,
|
|
246
|
+
`propagationMode=${input.propagationMode}`,
|
|
247
|
+
`enforcement=${input.enforcement}`,
|
|
248
|
+
`plainExitAllowed=${input.plainExitAllowed}`,
|
|
249
|
+
`nextPolicyRequired=${input.nextPolicyRequired}`,
|
|
250
|
+
`nextPolicyPresent=${input.nextPolicyPresent}`,
|
|
251
|
+
];
|
|
252
|
+
if (input.reason)
|
|
253
|
+
lines.push(`reason=${input.reason}`);
|
|
254
|
+
if (input.outputBinding) {
|
|
255
|
+
lines.push("outputBinding:");
|
|
256
|
+
lines.push(indent(formatPolicyOutputBindingSummary(input.outputBinding), 2));
|
|
257
|
+
}
|
|
258
|
+
return lines.join("\n");
|
|
259
|
+
}
|
|
260
|
+
function formatPolicyEvidenceSummary(input) {
|
|
261
|
+
const lines = [
|
|
262
|
+
`templateHash=${input.templateHash}`,
|
|
263
|
+
`stateHash=${input.stateHash}`,
|
|
264
|
+
`transferHash=${input.transferHash ?? "(none)"}`,
|
|
265
|
+
`enforcement=${input.enforcement}`,
|
|
266
|
+
`sourceVerificationMode=${input.sourceVerificationMode}`,
|
|
267
|
+
];
|
|
268
|
+
if (input.outputBinding) {
|
|
269
|
+
lines.push("outputBinding:");
|
|
270
|
+
lines.push(indent(formatPolicyOutputBindingSummary(input.outputBinding), 2));
|
|
271
|
+
}
|
|
272
|
+
return lines.join("\n");
|
|
273
|
+
}
|
|
274
|
+
function formatPolicyInspectOrExecuteSummary(input) {
|
|
275
|
+
const lines = [
|
|
276
|
+
`mode=${input.mode}`,
|
|
277
|
+
`propagationMode=${input.propagationMode}`,
|
|
278
|
+
`enforcement=${input.enforcement}`,
|
|
279
|
+
`plainExitAllowed=${input.plainExitAllowed}`,
|
|
280
|
+
`nextPolicyRequired=${input.nextPolicyRequired}`,
|
|
281
|
+
`nextPolicyPresent=${input.nextPolicyPresent}`,
|
|
282
|
+
];
|
|
283
|
+
if (input.summaryHash)
|
|
284
|
+
lines.push(`summaryHash=${input.summaryHash}`);
|
|
285
|
+
if (input.txId)
|
|
286
|
+
lines.push(`txId=${input.txId}`);
|
|
287
|
+
if (input.broadcasted !== undefined)
|
|
288
|
+
lines.push(`broadcasted=${input.broadcasted}`);
|
|
289
|
+
if (input.outputBinding) {
|
|
290
|
+
lines.push("outputBinding:");
|
|
291
|
+
lines.push(indent(formatPolicyOutputBindingSummary(input.outputBinding), 2));
|
|
292
|
+
}
|
|
293
|
+
return lines.join("\n");
|
|
294
|
+
}
|
|
295
|
+
function formatPolicyIssueSummary(input) {
|
|
296
|
+
return [
|
|
297
|
+
`propagationMode=${input.propagationMode}`,
|
|
298
|
+
`policyHash=${input.policyHash}`,
|
|
299
|
+
`contractAddress=${input.contractAddress}`,
|
|
300
|
+
`amountSat=${input.amountSat}`,
|
|
301
|
+
`assetId=${input.assetId}`,
|
|
302
|
+
`recipient=${input.recipient}`,
|
|
303
|
+
].join("\n");
|
|
304
|
+
}
|
|
305
|
+
function formatPolicyOutputDescriptorBuildSummary(input) {
|
|
306
|
+
const lines = [
|
|
307
|
+
`mode=${input.mode}`,
|
|
308
|
+
`nextContractAddress=${input.nextContractAddress}`,
|
|
309
|
+
`nextAmountSat=${input.nextAmountSat}`,
|
|
310
|
+
`assetId=${input.assetId}`,
|
|
311
|
+
];
|
|
312
|
+
if (input.supportedForm)
|
|
313
|
+
lines.push(`supportedForm=${input.supportedForm}`);
|
|
314
|
+
if (input.reasonCode)
|
|
315
|
+
lines.push(`reasonCode=${input.reasonCode}`);
|
|
316
|
+
if (input.nextOutputScriptHash)
|
|
317
|
+
lines.push(`nextOutputScriptHash=${input.nextOutputScriptHash}`);
|
|
318
|
+
if (input.nextOutputHash)
|
|
319
|
+
lines.push(`nextOutputHash=${input.nextOutputHash}`);
|
|
320
|
+
if (input.autoDerived !== undefined)
|
|
321
|
+
lines.push(`autoDerived=${input.autoDerived}`);
|
|
322
|
+
if (input.fallbackReason)
|
|
323
|
+
lines.push(`fallbackReason=${input.fallbackReason}`);
|
|
324
|
+
return lines.join("\n");
|
|
325
|
+
}
|
|
326
|
+
function formatPolicyBindingSupportSummary(input) {
|
|
327
|
+
const lines = ["supportedForms:"];
|
|
328
|
+
for (const form of input.supportedForms) {
|
|
329
|
+
lines.push(indent([
|
|
330
|
+
`form=${form.form}`,
|
|
331
|
+
`autoDerived=${form.autoDerived}`,
|
|
332
|
+
`description=${form.description}`,
|
|
333
|
+
].join("\n"), 2));
|
|
334
|
+
}
|
|
335
|
+
if (input.unsupportedOutputFeatures && input.unsupportedOutputFeatures.length > 0) {
|
|
336
|
+
lines.push("unsupportedOutputFeatures:");
|
|
337
|
+
for (const feature of input.unsupportedOutputFeatures) {
|
|
338
|
+
lines.push(indent([
|
|
339
|
+
`feature=${feature.feature}`,
|
|
340
|
+
`fallbackReasonCode=${feature.fallbackReasonCode}`,
|
|
341
|
+
`manualHashSupported=${feature.manualHashSupported}`,
|
|
342
|
+
`description=${feature.description}`,
|
|
343
|
+
].join("\n"), 2));
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
lines.push("outputBindingModes:");
|
|
347
|
+
for (const [mode, details] of Object.entries(input.outputBindingModes)) {
|
|
348
|
+
lines.push(indent([
|
|
349
|
+
`mode=${mode}`,
|
|
350
|
+
`runtimeBinding=${details.runtimeBinding}`,
|
|
351
|
+
`description=${details.description}`,
|
|
352
|
+
`fallbackBehavior=${details.fallbackBehavior}`,
|
|
353
|
+
].join("\n"), 2));
|
|
354
|
+
}
|
|
355
|
+
lines.push(`autoDeriveConditions=assetInput(${input.autoDeriveConditions.assetInput.join(", ")}), amountForm=${input.autoDeriveConditions.amountForm}, nonceForm=${input.autoDeriveConditions.nonceForm}, rangeProofForm=${input.autoDeriveConditions.rangeProofForm}`);
|
|
356
|
+
if (input.autoDeriveConditions.rawOutputFields?.length) {
|
|
357
|
+
lines.push(`rawOutputFields=${input.autoDeriveConditions.rawOutputFields.join(",")}`);
|
|
358
|
+
}
|
|
359
|
+
if (input.autoDeriveConditions.rawOutputFieldAlternatives) {
|
|
360
|
+
for (const [name, fields] of Object.entries(input.autoDeriveConditions.rawOutputFieldAlternatives)) {
|
|
361
|
+
lines.push(`rawOutputFieldAlternatives.${name}=${fields.join("|")}`);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (input.autoDeriveConditions.outputHashExclusions?.length) {
|
|
365
|
+
lines.push(`outputHashExclusions=${input.autoDeriveConditions.outputHashExclusions.join(",")}`);
|
|
366
|
+
}
|
|
367
|
+
lines.push(`manualHashPath.supported=${input.manualHashPath.supported}`);
|
|
368
|
+
lines.push(`manualHashPath.description=${input.manualHashPath.description}`);
|
|
369
|
+
lines.push(`fallback.defaultMode=${input.fallbackBehavior.defaultMode}`);
|
|
370
|
+
lines.push(`fallback.reasonCodes=${input.fallbackBehavior.reasonCodes.join(",")}`);
|
|
371
|
+
lines.push(`validation.local=${input.publicValidationMatrix.local.join(" | ")}`);
|
|
372
|
+
lines.push(`validation.testnet=${input.publicValidationMatrix.testnet.join(" | ")}`);
|
|
373
|
+
if (input.nonGoals.length > 0) {
|
|
374
|
+
lines.push("nonGoals:");
|
|
375
|
+
for (const goal of input.nonGoals) {
|
|
376
|
+
lines.push(indent(goal, 2));
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return lines.join("\n");
|
|
380
|
+
}
|
|
381
|
+
function formatOutputBindingSupportEvaluationSummary(input) {
|
|
382
|
+
const lines = [
|
|
383
|
+
`requestedBindingMode=${input.requestedBindingMode}`,
|
|
384
|
+
`resolvedBindingMode=${input.resolvedBindingMode}`,
|
|
385
|
+
`supportedForm=${input.supportedForm}`,
|
|
386
|
+
`reasonCode=${input.reasonCode}`,
|
|
387
|
+
`autoDerived=${input.autoDerived}`,
|
|
388
|
+
`assetId=${input.assetId}`,
|
|
389
|
+
`explicitAssetInputSupported=${input.explicitAssetInputSupported}`,
|
|
390
|
+
`manualHashSupplied=${input.manualHashSupplied}`,
|
|
391
|
+
`nextOutputScriptAvailable=${input.nextOutputScriptAvailable}`,
|
|
392
|
+
`rawOutputProvided=${input.rawOutputProvided === true}`,
|
|
393
|
+
`outputForm(assetForm=${input.outputForm.assetForm}, amountForm=${input.outputForm.amountForm}, nonceForm=${input.outputForm.nonceForm}, rangeProofForm=${input.outputForm.rangeProofForm})`,
|
|
394
|
+
];
|
|
395
|
+
if (input.fallbackReason)
|
|
396
|
+
lines.push(`fallbackReason=${input.fallbackReason}`);
|
|
397
|
+
if (input.rawOutputComponents) {
|
|
398
|
+
lines.push(`rawOutputComponents(scriptPubKey=${input.rawOutputComponents.scriptPubKey}, rangeProof=${input.rawOutputComponents.rangeProof})`);
|
|
399
|
+
}
|
|
400
|
+
if (input.unsupportedFeatures.length > 0) {
|
|
401
|
+
lines.push(`unsupportedFeatures=${input.unsupportedFeatures.join(",")}`);
|
|
402
|
+
}
|
|
403
|
+
return lines.join("\n");
|
|
404
|
+
}
|
|
405
|
+
function formatBondBindingMetadataSummary(input) {
|
|
406
|
+
const lines = [];
|
|
407
|
+
if (input.bindingMode)
|
|
408
|
+
lines.push(`bindingMode=${input.bindingMode}`);
|
|
409
|
+
if (input.supportedForm)
|
|
410
|
+
lines.push(`supportedForm=${input.supportedForm}`);
|
|
411
|
+
if (input.reasonCode)
|
|
412
|
+
lines.push(`reasonCode=${input.reasonCode}`);
|
|
413
|
+
if (input.nextOutputHash)
|
|
414
|
+
lines.push(`nextOutputHash=${input.nextOutputHash}`);
|
|
415
|
+
if (input.autoDerived !== undefined)
|
|
416
|
+
lines.push(`autoDerived=${input.autoDerived}`);
|
|
417
|
+
if (input.fallbackReason)
|
|
418
|
+
lines.push(`fallbackReason=${input.fallbackReason}`);
|
|
419
|
+
if (input.bindingInputs) {
|
|
420
|
+
lines.push(`bindingInputs(asset=${input.bindingInputs.assetId}, amountSat=${input.bindingInputs.nextAmountSat}, nextOutputIndex=${input.bindingInputs.nextOutputIndex}, feeIndex=${input.bindingInputs.feeIndex}, maxFeeSat=${input.bindingInputs.maxFeeSat})`, `bindingInputForms(assetForm=${input.bindingInputs.assetForm}, amountForm=${input.bindingInputs.amountForm}, nonceForm=${input.bindingInputs.nonceForm}, rangeProofForm=${input.bindingInputs.rangeProofForm})`);
|
|
421
|
+
if (input.bindingInputs.rawOutputComponents) {
|
|
422
|
+
lines.push(`rawOutputComponents(scriptPubKey=${input.bindingInputs.rawOutputComponents.scriptPubKey}, rangeProof=${input.bindingInputs.rawOutputComponents.rangeProof})`);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
return lines.join("\n");
|
|
426
|
+
}
|
|
427
|
+
function formatBondDefinitionOrVerificationSummary(input) {
|
|
428
|
+
return [
|
|
429
|
+
input.contractAddress ? `contractAddress=${input.contractAddress}` : undefined,
|
|
430
|
+
input.cmr ? `cmr=${input.cmr}` : undefined,
|
|
431
|
+
input.artifactPath ? `artifactPath=${input.artifactPath}` : undefined,
|
|
432
|
+
input.definitionHash ? `definitionHash=${input.definitionHash}` : undefined,
|
|
433
|
+
input.issuanceHash ? `issuanceHash=${input.issuanceHash}` : undefined,
|
|
434
|
+
input.definitionOk !== undefined ? `definitionOk=${input.definitionOk}` : undefined,
|
|
435
|
+
input.issuanceOk !== undefined ? `issuanceOk=${input.issuanceOk}` : undefined,
|
|
436
|
+
input.principalInvariantValid !== undefined
|
|
437
|
+
? `principalInvariantValid=${input.principalInvariantValid}`
|
|
438
|
+
: undefined,
|
|
439
|
+
input.definitionTrustMode ? `definitionTrustMode=${input.definitionTrustMode}` : undefined,
|
|
440
|
+
input.issuanceTrustMode ? `issuanceTrustMode=${input.issuanceTrustMode}` : undefined,
|
|
441
|
+
]
|
|
442
|
+
.filter(Boolean)
|
|
443
|
+
.join("\n");
|
|
444
|
+
}
|
|
445
|
+
function formatBondSettlementSummary(input) {
|
|
446
|
+
const lines = [
|
|
447
|
+
input.ok !== undefined ? `ok=${input.ok}` : undefined,
|
|
448
|
+
input.reason ? `reason=${input.reason}` : undefined,
|
|
449
|
+
`descriptorHash=${input.descriptorHash}`,
|
|
450
|
+
`bindingMode=${input.bindingMode}`,
|
|
451
|
+
input.previousStateHash ? `previousStateHash=${input.previousStateHash}` : undefined,
|
|
452
|
+
input.nextStateHash ? `nextStateHash=${input.nextStateHash}` : undefined,
|
|
453
|
+
input.nextContractAddress ? `nextContractAddress=${input.nextContractAddress}` : undefined,
|
|
454
|
+
input.nextAmountSat !== undefined ? `nextAmountSat=${input.nextAmountSat}` : undefined,
|
|
455
|
+
input.maxFeeSat !== undefined ? `maxFeeSat=${input.maxFeeSat}` : undefined,
|
|
456
|
+
].filter(Boolean);
|
|
457
|
+
const binding = formatBondBindingMetadataSummary({
|
|
458
|
+
bindingMode: input.bindingMode,
|
|
459
|
+
supportedForm: input.supportedForm,
|
|
460
|
+
reasonCode: input.reasonCode,
|
|
461
|
+
autoDerived: input.autoDerived,
|
|
462
|
+
fallbackReason: input.fallbackReason,
|
|
463
|
+
nextOutputHash: input.nextOutputHash,
|
|
464
|
+
bindingInputs: input.bindingInputs,
|
|
465
|
+
});
|
|
466
|
+
return binding ? `${lines.join("\n")}\n${binding}` : lines.join("\n");
|
|
467
|
+
}
|
|
468
|
+
function formatBondRedemptionSummary(input) {
|
|
469
|
+
const lines = [
|
|
470
|
+
`phase=${input.phase}`,
|
|
471
|
+
`mode=${input.mode}`,
|
|
472
|
+
input.nextStatus ? `nextStatus=${input.nextStatus}` : undefined,
|
|
473
|
+
`descriptorHash=${input.descriptorHash}`,
|
|
474
|
+
input.nextStateHash ? `nextStateHash=${input.nextStateHash}` : undefined,
|
|
475
|
+
input.nextContractAddress ? `nextContractAddress=${input.nextContractAddress}` : undefined,
|
|
476
|
+
input.nextAmountSat !== undefined ? `nextAmountSat=${input.nextAmountSat}` : undefined,
|
|
477
|
+
input.summaryHash ? `summaryHash=${input.summaryHash}` : undefined,
|
|
478
|
+
input.txId ? `txId=${input.txId}` : undefined,
|
|
479
|
+
input.broadcasted !== undefined ? `broadcasted=${input.broadcasted}` : undefined,
|
|
480
|
+
input.verified !== undefined ? `verified=${input.verified}` : undefined,
|
|
481
|
+
].filter(Boolean);
|
|
482
|
+
if (input.bindingMetadata) {
|
|
483
|
+
const bindingMetadata = formatBondBindingMetadataSummary(input.bindingMetadata);
|
|
484
|
+
if (bindingMetadata)
|
|
485
|
+
lines.push(bindingMetadata);
|
|
486
|
+
}
|
|
487
|
+
if (input.outputBindingTrust) {
|
|
488
|
+
lines.push([
|
|
489
|
+
`outputBinding.mode=${input.outputBindingTrust.mode}`,
|
|
490
|
+
`outputBinding.nextContractAddressCommitted=${input.outputBindingTrust.nextContractAddressCommitted}`,
|
|
491
|
+
input.outputBindingTrust.expectedOutputDescriptorCommitted !== undefined
|
|
492
|
+
? `outputBinding.expectedOutputDescriptorCommitted=${input.outputBindingTrust.expectedOutputDescriptorCommitted}`
|
|
493
|
+
: undefined,
|
|
494
|
+
input.outputBindingTrust.settlementDescriptorCommitted !== undefined
|
|
495
|
+
? `outputBinding.settlementDescriptorCommitted=${input.outputBindingTrust.settlementDescriptorCommitted}`
|
|
496
|
+
: undefined,
|
|
497
|
+
`outputBinding.outputCountRuntimeBound=${input.outputBindingTrust.outputCountRuntimeBound}`,
|
|
498
|
+
`outputBinding.feeIndexRuntimeBound=${input.outputBindingTrust.feeIndexRuntimeBound}`,
|
|
499
|
+
`outputBinding.amountRuntimeBound=${input.outputBindingTrust.amountRuntimeBound}`,
|
|
500
|
+
`outputBinding.nextOutputHashRuntimeBound=${input.outputBindingTrust.nextOutputHashRuntimeBound}`,
|
|
501
|
+
`outputBinding.nextOutputScriptRuntimeBound=${input.outputBindingTrust.nextOutputScriptRuntimeBound}`,
|
|
502
|
+
input.outputBindingTrust.supportedForm
|
|
503
|
+
? `outputBinding.supportedForm=${input.outputBindingTrust.supportedForm}`
|
|
504
|
+
: undefined,
|
|
505
|
+
input.outputBindingTrust.reasonCode
|
|
506
|
+
? `outputBinding.reasonCode=${input.outputBindingTrust.reasonCode}`
|
|
507
|
+
: undefined,
|
|
508
|
+
input.outputBindingTrust.nextOutputHash
|
|
509
|
+
? `outputBinding.nextOutputHash=${input.outputBindingTrust.nextOutputHash}`
|
|
510
|
+
: undefined,
|
|
511
|
+
input.outputBindingTrust.autoDerived !== undefined
|
|
512
|
+
? `outputBinding.autoDerived=${input.outputBindingTrust.autoDerived}`
|
|
513
|
+
: undefined,
|
|
514
|
+
input.outputBindingTrust.fallbackReason
|
|
515
|
+
? `outputBinding.fallbackReason=${input.outputBindingTrust.fallbackReason}`
|
|
516
|
+
: undefined,
|
|
517
|
+
]
|
|
518
|
+
.filter(Boolean)
|
|
519
|
+
.join("\n"));
|
|
520
|
+
if (input.outputBindingTrust.bindingInputs) {
|
|
521
|
+
lines.push(`outputBinding.bindingInputs(asset=${input.outputBindingTrust.bindingInputs.assetId}, amountSat=${input.outputBindingTrust.bindingInputs.nextAmountSat}, nextOutputIndex=${input.outputBindingTrust.bindingInputs.nextOutputIndex}, feeIndex=${input.outputBindingTrust.bindingInputs.feeIndex}, maxFeeSat=${input.outputBindingTrust.bindingInputs.maxFeeSat})`, `outputBinding.bindingInputForms(assetForm=${input.outputBindingTrust.bindingInputs.assetForm}, amountForm=${input.outputBindingTrust.bindingInputs.amountForm}, nonceForm=${input.outputBindingTrust.bindingInputs.nonceForm}, rangeProofForm=${input.outputBindingTrust.bindingInputs.rangeProofForm})`);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
return lines.join("\n");
|
|
525
|
+
}
|
|
526
|
+
function formatBondClosingSummary(input) {
|
|
527
|
+
const lines = [
|
|
528
|
+
`phase=${input.phase}`,
|
|
529
|
+
input.closingHash ? `closingHash=${input.closingHash}` : undefined,
|
|
530
|
+
input.closedAt ? `closedAt=${input.closedAt}` : undefined,
|
|
531
|
+
input.closingReason ? `closingReason=${input.closingReason}` : undefined,
|
|
532
|
+
input.finalSettlementDescriptorHash
|
|
533
|
+
? `finalSettlementDescriptorHash=${input.finalSettlementDescriptorHash}`
|
|
534
|
+
: undefined,
|
|
535
|
+
input.summaryHash ? `summaryHash=${input.summaryHash}` : undefined,
|
|
536
|
+
input.txId ? `txId=${input.txId}` : undefined,
|
|
537
|
+
input.broadcasted !== undefined ? `broadcasted=${input.broadcasted}` : undefined,
|
|
538
|
+
input.verified !== undefined ? `verified=${input.verified}` : undefined,
|
|
539
|
+
].filter(Boolean);
|
|
540
|
+
if (input.checks) {
|
|
541
|
+
lines.push(`checks=${Object.entries(input.checks)
|
|
542
|
+
.map(([key, value]) => `${key}:${value}`)
|
|
543
|
+
.join(",")}`);
|
|
544
|
+
}
|
|
545
|
+
return lines.join("\n");
|
|
546
|
+
}
|
|
547
|
+
function formatBondEvidenceSummary(input) {
|
|
548
|
+
return [
|
|
549
|
+
`definitionHash=${input.definitionHash}`,
|
|
550
|
+
`issuanceHash=${input.issuanceHash}`,
|
|
551
|
+
input.settlementHash ? `settlementHash=${input.settlementHash}` : undefined,
|
|
552
|
+
input.closingHash ? `closingHash=${input.closingHash}` : undefined,
|
|
553
|
+
input.renderedSourceHash ? `renderedSourceHash=${input.renderedSourceHash}` : undefined,
|
|
554
|
+
input.sourceVerificationMode ? `sourceVerificationMode=${input.sourceVerificationMode}` : undefined,
|
|
555
|
+
input.lineageKind ? `lineageKind=${input.lineageKind}` : undefined,
|
|
556
|
+
input.latestOrdinal !== undefined && input.latestOrdinal !== null ? `latestOrdinal=${input.latestOrdinal}` : undefined,
|
|
557
|
+
input.allHashLinksVerified !== undefined && input.allHashLinksVerified !== null
|
|
558
|
+
? `allHashLinksVerified=${input.allHashLinksVerified}`
|
|
559
|
+
: undefined,
|
|
560
|
+
input.identityConsistent !== undefined && input.identityConsistent !== null
|
|
561
|
+
? `identityConsistent=${input.identityConsistent}`
|
|
562
|
+
: undefined,
|
|
563
|
+
input.fullLineageVerified !== undefined && input.fullLineageVerified !== null
|
|
564
|
+
? `fullLineageVerified=${input.fullLineageVerified}`
|
|
565
|
+
: undefined,
|
|
566
|
+
input.fullHistoryVerified !== undefined && input.fullHistoryVerified !== null
|
|
567
|
+
? `fullHistoryVerified=${input.fullHistoryVerified}`
|
|
568
|
+
: undefined,
|
|
569
|
+
]
|
|
570
|
+
.filter(Boolean)
|
|
571
|
+
.join("\n");
|
|
572
|
+
}
|
|
573
|
+
function formatBondFinalityPayloadSummary(input) {
|
|
574
|
+
return [
|
|
575
|
+
`bondId=${input.bondId}`,
|
|
576
|
+
`issuanceId=${input.issuanceId}`,
|
|
577
|
+
`definitionHash=${input.definitionHash}`,
|
|
578
|
+
`issuanceStateHash=${input.issuanceStateHash}`,
|
|
579
|
+
input.settlementDescriptorHash ? `settlementDescriptorHash=${input.settlementDescriptorHash}` : undefined,
|
|
580
|
+
input.closingDescriptorHash ? `closingDescriptorHash=${input.closingDescriptorHash}` : undefined,
|
|
581
|
+
`contractAddress=${input.contractAddress}`,
|
|
582
|
+
`cmr=${input.cmr}`,
|
|
583
|
+
`bindingMode=${input.bindingMode}`,
|
|
584
|
+
input.lineageKind ? `lineageKind=${input.lineageKind}` : undefined,
|
|
585
|
+
input.latestOrdinal !== undefined && input.latestOrdinal !== null ? `latestOrdinal=${input.latestOrdinal}` : undefined,
|
|
586
|
+
input.allHashLinksVerified !== undefined && input.allHashLinksVerified !== null
|
|
587
|
+
? `allHashLinksVerified=${input.allHashLinksVerified}`
|
|
588
|
+
: undefined,
|
|
589
|
+
input.identityConsistent !== undefined && input.identityConsistent !== null
|
|
590
|
+
? `identityConsistent=${input.identityConsistent}`
|
|
591
|
+
: undefined,
|
|
592
|
+
input.fullLineageVerified !== undefined && input.fullLineageVerified !== null
|
|
593
|
+
? `fullLineageVerified=${input.fullLineageVerified}`
|
|
594
|
+
: undefined,
|
|
595
|
+
input.fullHistoryVerified !== undefined && input.fullHistoryVerified !== null
|
|
596
|
+
? `fullHistoryVerified=${input.fullHistoryVerified}`
|
|
597
|
+
: undefined,
|
|
598
|
+
]
|
|
599
|
+
.filter(Boolean)
|
|
600
|
+
.join("\n");
|
|
601
|
+
}
|
|
602
|
+
function formatBondIssuanceHistorySummary(input) {
|
|
603
|
+
return [
|
|
604
|
+
input.verified !== undefined ? `verified=${input.verified}` : undefined,
|
|
605
|
+
`issuanceId=${input.issuanceId}`,
|
|
606
|
+
`chainLength=${input.chainLength}`,
|
|
607
|
+
input.latestStatus ? `latestStatus=${input.latestStatus}` : undefined,
|
|
608
|
+
input.latestOrdinal !== undefined && input.latestOrdinal !== null ? `latestOrdinal=${input.latestOrdinal}` : undefined,
|
|
609
|
+
`startsAtGenesis=${input.startsAtGenesis}`,
|
|
610
|
+
input.allHashLinksVerified !== undefined ? `allHashLinksVerified=${input.allHashLinksVerified}` : undefined,
|
|
611
|
+
input.identityConsistent !== undefined ? `identityConsistent=${input.identityConsistent}` : undefined,
|
|
612
|
+
input.fullLineageVerified !== undefined ? `fullLineageVerified=${input.fullLineageVerified}` : undefined,
|
|
613
|
+
`fullHistoryVerified=${input.fullHistoryVerified}`,
|
|
614
|
+
]
|
|
615
|
+
.filter(Boolean)
|
|
616
|
+
.join("\n");
|
|
617
|
+
}
|
|
618
|
+
function formatFundOutputBindingSummary(outputBinding) {
|
|
619
|
+
const lines = [
|
|
620
|
+
`mode=${outputBinding.mode}`,
|
|
621
|
+
outputBinding.requestedMode ? `requestedMode=${outputBinding.requestedMode}` : undefined,
|
|
622
|
+
`nextReceiverRuntimeCommitted=${outputBinding.nextReceiverRuntimeCommitted}`,
|
|
623
|
+
`outputCountRuntimeBound=${outputBinding.outputCountRuntimeBound}`,
|
|
624
|
+
`feeIndexRuntimeBound=${outputBinding.feeIndexRuntimeBound}`,
|
|
625
|
+
`nextOutputHashRuntimeBound=${outputBinding.nextOutputHashRuntimeBound ?? false}`,
|
|
626
|
+
`nextOutputScriptRuntimeBound=${outputBinding.nextOutputScriptRuntimeBound}`,
|
|
627
|
+
`amountRuntimeBound=${outputBinding.amountRuntimeBound}`,
|
|
628
|
+
outputBinding.supportedForm ? `supportedForm=${outputBinding.supportedForm}` : undefined,
|
|
629
|
+
outputBinding.reasonCode ? `reasonCode=${outputBinding.reasonCode}` : undefined,
|
|
630
|
+
outputBinding.autoDerived !== undefined ? `autoDerived=${outputBinding.autoDerived}` : undefined,
|
|
631
|
+
outputBinding.fallbackReason ? `fallbackReason=${outputBinding.fallbackReason}` : undefined,
|
|
632
|
+
].filter(Boolean);
|
|
633
|
+
if (outputBinding.bindingInputs) {
|
|
634
|
+
lines.push(`bindingInputs(asset=${outputBinding.bindingInputs.assetId}, amountSat=${outputBinding.bindingInputs.nextAmountSat}, nextOutputIndex=${outputBinding.bindingInputs.nextOutputIndex}, feeIndex=${outputBinding.bindingInputs.feeIndex}, maxFeeSat=${outputBinding.bindingInputs.maxFeeSat})`, `bindingInputForms(assetForm=${outputBinding.bindingInputs.assetForm}, amountForm=${outputBinding.bindingInputs.amountForm}, nonceForm=${outputBinding.bindingInputs.nonceForm}, rangeProofForm=${outputBinding.bindingInputs.rangeProofForm})`);
|
|
635
|
+
if (outputBinding.bindingInputs.rawOutputComponents) {
|
|
636
|
+
lines.push(`rawOutputComponents(scriptPubKey=${outputBinding.bindingInputs.rawOutputComponents.scriptPubKey}, rangeProof=${outputBinding.bindingInputs.rawOutputComponents.rangeProof})`);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
return lines.join("\n");
|
|
640
|
+
}
|
|
641
|
+
function formatFundDefinitionSummary(input) {
|
|
642
|
+
return [
|
|
643
|
+
`ok=${input.ok ?? true}`,
|
|
644
|
+
`fundId=${input.fundId}`,
|
|
645
|
+
`managerEntityId=${input.managerEntityId}`,
|
|
646
|
+
`currencyAssetId=${input.currencyAssetId}`,
|
|
647
|
+
input.jurisdiction ? `jurisdiction=${input.jurisdiction}` : undefined,
|
|
648
|
+
input.vintage ? `vintage=${input.vintage}` : undefined,
|
|
649
|
+
]
|
|
650
|
+
.filter(Boolean)
|
|
651
|
+
.join("\n");
|
|
652
|
+
}
|
|
653
|
+
function formatFundCapitalCallSummary(input) {
|
|
654
|
+
const lines = [
|
|
655
|
+
`phase=${input.phase}`,
|
|
656
|
+
input.ok !== undefined ? `ok=${input.ok}` : undefined,
|
|
657
|
+
`callId=${input.callId}`,
|
|
658
|
+
`status=${input.status}`,
|
|
659
|
+
`amount=${input.amount}`,
|
|
660
|
+
`assetId=${input.assetId}`,
|
|
661
|
+
input.contractAddress ? `contractAddress=${input.contractAddress}` : undefined,
|
|
662
|
+
input.summaryHash ? `summaryHash=${input.summaryHash}` : undefined,
|
|
663
|
+
input.positionReceiptHash ? `positionReceiptHash=${input.positionReceiptHash}` : undefined,
|
|
664
|
+
input.txId ? `txId=${input.txId}` : undefined,
|
|
665
|
+
input.broadcasted !== undefined ? `broadcasted=${input.broadcasted}` : undefined,
|
|
666
|
+
input.reason ? `reason=${input.reason}` : undefined,
|
|
667
|
+
].filter(Boolean);
|
|
668
|
+
if (input.outputBinding) {
|
|
669
|
+
lines.push("outputBinding:");
|
|
670
|
+
lines.push(indent(formatFundOutputBindingSummary(input.outputBinding), 2));
|
|
671
|
+
}
|
|
672
|
+
return lines.join("\n");
|
|
673
|
+
}
|
|
674
|
+
function formatFundDistributionSummary(input) {
|
|
675
|
+
const lines = [
|
|
676
|
+
`phase=${input.phase}`,
|
|
677
|
+
input.ok !== undefined ? `ok=${input.ok}` : undefined,
|
|
678
|
+
`distributionId=${input.distributionId}`,
|
|
679
|
+
`positionId=${input.positionId}`,
|
|
680
|
+
`amountSat=${input.amountSat}`,
|
|
681
|
+
`assetId=${input.assetId}`,
|
|
682
|
+
input.contractAddress ? `contractAddress=${input.contractAddress}` : undefined,
|
|
683
|
+
input.summaryHash ? `summaryHash=${input.summaryHash}` : undefined,
|
|
684
|
+
input.txId ? `txId=${input.txId}` : undefined,
|
|
685
|
+
input.broadcasted !== undefined ? `broadcasted=${input.broadcasted}` : undefined,
|
|
686
|
+
input.reason ? `reason=${input.reason}` : undefined,
|
|
687
|
+
].filter(Boolean);
|
|
688
|
+
if (input.outputBinding) {
|
|
689
|
+
lines.push("outputBinding:");
|
|
690
|
+
lines.push(indent(formatFundOutputBindingSummary(input.outputBinding), 2));
|
|
691
|
+
}
|
|
692
|
+
return lines.join("\n");
|
|
693
|
+
}
|
|
694
|
+
function formatFundReceiptReconcileSummary(input) {
|
|
695
|
+
return [
|
|
696
|
+
`positionId=${input.positionId}`,
|
|
697
|
+
`distributionCount=${input.distributionCount}`,
|
|
698
|
+
`distributedAmount=${input.distributedAmount}`,
|
|
699
|
+
`fundedAmount=${input.fundedAmount}`,
|
|
700
|
+
`status=${input.status}`,
|
|
701
|
+
`receiptHash=${input.receiptHash}`,
|
|
702
|
+
input.sequence !== undefined ? `sequence=${input.sequence}` : undefined,
|
|
703
|
+
input.envelopeHash ? `envelopeHash=${input.envelopeHash}` : undefined,
|
|
704
|
+
].join("\n");
|
|
705
|
+
}
|
|
706
|
+
function formatFundClosingSummary(input) {
|
|
707
|
+
return [
|
|
708
|
+
`ok=${input.ok ?? true}`,
|
|
709
|
+
`closingHash=${input.closingHash}`,
|
|
710
|
+
`closedAt=${input.closedAt}`,
|
|
711
|
+
`closingReason=${input.closingReason}`,
|
|
712
|
+
`positionId=${input.positionId}`,
|
|
713
|
+
`distributionCount=${input.distributionCount}`,
|
|
714
|
+
input.continuityVerified !== undefined ? `continuityVerified=${input.continuityVerified}` : undefined,
|
|
715
|
+
input.lineageKind ? `lineageKind=${input.lineageKind}` : undefined,
|
|
716
|
+
input.latestOrdinal !== undefined && input.latestOrdinal !== null ? `latestOrdinal=${input.latestOrdinal}` : undefined,
|
|
717
|
+
input.allHashLinksVerified !== undefined && input.allHashLinksVerified !== null
|
|
718
|
+
? `allHashLinksVerified=${input.allHashLinksVerified}`
|
|
719
|
+
: undefined,
|
|
720
|
+
input.identityConsistent !== undefined && input.identityConsistent !== null
|
|
721
|
+
? `identityConsistent=${input.identityConsistent}`
|
|
722
|
+
: undefined,
|
|
723
|
+
input.fullLineageVerified !== undefined && input.fullLineageVerified !== null
|
|
724
|
+
? `fullLineageVerified=${input.fullLineageVerified}`
|
|
725
|
+
: undefined,
|
|
726
|
+
input.fullChainVerified !== undefined ? `fullChainVerified=${input.fullChainVerified}` : undefined,
|
|
727
|
+
input.reason ? `reason=${input.reason}` : undefined,
|
|
728
|
+
]
|
|
729
|
+
.filter(Boolean)
|
|
730
|
+
.join("\n");
|
|
731
|
+
}
|
|
732
|
+
function formatFundReceiptChainSummary(input) {
|
|
733
|
+
return [
|
|
734
|
+
input.verified !== undefined ? `verified=${input.verified}` : undefined,
|
|
735
|
+
`positionId=${input.positionId}`,
|
|
736
|
+
`chainLength=${input.chainLength}`,
|
|
737
|
+
input.latestSequence !== undefined && input.latestSequence !== null ? `latestSequence=${input.latestSequence}` : undefined,
|
|
738
|
+
input.latestOrdinal !== undefined && input.latestOrdinal !== null ? `latestOrdinal=${input.latestOrdinal}` : undefined,
|
|
739
|
+
`startsAtGenesis=${input.startsAtGenesis}`,
|
|
740
|
+
input.allHashLinksVerified !== undefined ? `allHashLinksVerified=${input.allHashLinksVerified}` : undefined,
|
|
741
|
+
input.identityConsistent !== undefined ? `identityConsistent=${input.identityConsistent}` : undefined,
|
|
742
|
+
input.fullLineageVerified !== undefined ? `fullLineageVerified=${input.fullLineageVerified}` : undefined,
|
|
743
|
+
`fullChainVerified=${input.fullChainVerified}`,
|
|
744
|
+
]
|
|
745
|
+
.filter(Boolean)
|
|
746
|
+
.join("\n");
|
|
747
|
+
}
|
|
748
|
+
function formatFundEvidenceSummary(input) {
|
|
749
|
+
return [
|
|
750
|
+
`definitionHash=${input.definitionHash}`,
|
|
751
|
+
input.capitalCallHash ? `capitalCallHash=${input.capitalCallHash}` : undefined,
|
|
752
|
+
input.positionReceiptHash ? `positionReceiptHash=${input.positionReceiptHash}` : undefined,
|
|
753
|
+
input.positionReceiptEnvelopeHash ? `positionReceiptEnvelopeHash=${input.positionReceiptEnvelopeHash}` : undefined,
|
|
754
|
+
input.distributionHash ? `distributionHash=${input.distributionHash}` : undefined,
|
|
755
|
+
input.closingHash ? `closingHash=${input.closingHash}` : undefined,
|
|
756
|
+
`sourceVerificationMode=${input.sourceVerificationMode}`,
|
|
757
|
+
input.lineageKind ? `lineageKind=${input.lineageKind}` : undefined,
|
|
758
|
+
input.latestOrdinal !== undefined && input.latestOrdinal !== null ? `latestOrdinal=${input.latestOrdinal}` : undefined,
|
|
759
|
+
input.allHashLinksVerified !== undefined && input.allHashLinksVerified !== null
|
|
760
|
+
? `allHashLinksVerified=${input.allHashLinksVerified}`
|
|
761
|
+
: undefined,
|
|
762
|
+
input.identityConsistent !== undefined && input.identityConsistent !== null
|
|
763
|
+
? `identityConsistent=${input.identityConsistent}`
|
|
764
|
+
: undefined,
|
|
765
|
+
input.fullLineageVerified !== undefined && input.fullLineageVerified !== null
|
|
766
|
+
? `fullLineageVerified=${input.fullLineageVerified}`
|
|
767
|
+
: undefined,
|
|
768
|
+
input.fullChainVerified !== undefined && input.fullChainVerified !== null
|
|
769
|
+
? `fullChainVerified=${input.fullChainVerified}`
|
|
770
|
+
: undefined,
|
|
771
|
+
]
|
|
772
|
+
.filter(Boolean)
|
|
773
|
+
.join("\n");
|
|
774
|
+
}
|
|
775
|
+
function formatFundFinalitySummary(input) {
|
|
776
|
+
return [
|
|
777
|
+
`fundId=${input.fundId}`,
|
|
778
|
+
`lpId=${input.lpId}`,
|
|
779
|
+
input.callId ? `callId=${input.callId}` : undefined,
|
|
780
|
+
input.positionId ? `positionId=${input.positionId}` : undefined,
|
|
781
|
+
`definitionHash=${input.definitionHash}`,
|
|
782
|
+
input.capitalCallStateHash ? `capitalCallStateHash=${input.capitalCallStateHash}` : undefined,
|
|
783
|
+
input.positionReceiptHash ? `positionReceiptHash=${input.positionReceiptHash}` : undefined,
|
|
784
|
+
input.positionReceiptEnvelopeHash ? `positionReceiptEnvelopeHash=${input.positionReceiptEnvelopeHash}` : undefined,
|
|
785
|
+
input.distributionHash ? `distributionHash=${input.distributionHash}` : undefined,
|
|
786
|
+
input.closingHash ? `closingHash=${input.closingHash}` : undefined,
|
|
787
|
+
`bindingMode=${input.bindingMode}`,
|
|
788
|
+
input.lineageKind ? `lineageKind=${input.lineageKind}` : undefined,
|
|
789
|
+
input.latestOrdinal !== undefined && input.latestOrdinal !== null ? `latestOrdinal=${input.latestOrdinal}` : undefined,
|
|
790
|
+
input.allHashLinksVerified !== undefined && input.allHashLinksVerified !== null
|
|
791
|
+
? `allHashLinksVerified=${input.allHashLinksVerified}`
|
|
792
|
+
: undefined,
|
|
793
|
+
input.identityConsistent !== undefined && input.identityConsistent !== null
|
|
794
|
+
? `identityConsistent=${input.identityConsistent}`
|
|
795
|
+
: undefined,
|
|
796
|
+
input.fullLineageVerified !== undefined && input.fullLineageVerified !== null
|
|
797
|
+
? `fullLineageVerified=${input.fullLineageVerified}`
|
|
798
|
+
: undefined,
|
|
799
|
+
input.fullChainVerified !== undefined && input.fullChainVerified !== null
|
|
800
|
+
? `fullChainVerified=${input.fullChainVerified}`
|
|
801
|
+
: undefined,
|
|
802
|
+
]
|
|
803
|
+
.filter(Boolean)
|
|
804
|
+
.join("\n");
|
|
805
|
+
}
|
|
806
|
+
function formatReceivableDefinitionSummary(input) {
|
|
807
|
+
return [
|
|
808
|
+
input.ok !== undefined ? `ok=${input.ok}` : undefined,
|
|
809
|
+
`receivableId=${input.receivableId}`,
|
|
810
|
+
`originatorEntityId=${input.originatorEntityId}`,
|
|
811
|
+
`debtorEntityId=${input.debtorEntityId}`,
|
|
812
|
+
`currencyAssetId=${input.currencyAssetId}`,
|
|
813
|
+
`faceValue=${input.faceValue}`,
|
|
814
|
+
`dueDate=${input.dueDate}`,
|
|
815
|
+
]
|
|
816
|
+
.filter(Boolean)
|
|
817
|
+
.join("\n");
|
|
818
|
+
}
|
|
819
|
+
function formatReceivableTransitionSummary(input) {
|
|
820
|
+
return [
|
|
821
|
+
`phase=${input.phase}`,
|
|
822
|
+
`verified=${input.verified}`,
|
|
823
|
+
`transitionType=${input.transitionType}`,
|
|
824
|
+
`receivableId=${input.receivableId}`,
|
|
825
|
+
`nextStateId=${input.nextStateId}`,
|
|
826
|
+
`holderEntityId=${input.holderEntityId}`,
|
|
827
|
+
`status=${input.status}`,
|
|
828
|
+
`outstandingAmount=${input.outstandingAmount}`,
|
|
829
|
+
`repaidAmount=${input.repaidAmount}`,
|
|
830
|
+
`stateHash=${input.stateHash}`,
|
|
831
|
+
].join("\n");
|
|
832
|
+
}
|
|
833
|
+
function formatReceivableClaimSummary(input) {
|
|
834
|
+
return [
|
|
835
|
+
`phase=${input.phase}`,
|
|
836
|
+
`verified=${input.verified}`,
|
|
837
|
+
`claimKind=${input.claimKind}`,
|
|
838
|
+
`receivableId=${input.receivableId}`,
|
|
839
|
+
`claimId=${input.claimId}`,
|
|
840
|
+
`currentStatus=${input.currentStatus}`,
|
|
841
|
+
`payerEntityId=${input.payerEntityId}`,
|
|
842
|
+
`payeeEntityId=${input.payeeEntityId}`,
|
|
843
|
+
`amountSat=${input.amountSat}`,
|
|
844
|
+
input.bindingMode ? `bindingMode=${input.bindingMode}` : undefined,
|
|
845
|
+
input.reasonCode ? `reasonCode=${input.reasonCode}` : undefined,
|
|
846
|
+
input.supportedForm ? `supportedForm=${input.supportedForm}` : undefined,
|
|
847
|
+
input.fullLineageVerified !== undefined ? `fullLineageVerified=${input.fullLineageVerified}` : undefined,
|
|
848
|
+
]
|
|
849
|
+
.filter(Boolean)
|
|
850
|
+
.join("\n");
|
|
851
|
+
}
|
|
852
|
+
function formatReceivableHistorySummary(input) {
|
|
853
|
+
return [
|
|
854
|
+
`verified=${input.verified}`,
|
|
855
|
+
`receivableId=${input.receivableId}`,
|
|
856
|
+
`chainLength=${input.chainLength}`,
|
|
857
|
+
`latestStatus=${input.latestStatus}`,
|
|
858
|
+
input.latestOrdinal !== null ? `latestOrdinal=${input.latestOrdinal}` : undefined,
|
|
859
|
+
`fullLineageVerified=${input.fullLineageVerified}`,
|
|
860
|
+
]
|
|
861
|
+
.filter(Boolean)
|
|
862
|
+
.join("\n");
|
|
863
|
+
}
|
|
864
|
+
function formatReceivableClosingSummary(input) {
|
|
865
|
+
return [
|
|
866
|
+
`verified=${input.verified}`,
|
|
867
|
+
`receivableId=${input.receivableId}`,
|
|
868
|
+
`latestStatus=${input.latestStatus}`,
|
|
869
|
+
`closingReason=${input.closingReason}`,
|
|
870
|
+
`closingHash=${input.closingHash}`,
|
|
871
|
+
input.fullLineageVerified !== undefined ? `fullLineageVerified=${input.fullLineageVerified}` : undefined,
|
|
872
|
+
]
|
|
873
|
+
.filter(Boolean)
|
|
874
|
+
.join("\n");
|
|
875
|
+
}
|
|
876
|
+
function formatReceivableEvidenceOrFinalitySummary(input) {
|
|
877
|
+
return [
|
|
878
|
+
`kind=${input.kind}`,
|
|
879
|
+
`receivableId=${input.receivableId}`,
|
|
880
|
+
`holderEntityId=${input.holderEntityId}`,
|
|
881
|
+
`definitionHash=${input.definitionHash}`,
|
|
882
|
+
`latestStateHash=${input.latestStateHash}`,
|
|
883
|
+
input.closingHash ? `closingHash=${input.closingHash}` : undefined,
|
|
884
|
+
input.closingReason ? `closingReason=${input.closingReason}` : undefined,
|
|
885
|
+
input.lineageKind ? `lineageKind=${input.lineageKind}` : undefined,
|
|
886
|
+
input.latestOrdinal !== undefined && input.latestOrdinal !== null
|
|
887
|
+
? `latestOrdinal=${input.latestOrdinal}`
|
|
888
|
+
: undefined,
|
|
889
|
+
input.fullLineageVerified !== undefined && input.fullLineageVerified !== null
|
|
890
|
+
? `fullLineageVerified=${input.fullLineageVerified}`
|
|
891
|
+
: undefined,
|
|
892
|
+
]
|
|
893
|
+
.filter(Boolean)
|
|
894
|
+
.join("\n");
|
|
895
|
+
}
|
|
133
896
|
function indent(text, spaces = 2) {
|
|
134
897
|
const prefix = " ".repeat(spaces);
|
|
135
898
|
return text
|
|
@@ -486,7 +1249,7 @@ async function main() {
|
|
|
486
1249
|
const subcommand = process.argv[3];
|
|
487
1250
|
const sdk = (0, SimplicityClient_1.createSimplicityClient)(resolveConfig());
|
|
488
1251
|
if (!command) {
|
|
489
|
-
throw new Error("Usage: simplicity-cli <compile|presets|preset|contract|artifact|definition|state|bond|gasless> ...");
|
|
1252
|
+
throw new Error("Usage: simplicity-cli <compile|presets|preset|contract|artifact|definition|state|binding|policy|bond|fund|receivable|gasless> ...");
|
|
490
1253
|
}
|
|
491
1254
|
if (command === "compile") {
|
|
492
1255
|
const result = await sdk.compileFromFile({
|
|
@@ -567,396 +1330,2705 @@ async function main() {
|
|
|
567
1330
|
});
|
|
568
1331
|
return;
|
|
569
1332
|
}
|
|
570
|
-
if (command === "
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
1333
|
+
if (command === "policy" && subcommand === "issue") {
|
|
1334
|
+
const result = await sdk.policies.issue({
|
|
1335
|
+
recipient: parsePolicyReceiver("recipient"),
|
|
1336
|
+
template: parsePolicyTemplateInput(),
|
|
1337
|
+
params: parseAssignments(getMultiArgs("param")),
|
|
1338
|
+
amountSat: Number(requireArg("amount-sat")),
|
|
1339
|
+
assetId: requireArg("asset-id"),
|
|
1340
|
+
propagationMode: getArg("propagation-mode", "required"),
|
|
1341
|
+
artifactPath: getArg("artifact"),
|
|
1342
|
+
});
|
|
1343
|
+
const stateOut = getArg("state-out");
|
|
1344
|
+
if (stateOut) {
|
|
1345
|
+
const resolved = node_path_1.default.resolve(stateOut);
|
|
1346
|
+
await (0, promises_1.mkdir)(node_path_1.default.dirname(resolved), { recursive: true });
|
|
1347
|
+
await (0, promises_1.writeFile)(resolved, `${JSON.stringify(result.state, null, 2)}\n`, "utf8");
|
|
579
1348
|
}
|
|
580
|
-
|
|
1349
|
+
printJson({
|
|
1350
|
+
summary: {
|
|
1351
|
+
propagationMode: result.state.propagationMode,
|
|
1352
|
+
policyHash: result.policyHash,
|
|
1353
|
+
contractAddress: result.compiled.deployment().contractAddress,
|
|
1354
|
+
amountSat: result.state.amountSat,
|
|
1355
|
+
assetId: result.state.assetId,
|
|
1356
|
+
recipient: result.state.recipient,
|
|
1357
|
+
},
|
|
1358
|
+
summaryText: formatPolicyIssueSummary({
|
|
1359
|
+
propagationMode: result.state.propagationMode,
|
|
1360
|
+
policyHash: result.policyHash,
|
|
1361
|
+
contractAddress: result.compiled.deployment().contractAddress,
|
|
1362
|
+
amountSat: result.state.amountSat,
|
|
1363
|
+
assetId: result.state.assetId,
|
|
1364
|
+
recipient: result.state.recipient,
|
|
1365
|
+
}),
|
|
1366
|
+
artifact: result.compiled.artifact,
|
|
1367
|
+
deployment: result.compiled.deployment(),
|
|
1368
|
+
state: result.state,
|
|
1369
|
+
policyTemplate: result.policyTemplate,
|
|
1370
|
+
policyHash: result.policyHash,
|
|
1371
|
+
stateOut: stateOut ? node_path_1.default.resolve(stateOut) : undefined,
|
|
1372
|
+
});
|
|
581
1373
|
return;
|
|
582
1374
|
}
|
|
583
|
-
if (command === "
|
|
584
|
-
|
|
585
|
-
const scaffold = buildScaffoldData(preset);
|
|
586
|
-
const writeDir = getArg("write-dir");
|
|
587
|
-
if (hasFlag("json")) {
|
|
588
|
-
printJson({
|
|
589
|
-
preset: (0, presets_1.describePreset)(preset),
|
|
590
|
-
compileCommand: scaffold.compileCommand,
|
|
591
|
-
executeCommand: scaffold.executeCommand,
|
|
592
|
-
gaslessCommand: scaffold.gaslessCommand,
|
|
593
|
-
});
|
|
594
|
-
return;
|
|
595
|
-
}
|
|
596
|
-
const writtenFiles = writeDir ? await writeScaffoldFiles(writeDir, preset) : [];
|
|
597
|
-
process.stdout.write(`${formatScaffoldBundle(preset)}\n`);
|
|
598
|
-
if (writtenFiles.length > 0) {
|
|
599
|
-
process.stdout.write(`\nWritten Files:\n${writtenFiles.map((file) => ` ${file}`).join("\n")}\n`);
|
|
600
|
-
}
|
|
1375
|
+
if (command === "policy" && subcommand === "list-templates") {
|
|
1376
|
+
printJson(sdk.policies.listTemplates());
|
|
601
1377
|
return;
|
|
602
1378
|
}
|
|
603
|
-
if (command === "
|
|
604
|
-
const
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
params.SIGNER_XONLY = params.signerXonly;
|
|
609
|
-
if (params.refundXonly !== undefined && params.REFUND_XONLY === undefined)
|
|
610
|
-
params.REFUND_XONLY = params.refundXonly;
|
|
611
|
-
const result = await sdk.compileFromPreset({
|
|
612
|
-
preset: requireArg("preset"),
|
|
613
|
-
params,
|
|
614
|
-
artifactPath: getArg("artifact"),
|
|
615
|
-
definition: parseDefinitionInput(),
|
|
616
|
-
state: parseStateInput(),
|
|
1379
|
+
if (command === "binding" && subcommand === "describe-support") {
|
|
1380
|
+
const result = sdk.outputBinding.describeSupport();
|
|
1381
|
+
printJson({
|
|
1382
|
+
summaryText: formatPolicyBindingSupportSummary(result),
|
|
1383
|
+
...result,
|
|
617
1384
|
});
|
|
618
|
-
printJson({ artifact: result.artifact, deployment: result.deployment() });
|
|
619
1385
|
return;
|
|
620
1386
|
}
|
|
621
|
-
if (command === "
|
|
622
|
-
const
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
:
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
}
|
|
630
|
-
catch {
|
|
631
|
-
utxos = null;
|
|
632
|
-
}
|
|
633
|
-
if (!hasFlag("json")) {
|
|
634
|
-
process.stdout.write(`${formatArtifactHelp(artifact, preset, utxos)}\n`);
|
|
635
|
-
return;
|
|
636
|
-
}
|
|
1387
|
+
if (command === "binding" && subcommand === "evaluate-support") {
|
|
1388
|
+
const result = sdk.outputBinding.evaluateSupport({
|
|
1389
|
+
assetId: requireArg("asset-id"),
|
|
1390
|
+
requestedBindingMode: getArg("output-binding-mode") ?? "descriptor-bound",
|
|
1391
|
+
outputForm: parsePolicyOutputForm(),
|
|
1392
|
+
rawOutput: parseRawOutputFields(),
|
|
1393
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
1394
|
+
nextOutputScriptAvailable: hasFlag("without-script-hash") ? false : true,
|
|
1395
|
+
});
|
|
637
1396
|
printJson({
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
utxos,
|
|
641
|
-
status: classifyArtifactStatus(utxos),
|
|
642
|
-
ready: classifyArtifactStatus(utxos) === "executable",
|
|
1397
|
+
...result,
|
|
1398
|
+
summaryText: formatOutputBindingSupportEvaluationSummary(result),
|
|
643
1399
|
});
|
|
644
1400
|
return;
|
|
645
1401
|
}
|
|
646
|
-
if (command === "
|
|
647
|
-
const result = await sdk.
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
1402
|
+
if (command === "policy" && subcommand === "verify-state") {
|
|
1403
|
+
const result = await sdk.policies.verifyState({
|
|
1404
|
+
artifactPath: requireArg("artifact"),
|
|
1405
|
+
template: parsePolicyTemplateInput(),
|
|
1406
|
+
statePath: getArg("state-json"),
|
|
1407
|
+
stateValue: getArg("state-value") ? JSON.parse(getArg("state-value")) : undefined,
|
|
1408
|
+
});
|
|
1409
|
+
printJson({
|
|
1410
|
+
summaryText: formatPolicyVerificationSummary({
|
|
1411
|
+
ok: result.ok,
|
|
1412
|
+
reason: result.reason,
|
|
1413
|
+
propagationMode: result.report.propagationMode,
|
|
1414
|
+
enforcement: result.report.enforcement,
|
|
1415
|
+
plainExitAllowed: result.report.plainExitAllowed,
|
|
1416
|
+
nextPolicyRequired: result.report.nextPolicyRequired,
|
|
1417
|
+
nextPolicyPresent: result.report.nextPolicyPresent,
|
|
1418
|
+
outputBinding: result.report.outputBinding,
|
|
1419
|
+
}),
|
|
1420
|
+
...result,
|
|
652
1421
|
});
|
|
653
|
-
printJson({ artifact: result.artifact, deployment: result.deployment() });
|
|
654
1422
|
return;
|
|
655
1423
|
}
|
|
656
|
-
if (command === "
|
|
657
|
-
const
|
|
658
|
-
|
|
659
|
-
|
|
1424
|
+
if (command === "policy" && subcommand === "describe-template") {
|
|
1425
|
+
const templateManifest = getArg("template-manifest");
|
|
1426
|
+
const templateManifestValue = getArg("template-manifest-value");
|
|
1427
|
+
const templateId = getArg("template-id");
|
|
1428
|
+
const result = templateManifest || templateManifestValue || !templateId
|
|
1429
|
+
? await sdk.policies.loadTemplateManifest({
|
|
1430
|
+
templateId: templateId || undefined,
|
|
1431
|
+
propagationMode: getArg("propagation-mode"),
|
|
1432
|
+
manifestPath: templateManifest || undefined,
|
|
1433
|
+
manifestValue: templateManifestValue ? JSON.parse(templateManifestValue) : undefined,
|
|
1434
|
+
})
|
|
1435
|
+
: sdk.policies.describeTemplate({
|
|
1436
|
+
templateId,
|
|
1437
|
+
propagationMode: getArg("propagation-mode"),
|
|
1438
|
+
});
|
|
1439
|
+
printJson(result);
|
|
1440
|
+
return;
|
|
1441
|
+
}
|
|
1442
|
+
if (command === "policy" && subcommand === "validate-template-params") {
|
|
1443
|
+
const templateManifest = getArg("template-manifest");
|
|
1444
|
+
const templateManifestValue = getArg("template-manifest-value");
|
|
1445
|
+
const manifest = templateManifest || templateManifestValue
|
|
1446
|
+
? await sdk.policies.loadTemplateManifest({
|
|
1447
|
+
templateId: getArg("template-id") || undefined,
|
|
1448
|
+
propagationMode: getArg("propagation-mode"),
|
|
1449
|
+
manifestPath: templateManifest || undefined,
|
|
1450
|
+
manifestValue: templateManifestValue ? JSON.parse(templateManifestValue) : undefined,
|
|
1451
|
+
})
|
|
1452
|
+
: undefined;
|
|
1453
|
+
const result = sdk.policies.validateTemplateParams({
|
|
1454
|
+
templateId: getArg("template-id") || manifest?.templateId,
|
|
1455
|
+
manifestValue: manifest,
|
|
1456
|
+
propagationMode: getArg("propagation-mode"),
|
|
1457
|
+
params: parseAssignments(getMultiArgs("param")),
|
|
1458
|
+
});
|
|
1459
|
+
printJson({ ok: true, params: result });
|
|
1460
|
+
return;
|
|
1461
|
+
}
|
|
1462
|
+
if (command === "policy" && subcommand === "build-output-descriptor") {
|
|
1463
|
+
const result = await sdk.policies.buildOutputDescriptor({
|
|
1464
|
+
nextCompiledContractAddress: requireArg("next-contract-address"),
|
|
1465
|
+
nextAmountSat: Number(requireArg("next-amount-sat")),
|
|
1466
|
+
assetId: requireArg("asset-id"),
|
|
1467
|
+
maxFeeSat: getArg("max-fee-sat") ? Number(getArg("max-fee-sat")) : undefined,
|
|
1468
|
+
nextOutputIndex: getArg("next-output-index") ? Number(getArg("next-output-index")) : undefined,
|
|
1469
|
+
feeIndex: getArg("fee-index") ? Number(getArg("fee-index")) : undefined,
|
|
1470
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
1471
|
+
outputForm: parsePolicyOutputForm(),
|
|
1472
|
+
rawOutput: parseRawOutputFields(),
|
|
1473
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
1474
|
+
});
|
|
1475
|
+
printJson({
|
|
1476
|
+
summary: {
|
|
1477
|
+
mode: result.descriptor.outputBindingMode,
|
|
1478
|
+
nextContractAddress: result.descriptor.nextContractAddress,
|
|
1479
|
+
nextOutputScriptHash: result.descriptor.nextOutputScriptHash ?? null,
|
|
1480
|
+
nextOutputHash: result.descriptor.nextOutputHash ?? null,
|
|
1481
|
+
nextAmountSat: result.descriptor.nextAmountSat,
|
|
1482
|
+
assetId: result.descriptor.assetId,
|
|
1483
|
+
supportedForm: result.supportedForm,
|
|
1484
|
+
reasonCode: result.reasonCode,
|
|
1485
|
+
autoDerived: result.autoDerivedNextOutputHash,
|
|
1486
|
+
fallbackReason: result.fallbackReason ?? null,
|
|
1487
|
+
},
|
|
1488
|
+
summaryText: formatPolicyOutputDescriptorBuildSummary({
|
|
1489
|
+
mode: result.descriptor.outputBindingMode,
|
|
1490
|
+
nextContractAddress: result.descriptor.nextContractAddress,
|
|
1491
|
+
nextOutputScriptHash: result.descriptor.nextOutputScriptHash,
|
|
1492
|
+
nextOutputHash: result.descriptor.nextOutputHash,
|
|
1493
|
+
nextAmountSat: result.descriptor.nextAmountSat,
|
|
1494
|
+
assetId: result.descriptor.assetId,
|
|
1495
|
+
supportedForm: result.supportedForm,
|
|
1496
|
+
reasonCode: result.reasonCode,
|
|
1497
|
+
autoDerived: result.autoDerivedNextOutputHash,
|
|
1498
|
+
fallbackReason: result.fallbackReason,
|
|
1499
|
+
}),
|
|
1500
|
+
descriptor: result.descriptor,
|
|
1501
|
+
descriptorSummary: result.summary,
|
|
1502
|
+
supportedForm: result.supportedForm,
|
|
1503
|
+
autoDerivedNextOutputHash: result.autoDerivedNextOutputHash,
|
|
1504
|
+
reasonCode: result.reasonCode,
|
|
1505
|
+
bindingInputs: result.bindingInputs,
|
|
1506
|
+
fallbackReason: result.fallbackReason ?? null,
|
|
1507
|
+
});
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
if (command === "policy" && subcommand === "prepare-transfer") {
|
|
1511
|
+
const result = await sdk.policies.prepareTransfer({
|
|
1512
|
+
currentArtifactPath: requireArg("current-artifact"),
|
|
1513
|
+
template: parsePolicyTemplateInput(),
|
|
1514
|
+
currentStatePath: getArg("current-state-json"),
|
|
1515
|
+
currentStateValue: getArg("current-state-value") ? JSON.parse(getArg("current-state-value")) : undefined,
|
|
1516
|
+
nextReceiver: parsePolicyReceiver("next"),
|
|
1517
|
+
nextAmountSat: Number(requireArg("next-amount-sat")),
|
|
1518
|
+
nextParams: parseAssignments(getMultiArgs("next-param")),
|
|
1519
|
+
propagationMode: getArg("propagation-mode"),
|
|
1520
|
+
nextArtifactPath: getArg("next-artifact"),
|
|
1521
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
1522
|
+
nextOutputForm: parsePolicyOutputForm(),
|
|
1523
|
+
nextRawOutput: parseRawOutputFields(),
|
|
1524
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
1525
|
+
});
|
|
1526
|
+
const nextStateOut = getArg("next-state-out");
|
|
1527
|
+
if (nextStateOut && result.nextState) {
|
|
1528
|
+
const resolved = node_path_1.default.resolve(nextStateOut);
|
|
1529
|
+
await (0, promises_1.mkdir)(node_path_1.default.dirname(resolved), { recursive: true });
|
|
1530
|
+
await (0, promises_1.writeFile)(resolved, `${JSON.stringify(result.nextState, null, 2)}\n`, "utf8");
|
|
1531
|
+
}
|
|
1532
|
+
const prepareOutputBinding = result.verificationReport.outputBinding;
|
|
1533
|
+
printJson({
|
|
1534
|
+
summary: {
|
|
1535
|
+
mode: "prepare",
|
|
1536
|
+
enforcement: result.verificationReport.enforcement,
|
|
1537
|
+
propagationMode: result.verificationReport.propagationMode,
|
|
1538
|
+
plainExitAllowed: result.verificationReport.plainExitAllowed,
|
|
1539
|
+
nextPolicyRequired: result.verificationReport.nextPolicyRequired,
|
|
1540
|
+
nextPolicyPresent: result.verificationReport.nextPolicyPresent,
|
|
1541
|
+
outputBinding: prepareOutputBinding ?? null,
|
|
1542
|
+
summaryHash: result.transferSummary.hash,
|
|
1543
|
+
},
|
|
1544
|
+
summaryText: formatPolicyInspectOrExecuteSummary({
|
|
1545
|
+
mode: "prepare",
|
|
1546
|
+
propagationMode: result.verificationReport.propagationMode,
|
|
1547
|
+
enforcement: result.verificationReport.enforcement,
|
|
1548
|
+
plainExitAllowed: result.verificationReport.plainExitAllowed,
|
|
1549
|
+
nextPolicyRequired: result.verificationReport.nextPolicyRequired,
|
|
1550
|
+
nextPolicyPresent: result.verificationReport.nextPolicyPresent,
|
|
1551
|
+
outputBinding: prepareOutputBinding,
|
|
1552
|
+
summaryHash: result.transferSummary.hash,
|
|
1553
|
+
}),
|
|
1554
|
+
...result,
|
|
1555
|
+
nextStateOut: nextStateOut && result.nextState ? node_path_1.default.resolve(nextStateOut) : undefined,
|
|
1556
|
+
});
|
|
1557
|
+
return;
|
|
1558
|
+
}
|
|
1559
|
+
if (command === "policy" && subcommand === "verify-transfer") {
|
|
1560
|
+
const result = await sdk.policies.verifyTransfer({
|
|
1561
|
+
template: parsePolicyTemplateInput(),
|
|
1562
|
+
currentArtifactPath: requireArg("current-artifact"),
|
|
1563
|
+
currentStatePath: getArg("current-state-json"),
|
|
1564
|
+
currentStateValue: getArg("current-state-value") ? JSON.parse(getArg("current-state-value")) : undefined,
|
|
1565
|
+
transferDescriptorValue: getArg("transfer-value") ? JSON.parse(getArg("transfer-value")) : undefined,
|
|
1566
|
+
nextStatePath: getArg("next-state-json"),
|
|
1567
|
+
nextStateValue: getArg("next-state-value") ? JSON.parse(getArg("next-state-value")) : undefined,
|
|
1568
|
+
});
|
|
1569
|
+
printJson({
|
|
1570
|
+
summary: {
|
|
1571
|
+
ok: result.ok,
|
|
1572
|
+
reason: result.reason,
|
|
1573
|
+
enforcement: result.verificationReport.enforcement,
|
|
1574
|
+
propagationMode: result.verificationReport.propagationMode,
|
|
1575
|
+
plainExitAllowed: result.verificationReport.plainExitAllowed,
|
|
1576
|
+
nextPolicyRequired: result.verificationReport.nextPolicyRequired,
|
|
1577
|
+
nextPolicyPresent: result.verificationReport.nextPolicyPresent,
|
|
1578
|
+
outputBinding: result.verificationReport.outputBinding ?? null,
|
|
1579
|
+
},
|
|
1580
|
+
summaryText: formatPolicyVerificationSummary({
|
|
1581
|
+
ok: result.ok,
|
|
1582
|
+
reason: result.reason,
|
|
1583
|
+
propagationMode: result.verificationReport.propagationMode,
|
|
1584
|
+
enforcement: result.verificationReport.enforcement,
|
|
1585
|
+
plainExitAllowed: result.verificationReport.plainExitAllowed,
|
|
1586
|
+
nextPolicyRequired: result.verificationReport.nextPolicyRequired,
|
|
1587
|
+
nextPolicyPresent: result.verificationReport.nextPolicyPresent,
|
|
1588
|
+
outputBinding: result.verificationReport.outputBinding,
|
|
1589
|
+
}),
|
|
1590
|
+
...result,
|
|
1591
|
+
});
|
|
1592
|
+
return;
|
|
1593
|
+
}
|
|
1594
|
+
if (command === "policy" && subcommand === "inspect-transfer") {
|
|
1595
|
+
const result = await sdk.policies.inspectTransfer({
|
|
1596
|
+
currentArtifactPath: requireArg("current-artifact"),
|
|
1597
|
+
template: parsePolicyTemplateInput(),
|
|
1598
|
+
currentStatePath: getArg("current-state-json"),
|
|
1599
|
+
currentStateValue: getArg("current-state-value") ? JSON.parse(getArg("current-state-value")) : undefined,
|
|
1600
|
+
nextReceiver: parsePolicyReceiver("next"),
|
|
1601
|
+
nextAmountSat: Number(requireArg("next-amount-sat")),
|
|
1602
|
+
nextParams: parseAssignments(getMultiArgs("next-param")),
|
|
1603
|
+
propagationMode: getArg("propagation-mode"),
|
|
1604
|
+
nextArtifactPath: getArg("next-artifact"),
|
|
1605
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
1606
|
+
nextOutputForm: parsePolicyOutputForm(),
|
|
1607
|
+
nextRawOutput: parseRawOutputFields(),
|
|
1608
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
1609
|
+
wallet: requireArg("wallet"),
|
|
1610
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
1611
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
1612
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
1613
|
+
});
|
|
1614
|
+
const inspectOutputBinding = result.prepared.verificationReport.outputBinding;
|
|
1615
|
+
printJson({
|
|
1616
|
+
summary: {
|
|
1617
|
+
mode: result.mode,
|
|
1618
|
+
enforcement: result.prepared.verificationReport.enforcement,
|
|
1619
|
+
propagationMode: result.prepared.verificationReport.propagationMode,
|
|
1620
|
+
plainExitAllowed: result.prepared.verificationReport.plainExitAllowed,
|
|
1621
|
+
nextPolicyRequired: result.prepared.verificationReport.nextPolicyRequired,
|
|
1622
|
+
nextPolicyPresent: result.prepared.verificationReport.nextPolicyPresent,
|
|
1623
|
+
outputBinding: inspectOutputBinding ?? null,
|
|
1624
|
+
summaryHash: result.inspect.summaryHash,
|
|
1625
|
+
},
|
|
1626
|
+
summaryText: formatPolicyInspectOrExecuteSummary({
|
|
1627
|
+
mode: result.mode,
|
|
1628
|
+
propagationMode: result.prepared.verificationReport.propagationMode,
|
|
1629
|
+
enforcement: result.prepared.verificationReport.enforcement,
|
|
1630
|
+
plainExitAllowed: result.prepared.verificationReport.plainExitAllowed,
|
|
1631
|
+
nextPolicyRequired: result.prepared.verificationReport.nextPolicyRequired,
|
|
1632
|
+
nextPolicyPresent: result.prepared.verificationReport.nextPolicyPresent,
|
|
1633
|
+
outputBinding: inspectOutputBinding,
|
|
1634
|
+
summaryHash: result.inspect.summaryHash,
|
|
1635
|
+
}),
|
|
1636
|
+
...result,
|
|
1637
|
+
});
|
|
1638
|
+
return;
|
|
1639
|
+
}
|
|
1640
|
+
if (command === "policy" && subcommand === "execute-transfer") {
|
|
1641
|
+
const result = await sdk.policies.executeTransfer({
|
|
1642
|
+
currentArtifactPath: requireArg("current-artifact"),
|
|
1643
|
+
template: parsePolicyTemplateInput(),
|
|
1644
|
+
currentStatePath: getArg("current-state-json"),
|
|
1645
|
+
currentStateValue: getArg("current-state-value") ? JSON.parse(getArg("current-state-value")) : undefined,
|
|
1646
|
+
nextReceiver: parsePolicyReceiver("next"),
|
|
1647
|
+
nextAmountSat: Number(requireArg("next-amount-sat")),
|
|
1648
|
+
nextParams: parseAssignments(getMultiArgs("next-param")),
|
|
1649
|
+
propagationMode: getArg("propagation-mode"),
|
|
1650
|
+
nextArtifactPath: getArg("next-artifact"),
|
|
1651
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
1652
|
+
nextOutputForm: parsePolicyOutputForm(),
|
|
1653
|
+
nextRawOutput: parseRawOutputFields(),
|
|
1654
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
1655
|
+
wallet: requireArg("wallet"),
|
|
1656
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
1657
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
1658
|
+
broadcast: hasFlag("broadcast"),
|
|
1659
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
1660
|
+
});
|
|
1661
|
+
const executeOutputBinding = result.prepared.verificationReport.outputBinding;
|
|
1662
|
+
printJson({
|
|
1663
|
+
summary: {
|
|
1664
|
+
mode: result.mode,
|
|
1665
|
+
enforcement: result.prepared.verificationReport.enforcement,
|
|
1666
|
+
propagationMode: result.prepared.verificationReport.propagationMode,
|
|
1667
|
+
plainExitAllowed: result.prepared.verificationReport.plainExitAllowed,
|
|
1668
|
+
nextPolicyRequired: result.prepared.verificationReport.nextPolicyRequired,
|
|
1669
|
+
nextPolicyPresent: result.prepared.verificationReport.nextPolicyPresent,
|
|
1670
|
+
outputBinding: executeOutputBinding ?? null,
|
|
1671
|
+
summaryHash: result.execution.summaryHash,
|
|
1672
|
+
txId: result.execution.txId ?? null,
|
|
1673
|
+
broadcasted: result.execution.broadcasted,
|
|
1674
|
+
},
|
|
1675
|
+
summaryText: formatPolicyInspectOrExecuteSummary({
|
|
1676
|
+
mode: result.mode,
|
|
1677
|
+
propagationMode: result.prepared.verificationReport.propagationMode,
|
|
1678
|
+
enforcement: result.prepared.verificationReport.enforcement,
|
|
1679
|
+
plainExitAllowed: result.prepared.verificationReport.plainExitAllowed,
|
|
1680
|
+
nextPolicyRequired: result.prepared.verificationReport.nextPolicyRequired,
|
|
1681
|
+
nextPolicyPresent: result.prepared.verificationReport.nextPolicyPresent,
|
|
1682
|
+
outputBinding: executeOutputBinding,
|
|
1683
|
+
summaryHash: result.execution.summaryHash,
|
|
1684
|
+
txId: result.execution.txId,
|
|
1685
|
+
broadcasted: result.execution.broadcasted,
|
|
1686
|
+
}),
|
|
1687
|
+
...result,
|
|
1688
|
+
});
|
|
1689
|
+
return;
|
|
1690
|
+
}
|
|
1691
|
+
if (command === "policy" && subcommand === "export-evidence") {
|
|
1692
|
+
const result = await sdk.policies.exportEvidence({
|
|
1693
|
+
artifactPath: requireArg("artifact"),
|
|
1694
|
+
template: parsePolicyTemplateInput(),
|
|
1695
|
+
statePath: getArg("state-json"),
|
|
1696
|
+
stateValue: getArg("state-value") ? JSON.parse(getArg("state-value")) : undefined,
|
|
1697
|
+
transferDescriptorValue: getArg("transfer-value") ? JSON.parse(getArg("transfer-value")) : undefined,
|
|
1698
|
+
});
|
|
1699
|
+
printJson({
|
|
1700
|
+
summary: {
|
|
1701
|
+
templateHash: result.template.hash,
|
|
1702
|
+
stateHash: result.state.hash,
|
|
1703
|
+
transferHash: result.transfer?.hash ?? null,
|
|
1704
|
+
enforcement: result.report.enforcement,
|
|
1705
|
+
outputBinding: result.report.outputBinding ?? null,
|
|
1706
|
+
sourceVerificationMode: result.sourceVerificationMode,
|
|
1707
|
+
},
|
|
1708
|
+
summaryText: formatPolicyEvidenceSummary({
|
|
1709
|
+
templateHash: result.template.hash,
|
|
1710
|
+
stateHash: result.state.hash,
|
|
1711
|
+
transferHash: result.transfer?.hash ?? null,
|
|
1712
|
+
enforcement: result.report.enforcement,
|
|
1713
|
+
outputBinding: result.report.outputBinding ?? null,
|
|
1714
|
+
sourceVerificationMode: result.sourceVerificationMode,
|
|
1715
|
+
}),
|
|
1716
|
+
...result,
|
|
1717
|
+
});
|
|
1718
|
+
return;
|
|
1719
|
+
}
|
|
1720
|
+
if (command === "presets" && subcommand === "list") {
|
|
1721
|
+
printJson((0, presets_1.listPresets)().map((preset) => (0, presets_1.describePreset)(preset)));
|
|
1722
|
+
return;
|
|
1723
|
+
}
|
|
1724
|
+
if (command === "presets" && subcommand === "show") {
|
|
1725
|
+
const preset = (0, presets_1.getPresetOrThrow)(requireArg("preset"));
|
|
1726
|
+
if (hasFlag("json")) {
|
|
1727
|
+
printJson((0, presets_1.describePreset)(preset));
|
|
1728
|
+
return;
|
|
1729
|
+
}
|
|
1730
|
+
process.stdout.write(`${formatPresetHelp(preset)}\n`);
|
|
1731
|
+
return;
|
|
1732
|
+
}
|
|
1733
|
+
if (command === "presets" && subcommand === "scaffold") {
|
|
1734
|
+
const preset = (0, presets_1.getPresetOrThrow)(requireArg("preset"));
|
|
1735
|
+
const scaffold = buildScaffoldData(preset);
|
|
1736
|
+
const writeDir = getArg("write-dir");
|
|
1737
|
+
if (hasFlag("json")) {
|
|
1738
|
+
printJson({
|
|
1739
|
+
preset: (0, presets_1.describePreset)(preset),
|
|
1740
|
+
compileCommand: scaffold.compileCommand,
|
|
1741
|
+
executeCommand: scaffold.executeCommand,
|
|
1742
|
+
gaslessCommand: scaffold.gaslessCommand,
|
|
1743
|
+
});
|
|
1744
|
+
return;
|
|
1745
|
+
}
|
|
1746
|
+
const writtenFiles = writeDir ? await writeScaffoldFiles(writeDir, preset) : [];
|
|
1747
|
+
process.stdout.write(`${formatScaffoldBundle(preset)}\n`);
|
|
1748
|
+
if (writtenFiles.length > 0) {
|
|
1749
|
+
process.stdout.write(`\nWritten Files:\n${writtenFiles.map((file) => ` ${file}`).join("\n")}\n`);
|
|
1750
|
+
}
|
|
1751
|
+
return;
|
|
1752
|
+
}
|
|
1753
|
+
if (command === "preset" && subcommand === "compile") {
|
|
1754
|
+
const params = parseAssignments(getMultiArgs("param"));
|
|
1755
|
+
if (params.minHeight !== undefined && params.MIN_HEIGHT === undefined)
|
|
1756
|
+
params.MIN_HEIGHT = params.minHeight;
|
|
1757
|
+
if (params.signerXonly !== undefined && params.SIGNER_XONLY === undefined)
|
|
1758
|
+
params.SIGNER_XONLY = params.signerXonly;
|
|
1759
|
+
if (params.refundXonly !== undefined && params.REFUND_XONLY === undefined)
|
|
1760
|
+
params.REFUND_XONLY = params.refundXonly;
|
|
1761
|
+
const result = await sdk.compileFromPreset({
|
|
1762
|
+
preset: requireArg("preset"),
|
|
1763
|
+
params,
|
|
1764
|
+
artifactPath: getArg("artifact"),
|
|
1765
|
+
definition: parseDefinitionInput(),
|
|
1766
|
+
state: parseStateInput(),
|
|
1767
|
+
});
|
|
1768
|
+
printJson({ artifact: result.artifact, deployment: result.deployment() });
|
|
1769
|
+
return;
|
|
1770
|
+
}
|
|
1771
|
+
if (command === "artifact" && subcommand === "show") {
|
|
1772
|
+
const artifact = await (0, artifact_1.loadArtifact)(requireArg("artifact"));
|
|
1773
|
+
const preset = artifact.source.mode === "preset" && artifact.source.preset
|
|
1774
|
+
? (0, presets_1.getPresetOrThrow)(artifact.source.preset)
|
|
1775
|
+
: null;
|
|
1776
|
+
let utxos = null;
|
|
1777
|
+
try {
|
|
1778
|
+
utxos = await sdk.fromArtifact(artifact).findUtxos();
|
|
1779
|
+
}
|
|
1780
|
+
catch {
|
|
1781
|
+
utxos = null;
|
|
1782
|
+
}
|
|
1783
|
+
if (!hasFlag("json")) {
|
|
1784
|
+
process.stdout.write(`${formatArtifactHelp(artifact, preset, utxos)}\n`);
|
|
1785
|
+
return;
|
|
1786
|
+
}
|
|
1787
|
+
printJson({
|
|
1788
|
+
artifact,
|
|
1789
|
+
preset,
|
|
1790
|
+
utxos,
|
|
1791
|
+
status: classifyArtifactStatus(utxos),
|
|
1792
|
+
ready: classifyArtifactStatus(utxos) === "executable",
|
|
1793
|
+
});
|
|
1794
|
+
return;
|
|
1795
|
+
}
|
|
1796
|
+
if (command === "bond" && subcommand === "define") {
|
|
1797
|
+
const result = await sdk.bonds.define({
|
|
1798
|
+
definitionPath: getArg("definition-json"),
|
|
1799
|
+
issuancePath: getArg("issuance-json"),
|
|
1800
|
+
simfPath: getArg("simf"),
|
|
1801
|
+
artifactPath: getArg("artifact"),
|
|
1802
|
+
});
|
|
1803
|
+
printJson({
|
|
1804
|
+
artifact: result.artifact,
|
|
1805
|
+
deployment: result.deployment(),
|
|
1806
|
+
summary: {
|
|
1807
|
+
artifactPath: getArg("artifact") ? node_path_1.default.resolve(getArg("artifact")) : undefined,
|
|
1808
|
+
contractAddress: result.artifact.compiled.contractAddress,
|
|
1809
|
+
cmr: result.artifact.compiled.cmr,
|
|
1810
|
+
definitionHash: result.artifact.definition?.hash,
|
|
1811
|
+
issuanceHash: result.artifact.state?.hash,
|
|
1812
|
+
},
|
|
1813
|
+
summaryText: formatBondDefinitionOrVerificationSummary({
|
|
1814
|
+
artifactPath: getArg("artifact") ? node_path_1.default.resolve(getArg("artifact")) : undefined,
|
|
1815
|
+
contractAddress: result.artifact.compiled.contractAddress,
|
|
1816
|
+
cmr: result.artifact.compiled.cmr,
|
|
1817
|
+
definitionHash: result.artifact.definition?.hash,
|
|
1818
|
+
issuanceHash: result.artifact.state?.hash,
|
|
1819
|
+
}),
|
|
1820
|
+
});
|
|
1821
|
+
return;
|
|
1822
|
+
}
|
|
1823
|
+
if (command === "bond" && subcommand === "issue") {
|
|
1824
|
+
const result = await sdk.bonds.issue({
|
|
1825
|
+
definitionPath: getArg("definition-json"),
|
|
1826
|
+
issuancePath: getArg("issuance-json"),
|
|
1827
|
+
simfPath: getArg("simf"),
|
|
1828
|
+
artifactPath: getArg("artifact"),
|
|
1829
|
+
});
|
|
1830
|
+
printJson({
|
|
1831
|
+
artifact: result.artifact,
|
|
1832
|
+
deployment: result.deployment(),
|
|
1833
|
+
summary: {
|
|
1834
|
+
artifactPath: getArg("artifact") ? node_path_1.default.resolve(getArg("artifact")) : undefined,
|
|
1835
|
+
contractAddress: result.artifact.compiled.contractAddress,
|
|
1836
|
+
cmr: result.artifact.compiled.cmr,
|
|
1837
|
+
definitionHash: result.artifact.definition?.hash,
|
|
1838
|
+
issuanceHash: result.artifact.state?.hash,
|
|
1839
|
+
},
|
|
1840
|
+
summaryText: formatBondDefinitionOrVerificationSummary({
|
|
1841
|
+
artifactPath: getArg("artifact") ? node_path_1.default.resolve(getArg("artifact")) : undefined,
|
|
1842
|
+
contractAddress: result.artifact.compiled.contractAddress,
|
|
1843
|
+
cmr: result.artifact.compiled.cmr,
|
|
1844
|
+
definitionHash: result.artifact.definition?.hash,
|
|
1845
|
+
issuanceHash: result.artifact.state?.hash,
|
|
1846
|
+
}),
|
|
1847
|
+
});
|
|
1848
|
+
return;
|
|
1849
|
+
}
|
|
1850
|
+
if (command === "bond" && subcommand === "verify") {
|
|
1851
|
+
const result = await sdk.bonds.verify({
|
|
1852
|
+
artifactPath: requireArg("artifact"),
|
|
1853
|
+
definitionPath: getArg("definition-json"),
|
|
1854
|
+
issuancePath: getArg("issuance-json"),
|
|
1855
|
+
});
|
|
1856
|
+
printJson({
|
|
1857
|
+
...result,
|
|
1858
|
+
summary: {
|
|
1859
|
+
artifactPath: node_path_1.default.resolve(requireArg("artifact")),
|
|
1860
|
+
contractAddress: result.artifact.compiled.contractAddress,
|
|
1861
|
+
cmr: result.artifact.compiled.cmr,
|
|
1862
|
+
definitionHash: result.definition.definition.hash,
|
|
1863
|
+
issuanceHash: result.issuance.state.hash,
|
|
1864
|
+
definitionOk: result.definition.ok,
|
|
1865
|
+
issuanceOk: result.issuance.ok,
|
|
1866
|
+
principalInvariantValid: result.crossChecks.principalInvariantValid,
|
|
1867
|
+
definitionTrustMode: result.definition.trust.effectiveMode,
|
|
1868
|
+
issuanceTrustMode: result.issuance.trust.effectiveMode,
|
|
1869
|
+
},
|
|
1870
|
+
summaryText: formatBondDefinitionOrVerificationSummary({
|
|
1871
|
+
artifactPath: node_path_1.default.resolve(requireArg("artifact")),
|
|
1872
|
+
contractAddress: result.artifact.compiled.contractAddress,
|
|
1873
|
+
cmr: result.artifact.compiled.cmr,
|
|
1874
|
+
definitionHash: result.definition.definition.hash,
|
|
1875
|
+
issuanceHash: result.issuance.state.hash,
|
|
1876
|
+
definitionOk: result.definition.ok,
|
|
1877
|
+
issuanceOk: result.issuance.ok,
|
|
1878
|
+
principalInvariantValid: result.crossChecks.principalInvariantValid,
|
|
1879
|
+
definitionTrustMode: result.definition.trust.effectiveMode,
|
|
1880
|
+
issuanceTrustMode: result.issuance.trust.effectiveMode,
|
|
1881
|
+
}),
|
|
1882
|
+
});
|
|
1883
|
+
return;
|
|
1884
|
+
}
|
|
1885
|
+
if (command === "bond" && subcommand === "verify-issuance-history") {
|
|
1886
|
+
const issuanceHistoryPaths = getMultiArgs("issuance-history-json");
|
|
1887
|
+
const issuanceHistoryValues = getMultiArgs("issuance-history-value").map((value) => JSON.parse(value));
|
|
1888
|
+
const result = await sdk.bonds.verifyIssuanceHistory({
|
|
1889
|
+
definitionPath: getArg("definition-json"),
|
|
1890
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
1891
|
+
issuanceHistoryPaths: issuanceHistoryPaths.length > 0 ? issuanceHistoryPaths : undefined,
|
|
1892
|
+
issuanceHistoryValues: issuanceHistoryValues.length > 0 ? issuanceHistoryValues : undefined,
|
|
1893
|
+
});
|
|
1894
|
+
printJson({
|
|
1895
|
+
summary: {
|
|
1896
|
+
verified: result.verified,
|
|
1897
|
+
issuanceId: result.issuanceHistoryValues.at(-1)?.issuanceId ?? null,
|
|
1898
|
+
chainLength: result.report.issuanceLineageTrust?.chainLength ?? 0,
|
|
1899
|
+
latestStatus: result.report.issuanceLineageTrust?.latestStatus ?? null,
|
|
1900
|
+
latestOrdinal: result.report.issuanceLineageTrust?.latestOrdinal ?? null,
|
|
1901
|
+
startsAtGenesis: result.report.issuanceLineageTrust?.startsAtGenesis ?? false,
|
|
1902
|
+
allHashLinksVerified: result.report.issuanceLineageTrust?.allHashLinksVerified ?? false,
|
|
1903
|
+
identityConsistent: result.report.issuanceLineageTrust?.identityConsistent ?? false,
|
|
1904
|
+
fullLineageVerified: result.report.issuanceLineageTrust?.fullLineageVerified ?? false,
|
|
1905
|
+
fullHistoryVerified: result.report.issuanceLineageTrust?.fullHistoryVerified ?? false,
|
|
1906
|
+
},
|
|
1907
|
+
summaryText: formatBondIssuanceHistorySummary({
|
|
1908
|
+
verified: result.verified,
|
|
1909
|
+
issuanceId: result.issuanceHistoryValues.at(-1)?.issuanceId ?? "unknown",
|
|
1910
|
+
chainLength: result.report.issuanceLineageTrust?.chainLength ?? 0,
|
|
1911
|
+
latestStatus: result.report.issuanceLineageTrust?.latestStatus ?? null,
|
|
1912
|
+
latestOrdinal: result.report.issuanceLineageTrust?.latestOrdinal ?? null,
|
|
1913
|
+
startsAtGenesis: result.report.issuanceLineageTrust?.startsAtGenesis ?? false,
|
|
1914
|
+
allHashLinksVerified: result.report.issuanceLineageTrust?.allHashLinksVerified ?? false,
|
|
1915
|
+
identityConsistent: result.report.issuanceLineageTrust?.identityConsistent ?? false,
|
|
1916
|
+
fullLineageVerified: result.report.issuanceLineageTrust?.fullLineageVerified ?? false,
|
|
1917
|
+
fullHistoryVerified: result.report.issuanceLineageTrust?.fullHistoryVerified ?? false,
|
|
1918
|
+
}),
|
|
1919
|
+
...result,
|
|
1920
|
+
});
|
|
1921
|
+
return;
|
|
1922
|
+
}
|
|
1923
|
+
if (command === "bond" && subcommand === "prepare-redemption") {
|
|
1924
|
+
const result = await sdk.bonds.prepareRedemption({
|
|
1925
|
+
definitionPath: getArg("definition-json"),
|
|
1926
|
+
previousIssuancePath: getArg("previous-issuance-json"),
|
|
1927
|
+
amount: Number(requireArg("amount")),
|
|
1928
|
+
redeemedAt: requireArg("redeemed-at"),
|
|
1929
|
+
nextStateSimfPath: getArg("next-state-simf"),
|
|
1930
|
+
nextAmountSat: Number(requireArg("next-amount-sat")),
|
|
1931
|
+
maxFeeSat: getArg("max-fee-sat") ? Number(getArg("max-fee-sat")) : undefined,
|
|
1932
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
1933
|
+
outputForm: parsePolicyOutputForm(),
|
|
1934
|
+
rawOutput: parseRawOutputFields(),
|
|
1935
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
1936
|
+
});
|
|
1937
|
+
const nextIssuanceOut = getArg("next-issuance-out");
|
|
1938
|
+
if (nextIssuanceOut) {
|
|
1939
|
+
const resolved = node_path_1.default.resolve(nextIssuanceOut);
|
|
1940
|
+
await (0, promises_1.mkdir)(node_path_1.default.dirname(resolved), { recursive: true });
|
|
1941
|
+
await (0, promises_1.writeFile)(`${resolved}`, `${JSON.stringify(result.preview.next, null, 2)}\n`, "utf8");
|
|
1942
|
+
}
|
|
1943
|
+
printJson({
|
|
1944
|
+
...result,
|
|
1945
|
+
nextIssuanceState: result.preview.next,
|
|
1946
|
+
nextIssuanceOut: nextIssuanceOut ? node_path_1.default.resolve(nextIssuanceOut) : undefined,
|
|
1947
|
+
summary: {
|
|
1948
|
+
mode: result.settlement.descriptor.outputBindingMode,
|
|
1949
|
+
nextStatus: result.preview.next.status,
|
|
1950
|
+
descriptorHash: result.settlement.descriptorHash,
|
|
1951
|
+
nextStateHash: result.settlement.nextStateHash,
|
|
1952
|
+
nextContractAddress: result.settlement.nextContractAddress,
|
|
1953
|
+
nextAmountSat: result.settlement.nextAmountSat,
|
|
1954
|
+
supportedForm: result.settlement.supportedForm,
|
|
1955
|
+
reasonCode: result.settlement.reasonCode,
|
|
1956
|
+
autoDerived: result.settlement.autoDerivedNextOutputHash,
|
|
1957
|
+
fallbackReason: result.settlement.fallbackReason,
|
|
1958
|
+
nextOutputHash: result.settlement.expectedOutputDescriptor?.nextOutputHash,
|
|
1959
|
+
bindingInputs: result.settlement.bindingInputs ?? null,
|
|
1960
|
+
},
|
|
1961
|
+
summaryText: formatBondRedemptionSummary({
|
|
1962
|
+
phase: "prepare",
|
|
1963
|
+
mode: result.settlement.descriptor.outputBindingMode ?? "none",
|
|
1964
|
+
nextStatus: result.preview.next.status,
|
|
1965
|
+
descriptorHash: result.settlement.descriptorHash,
|
|
1966
|
+
nextStateHash: result.settlement.nextStateHash,
|
|
1967
|
+
nextContractAddress: result.settlement.nextContractAddress,
|
|
1968
|
+
nextAmountSat: result.settlement.nextAmountSat,
|
|
1969
|
+
bindingMetadata: {
|
|
1970
|
+
bindingMode: result.settlement.descriptor.outputBindingMode,
|
|
1971
|
+
supportedForm: result.settlement.supportedForm,
|
|
1972
|
+
reasonCode: result.settlement.reasonCode,
|
|
1973
|
+
nextOutputHash: result.settlement.expectedOutputDescriptor?.nextOutputHash,
|
|
1974
|
+
autoDerived: result.settlement.autoDerivedNextOutputHash,
|
|
1975
|
+
fallbackReason: result.settlement.fallbackReason,
|
|
1976
|
+
bindingInputs: result.settlement.bindingInputs,
|
|
1977
|
+
},
|
|
1978
|
+
}),
|
|
1979
|
+
});
|
|
1980
|
+
return;
|
|
1981
|
+
}
|
|
1982
|
+
if (command === "bond" && subcommand === "inspect-redemption") {
|
|
1983
|
+
const result = await sdk.bonds.inspectRedemption({
|
|
1984
|
+
currentArtifactPath: requireArg("current-artifact"),
|
|
1985
|
+
definitionPath: getArg("definition-json"),
|
|
1986
|
+
previousIssuancePath: getArg("previous-issuance-json"),
|
|
1987
|
+
nextIssuancePath: getArg("next-issuance-json"),
|
|
1988
|
+
nextStateSimfPath: getArg("next-state-simf"),
|
|
1989
|
+
machineSimfPath: getArg("machine-simf"),
|
|
1990
|
+
machineArtifactPath: getArg("machine-artifact"),
|
|
1991
|
+
nextAmountSat: getArg("next-amount-sat") ? Number(getArg("next-amount-sat")) : undefined,
|
|
1992
|
+
maxFeeSat: getArg("max-fee-sat") ? Number(getArg("max-fee-sat")) : undefined,
|
|
1993
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
1994
|
+
outputForm: parsePolicyOutputForm(),
|
|
1995
|
+
rawOutput: parseRawOutputFields(),
|
|
1996
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
1997
|
+
wallet: requireArg("wallet"),
|
|
1998
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
1999
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
2000
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
2001
|
+
});
|
|
2002
|
+
printJson({
|
|
2003
|
+
...result,
|
|
2004
|
+
summary: {
|
|
2005
|
+
mode: result.mode,
|
|
2006
|
+
nextStatus: result.settlement.descriptor.nextStatus,
|
|
2007
|
+
descriptorHash: result.settlement.descriptorHash,
|
|
2008
|
+
nextStateHash: result.settlement.nextStateHash,
|
|
2009
|
+
nextContractAddress: result.plan.nextContractAddress,
|
|
2010
|
+
nextAmountSat: result.settlement.nextAmountSat,
|
|
2011
|
+
summaryHash: result.inspect.summaryHash,
|
|
2012
|
+
},
|
|
2013
|
+
summaryText: formatBondRedemptionSummary({
|
|
2014
|
+
phase: "inspect",
|
|
2015
|
+
mode: result.mode,
|
|
2016
|
+
nextStatus: result.settlement.descriptor.nextStatus,
|
|
2017
|
+
descriptorHash: result.settlement.descriptorHash,
|
|
2018
|
+
nextStateHash: result.settlement.nextStateHash,
|
|
2019
|
+
nextContractAddress: result.plan.nextContractAddress,
|
|
2020
|
+
nextAmountSat: result.settlement.nextAmountSat,
|
|
2021
|
+
summaryHash: result.inspect.summaryHash,
|
|
2022
|
+
bindingMetadata: {
|
|
2023
|
+
bindingMode: result.settlement.descriptor.outputBindingMode,
|
|
2024
|
+
supportedForm: result.settlement.supportedForm,
|
|
2025
|
+
reasonCode: result.settlement.reasonCode,
|
|
2026
|
+
nextOutputHash: result.settlement.expectedOutputDescriptor?.nextOutputHash,
|
|
2027
|
+
autoDerived: result.settlement.autoDerivedNextOutputHash,
|
|
2028
|
+
fallbackReason: result.settlement.fallbackReason,
|
|
2029
|
+
bindingInputs: result.settlement.bindingInputs,
|
|
2030
|
+
},
|
|
2031
|
+
}),
|
|
2032
|
+
});
|
|
2033
|
+
return;
|
|
2034
|
+
}
|
|
2035
|
+
if (command === "bond" && subcommand === "execute-redemption") {
|
|
2036
|
+
const result = await sdk.bonds.executeRedemption({
|
|
2037
|
+
currentArtifactPath: requireArg("current-artifact"),
|
|
2038
|
+
definitionPath: getArg("definition-json"),
|
|
2039
|
+
previousIssuancePath: getArg("previous-issuance-json"),
|
|
2040
|
+
nextIssuancePath: getArg("next-issuance-json"),
|
|
2041
|
+
nextStateSimfPath: getArg("next-state-simf"),
|
|
2042
|
+
machineSimfPath: getArg("machine-simf"),
|
|
2043
|
+
machineArtifactPath: getArg("machine-artifact"),
|
|
2044
|
+
nextAmountSat: getArg("next-amount-sat") ? Number(getArg("next-amount-sat")) : undefined,
|
|
2045
|
+
maxFeeSat: getArg("max-fee-sat") ? Number(getArg("max-fee-sat")) : undefined,
|
|
2046
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
2047
|
+
outputForm: parsePolicyOutputForm(),
|
|
2048
|
+
rawOutput: parseRawOutputFields(),
|
|
2049
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
2050
|
+
wallet: requireArg("wallet"),
|
|
2051
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
2052
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
2053
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
2054
|
+
broadcast: hasFlag("broadcast"),
|
|
2055
|
+
});
|
|
2056
|
+
printJson({
|
|
2057
|
+
...result,
|
|
2058
|
+
summary: {
|
|
2059
|
+
mode: result.mode,
|
|
2060
|
+
nextStatus: result.settlement.descriptor.nextStatus,
|
|
2061
|
+
descriptorHash: result.settlement.descriptorHash,
|
|
2062
|
+
nextStateHash: result.settlement.nextStateHash,
|
|
2063
|
+
nextContractAddress: result.plan.nextContractAddress,
|
|
2064
|
+
nextAmountSat: result.settlement.nextAmountSat,
|
|
2065
|
+
txId: result.execution.txId ?? null,
|
|
2066
|
+
broadcasted: Boolean(result.execution.txId),
|
|
2067
|
+
},
|
|
2068
|
+
summaryText: formatBondRedemptionSummary({
|
|
2069
|
+
phase: "execute",
|
|
2070
|
+
mode: result.mode,
|
|
2071
|
+
nextStatus: result.settlement.descriptor.nextStatus,
|
|
2072
|
+
descriptorHash: result.settlement.descriptorHash,
|
|
2073
|
+
nextStateHash: result.settlement.nextStateHash,
|
|
2074
|
+
nextContractAddress: result.plan.nextContractAddress,
|
|
2075
|
+
nextAmountSat: result.settlement.nextAmountSat,
|
|
2076
|
+
txId: result.execution.txId,
|
|
2077
|
+
broadcasted: Boolean(result.execution.txId),
|
|
2078
|
+
bindingMetadata: {
|
|
2079
|
+
bindingMode: result.settlement.descriptor.outputBindingMode,
|
|
2080
|
+
supportedForm: result.settlement.supportedForm,
|
|
2081
|
+
reasonCode: result.settlement.reasonCode,
|
|
2082
|
+
nextOutputHash: result.settlement.expectedOutputDescriptor?.nextOutputHash,
|
|
2083
|
+
autoDerived: result.settlement.autoDerivedNextOutputHash,
|
|
2084
|
+
fallbackReason: result.settlement.fallbackReason,
|
|
2085
|
+
bindingInputs: result.settlement.bindingInputs,
|
|
2086
|
+
},
|
|
2087
|
+
}),
|
|
2088
|
+
});
|
|
2089
|
+
return;
|
|
2090
|
+
}
|
|
2091
|
+
if (command === "bond" && subcommand === "verify-redemption") {
|
|
2092
|
+
const result = await sdk.bonds.verifyRedemption({
|
|
2093
|
+
artifactPath: requireArg("artifact"),
|
|
2094
|
+
definitionPath: getArg("definition-json"),
|
|
2095
|
+
previousIssuancePath: getArg("previous-issuance-json"),
|
|
2096
|
+
nextIssuancePath: getArg("next-issuance-json"),
|
|
2097
|
+
nextStateSimfPath: getArg("next-state-simf"),
|
|
2098
|
+
nextAmountSat: getArg("next-amount-sat") ? Number(getArg("next-amount-sat")) : undefined,
|
|
2099
|
+
maxFeeSat: getArg("max-fee-sat") ? Number(getArg("max-fee-sat")) : undefined,
|
|
2100
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
2101
|
+
outputForm: parsePolicyOutputForm(),
|
|
2102
|
+
rawOutput: parseRawOutputFields(),
|
|
2103
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
2104
|
+
});
|
|
2105
|
+
const outputBindingTrust = "outputBindingTrust" in result ? result.outputBindingTrust : undefined;
|
|
2106
|
+
printJson({
|
|
2107
|
+
...result,
|
|
2108
|
+
summary: {
|
|
2109
|
+
verified: result.verified,
|
|
2110
|
+
mode: result.mode,
|
|
2111
|
+
descriptorHash: result.settlement.descriptorHash,
|
|
2112
|
+
nextStateHash: result.settlement.nextStateHash,
|
|
2113
|
+
nextAmountSat: result.settlement.nextAmountSat,
|
|
2114
|
+
supportedForm: result.outputBindingMetadata?.supportedForm ?? null,
|
|
2115
|
+
reasonCode: result.outputBindingMetadata?.reasonCode ?? null,
|
|
2116
|
+
autoDerived: result.outputBindingMetadata?.autoDerived ?? null,
|
|
2117
|
+
fallbackReason: result.outputBindingMetadata?.fallbackReason ?? null,
|
|
2118
|
+
nextOutputHash: result.settlement.expectedOutputDescriptor?.nextOutputHash ?? null,
|
|
2119
|
+
bindingInputs: result.outputBindingMetadata?.bindingInputs ?? null,
|
|
2120
|
+
outputBindingTrust: outputBindingTrust ?? null,
|
|
2121
|
+
},
|
|
2122
|
+
summaryText: formatBondRedemptionSummary({
|
|
2123
|
+
phase: "verify",
|
|
2124
|
+
mode: result.mode,
|
|
2125
|
+
descriptorHash: result.settlement.descriptorHash,
|
|
2126
|
+
nextStateHash: result.settlement.nextStateHash,
|
|
2127
|
+
nextAmountSat: result.settlement.nextAmountSat,
|
|
2128
|
+
verified: result.verified,
|
|
2129
|
+
bindingMetadata: {
|
|
2130
|
+
bindingMode: result.settlement.descriptor.outputBindingMode,
|
|
2131
|
+
supportedForm: result.outputBindingMetadata?.supportedForm,
|
|
2132
|
+
reasonCode: result.outputBindingMetadata?.reasonCode,
|
|
2133
|
+
nextOutputHash: result.settlement.expectedOutputDescriptor?.nextOutputHash,
|
|
2134
|
+
autoDerived: result.outputBindingMetadata?.autoDerived,
|
|
2135
|
+
fallbackReason: result.outputBindingMetadata?.fallbackReason,
|
|
2136
|
+
bindingInputs: result.outputBindingMetadata?.bindingInputs,
|
|
2137
|
+
},
|
|
2138
|
+
outputBindingTrust,
|
|
2139
|
+
}),
|
|
2140
|
+
});
|
|
2141
|
+
return;
|
|
2142
|
+
}
|
|
2143
|
+
if (command === "bond" && subcommand === "build-settlement") {
|
|
2144
|
+
const result = await sdk.bonds.buildSettlement({
|
|
2145
|
+
definitionPath: getArg("definition-json"),
|
|
2146
|
+
previousIssuancePath: getArg("previous-issuance-json"),
|
|
2147
|
+
nextIssuancePath: getArg("next-issuance-json"),
|
|
2148
|
+
nextStateSimfPath: getArg("next-state-simf"),
|
|
2149
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
2150
|
+
nextAmountSat: Number(requireArg("next-amount-sat")),
|
|
2151
|
+
maxFeeSat: getArg("max-fee-sat") ? Number(getArg("max-fee-sat")) : undefined,
|
|
2152
|
+
outputForm: parsePolicyOutputForm(),
|
|
2153
|
+
rawOutput: parseRawOutputFields(),
|
|
2154
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
2155
|
+
});
|
|
2156
|
+
printJson({
|
|
2157
|
+
...result,
|
|
2158
|
+
summary: {
|
|
2159
|
+
descriptorHash: result.descriptorHash,
|
|
2160
|
+
bindingMode: result.descriptor.outputBindingMode,
|
|
2161
|
+
previousStateHash: result.previousStateHash,
|
|
2162
|
+
nextStateHash: result.nextStateHash,
|
|
2163
|
+
nextContractAddress: result.nextContractAddress,
|
|
2164
|
+
nextAmountSat: result.nextAmountSat,
|
|
2165
|
+
maxFeeSat: result.maxFeeSat,
|
|
2166
|
+
supportedForm: result.supportedForm,
|
|
2167
|
+
reasonCode: result.reasonCode,
|
|
2168
|
+
autoDerived: result.autoDerivedNextOutputHash,
|
|
2169
|
+
fallbackReason: result.fallbackReason,
|
|
2170
|
+
nextOutputHash: result.expectedOutputDescriptor?.nextOutputHash,
|
|
2171
|
+
bindingInputs: result.bindingInputs ?? null,
|
|
2172
|
+
},
|
|
2173
|
+
summaryText: formatBondSettlementSummary({
|
|
2174
|
+
descriptorHash: result.descriptorHash,
|
|
2175
|
+
bindingMode: result.descriptor.outputBindingMode ?? "none",
|
|
2176
|
+
previousStateHash: result.previousStateHash,
|
|
2177
|
+
nextStateHash: result.nextStateHash,
|
|
2178
|
+
nextContractAddress: result.nextContractAddress,
|
|
2179
|
+
nextAmountSat: result.nextAmountSat,
|
|
2180
|
+
maxFeeSat: result.maxFeeSat,
|
|
2181
|
+
supportedForm: result.supportedForm,
|
|
2182
|
+
reasonCode: result.reasonCode,
|
|
2183
|
+
autoDerived: result.autoDerivedNextOutputHash,
|
|
2184
|
+
fallbackReason: result.fallbackReason,
|
|
2185
|
+
nextOutputHash: result.expectedOutputDescriptor?.nextOutputHash,
|
|
2186
|
+
bindingInputs: result.bindingInputs ?? undefined,
|
|
2187
|
+
}),
|
|
2188
|
+
});
|
|
2189
|
+
return;
|
|
2190
|
+
}
|
|
2191
|
+
if (command === "bond" && subcommand === "verify-settlement") {
|
|
2192
|
+
const result = await sdk.bonds.verifySettlement({
|
|
2193
|
+
descriptorPath: getArg("descriptor-json"),
|
|
2194
|
+
definitionPath: getArg("definition-json"),
|
|
2195
|
+
previousIssuancePath: getArg("previous-issuance-json"),
|
|
2196
|
+
nextIssuancePath: getArg("next-issuance-json"),
|
|
2197
|
+
nextStateSimfPath: getArg("next-state-simf"),
|
|
2198
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
2199
|
+
nextAmountSat: getArg("next-amount-sat") ? Number(getArg("next-amount-sat")) : undefined,
|
|
2200
|
+
maxFeeSat: getArg("max-fee-sat") ? Number(getArg("max-fee-sat")) : undefined,
|
|
2201
|
+
outputForm: parsePolicyOutputForm(),
|
|
2202
|
+
rawOutput: parseRawOutputFields(),
|
|
2203
|
+
});
|
|
2204
|
+
printJson({
|
|
2205
|
+
...result,
|
|
2206
|
+
summary: {
|
|
2207
|
+
ok: result.ok,
|
|
2208
|
+
reason: result.reason,
|
|
2209
|
+
descriptorHash: result.hash,
|
|
2210
|
+
bindingMode: result.descriptor.outputBindingMode,
|
|
2211
|
+
previousStateHash: result.descriptor.previousStateHash,
|
|
2212
|
+
nextStateHash: result.descriptor.nextStateHash,
|
|
2213
|
+
nextContractAddress: result.descriptor.nextContractAddress,
|
|
2214
|
+
nextAmountSat: result.descriptor.nextAmountSat,
|
|
2215
|
+
maxFeeSat: result.descriptor.maxFeeSat,
|
|
2216
|
+
supportedForm: result.supportedForm,
|
|
2217
|
+
reasonCode: result.reasonCode,
|
|
2218
|
+
autoDerived: result.autoDerivedNextOutputHash,
|
|
2219
|
+
fallbackReason: result.fallbackReason,
|
|
2220
|
+
bindingInputs: result.bindingInputs ?? null,
|
|
2221
|
+
},
|
|
2222
|
+
summaryText: formatBondSettlementSummary({
|
|
2223
|
+
ok: result.ok,
|
|
2224
|
+
reason: result.reason,
|
|
2225
|
+
descriptorHash: result.hash,
|
|
2226
|
+
bindingMode: result.descriptor.outputBindingMode ?? "none",
|
|
2227
|
+
previousStateHash: result.descriptor.previousStateHash,
|
|
2228
|
+
nextStateHash: result.descriptor.nextStateHash,
|
|
2229
|
+
nextContractAddress: result.descriptor.nextContractAddress,
|
|
2230
|
+
nextAmountSat: result.descriptor.nextAmountSat,
|
|
2231
|
+
maxFeeSat: result.descriptor.maxFeeSat,
|
|
2232
|
+
supportedForm: result.supportedForm,
|
|
2233
|
+
reasonCode: result.reasonCode,
|
|
2234
|
+
autoDerived: result.autoDerivedNextOutputHash,
|
|
2235
|
+
fallbackReason: result.fallbackReason,
|
|
2236
|
+
bindingInputs: result.bindingInputs ?? undefined,
|
|
2237
|
+
}),
|
|
2238
|
+
});
|
|
2239
|
+
return;
|
|
2240
|
+
}
|
|
2241
|
+
if (command === "bond" && subcommand === "prepare-closing") {
|
|
2242
|
+
const result = await sdk.bonds.prepareClosing({
|
|
2243
|
+
definitionPath: getArg("definition-json"),
|
|
2244
|
+
redeemedIssuancePath: getArg("redeemed-issuance-json"),
|
|
2245
|
+
settlementDescriptorPath: getArg("settlement-descriptor-json"),
|
|
2246
|
+
closedAt: requireArg("closed-at"),
|
|
2247
|
+
closingReason: getArg("closing-reason"),
|
|
2248
|
+
});
|
|
2249
|
+
printJson({
|
|
2250
|
+
...result,
|
|
2251
|
+
summary: {
|
|
2252
|
+
closingHash: result.closingHash,
|
|
2253
|
+
closedAt: result.closing.closedAt,
|
|
2254
|
+
closingReason: result.closing.closingReason,
|
|
2255
|
+
finalSettlementDescriptorHash: result.closing.finalSettlementDescriptorHash,
|
|
2256
|
+
},
|
|
2257
|
+
summaryText: formatBondClosingSummary({
|
|
2258
|
+
phase: "prepare",
|
|
2259
|
+
closingHash: result.closingHash,
|
|
2260
|
+
closedAt: result.closing.closedAt,
|
|
2261
|
+
closingReason: result.closing.closingReason,
|
|
2262
|
+
finalSettlementDescriptorHash: result.closing.finalSettlementDescriptorHash,
|
|
2263
|
+
}),
|
|
2264
|
+
});
|
|
2265
|
+
return;
|
|
2266
|
+
}
|
|
2267
|
+
if (command === "bond" && subcommand === "inspect-closing") {
|
|
2268
|
+
const result = await sdk.bonds.inspectClosing({
|
|
2269
|
+
currentArtifactPath: requireArg("current-artifact"),
|
|
2270
|
+
definitionPath: getArg("definition-json"),
|
|
2271
|
+
redeemedIssuancePath: getArg("redeemed-issuance-json"),
|
|
2272
|
+
settlementDescriptorPath: getArg("settlement-descriptor-json"),
|
|
2273
|
+
closedIssuanceSimfPath: getArg("closed-issuance-simf"),
|
|
2274
|
+
closingArtifactPath: getArg("closing-artifact"),
|
|
2275
|
+
closedAt: requireArg("closed-at"),
|
|
2276
|
+
closingReason: getArg("closing-reason"),
|
|
2277
|
+
wallet: requireArg("wallet"),
|
|
2278
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
2279
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
2280
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
2281
|
+
});
|
|
2282
|
+
printJson({
|
|
2283
|
+
...result,
|
|
2284
|
+
summary: {
|
|
2285
|
+
closingHash: result.plan.closingHash,
|
|
2286
|
+
closedAt: result.plan.closingDescriptor.closedAt,
|
|
2287
|
+
closingReason: result.plan.closingDescriptor.closingReason,
|
|
2288
|
+
finalSettlementDescriptorHash: result.plan.closingDescriptor.finalSettlementDescriptorHash,
|
|
2289
|
+
summaryHash: result.inspect.summaryHash,
|
|
2290
|
+
},
|
|
2291
|
+
summaryText: formatBondClosingSummary({
|
|
2292
|
+
phase: "inspect",
|
|
2293
|
+
closingHash: result.plan.closingHash,
|
|
2294
|
+
closedAt: result.plan.closingDescriptor.closedAt,
|
|
2295
|
+
closingReason: result.plan.closingDescriptor.closingReason,
|
|
2296
|
+
finalSettlementDescriptorHash: result.plan.closingDescriptor.finalSettlementDescriptorHash,
|
|
2297
|
+
summaryHash: result.inspect.summaryHash,
|
|
2298
|
+
}),
|
|
2299
|
+
});
|
|
2300
|
+
return;
|
|
2301
|
+
}
|
|
2302
|
+
if (command === "bond" && subcommand === "execute-closing") {
|
|
2303
|
+
const result = await sdk.bonds.executeClosing({
|
|
2304
|
+
currentArtifactPath: requireArg("current-artifact"),
|
|
2305
|
+
definitionPath: getArg("definition-json"),
|
|
2306
|
+
redeemedIssuancePath: getArg("redeemed-issuance-json"),
|
|
2307
|
+
settlementDescriptorPath: getArg("settlement-descriptor-json"),
|
|
2308
|
+
closedIssuanceSimfPath: getArg("closed-issuance-simf"),
|
|
2309
|
+
closingArtifactPath: getArg("closing-artifact"),
|
|
2310
|
+
closedAt: requireArg("closed-at"),
|
|
2311
|
+
closingReason: getArg("closing-reason"),
|
|
2312
|
+
wallet: requireArg("wallet"),
|
|
2313
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
2314
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
2315
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
2316
|
+
broadcast: hasFlag("broadcast"),
|
|
2317
|
+
});
|
|
2318
|
+
printJson({
|
|
2319
|
+
...result,
|
|
2320
|
+
summary: {
|
|
2321
|
+
closingHash: result.plan.closingHash,
|
|
2322
|
+
closedAt: result.plan.closingDescriptor.closedAt,
|
|
2323
|
+
closingReason: result.plan.closingDescriptor.closingReason,
|
|
2324
|
+
finalSettlementDescriptorHash: result.plan.closingDescriptor.finalSettlementDescriptorHash,
|
|
2325
|
+
txId: result.execution.txId ?? null,
|
|
2326
|
+
broadcasted: Boolean(result.execution.txId),
|
|
2327
|
+
},
|
|
2328
|
+
summaryText: formatBondClosingSummary({
|
|
2329
|
+
phase: "execute",
|
|
2330
|
+
closingHash: result.plan.closingHash,
|
|
2331
|
+
closedAt: result.plan.closingDescriptor.closedAt,
|
|
2332
|
+
closingReason: result.plan.closingDescriptor.closingReason,
|
|
2333
|
+
finalSettlementDescriptorHash: result.plan.closingDescriptor.finalSettlementDescriptorHash,
|
|
2334
|
+
txId: result.execution.txId,
|
|
2335
|
+
broadcasted: Boolean(result.execution.txId),
|
|
2336
|
+
}),
|
|
2337
|
+
});
|
|
2338
|
+
return;
|
|
2339
|
+
}
|
|
2340
|
+
if (command === "bond" && subcommand === "verify-closing") {
|
|
2341
|
+
const closedIssuancePath = getArg("closed-issuance-json");
|
|
2342
|
+
const closedIssuanceValue = getArg("closed-issuance-value")
|
|
2343
|
+
? JSON.parse(getArg("closed-issuance-value"))
|
|
2344
|
+
: undefined;
|
|
2345
|
+
const closingDescriptorValue = getArg("closing-descriptor-value")
|
|
2346
|
+
? JSON.parse(getArg("closing-descriptor-value"))
|
|
2347
|
+
: undefined;
|
|
2348
|
+
const result = await sdk.bonds.verifyClosing({
|
|
2349
|
+
definitionPath: getArg("definition-json"),
|
|
2350
|
+
redeemedIssuancePath: getArg("redeemed-issuance-json"),
|
|
2351
|
+
closedIssuancePath,
|
|
2352
|
+
closedIssuanceValue,
|
|
2353
|
+
settlementDescriptorPath: getArg("settlement-descriptor-json"),
|
|
2354
|
+
closingDescriptorValue,
|
|
2355
|
+
});
|
|
2356
|
+
printJson({
|
|
2357
|
+
...result,
|
|
2358
|
+
summary: {
|
|
2359
|
+
verified: result.verified,
|
|
2360
|
+
closedAt: result.closed.closedAt,
|
|
2361
|
+
closingReason: result.closed.closingReason,
|
|
2362
|
+
finalSettlementDescriptorHash: result.closed.finalSettlementDescriptorHash,
|
|
2363
|
+
checks: result.checks,
|
|
2364
|
+
},
|
|
2365
|
+
summaryText: formatBondClosingSummary({
|
|
2366
|
+
phase: "verify",
|
|
2367
|
+
verified: result.verified,
|
|
2368
|
+
closedAt: result.closed.closedAt,
|
|
2369
|
+
closingReason: result.closed.closingReason,
|
|
2370
|
+
finalSettlementDescriptorHash: result.closed.finalSettlementDescriptorHash,
|
|
2371
|
+
checks: result.checks,
|
|
2372
|
+
}),
|
|
2373
|
+
});
|
|
2374
|
+
return;
|
|
2375
|
+
}
|
|
2376
|
+
if (command === "bond" && subcommand === "export-evidence") {
|
|
2377
|
+
const issuanceHistoryPaths = getMultiArgs("issuance-history-json");
|
|
2378
|
+
const issuanceHistoryValues = getMultiArgs("issuance-history-value").map((value) => JSON.parse(value));
|
|
2379
|
+
const settlementDescriptorValue = getArg("settlement-descriptor-value")
|
|
2380
|
+
? JSON.parse(getArg("settlement-descriptor-value"))
|
|
2381
|
+
: undefined;
|
|
2382
|
+
const transitionValue = getArg("transition-value")
|
|
2383
|
+
? JSON.parse(getArg("transition-value"))
|
|
2384
|
+
: undefined;
|
|
2385
|
+
const result = await sdk.bonds.exportEvidence({
|
|
2386
|
+
artifactPath: requireArg("artifact"),
|
|
2387
|
+
definitionPath: getArg("definition-json"),
|
|
660
2388
|
issuancePath: getArg("issuance-json"),
|
|
2389
|
+
issuanceHistoryPaths: issuanceHistoryPaths.length > 0 ? issuanceHistoryPaths : undefined,
|
|
2390
|
+
issuanceHistoryValues: issuanceHistoryValues.length > 0 ? issuanceHistoryValues : undefined,
|
|
2391
|
+
settlementDescriptorValue,
|
|
2392
|
+
transitionValue,
|
|
2393
|
+
});
|
|
2394
|
+
printJson({
|
|
2395
|
+
...result,
|
|
2396
|
+
summary: {
|
|
2397
|
+
definitionHash: result.definition.hash,
|
|
2398
|
+
issuanceHash: result.issuance.hash,
|
|
2399
|
+
settlementHash: result.settlement?.hash ?? null,
|
|
2400
|
+
closingHash: result.closing?.hash ?? null,
|
|
2401
|
+
renderedSourceHash: result.renderedSourceHash ?? null,
|
|
2402
|
+
sourceVerificationMode: result.sourceVerificationMode,
|
|
2403
|
+
lineageKind: result.trust.issuanceLineageTrust?.lineageKind ?? null,
|
|
2404
|
+
latestOrdinal: result.trust.issuanceLineageTrust?.latestOrdinal ?? null,
|
|
2405
|
+
allHashLinksVerified: result.trust.issuanceLineageTrust?.allHashLinksVerified ?? null,
|
|
2406
|
+
identityConsistent: result.trust.issuanceLineageTrust?.identityConsistent ?? null,
|
|
2407
|
+
fullLineageVerified: result.trust.issuanceLineageTrust?.fullLineageVerified ?? null,
|
|
2408
|
+
fullHistoryVerified: result.trust.issuanceLineageTrust?.fullHistoryVerified ?? null,
|
|
2409
|
+
},
|
|
2410
|
+
summaryText: formatBondEvidenceSummary({
|
|
2411
|
+
definitionHash: result.definition.hash,
|
|
2412
|
+
issuanceHash: result.issuance.hash,
|
|
2413
|
+
settlementHash: result.settlement?.hash ?? null,
|
|
2414
|
+
closingHash: result.closing?.hash ?? null,
|
|
2415
|
+
renderedSourceHash: result.renderedSourceHash ?? null,
|
|
2416
|
+
sourceVerificationMode: result.sourceVerificationMode,
|
|
2417
|
+
lineageKind: result.trust.issuanceLineageTrust?.lineageKind ?? null,
|
|
2418
|
+
latestOrdinal: result.trust.issuanceLineageTrust?.latestOrdinal ?? null,
|
|
2419
|
+
allHashLinksVerified: result.trust.issuanceLineageTrust?.allHashLinksVerified ?? null,
|
|
2420
|
+
identityConsistent: result.trust.issuanceLineageTrust?.identityConsistent ?? null,
|
|
2421
|
+
fullLineageVerified: result.trust.issuanceLineageTrust?.fullLineageVerified ?? null,
|
|
2422
|
+
fullHistoryVerified: result.trust.issuanceLineageTrust?.fullHistoryVerified ?? null,
|
|
2423
|
+
}),
|
|
2424
|
+
});
|
|
2425
|
+
return;
|
|
2426
|
+
}
|
|
2427
|
+
if (command === "bond" && subcommand === "export-finality-payload") {
|
|
2428
|
+
const issuanceHistoryPaths = getMultiArgs("issuance-history-json");
|
|
2429
|
+
const issuanceHistoryValues = getMultiArgs("issuance-history-value").map((value) => JSON.parse(value));
|
|
2430
|
+
const settlementDescriptorValue = getArg("settlement-descriptor-value")
|
|
2431
|
+
? JSON.parse(getArg("settlement-descriptor-value"))
|
|
2432
|
+
: undefined;
|
|
2433
|
+
const closingDescriptorValue = getArg("closing-descriptor-value")
|
|
2434
|
+
? JSON.parse(getArg("closing-descriptor-value"))
|
|
2435
|
+
: undefined;
|
|
2436
|
+
const result = await sdk.bonds.exportFinalityPayload({
|
|
2437
|
+
artifactPath: requireArg("artifact"),
|
|
2438
|
+
definitionPath: getArg("definition-json"),
|
|
2439
|
+
issuancePath: getArg("issuance-json"),
|
|
2440
|
+
issuanceHistoryPaths: issuanceHistoryPaths.length > 0 ? issuanceHistoryPaths : undefined,
|
|
2441
|
+
issuanceHistoryValues: issuanceHistoryValues.length > 0 ? issuanceHistoryValues : undefined,
|
|
2442
|
+
settlementDescriptorValue,
|
|
2443
|
+
closingDescriptorValue,
|
|
2444
|
+
});
|
|
2445
|
+
printJson({
|
|
2446
|
+
...result,
|
|
2447
|
+
summary: {
|
|
2448
|
+
bondId: result.payload.bondId,
|
|
2449
|
+
issuanceId: result.payload.issuanceId,
|
|
2450
|
+
definitionHash: result.payload.definitionHash,
|
|
2451
|
+
issuanceStateHash: result.payload.issuanceStateHash,
|
|
2452
|
+
settlementDescriptorHash: result.evidenceSummary.settlementHash,
|
|
2453
|
+
closingDescriptorHash: result.evidenceSummary.closingHash,
|
|
2454
|
+
contractAddress: result.payload.contractAddress,
|
|
2455
|
+
cmr: result.payload.cmr,
|
|
2456
|
+
bindingMode: result.bindingMode,
|
|
2457
|
+
lineageKind: result.trust.issuanceLineageTrust?.lineageKind ?? null,
|
|
2458
|
+
latestOrdinal: result.trust.issuanceLineageTrust?.latestOrdinal ?? null,
|
|
2459
|
+
allHashLinksVerified: result.trust.issuanceLineageTrust?.allHashLinksVerified ?? null,
|
|
2460
|
+
identityConsistent: result.trust.issuanceLineageTrust?.identityConsistent ?? null,
|
|
2461
|
+
fullLineageVerified: result.trust.issuanceLineageTrust?.fullLineageVerified ?? null,
|
|
2462
|
+
fullHistoryVerified: result.trust.issuanceLineageTrust?.fullHistoryVerified ?? null,
|
|
2463
|
+
},
|
|
2464
|
+
summaryText: formatBondFinalityPayloadSummary({
|
|
2465
|
+
bondId: result.payload.bondId,
|
|
2466
|
+
issuanceId: result.payload.issuanceId,
|
|
2467
|
+
definitionHash: result.payload.definitionHash,
|
|
2468
|
+
issuanceStateHash: result.payload.issuanceStateHash,
|
|
2469
|
+
settlementDescriptorHash: result.evidenceSummary.settlementHash,
|
|
2470
|
+
closingDescriptorHash: result.evidenceSummary.closingHash,
|
|
2471
|
+
contractAddress: result.payload.contractAddress,
|
|
2472
|
+
cmr: result.payload.cmr,
|
|
2473
|
+
bindingMode: result.bindingMode,
|
|
2474
|
+
lineageKind: result.trust.issuanceLineageTrust?.lineageKind ?? null,
|
|
2475
|
+
latestOrdinal: result.trust.issuanceLineageTrust?.latestOrdinal ?? null,
|
|
2476
|
+
allHashLinksVerified: result.trust.issuanceLineageTrust?.allHashLinksVerified ?? null,
|
|
2477
|
+
identityConsistent: result.trust.issuanceLineageTrust?.identityConsistent ?? null,
|
|
2478
|
+
fullLineageVerified: result.trust.issuanceLineageTrust?.fullLineageVerified ?? null,
|
|
2479
|
+
fullHistoryVerified: result.trust.issuanceLineageTrust?.fullHistoryVerified ?? null,
|
|
2480
|
+
}),
|
|
2481
|
+
});
|
|
2482
|
+
return;
|
|
2483
|
+
}
|
|
2484
|
+
if (command === "fund" && subcommand === "define") {
|
|
2485
|
+
const result = await sdk.funds.define({
|
|
2486
|
+
definitionPath: getArg("definition-json"),
|
|
2487
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2488
|
+
});
|
|
2489
|
+
printJson({
|
|
2490
|
+
summaryText: formatFundDefinitionSummary({
|
|
2491
|
+
ok: result.ok,
|
|
2492
|
+
fundId: result.definitionValue.fundId,
|
|
2493
|
+
managerEntityId: result.definitionValue.managerEntityId,
|
|
2494
|
+
currencyAssetId: result.definitionValue.currencyAssetId,
|
|
2495
|
+
jurisdiction: result.definitionValue.jurisdiction,
|
|
2496
|
+
vintage: result.definitionValue.vintage,
|
|
2497
|
+
}),
|
|
2498
|
+
...result,
|
|
2499
|
+
});
|
|
2500
|
+
return;
|
|
2501
|
+
}
|
|
2502
|
+
if (command === "fund" && subcommand === "verify") {
|
|
2503
|
+
const result = await sdk.funds.verify({
|
|
2504
|
+
definitionPath: getArg("definition-json"),
|
|
2505
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2506
|
+
});
|
|
2507
|
+
printJson({
|
|
2508
|
+
summaryText: formatFundDefinitionSummary({
|
|
2509
|
+
ok: result.ok,
|
|
2510
|
+
fundId: result.definitionValue.fundId,
|
|
2511
|
+
managerEntityId: result.definitionValue.managerEntityId,
|
|
2512
|
+
currencyAssetId: result.definitionValue.currencyAssetId,
|
|
2513
|
+
jurisdiction: result.definitionValue.jurisdiction,
|
|
2514
|
+
vintage: result.definitionValue.vintage,
|
|
2515
|
+
}),
|
|
2516
|
+
...result,
|
|
2517
|
+
});
|
|
2518
|
+
return;
|
|
2519
|
+
}
|
|
2520
|
+
if (command === "fund" && subcommand === "prepare-capital-call") {
|
|
2521
|
+
const result = await sdk.funds.prepareCapitalCall({
|
|
2522
|
+
definitionPath: getArg("definition-json"),
|
|
2523
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2524
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
2525
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
2526
|
+
openSimfPath: getArg("open-simf") ?? getArg("simf"),
|
|
2527
|
+
refundOnlySimfPath: getArg("refund-only-simf"),
|
|
2528
|
+
openArtifactPath: getArg("open-artifact") ?? getArg("artifact"),
|
|
2529
|
+
refundOnlyArtifactPath: getArg("refund-only-artifact"),
|
|
2530
|
+
});
|
|
2531
|
+
printJson({
|
|
2532
|
+
summary: {
|
|
2533
|
+
callId: result.capitalCallValue.callId,
|
|
2534
|
+
status: result.capitalCallValue.status,
|
|
2535
|
+
amount: result.capitalCallValue.amount,
|
|
2536
|
+
assetId: result.capitalCallValue.currencyAssetId,
|
|
2537
|
+
openContractAddress: result.openCompiled.deployment().contractAddress,
|
|
2538
|
+
refundOnlyContractAddress: result.refundOnlyCompiled.deployment().contractAddress,
|
|
2539
|
+
},
|
|
2540
|
+
summaryText: formatFundCapitalCallSummary({
|
|
2541
|
+
phase: "prepare",
|
|
2542
|
+
callId: result.capitalCallValue.callId,
|
|
2543
|
+
status: result.capitalCallValue.status,
|
|
2544
|
+
amount: result.capitalCallValue.amount,
|
|
2545
|
+
assetId: result.capitalCallValue.currencyAssetId,
|
|
2546
|
+
contractAddress: result.openCompiled.deployment().contractAddress,
|
|
2547
|
+
}),
|
|
2548
|
+
...result,
|
|
2549
|
+
});
|
|
2550
|
+
return;
|
|
2551
|
+
}
|
|
2552
|
+
if (command === "fund" && subcommand === "verify-capital-call") {
|
|
2553
|
+
const result = await sdk.funds.verifyCapitalCall({
|
|
2554
|
+
artifactPath: getArg("artifact"),
|
|
2555
|
+
definitionPath: getArg("definition-json"),
|
|
2556
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2557
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
2558
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
2559
|
+
});
|
|
2560
|
+
printJson({
|
|
2561
|
+
summary: {
|
|
2562
|
+
ok: result.ok,
|
|
2563
|
+
reason: result.reason,
|
|
2564
|
+
callId: result.capitalCallValue.callId,
|
|
2565
|
+
status: result.capitalCallValue.status,
|
|
2566
|
+
amount: result.capitalCallValue.amount,
|
|
2567
|
+
assetId: result.capitalCallValue.currencyAssetId,
|
|
2568
|
+
},
|
|
2569
|
+
summaryText: formatFundCapitalCallSummary({
|
|
2570
|
+
phase: "verify",
|
|
2571
|
+
ok: result.ok,
|
|
2572
|
+
reason: result.reason,
|
|
2573
|
+
callId: result.capitalCallValue.callId,
|
|
2574
|
+
status: result.capitalCallValue.status,
|
|
2575
|
+
amount: result.capitalCallValue.amount,
|
|
2576
|
+
assetId: result.capitalCallValue.currencyAssetId,
|
|
2577
|
+
}),
|
|
2578
|
+
...result,
|
|
2579
|
+
});
|
|
2580
|
+
return;
|
|
2581
|
+
}
|
|
2582
|
+
if (command === "fund" && subcommand === "inspect-capital-call-claim") {
|
|
2583
|
+
const result = await sdk.funds.inspectCapitalCallClaim({
|
|
2584
|
+
artifactPath: requireArg("artifact"),
|
|
2585
|
+
definitionPath: getArg("definition-json"),
|
|
2586
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2587
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
2588
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
2589
|
+
payoutAddress: requireArg("payout-address"),
|
|
2590
|
+
positionId: getArg("position-id"),
|
|
2591
|
+
claimedAt: getArg("claimed-at"),
|
|
2592
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
2593
|
+
outputForm: parsePolicyOutputForm(),
|
|
2594
|
+
rawOutput: parseRawOutputFields(),
|
|
2595
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
2596
|
+
wallet: requireArg("wallet"),
|
|
2597
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
2598
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
2599
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
2600
|
+
});
|
|
2601
|
+
printJson({
|
|
2602
|
+
summary: {
|
|
2603
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2604
|
+
status: result.claimedCapitalCall.status,
|
|
2605
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2606
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2607
|
+
summaryHash: result.inspect.summaryHash,
|
|
2608
|
+
positionReceiptHash: result.report.receiptTrust?.positionReceiptHash ?? null,
|
|
2609
|
+
positionReceiptEnvelopeHash: result.positionReceiptEnvelope ? result.positionReceiptEnvelopeSummary?.hash ?? null : null,
|
|
2610
|
+
outputBinding: result.report.outputBindingTrust ?? null,
|
|
2611
|
+
},
|
|
2612
|
+
summaryText: formatFundCapitalCallSummary({
|
|
2613
|
+
phase: "inspect-claim",
|
|
2614
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2615
|
+
status: result.claimedCapitalCall.status,
|
|
2616
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2617
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2618
|
+
summaryHash: result.inspect.summaryHash,
|
|
2619
|
+
positionReceiptHash: result.report.receiptTrust?.positionReceiptHash,
|
|
2620
|
+
outputBinding: result.report.outputBindingTrust,
|
|
2621
|
+
}),
|
|
2622
|
+
...result,
|
|
2623
|
+
});
|
|
2624
|
+
return;
|
|
2625
|
+
}
|
|
2626
|
+
if (command === "fund" && subcommand === "execute-capital-call-claim") {
|
|
2627
|
+
const result = await sdk.funds.executeCapitalCallClaim({
|
|
2628
|
+
artifactPath: requireArg("artifact"),
|
|
2629
|
+
definitionPath: getArg("definition-json"),
|
|
2630
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2631
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
2632
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
2633
|
+
payoutAddress: requireArg("payout-address"),
|
|
2634
|
+
positionId: getArg("position-id"),
|
|
2635
|
+
claimedAt: getArg("claimed-at"),
|
|
2636
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
2637
|
+
outputForm: parsePolicyOutputForm(),
|
|
2638
|
+
rawOutput: parseRawOutputFields(),
|
|
2639
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
2640
|
+
wallet: requireArg("wallet"),
|
|
2641
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
2642
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
2643
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
2644
|
+
broadcast: hasFlag("broadcast"),
|
|
2645
|
+
});
|
|
2646
|
+
printJson({
|
|
2647
|
+
summary: {
|
|
2648
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2649
|
+
status: result.claimedCapitalCall.status,
|
|
2650
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2651
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2652
|
+
txId: result.execution.txId ?? null,
|
|
2653
|
+
broadcasted: result.execution.broadcasted,
|
|
2654
|
+
positionReceiptHash: result.report.receiptTrust?.positionReceiptHash ?? null,
|
|
2655
|
+
outputBinding: result.report.outputBindingTrust ?? null,
|
|
2656
|
+
},
|
|
2657
|
+
summaryText: formatFundCapitalCallSummary({
|
|
2658
|
+
phase: "execute-claim",
|
|
2659
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2660
|
+
status: result.claimedCapitalCall.status,
|
|
2661
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2662
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2663
|
+
txId: result.execution.txId,
|
|
2664
|
+
broadcasted: result.execution.broadcasted,
|
|
2665
|
+
positionReceiptHash: result.report.receiptTrust?.positionReceiptHash,
|
|
2666
|
+
outputBinding: result.report.outputBindingTrust,
|
|
2667
|
+
}),
|
|
2668
|
+
...result,
|
|
2669
|
+
});
|
|
2670
|
+
return;
|
|
2671
|
+
}
|
|
2672
|
+
if (command === "fund" && subcommand === "inspect-capital-call-rollover") {
|
|
2673
|
+
const result = await sdk.funds.inspectCapitalCallRollover({
|
|
2674
|
+
artifactPath: requireArg("artifact"),
|
|
2675
|
+
refundOnlyArtifactPath: requireArg("refund-only-artifact"),
|
|
2676
|
+
definitionPath: getArg("definition-json"),
|
|
2677
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2678
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
2679
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
2680
|
+
wallet: requireArg("wallet"),
|
|
2681
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
2682
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
2683
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
2684
|
+
});
|
|
2685
|
+
printJson({
|
|
2686
|
+
summary: {
|
|
2687
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2688
|
+
status: result.rolledOverCapitalCall.status,
|
|
2689
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2690
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2691
|
+
summaryHash: result.inspect.summaryHash,
|
|
2692
|
+
refundOnlyContractAddress: result.refundOnlyArtifact.compiled.contractAddress,
|
|
2693
|
+
},
|
|
2694
|
+
summaryText: formatFundCapitalCallSummary({
|
|
2695
|
+
phase: "inspect-rollover",
|
|
2696
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2697
|
+
status: result.rolledOverCapitalCall.status,
|
|
2698
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2699
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2700
|
+
summaryHash: result.inspect.summaryHash,
|
|
2701
|
+
contractAddress: result.refundOnlyArtifact.compiled.contractAddress,
|
|
2702
|
+
}),
|
|
2703
|
+
...result,
|
|
2704
|
+
});
|
|
2705
|
+
return;
|
|
2706
|
+
}
|
|
2707
|
+
if (command === "fund" && subcommand === "execute-capital-call-rollover") {
|
|
2708
|
+
const result = await sdk.funds.executeCapitalCallRollover({
|
|
2709
|
+
artifactPath: requireArg("artifact"),
|
|
2710
|
+
refundOnlyArtifactPath: requireArg("refund-only-artifact"),
|
|
2711
|
+
definitionPath: getArg("definition-json"),
|
|
2712
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2713
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
2714
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
2715
|
+
wallet: requireArg("wallet"),
|
|
2716
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
2717
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
2718
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
2719
|
+
broadcast: hasFlag("broadcast"),
|
|
2720
|
+
});
|
|
2721
|
+
printJson({
|
|
2722
|
+
summary: {
|
|
2723
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2724
|
+
status: result.rolledOverCapitalCall.status,
|
|
2725
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2726
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2727
|
+
txId: result.execution.txId ?? null,
|
|
2728
|
+
broadcasted: result.execution.broadcasted,
|
|
2729
|
+
refundOnlyContractAddress: result.refundOnlyArtifact.compiled.contractAddress,
|
|
2730
|
+
},
|
|
2731
|
+
summaryText: formatFundCapitalCallSummary({
|
|
2732
|
+
phase: "execute-rollover",
|
|
2733
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2734
|
+
status: result.rolledOverCapitalCall.status,
|
|
2735
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2736
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2737
|
+
txId: result.execution.txId,
|
|
2738
|
+
broadcasted: result.execution.broadcasted,
|
|
2739
|
+
contractAddress: result.refundOnlyArtifact.compiled.contractAddress,
|
|
2740
|
+
}),
|
|
2741
|
+
...result,
|
|
2742
|
+
});
|
|
2743
|
+
return;
|
|
2744
|
+
}
|
|
2745
|
+
if (command === "fund" && subcommand === "inspect-capital-call-refund") {
|
|
2746
|
+
const result = await sdk.funds.inspectCapitalCallRefund({
|
|
2747
|
+
artifactPath: requireArg("artifact"),
|
|
2748
|
+
definitionPath: getArg("definition-json"),
|
|
2749
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2750
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
2751
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
2752
|
+
refundAddress: requireArg("refund-address"),
|
|
2753
|
+
refundedAt: getArg("refunded-at"),
|
|
2754
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
2755
|
+
outputForm: parsePolicyOutputForm(),
|
|
2756
|
+
rawOutput: parseRawOutputFields(),
|
|
2757
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
2758
|
+
wallet: requireArg("wallet"),
|
|
2759
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
2760
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
2761
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
2762
|
+
});
|
|
2763
|
+
printJson({
|
|
2764
|
+
summary: {
|
|
2765
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2766
|
+
status: result.refundedCapitalCall.status,
|
|
2767
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2768
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2769
|
+
summaryHash: result.inspect.summaryHash,
|
|
2770
|
+
outputBinding: result.report.outputBindingTrust ?? null,
|
|
2771
|
+
},
|
|
2772
|
+
summaryText: formatFundCapitalCallSummary({
|
|
2773
|
+
phase: "inspect-refund",
|
|
2774
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2775
|
+
status: result.refundedCapitalCall.status,
|
|
2776
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2777
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2778
|
+
summaryHash: result.inspect.summaryHash,
|
|
2779
|
+
outputBinding: result.report.outputBindingTrust,
|
|
2780
|
+
}),
|
|
2781
|
+
...result,
|
|
2782
|
+
});
|
|
2783
|
+
return;
|
|
2784
|
+
}
|
|
2785
|
+
if (command === "fund" && subcommand === "execute-capital-call-refund") {
|
|
2786
|
+
const result = await sdk.funds.executeCapitalCallRefund({
|
|
2787
|
+
artifactPath: requireArg("artifact"),
|
|
2788
|
+
definitionPath: getArg("definition-json"),
|
|
2789
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2790
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
2791
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
2792
|
+
refundAddress: requireArg("refund-address"),
|
|
2793
|
+
refundedAt: getArg("refunded-at"),
|
|
2794
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
2795
|
+
outputForm: parsePolicyOutputForm(),
|
|
2796
|
+
rawOutput: parseRawOutputFields(),
|
|
2797
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
2798
|
+
wallet: requireArg("wallet"),
|
|
2799
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
2800
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
2801
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
2802
|
+
broadcast: hasFlag("broadcast"),
|
|
2803
|
+
});
|
|
2804
|
+
printJson({
|
|
2805
|
+
summary: {
|
|
2806
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2807
|
+
status: result.refundedCapitalCall.status,
|
|
2808
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2809
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2810
|
+
txId: result.execution.txId ?? null,
|
|
2811
|
+
broadcasted: result.execution.broadcasted,
|
|
2812
|
+
outputBinding: result.report.outputBindingTrust ?? null,
|
|
2813
|
+
},
|
|
2814
|
+
summaryText: formatFundCapitalCallSummary({
|
|
2815
|
+
phase: "execute-refund",
|
|
2816
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2817
|
+
status: result.refundedCapitalCall.status,
|
|
2818
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2819
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2820
|
+
txId: result.execution.txId,
|
|
2821
|
+
broadcasted: result.execution.broadcasted,
|
|
2822
|
+
outputBinding: result.report.outputBindingTrust,
|
|
2823
|
+
}),
|
|
2824
|
+
...result,
|
|
2825
|
+
});
|
|
2826
|
+
return;
|
|
2827
|
+
}
|
|
2828
|
+
if (command === "fund" && subcommand === "prepare-distribution") {
|
|
2829
|
+
const result = await sdk.funds.prepareDistribution({
|
|
2830
|
+
definitionPath: getArg("definition-json"),
|
|
2831
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2832
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
2833
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
2834
|
+
distributionPath: getArg("distribution-json"),
|
|
2835
|
+
distributionValue: getArg("distribution-value") ? JSON.parse(getArg("distribution-value")) : undefined,
|
|
2836
|
+
distributionId: getArg("distribution-id"),
|
|
2837
|
+
assetId: getArg("asset-id"),
|
|
2838
|
+
amountSat: getArg("amount-sat") ? Number(getArg("amount-sat")) : undefined,
|
|
2839
|
+
approvedAt: getArg("approved-at"),
|
|
2840
|
+
simfPath: getArg("simf"),
|
|
2841
|
+
artifactPath: getArg("artifact"),
|
|
2842
|
+
});
|
|
2843
|
+
printJson({
|
|
2844
|
+
summary: {
|
|
2845
|
+
distributionId: result.distributionValue.distributionId,
|
|
2846
|
+
positionId: result.distributionValue.positionId,
|
|
2847
|
+
amountSat: result.distributionValue.amountSat,
|
|
2848
|
+
assetId: result.distributionValue.assetId,
|
|
2849
|
+
contractAddress: result.compiled.deployment().contractAddress,
|
|
2850
|
+
},
|
|
2851
|
+
summaryText: formatFundDistributionSummary({
|
|
2852
|
+
phase: "prepare",
|
|
2853
|
+
distributionId: result.distributionValue.distributionId,
|
|
2854
|
+
positionId: result.distributionValue.positionId,
|
|
2855
|
+
amountSat: result.distributionValue.amountSat,
|
|
2856
|
+
assetId: result.distributionValue.assetId,
|
|
2857
|
+
contractAddress: result.compiled.deployment().contractAddress,
|
|
2858
|
+
}),
|
|
2859
|
+
...result,
|
|
2860
|
+
});
|
|
2861
|
+
return;
|
|
2862
|
+
}
|
|
2863
|
+
if (command === "fund" && subcommand === "sign-position-receipt") {
|
|
2864
|
+
const result = await sdk.funds.signPositionReceipt({
|
|
2865
|
+
definitionPath: getArg("definition-json"),
|
|
2866
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2867
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
2868
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
2869
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
2870
|
+
signedAt: getArg("signed-at"),
|
|
2871
|
+
});
|
|
2872
|
+
printJson({
|
|
2873
|
+
summary: {
|
|
2874
|
+
positionId: result.positionReceiptValue.positionId,
|
|
2875
|
+
sequence: result.positionReceiptEnvelope.receipt.sequence,
|
|
2876
|
+
receiptHash: result.positionReceiptSummary.hash,
|
|
2877
|
+
envelopeHash: result.positionReceiptEnvelopeSummary.hash,
|
|
2878
|
+
},
|
|
2879
|
+
summaryText: [
|
|
2880
|
+
`positionId=${result.positionReceiptValue.positionId}`,
|
|
2881
|
+
`sequence=${result.positionReceiptEnvelope.receipt.sequence}`,
|
|
2882
|
+
`receiptHash=${result.positionReceiptSummary.hash}`,
|
|
2883
|
+
`envelopeHash=${result.positionReceiptEnvelopeSummary.hash}`,
|
|
2884
|
+
].join("\n"),
|
|
2885
|
+
...result,
|
|
661
2886
|
});
|
|
662
|
-
printJson(result);
|
|
663
2887
|
return;
|
|
664
2888
|
}
|
|
665
|
-
if (command === "
|
|
666
|
-
const
|
|
2889
|
+
if (command === "fund" && subcommand === "verify-position-receipt") {
|
|
2890
|
+
const positionReceiptChainPaths = getMultiArgs("position-receipt-chain-json");
|
|
2891
|
+
const positionReceiptChainValues = getMultiArgs("position-receipt-chain-value").map((value) => JSON.parse(value));
|
|
2892
|
+
const result = await sdk.funds.verifyPositionReceipt({
|
|
667
2893
|
definitionPath: getArg("definition-json"),
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
2894
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2895
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
2896
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
2897
|
+
previousPositionReceiptPath: getArg("previous-position-receipt-json"),
|
|
2898
|
+
previousPositionReceiptValue: getArg("previous-position-receipt-value")
|
|
2899
|
+
? JSON.parse(getArg("previous-position-receipt-value"))
|
|
2900
|
+
: undefined,
|
|
2901
|
+
positionReceiptChainPaths: positionReceiptChainPaths.length > 0 ? positionReceiptChainPaths : undefined,
|
|
2902
|
+
positionReceiptChainValues: positionReceiptChainValues.length > 0 ? positionReceiptChainValues : undefined,
|
|
671
2903
|
});
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
2904
|
+
printJson({
|
|
2905
|
+
summary: {
|
|
2906
|
+
verified: result.verified,
|
|
2907
|
+
positionId: result.positionReceiptValue.receipt.positionId,
|
|
2908
|
+
sequence: result.positionReceiptValue.receipt.sequence,
|
|
2909
|
+
receiptHash: result.positionReceiptSummary.hash,
|
|
2910
|
+
envelopeHash: result.positionReceiptEnvelopeSummary.hash,
|
|
2911
|
+
continuityVerified: result.report.receiptTrust?.continuityVerified ?? null,
|
|
2912
|
+
lineageKind: result.report.receiptChainTrust?.lineageKind ?? null,
|
|
2913
|
+
latestOrdinal: result.report.receiptChainTrust?.latestOrdinal ?? null,
|
|
2914
|
+
allHashLinksVerified: result.report.receiptChainTrust?.allHashLinksVerified ?? null,
|
|
2915
|
+
identityConsistent: result.report.receiptChainTrust?.identityConsistent ?? null,
|
|
2916
|
+
fullLineageVerified: result.report.receiptChainTrust?.fullLineageVerified ?? null,
|
|
2917
|
+
chainLength: result.report.receiptChainTrust?.chainLength ?? null,
|
|
2918
|
+
fullChainVerified: result.report.receiptChainTrust?.fullChainVerified ?? null,
|
|
2919
|
+
},
|
|
2920
|
+
summaryText: [
|
|
2921
|
+
`verified=${result.verified}`,
|
|
2922
|
+
`positionId=${result.positionReceiptValue.receipt.positionId}`,
|
|
2923
|
+
`sequence=${result.positionReceiptValue.receipt.sequence}`,
|
|
2924
|
+
`receiptHash=${result.positionReceiptSummary.hash}`,
|
|
2925
|
+
`envelopeHash=${result.positionReceiptEnvelopeSummary.hash}`,
|
|
2926
|
+
`continuityVerified=${result.report.receiptTrust?.continuityVerified ?? false}`,
|
|
2927
|
+
`lineageKind=${result.report.receiptChainTrust?.lineageKind ?? "receipt-chain"}`,
|
|
2928
|
+
`latestOrdinal=${result.report.receiptChainTrust?.latestOrdinal ?? result.positionReceiptValue.receipt.sequence}`,
|
|
2929
|
+
`allHashLinksVerified=${result.report.receiptChainTrust?.allHashLinksVerified ?? false}`,
|
|
2930
|
+
`identityConsistent=${result.report.receiptChainTrust?.identityConsistent ?? false}`,
|
|
2931
|
+
`fullLineageVerified=${result.report.receiptChainTrust?.fullLineageVerified ?? false}`,
|
|
2932
|
+
`chainLength=${result.report.receiptChainTrust?.chainLength ?? 0}`,
|
|
2933
|
+
`fullChainVerified=${result.report.receiptChainTrust?.fullChainVerified ?? false}`,
|
|
2934
|
+
].join("\n"),
|
|
2935
|
+
...result,
|
|
2936
|
+
});
|
|
2937
|
+
return;
|
|
2938
|
+
}
|
|
2939
|
+
if (command === "fund" && subcommand === "verify-position-receipt-chain") {
|
|
2940
|
+
const positionReceiptChainPaths = getMultiArgs("position-receipt-chain-json");
|
|
2941
|
+
const positionReceiptChainValues = getMultiArgs("position-receipt-chain-value").map((value) => JSON.parse(value));
|
|
2942
|
+
const result = await sdk.funds.verifyPositionReceiptChain({
|
|
679
2943
|
definitionPath: getArg("definition-json"),
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
2944
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2945
|
+
positionReceiptChainPaths: positionReceiptChainPaths.length > 0 ? positionReceiptChainPaths : undefined,
|
|
2946
|
+
positionReceiptChainValues: positionReceiptChainValues.length > 0 ? positionReceiptChainValues : undefined,
|
|
2947
|
+
});
|
|
2948
|
+
printJson({
|
|
2949
|
+
summary: {
|
|
2950
|
+
verified: result.verified,
|
|
2951
|
+
positionId: result.positionReceiptValue.receipt.positionId,
|
|
2952
|
+
chainLength: result.report.receiptChainTrust?.chainLength ?? 0,
|
|
2953
|
+
latestSequence: result.report.receiptChainTrust?.latestSequence ?? null,
|
|
2954
|
+
latestOrdinal: result.report.receiptChainTrust?.latestOrdinal ?? null,
|
|
2955
|
+
startsAtGenesis: result.report.receiptChainTrust?.startsAtGenesis ?? false,
|
|
2956
|
+
allHashLinksVerified: result.report.receiptChainTrust?.allHashLinksVerified ?? false,
|
|
2957
|
+
identityConsistent: result.report.receiptChainTrust?.identityConsistent ?? false,
|
|
2958
|
+
fullLineageVerified: result.report.receiptChainTrust?.fullLineageVerified ?? false,
|
|
2959
|
+
fullChainVerified: result.report.receiptChainTrust?.fullChainVerified ?? false,
|
|
2960
|
+
},
|
|
2961
|
+
summaryText: formatFundReceiptChainSummary({
|
|
2962
|
+
verified: result.verified,
|
|
2963
|
+
positionId: result.positionReceiptValue.receipt.positionId,
|
|
2964
|
+
chainLength: result.report.receiptChainTrust?.chainLength ?? 0,
|
|
2965
|
+
latestSequence: result.report.receiptChainTrust?.latestSequence ?? null,
|
|
2966
|
+
latestOrdinal: result.report.receiptChainTrust?.latestOrdinal ?? null,
|
|
2967
|
+
startsAtGenesis: result.report.receiptChainTrust?.startsAtGenesis ?? false,
|
|
2968
|
+
allHashLinksVerified: result.report.receiptChainTrust?.allHashLinksVerified ?? false,
|
|
2969
|
+
identityConsistent: result.report.receiptChainTrust?.identityConsistent ?? false,
|
|
2970
|
+
fullLineageVerified: result.report.receiptChainTrust?.fullLineageVerified ?? false,
|
|
2971
|
+
fullChainVerified: result.report.receiptChainTrust?.fullChainVerified ?? false,
|
|
2972
|
+
}),
|
|
2973
|
+
...result,
|
|
2974
|
+
});
|
|
2975
|
+
return;
|
|
2976
|
+
}
|
|
2977
|
+
if (command === "fund" && subcommand === "reconcile-position") {
|
|
2978
|
+
const distributionJsons = getMultiArgs("distribution-json");
|
|
2979
|
+
const distributionValues = getMultiArgs("distribution-value").map((value) => JSON.parse(value));
|
|
2980
|
+
const result = await sdk.funds.reconcilePosition({
|
|
2981
|
+
definitionPath: getArg("definition-json"),
|
|
2982
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2983
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
2984
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
2985
|
+
distributionPaths: distributionJsons.length > 0 ? distributionJsons : undefined,
|
|
2986
|
+
distributionValues: distributionValues.length > 0 ? distributionValues : undefined,
|
|
2987
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
2988
|
+
signedAt: getArg("signed-at"),
|
|
2989
|
+
});
|
|
2990
|
+
printJson({
|
|
2991
|
+
summary: {
|
|
2992
|
+
positionId: result.reconciledReceiptValue.positionId,
|
|
2993
|
+
distributionCount: result.distributionCount,
|
|
2994
|
+
distributedAmount: result.totalDistributedAmount,
|
|
2995
|
+
fundedAmount: result.reconciledReceiptValue.fundedAmount,
|
|
2996
|
+
status: result.reconciledReceiptValue.status,
|
|
2997
|
+
receiptHash: result.reconciledReceiptSummary.hash,
|
|
2998
|
+
sequence: result.reconciledReceiptValue.sequence,
|
|
2999
|
+
envelopeHash: result.reconciledReceiptEnvelopeSummary.hash,
|
|
3000
|
+
},
|
|
3001
|
+
summaryText: formatFundReceiptReconcileSummary({
|
|
3002
|
+
positionId: result.reconciledReceiptValue.positionId,
|
|
3003
|
+
distributionCount: result.distributionCount,
|
|
3004
|
+
distributedAmount: result.totalDistributedAmount,
|
|
3005
|
+
fundedAmount: result.reconciledReceiptValue.fundedAmount,
|
|
3006
|
+
status: result.reconciledReceiptValue.status,
|
|
3007
|
+
receiptHash: result.reconciledReceiptSummary.hash,
|
|
3008
|
+
sequence: result.reconciledReceiptValue.sequence,
|
|
3009
|
+
envelopeHash: result.reconciledReceiptEnvelopeSummary.hash,
|
|
3010
|
+
}),
|
|
3011
|
+
...result,
|
|
3012
|
+
});
|
|
3013
|
+
return;
|
|
3014
|
+
}
|
|
3015
|
+
if (command === "fund" && subcommand === "verify-distribution") {
|
|
3016
|
+
const result = await sdk.funds.verifyDistribution({
|
|
684
3017
|
artifactPath: getArg("artifact"),
|
|
3018
|
+
definitionPath: getArg("definition-json"),
|
|
3019
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
3020
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
3021
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
3022
|
+
distributionPath: getArg("distribution-json"),
|
|
3023
|
+
distributionValue: getArg("distribution-value") ? JSON.parse(getArg("distribution-value")) : undefined,
|
|
685
3024
|
});
|
|
686
3025
|
printJson({
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
3026
|
+
summary: {
|
|
3027
|
+
ok: result.ok,
|
|
3028
|
+
reason: result.reason,
|
|
3029
|
+
distributionId: result.distributionValue.distributionId,
|
|
3030
|
+
positionId: result.distributionValue.positionId,
|
|
3031
|
+
amountSat: result.distributionValue.amountSat,
|
|
3032
|
+
assetId: result.distributionValue.assetId,
|
|
3033
|
+
},
|
|
3034
|
+
summaryText: formatFundDistributionSummary({
|
|
3035
|
+
phase: "verify",
|
|
3036
|
+
ok: result.ok,
|
|
3037
|
+
reason: result.reason,
|
|
3038
|
+
distributionId: result.distributionValue.distributionId,
|
|
3039
|
+
positionId: result.distributionValue.positionId,
|
|
3040
|
+
amountSat: result.distributionValue.amountSat,
|
|
3041
|
+
assetId: result.distributionValue.assetId,
|
|
3042
|
+
}),
|
|
3043
|
+
...result,
|
|
694
3044
|
});
|
|
695
3045
|
return;
|
|
696
3046
|
}
|
|
697
|
-
if (command === "
|
|
698
|
-
const result = await sdk.
|
|
699
|
-
|
|
700
|
-
|
|
3047
|
+
if (command === "fund" && subcommand === "inspect-distribution-claim") {
|
|
3048
|
+
const result = await sdk.funds.inspectDistributionClaim({
|
|
3049
|
+
artifactPath: requireArg("artifact"),
|
|
3050
|
+
definitionPath: getArg("definition-json"),
|
|
3051
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
3052
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
3053
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
3054
|
+
distributionPath: getArg("distribution-json"),
|
|
3055
|
+
distributionValue: getArg("distribution-value") ? JSON.parse(getArg("distribution-value")) : undefined,
|
|
3056
|
+
payoutAddress: requireArg("payout-address"),
|
|
3057
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
3058
|
+
outputForm: parsePolicyOutputForm(),
|
|
3059
|
+
rawOutput: parseRawOutputFields(),
|
|
3060
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
3061
|
+
wallet: requireArg("wallet"),
|
|
3062
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
3063
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
3064
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
3065
|
+
});
|
|
3066
|
+
printJson({
|
|
3067
|
+
summary: {
|
|
3068
|
+
distributionId: result.verified.distributionValue.distributionId,
|
|
3069
|
+
positionId: result.verified.distributionValue.positionId,
|
|
3070
|
+
amountSat: result.verified.distributionValue.amountSat,
|
|
3071
|
+
assetId: result.verified.distributionValue.assetId,
|
|
3072
|
+
summaryHash: result.inspect.summaryHash,
|
|
3073
|
+
outputBinding: result.report.outputBindingTrust ?? null,
|
|
3074
|
+
},
|
|
3075
|
+
summaryText: formatFundDistributionSummary({
|
|
3076
|
+
phase: "inspect-claim",
|
|
3077
|
+
distributionId: result.verified.distributionValue.distributionId,
|
|
3078
|
+
positionId: result.verified.distributionValue.positionId,
|
|
3079
|
+
amountSat: result.verified.distributionValue.amountSat,
|
|
3080
|
+
assetId: result.verified.distributionValue.assetId,
|
|
3081
|
+
summaryHash: result.inspect.summaryHash,
|
|
3082
|
+
outputBinding: result.report.outputBindingTrust,
|
|
3083
|
+
}),
|
|
3084
|
+
...result,
|
|
701
3085
|
});
|
|
702
|
-
printJson(result);
|
|
703
3086
|
return;
|
|
704
3087
|
}
|
|
705
|
-
if (command === "
|
|
706
|
-
const result = await sdk.
|
|
3088
|
+
if (command === "fund" && subcommand === "execute-distribution-claim") {
|
|
3089
|
+
const result = await sdk.funds.executeDistributionClaim({
|
|
3090
|
+
artifactPath: requireArg("artifact"),
|
|
707
3091
|
definitionPath: getArg("definition-json"),
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
3092
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
3093
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
3094
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
3095
|
+
distributionPath: getArg("distribution-json"),
|
|
3096
|
+
distributionValue: getArg("distribution-value") ? JSON.parse(getArg("distribution-value")) : undefined,
|
|
3097
|
+
payoutAddress: requireArg("payout-address"),
|
|
3098
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
3099
|
+
outputForm: parsePolicyOutputForm(),
|
|
3100
|
+
rawOutput: parseRawOutputFields(),
|
|
3101
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
3102
|
+
wallet: requireArg("wallet"),
|
|
3103
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
3104
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
3105
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
3106
|
+
broadcast: hasFlag("broadcast"),
|
|
712
3107
|
});
|
|
713
3108
|
printJson({
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
3109
|
+
summary: {
|
|
3110
|
+
distributionId: result.verified.distributionValue.distributionId,
|
|
3111
|
+
positionId: result.verified.distributionValue.positionId,
|
|
3112
|
+
amountSat: result.verified.distributionValue.amountSat,
|
|
3113
|
+
assetId: result.verified.distributionValue.assetId,
|
|
3114
|
+
txId: result.execution.txId ?? null,
|
|
3115
|
+
broadcasted: result.execution.broadcasted,
|
|
3116
|
+
outputBinding: result.report.outputBindingTrust ?? null,
|
|
3117
|
+
},
|
|
3118
|
+
summaryText: formatFundDistributionSummary({
|
|
3119
|
+
phase: "execute-claim",
|
|
3120
|
+
distributionId: result.verified.distributionValue.distributionId,
|
|
3121
|
+
positionId: result.verified.distributionValue.positionId,
|
|
3122
|
+
amountSat: result.verified.distributionValue.amountSat,
|
|
3123
|
+
assetId: result.verified.distributionValue.assetId,
|
|
3124
|
+
txId: result.execution.txId,
|
|
3125
|
+
broadcasted: result.execution.broadcasted,
|
|
3126
|
+
outputBinding: result.report.outputBindingTrust,
|
|
3127
|
+
}),
|
|
3128
|
+
...result,
|
|
720
3129
|
});
|
|
721
3130
|
return;
|
|
722
3131
|
}
|
|
723
|
-
if (command === "
|
|
724
|
-
const
|
|
3132
|
+
if (command === "fund" && subcommand === "prepare-closing") {
|
|
3133
|
+
const positionReceiptChainPaths = getMultiArgs("position-receipt-chain-json");
|
|
3134
|
+
const positionReceiptChainValues = getMultiArgs("position-receipt-chain-value").map((value) => JSON.parse(value));
|
|
3135
|
+
const result = await sdk.funds.prepareClosing({
|
|
725
3136
|
definitionPath: getArg("definition-json"),
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
3137
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
3138
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
3139
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
3140
|
+
previousPositionReceiptPath: getArg("previous-position-receipt-json"),
|
|
3141
|
+
previousPositionReceiptValue: getArg("previous-position-receipt-value")
|
|
3142
|
+
? JSON.parse(getArg("previous-position-receipt-value"))
|
|
3143
|
+
: undefined,
|
|
3144
|
+
positionReceiptChainPaths: positionReceiptChainPaths.length > 0 ? positionReceiptChainPaths : undefined,
|
|
3145
|
+
positionReceiptChainValues: positionReceiptChainValues.length > 0 ? positionReceiptChainValues : undefined,
|
|
3146
|
+
closingPath: getArg("closing-json"),
|
|
3147
|
+
closingValue: getArg("closing-value") ? JSON.parse(getArg("closing-value")) : undefined,
|
|
3148
|
+
closingId: getArg("closing-id"),
|
|
3149
|
+
finalDistributionHashes: getMultiArgs("final-distribution-hash"),
|
|
3150
|
+
closedAt: getArg("closed-at"),
|
|
3151
|
+
closingReason: getArg("closing-reason"),
|
|
3152
|
+
});
|
|
3153
|
+
printJson({
|
|
3154
|
+
summary: {
|
|
3155
|
+
closingHash: result.closingHash,
|
|
3156
|
+
closedAt: result.closingValue.closedAt,
|
|
3157
|
+
closingReason: result.closingValue.closingReason,
|
|
3158
|
+
positionId: result.closingValue.positionId,
|
|
3159
|
+
distributionCount: result.closingValue.finalDistributionHashes.length,
|
|
3160
|
+
continuityVerified: result.report.receiptTrust?.continuityVerified ?? null,
|
|
3161
|
+
lineageKind: result.report.receiptChainTrust?.lineageKind ?? null,
|
|
3162
|
+
latestOrdinal: result.report.receiptChainTrust?.latestOrdinal ?? null,
|
|
3163
|
+
allHashLinksVerified: result.report.receiptChainTrust?.allHashLinksVerified ?? null,
|
|
3164
|
+
identityConsistent: result.report.receiptChainTrust?.identityConsistent ?? null,
|
|
3165
|
+
fullLineageVerified: result.report.receiptChainTrust?.fullLineageVerified ?? null,
|
|
3166
|
+
fullChainVerified: result.report.receiptChainTrust?.fullChainVerified ?? null,
|
|
3167
|
+
},
|
|
3168
|
+
summaryText: formatFundClosingSummary({
|
|
3169
|
+
closingHash: result.closingHash,
|
|
3170
|
+
closedAt: result.closingValue.closedAt,
|
|
3171
|
+
closingReason: result.closingValue.closingReason,
|
|
3172
|
+
positionId: result.closingValue.positionId,
|
|
3173
|
+
distributionCount: result.closingValue.finalDistributionHashes.length,
|
|
3174
|
+
continuityVerified: result.report.receiptTrust?.continuityVerified ?? false,
|
|
3175
|
+
lineageKind: result.report.receiptChainTrust?.lineageKind ?? null,
|
|
3176
|
+
latestOrdinal: result.report.receiptChainTrust?.latestOrdinal ?? null,
|
|
3177
|
+
allHashLinksVerified: result.report.receiptChainTrust?.allHashLinksVerified ?? null,
|
|
3178
|
+
identityConsistent: result.report.receiptChainTrust?.identityConsistent ?? null,
|
|
3179
|
+
fullLineageVerified: result.report.receiptChainTrust?.fullLineageVerified ?? null,
|
|
3180
|
+
fullChainVerified: result.report.receiptChainTrust?.fullChainVerified ?? false,
|
|
3181
|
+
}),
|
|
3182
|
+
...result,
|
|
3183
|
+
});
|
|
3184
|
+
return;
|
|
3185
|
+
}
|
|
3186
|
+
if (command === "fund" && subcommand === "verify-closing") {
|
|
3187
|
+
const positionReceiptChainPaths = getMultiArgs("position-receipt-chain-json");
|
|
3188
|
+
const positionReceiptChainValues = getMultiArgs("position-receipt-chain-value").map((value) => JSON.parse(value));
|
|
3189
|
+
const result = await sdk.funds.verifyClosing({
|
|
3190
|
+
definitionPath: getArg("definition-json"),
|
|
3191
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
3192
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
3193
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
3194
|
+
previousPositionReceiptPath: getArg("previous-position-receipt-json"),
|
|
3195
|
+
previousPositionReceiptValue: getArg("previous-position-receipt-value")
|
|
3196
|
+
? JSON.parse(getArg("previous-position-receipt-value"))
|
|
3197
|
+
: undefined,
|
|
3198
|
+
positionReceiptChainPaths: positionReceiptChainPaths.length > 0 ? positionReceiptChainPaths : undefined,
|
|
3199
|
+
positionReceiptChainValues: positionReceiptChainValues.length > 0 ? positionReceiptChainValues : undefined,
|
|
3200
|
+
closingPath: getArg("closing-json"),
|
|
3201
|
+
closingValue: getArg("closing-value") ? JSON.parse(getArg("closing-value")) : undefined,
|
|
3202
|
+
});
|
|
3203
|
+
printJson({
|
|
3204
|
+
summary: {
|
|
3205
|
+
verified: result.verified,
|
|
3206
|
+
closingHash: result.closingSummary.hash,
|
|
3207
|
+
closedAt: result.closingValue.closedAt,
|
|
3208
|
+
closingReason: result.closingValue.closingReason,
|
|
3209
|
+
positionId: result.closingValue.positionId,
|
|
3210
|
+
distributionCount: result.closingValue.finalDistributionHashes.length,
|
|
3211
|
+
continuityVerified: result.report.receiptTrust?.continuityVerified ?? null,
|
|
3212
|
+
lineageKind: result.report.receiptChainTrust?.lineageKind ?? null,
|
|
3213
|
+
latestOrdinal: result.report.receiptChainTrust?.latestOrdinal ?? null,
|
|
3214
|
+
allHashLinksVerified: result.report.receiptChainTrust?.allHashLinksVerified ?? null,
|
|
3215
|
+
identityConsistent: result.report.receiptChainTrust?.identityConsistent ?? null,
|
|
3216
|
+
fullLineageVerified: result.report.receiptChainTrust?.fullLineageVerified ?? null,
|
|
3217
|
+
fullChainVerified: result.report.receiptChainTrust?.fullChainVerified ?? null,
|
|
3218
|
+
},
|
|
3219
|
+
summaryText: formatFundClosingSummary({
|
|
3220
|
+
ok: result.verified,
|
|
3221
|
+
closingHash: result.closingSummary.hash,
|
|
3222
|
+
closedAt: result.closingValue.closedAt,
|
|
3223
|
+
closingReason: result.closingValue.closingReason,
|
|
3224
|
+
positionId: result.closingValue.positionId,
|
|
3225
|
+
distributionCount: result.closingValue.finalDistributionHashes.length,
|
|
3226
|
+
continuityVerified: result.report.receiptTrust?.continuityVerified ?? false,
|
|
3227
|
+
lineageKind: result.report.receiptChainTrust?.lineageKind ?? null,
|
|
3228
|
+
latestOrdinal: result.report.receiptChainTrust?.latestOrdinal ?? null,
|
|
3229
|
+
allHashLinksVerified: result.report.receiptChainTrust?.allHashLinksVerified ?? null,
|
|
3230
|
+
identityConsistent: result.report.receiptChainTrust?.identityConsistent ?? null,
|
|
3231
|
+
fullLineageVerified: result.report.receiptChainTrust?.fullLineageVerified ?? null,
|
|
3232
|
+
fullChainVerified: result.report.receiptChainTrust?.fullChainVerified ?? false,
|
|
3233
|
+
}),
|
|
3234
|
+
...result,
|
|
3235
|
+
});
|
|
3236
|
+
return;
|
|
3237
|
+
}
|
|
3238
|
+
if (command === "fund" && subcommand === "export-evidence") {
|
|
3239
|
+
const positionReceiptChainPaths = getMultiArgs("position-receipt-chain-json");
|
|
3240
|
+
const positionReceiptChainValues = getMultiArgs("position-receipt-chain-value").map((value) => JSON.parse(value));
|
|
3241
|
+
const result = await sdk.funds.exportEvidence({
|
|
732
3242
|
artifactPath: getArg("artifact"),
|
|
3243
|
+
definitionPath: getArg("definition-json"),
|
|
3244
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
3245
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
3246
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
3247
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
3248
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
3249
|
+
previousPositionReceiptPath: getArg("previous-position-receipt-json"),
|
|
3250
|
+
previousPositionReceiptValue: getArg("previous-position-receipt-value")
|
|
3251
|
+
? JSON.parse(getArg("previous-position-receipt-value"))
|
|
3252
|
+
: undefined,
|
|
3253
|
+
positionReceiptChainPaths: positionReceiptChainPaths.length > 0 ? positionReceiptChainPaths : undefined,
|
|
3254
|
+
positionReceiptChainValues: positionReceiptChainValues.length > 0 ? positionReceiptChainValues : undefined,
|
|
3255
|
+
distributionPath: getArg("distribution-json"),
|
|
3256
|
+
distributionValue: getArg("distribution-value") ? JSON.parse(getArg("distribution-value")) : undefined,
|
|
3257
|
+
closingPath: getArg("closing-json"),
|
|
3258
|
+
closingValue: getArg("closing-value") ? JSON.parse(getArg("closing-value")) : undefined,
|
|
3259
|
+
verificationReportValue: getArg("verification-report-value") ? JSON.parse(getArg("verification-report-value")) : undefined,
|
|
733
3260
|
});
|
|
734
3261
|
printJson({
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
3262
|
+
summary: {
|
|
3263
|
+
definitionHash: result.definition.hash,
|
|
3264
|
+
capitalCallHash: result.capitalCall?.hash ?? null,
|
|
3265
|
+
positionReceiptHash: result.positionReceipt?.hash ?? null,
|
|
3266
|
+
distributionHash: result.distribution?.hash ?? null,
|
|
3267
|
+
closingHash: result.closing?.hash ?? null,
|
|
3268
|
+
sourceVerificationMode: result.sourceVerificationMode,
|
|
3269
|
+
lineageKind: result.trust.receiptChainTrust?.lineageKind ?? null,
|
|
3270
|
+
latestOrdinal: result.trust.receiptChainTrust?.latestOrdinal ?? null,
|
|
3271
|
+
allHashLinksVerified: result.trust.receiptChainTrust?.allHashLinksVerified ?? null,
|
|
3272
|
+
identityConsistent: result.trust.receiptChainTrust?.identityConsistent ?? null,
|
|
3273
|
+
fullLineageVerified: result.trust.receiptChainTrust?.fullLineageVerified ?? null,
|
|
3274
|
+
fullChainVerified: result.trust.receiptChainTrust?.fullChainVerified ?? null,
|
|
3275
|
+
},
|
|
3276
|
+
summaryText: formatFundEvidenceSummary({
|
|
3277
|
+
definitionHash: result.definition.hash,
|
|
3278
|
+
capitalCallHash: result.capitalCall?.hash ?? null,
|
|
3279
|
+
positionReceiptHash: result.positionReceipt?.hash ?? null,
|
|
3280
|
+
positionReceiptEnvelopeHash: result.positionReceiptEnvelope?.hash ?? null,
|
|
3281
|
+
distributionHash: result.distribution?.hash ?? null,
|
|
3282
|
+
closingHash: result.closing?.hash ?? null,
|
|
3283
|
+
sourceVerificationMode: result.sourceVerificationMode,
|
|
3284
|
+
lineageKind: result.trust.receiptChainTrust?.lineageKind ?? null,
|
|
3285
|
+
latestOrdinal: result.trust.receiptChainTrust?.latestOrdinal ?? null,
|
|
3286
|
+
allHashLinksVerified: result.trust.receiptChainTrust?.allHashLinksVerified ?? null,
|
|
3287
|
+
identityConsistent: result.trust.receiptChainTrust?.identityConsistent ?? null,
|
|
3288
|
+
fullLineageVerified: result.trust.receiptChainTrust?.fullLineageVerified ?? null,
|
|
3289
|
+
fullChainVerified: result.trust.receiptChainTrust?.fullChainVerified ?? null,
|
|
3290
|
+
}),
|
|
3291
|
+
...result,
|
|
747
3292
|
});
|
|
748
3293
|
return;
|
|
749
3294
|
}
|
|
750
|
-
if (command === "
|
|
751
|
-
const
|
|
752
|
-
|
|
3295
|
+
if (command === "fund" && subcommand === "export-finality-payload") {
|
|
3296
|
+
const positionReceiptChainPaths = getMultiArgs("position-receipt-chain-json");
|
|
3297
|
+
const positionReceiptChainValues = getMultiArgs("position-receipt-chain-value").map((value) => JSON.parse(value));
|
|
3298
|
+
const result = await sdk.funds.exportFinalityPayload({
|
|
3299
|
+
artifactPath: getArg("artifact"),
|
|
753
3300
|
definitionPath: getArg("definition-json"),
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
3301
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
3302
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
3303
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
3304
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
3305
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
3306
|
+
previousPositionReceiptPath: getArg("previous-position-receipt-json"),
|
|
3307
|
+
previousPositionReceiptValue: getArg("previous-position-receipt-value")
|
|
3308
|
+
? JSON.parse(getArg("previous-position-receipt-value"))
|
|
3309
|
+
: undefined,
|
|
3310
|
+
positionReceiptChainPaths: positionReceiptChainPaths.length > 0 ? positionReceiptChainPaths : undefined,
|
|
3311
|
+
positionReceiptChainValues: positionReceiptChainValues.length > 0 ? positionReceiptChainValues : undefined,
|
|
3312
|
+
distributionPath: getArg("distribution-json"),
|
|
3313
|
+
distributionValue: getArg("distribution-value") ? JSON.parse(getArg("distribution-value")) : undefined,
|
|
3314
|
+
closingPath: getArg("closing-json"),
|
|
3315
|
+
closingValue: getArg("closing-value") ? JSON.parse(getArg("closing-value")) : undefined,
|
|
3316
|
+
verificationReportValue: getArg("verification-report-value") ? JSON.parse(getArg("verification-report-value")) : undefined,
|
|
3317
|
+
});
|
|
3318
|
+
printJson({
|
|
3319
|
+
summary: {
|
|
3320
|
+
fundId: result.fundId,
|
|
3321
|
+
lpId: result.lpId,
|
|
3322
|
+
callId: result.callId ?? null,
|
|
3323
|
+
positionId: result.positionId ?? null,
|
|
3324
|
+
definitionHash: result.definitionHash,
|
|
3325
|
+
capitalCallStateHash: result.capitalCallStateHash ?? null,
|
|
3326
|
+
positionReceiptHash: result.positionReceiptHash ?? null,
|
|
3327
|
+
distributionHash: result.distributionHash ?? null,
|
|
3328
|
+
closingHash: result.closingHash ?? null,
|
|
3329
|
+
bindingMode: result.bindingMode,
|
|
3330
|
+
lineageKind: result.trust.receiptChainTrust?.lineageKind ?? null,
|
|
3331
|
+
latestOrdinal: result.trust.receiptChainTrust?.latestOrdinal ?? null,
|
|
3332
|
+
allHashLinksVerified: result.trust.receiptChainTrust?.allHashLinksVerified ?? null,
|
|
3333
|
+
identityConsistent: result.trust.receiptChainTrust?.identityConsistent ?? null,
|
|
3334
|
+
fullLineageVerified: result.trust.receiptChainTrust?.fullLineageVerified ?? null,
|
|
3335
|
+
fullChainVerified: result.trust.receiptChainTrust?.fullChainVerified ?? null,
|
|
3336
|
+
},
|
|
3337
|
+
summaryText: formatFundFinalitySummary({
|
|
3338
|
+
fundId: result.fundId,
|
|
3339
|
+
lpId: result.lpId,
|
|
3340
|
+
callId: result.callId,
|
|
3341
|
+
positionId: result.positionId,
|
|
3342
|
+
definitionHash: result.definitionHash,
|
|
3343
|
+
capitalCallStateHash: result.capitalCallStateHash,
|
|
3344
|
+
positionReceiptHash: result.positionReceiptHash,
|
|
3345
|
+
positionReceiptEnvelopeHash: result.positionReceiptEnvelopeHash,
|
|
3346
|
+
distributionHash: result.distributionHash,
|
|
3347
|
+
closingHash: result.closingHash,
|
|
3348
|
+
bindingMode: result.bindingMode,
|
|
3349
|
+
lineageKind: result.trust.receiptChainTrust?.lineageKind ?? null,
|
|
3350
|
+
latestOrdinal: result.trust.receiptChainTrust?.latestOrdinal ?? null,
|
|
3351
|
+
allHashLinksVerified: result.trust.receiptChainTrust?.allHashLinksVerified ?? null,
|
|
3352
|
+
identityConsistent: result.trust.receiptChainTrust?.identityConsistent ?? null,
|
|
3353
|
+
fullLineageVerified: result.trust.receiptChainTrust?.fullLineageVerified ?? null,
|
|
3354
|
+
fullChainVerified: result.trust.receiptChainTrust?.fullChainVerified ?? null,
|
|
3355
|
+
}),
|
|
3356
|
+
...result,
|
|
759
3357
|
});
|
|
760
|
-
printJson(result);
|
|
761
3358
|
return;
|
|
762
3359
|
}
|
|
763
|
-
if (command === "
|
|
764
|
-
const result = await sdk.
|
|
3360
|
+
if (command === "receivable" && subcommand === "define") {
|
|
3361
|
+
const result = await sdk.receivables.define({
|
|
765
3362
|
definitionPath: getArg("definition-json"),
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
3363
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3364
|
+
});
|
|
3365
|
+
printJson({
|
|
3366
|
+
summaryText: formatReceivableDefinitionSummary({
|
|
3367
|
+
ok: result.ok,
|
|
3368
|
+
receivableId: result.definitionValue.receivableId,
|
|
3369
|
+
originatorEntityId: result.definitionValue.originatorEntityId,
|
|
3370
|
+
debtorEntityId: result.definitionValue.debtorEntityId,
|
|
3371
|
+
currencyAssetId: result.definitionValue.currencyAssetId,
|
|
3372
|
+
faceValue: result.definitionValue.faceValue,
|
|
3373
|
+
dueDate: result.definitionValue.dueDate,
|
|
3374
|
+
}),
|
|
3375
|
+
...result,
|
|
771
3376
|
});
|
|
772
|
-
printJson(result);
|
|
773
3377
|
return;
|
|
774
3378
|
}
|
|
775
|
-
if (command === "
|
|
776
|
-
const result = await sdk.
|
|
777
|
-
descriptorPath: getArg("descriptor-json"),
|
|
3379
|
+
if (command === "receivable" && subcommand === "verify") {
|
|
3380
|
+
const result = await sdk.receivables.verify({
|
|
778
3381
|
definitionPath: getArg("definition-json"),
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
3382
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3383
|
+
statePath: getArg("state-json"),
|
|
3384
|
+
stateValue: parseJsonArg("state-value"),
|
|
3385
|
+
});
|
|
3386
|
+
printJson({
|
|
3387
|
+
summaryText: formatReceivableDefinitionSummary({
|
|
3388
|
+
ok: result.verified,
|
|
3389
|
+
receivableId: result.definitionValue.receivableId,
|
|
3390
|
+
originatorEntityId: result.definitionValue.originatorEntityId,
|
|
3391
|
+
debtorEntityId: result.definitionValue.debtorEntityId,
|
|
3392
|
+
currencyAssetId: result.definitionValue.currencyAssetId,
|
|
3393
|
+
faceValue: result.definitionValue.faceValue,
|
|
3394
|
+
dueDate: result.definitionValue.dueDate,
|
|
3395
|
+
}),
|
|
3396
|
+
...result,
|
|
784
3397
|
});
|
|
785
|
-
printJson(result);
|
|
786
3398
|
return;
|
|
787
3399
|
}
|
|
788
|
-
if (command === "
|
|
789
|
-
const result = await sdk.
|
|
790
|
-
currentArtifactPath: requireArg("current-artifact"),
|
|
3400
|
+
if (command === "receivable" && subcommand === "load") {
|
|
3401
|
+
const result = await sdk.receivables.load({
|
|
791
3402
|
definitionPath: getArg("definition-json"),
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
nextArtifactPath: getArg("next-artifact"),
|
|
3403
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3404
|
+
statePath: getArg("state-json"),
|
|
3405
|
+
stateValue: parseJsonArg("state-value"),
|
|
796
3406
|
});
|
|
797
3407
|
printJson({
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
3408
|
+
summaryText: formatReceivableDefinitionSummary({
|
|
3409
|
+
receivableId: result.definitionValue.receivableId,
|
|
3410
|
+
originatorEntityId: result.definitionValue.originatorEntityId,
|
|
3411
|
+
debtorEntityId: result.definitionValue.debtorEntityId,
|
|
3412
|
+
currencyAssetId: result.definitionValue.currencyAssetId,
|
|
3413
|
+
faceValue: result.definitionValue.faceValue,
|
|
3414
|
+
dueDate: result.definitionValue.dueDate,
|
|
3415
|
+
}),
|
|
3416
|
+
...result,
|
|
803
3417
|
});
|
|
804
3418
|
return;
|
|
805
3419
|
}
|
|
806
|
-
if (command === "
|
|
807
|
-
const result = await sdk.
|
|
808
|
-
currentArtifactPath: requireArg("current-artifact"),
|
|
3420
|
+
if (command === "receivable" && subcommand === "prepare-funding") {
|
|
3421
|
+
const result = await sdk.receivables.prepareFunding({
|
|
809
3422
|
definitionPath: getArg("definition-json"),
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
3423
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3424
|
+
previousStatePath: getArg("previous-state-json"),
|
|
3425
|
+
previousStateValue: parseJsonArg("previous-state-value"),
|
|
3426
|
+
nextStatePath: getArg("next-state-json"),
|
|
3427
|
+
nextStateValue: parseJsonArg("next-state-value"),
|
|
3428
|
+
stateId: getArg("state-id"),
|
|
3429
|
+
holderEntityId: getArg("holder-entity-id"),
|
|
3430
|
+
fundedAt: getArg("funded-at"),
|
|
815
3431
|
});
|
|
816
3432
|
printJson({
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
3433
|
+
summaryText: formatReceivableTransitionSummary({
|
|
3434
|
+
phase: "prepare-funding",
|
|
3435
|
+
verified: result.verified,
|
|
3436
|
+
transitionType: result.report.transitionTrust?.transitionType ?? "FUND",
|
|
3437
|
+
receivableId: result.nextStateValue.receivableId,
|
|
3438
|
+
nextStateId: result.nextStateValue.stateId,
|
|
3439
|
+
holderEntityId: result.nextStateValue.holderEntityId,
|
|
3440
|
+
status: result.nextStateValue.status,
|
|
3441
|
+
outstandingAmount: result.nextStateValue.outstandingAmount,
|
|
3442
|
+
repaidAmount: result.nextStateValue.repaidAmount,
|
|
3443
|
+
stateHash: result.nextStateSummary.hash,
|
|
3444
|
+
}),
|
|
3445
|
+
...result,
|
|
823
3446
|
});
|
|
824
3447
|
return;
|
|
825
3448
|
}
|
|
826
|
-
if (command === "
|
|
827
|
-
const result = await sdk.
|
|
828
|
-
currentArtifactPath: requireArg("current-artifact"),
|
|
3449
|
+
if (command === "receivable" && subcommand === "verify-funding") {
|
|
3450
|
+
const result = await sdk.receivables.verifyFunding({
|
|
829
3451
|
definitionPath: getArg("definition-json"),
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
3452
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3453
|
+
previousStatePath: getArg("previous-state-json"),
|
|
3454
|
+
previousStateValue: parseJsonArg("previous-state-value"),
|
|
3455
|
+
nextStatePath: getArg("next-state-json"),
|
|
3456
|
+
nextStateValue: parseJsonArg("next-state-value"),
|
|
3457
|
+
});
|
|
3458
|
+
printJson({
|
|
3459
|
+
summaryText: formatReceivableTransitionSummary({
|
|
3460
|
+
phase: "verify-funding",
|
|
3461
|
+
verified: result.verified,
|
|
3462
|
+
transitionType: result.report.transitionTrust?.transitionType ?? "FUND",
|
|
3463
|
+
receivableId: result.nextStateValue.receivableId,
|
|
3464
|
+
nextStateId: result.nextStateValue.stateId,
|
|
3465
|
+
holderEntityId: result.nextStateValue.holderEntityId,
|
|
3466
|
+
status: result.nextStateValue.status,
|
|
3467
|
+
outstandingAmount: result.nextStateValue.outstandingAmount,
|
|
3468
|
+
repaidAmount: result.nextStateValue.repaidAmount,
|
|
3469
|
+
stateHash: result.nextStateSummary.hash,
|
|
3470
|
+
}),
|
|
3471
|
+
...result,
|
|
838
3472
|
});
|
|
839
|
-
printJson(result);
|
|
840
3473
|
return;
|
|
841
3474
|
}
|
|
842
|
-
if (command === "
|
|
843
|
-
const result = await sdk.
|
|
844
|
-
currentArtifactPath: requireArg("current-artifact"),
|
|
3475
|
+
if (command === "receivable" && subcommand === "prepare-funding-claim") {
|
|
3476
|
+
const result = await sdk.receivables.prepareFundingClaim({
|
|
845
3477
|
definitionPath: getArg("definition-json"),
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
3478
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3479
|
+
currentStatePath: getArg("current-state-json"),
|
|
3480
|
+
currentStateValue: parseJsonArg("current-state-value"),
|
|
3481
|
+
stateHistoryPaths: getMultiArgs("state-history-json"),
|
|
3482
|
+
stateHistoryValues: parseJsonArgs("state-history-value"),
|
|
3483
|
+
fundingClaimPath: getArg("funding-claim-json"),
|
|
3484
|
+
fundingClaimValue: parseJsonArg("funding-claim-value"),
|
|
3485
|
+
claimId: getArg("claim-id"),
|
|
3486
|
+
payerEntityId: getArg("payer-entity-id"),
|
|
3487
|
+
payeeEntityId: getArg("payee-entity-id"),
|
|
3488
|
+
claimantXonly: getArg("claimant-xonly"),
|
|
3489
|
+
amountSat: getArg("amount-sat") ? Number(getArg("amount-sat")) : undefined,
|
|
3490
|
+
eventTimestamp: getArg("event-timestamp"),
|
|
3491
|
+
simfPath: getArg("simf"),
|
|
3492
|
+
artifactPath: getArg("artifact"),
|
|
3493
|
+
});
|
|
3494
|
+
printJson({
|
|
3495
|
+
summaryText: formatReceivableClaimSummary({
|
|
3496
|
+
phase: "prepare-funding-claim",
|
|
3497
|
+
verified: result.verified,
|
|
3498
|
+
claimKind: result.claimValue.claimKind,
|
|
3499
|
+
receivableId: result.claimValue.receivableId,
|
|
3500
|
+
claimId: result.claimValue.claimId,
|
|
3501
|
+
currentStatus: result.claimValue.currentStatus,
|
|
3502
|
+
payerEntityId: result.claimValue.payerEntityId,
|
|
3503
|
+
payeeEntityId: result.claimValue.payeeEntityId,
|
|
3504
|
+
amountSat: result.claimValue.amountSat,
|
|
3505
|
+
bindingMode: result.report.fundingClaimTrust?.bindingMode,
|
|
3506
|
+
reasonCode: result.report.fundingClaimTrust?.reasonCode,
|
|
3507
|
+
supportedForm: result.report.fundingClaimTrust?.supportedForm,
|
|
3508
|
+
fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
|
|
3509
|
+
}),
|
|
3510
|
+
...result,
|
|
854
3511
|
});
|
|
855
|
-
printJson(result);
|
|
856
3512
|
return;
|
|
857
3513
|
}
|
|
858
|
-
if (command === "
|
|
859
|
-
const result = await sdk.
|
|
860
|
-
|
|
3514
|
+
if (command === "receivable" && subcommand === "verify-funding-claim") {
|
|
3515
|
+
const result = await sdk.receivables.verifyFundingClaim({
|
|
3516
|
+
artifactPath: getArg("artifact"),
|
|
861
3517
|
definitionPath: getArg("definition-json"),
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
3518
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3519
|
+
currentStatePath: getArg("current-state-json"),
|
|
3520
|
+
currentStateValue: parseJsonArg("current-state-value"),
|
|
3521
|
+
stateHistoryPaths: getMultiArgs("state-history-json"),
|
|
3522
|
+
stateHistoryValues: parseJsonArgs("state-history-value"),
|
|
3523
|
+
fundingClaimPath: getArg("funding-claim-json"),
|
|
3524
|
+
fundingClaimValue: parseJsonArg("funding-claim-value"),
|
|
3525
|
+
});
|
|
3526
|
+
printJson({
|
|
3527
|
+
summaryText: formatReceivableClaimSummary({
|
|
3528
|
+
phase: "verify-funding-claim",
|
|
3529
|
+
verified: result.verified,
|
|
3530
|
+
claimKind: result.claimValue.claimKind,
|
|
3531
|
+
receivableId: result.claimValue.receivableId,
|
|
3532
|
+
claimId: result.claimValue.claimId,
|
|
3533
|
+
currentStatus: result.claimValue.currentStatus,
|
|
3534
|
+
payerEntityId: result.claimValue.payerEntityId,
|
|
3535
|
+
payeeEntityId: result.claimValue.payeeEntityId,
|
|
3536
|
+
amountSat: result.claimValue.amountSat,
|
|
3537
|
+
bindingMode: result.report.fundingClaimTrust?.bindingMode,
|
|
3538
|
+
reasonCode: result.report.fundingClaimTrust?.reasonCode,
|
|
3539
|
+
supportedForm: result.report.fundingClaimTrust?.supportedForm,
|
|
3540
|
+
fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
|
|
3541
|
+
}),
|
|
3542
|
+
...result,
|
|
3543
|
+
});
|
|
3544
|
+
return;
|
|
3545
|
+
}
|
|
3546
|
+
if (command === "receivable" && subcommand === "inspect-funding-claim") {
|
|
3547
|
+
const result = await sdk.receivables.inspectFundingClaim({
|
|
3548
|
+
artifactPath: requireArg("artifact"),
|
|
3549
|
+
definitionPath: getArg("definition-json"),
|
|
3550
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3551
|
+
currentStatePath: getArg("current-state-json"),
|
|
3552
|
+
currentStateValue: parseJsonArg("current-state-value"),
|
|
3553
|
+
stateHistoryPaths: getMultiArgs("state-history-json"),
|
|
3554
|
+
stateHistoryValues: parseJsonArgs("state-history-value"),
|
|
3555
|
+
fundingClaimPath: getArg("funding-claim-json"),
|
|
3556
|
+
fundingClaimValue: parseJsonArg("funding-claim-value"),
|
|
3557
|
+
payoutAddress: requireArg("payout-address"),
|
|
3558
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
3559
|
+
outputForm: parsePolicyOutputForm(),
|
|
3560
|
+
rawOutput: parseRawOutputFields(),
|
|
3561
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
866
3562
|
wallet: requireArg("wallet"),
|
|
867
3563
|
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
868
3564
|
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
869
3565
|
utxoPolicy: getArg("utxo-policy"),
|
|
870
|
-
broadcast: hasFlag("broadcast"),
|
|
871
3566
|
});
|
|
872
|
-
printJson(
|
|
3567
|
+
printJson({
|
|
3568
|
+
summaryText: formatReceivableClaimSummary({
|
|
3569
|
+
phase: "inspect-funding-claim",
|
|
3570
|
+
verified: result.verified,
|
|
3571
|
+
claimKind: result.claimValue.claimKind,
|
|
3572
|
+
receivableId: result.claimValue.receivableId,
|
|
3573
|
+
claimId: result.claimValue.claimId,
|
|
3574
|
+
currentStatus: result.claimValue.currentStatus,
|
|
3575
|
+
payerEntityId: result.claimValue.payerEntityId,
|
|
3576
|
+
payeeEntityId: result.claimValue.payeeEntityId,
|
|
3577
|
+
amountSat: result.claimValue.amountSat,
|
|
3578
|
+
bindingMode: result.report.fundingClaimTrust?.bindingMode,
|
|
3579
|
+
reasonCode: result.report.fundingClaimTrust?.reasonCode,
|
|
3580
|
+
supportedForm: result.report.fundingClaimTrust?.supportedForm,
|
|
3581
|
+
fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
|
|
3582
|
+
}),
|
|
3583
|
+
...result,
|
|
3584
|
+
});
|
|
873
3585
|
return;
|
|
874
3586
|
}
|
|
875
|
-
if (command === "
|
|
876
|
-
const result = await sdk.
|
|
877
|
-
|
|
3587
|
+
if (command === "receivable" && subcommand === "execute-funding-claim") {
|
|
3588
|
+
const result = await sdk.receivables.executeFundingClaim({
|
|
3589
|
+
artifactPath: requireArg("artifact"),
|
|
878
3590
|
definitionPath: getArg("definition-json"),
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
3591
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3592
|
+
currentStatePath: getArg("current-state-json"),
|
|
3593
|
+
currentStateValue: parseJsonArg("current-state-value"),
|
|
3594
|
+
stateHistoryPaths: getMultiArgs("state-history-json"),
|
|
3595
|
+
stateHistoryValues: parseJsonArgs("state-history-value"),
|
|
3596
|
+
fundingClaimPath: getArg("funding-claim-json"),
|
|
3597
|
+
fundingClaimValue: parseJsonArg("funding-claim-value"),
|
|
3598
|
+
payoutAddress: requireArg("payout-address"),
|
|
3599
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
3600
|
+
outputForm: parsePolicyOutputForm(),
|
|
3601
|
+
rawOutput: parseRawOutputFields(),
|
|
3602
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
883
3603
|
wallet: requireArg("wallet"),
|
|
884
3604
|
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
885
3605
|
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
886
3606
|
utxoPolicy: getArg("utxo-policy"),
|
|
887
3607
|
broadcast: hasFlag("broadcast"),
|
|
888
3608
|
});
|
|
889
|
-
printJson(
|
|
3609
|
+
printJson({
|
|
3610
|
+
summaryText: formatReceivableClaimSummary({
|
|
3611
|
+
phase: "execute-funding-claim",
|
|
3612
|
+
verified: result.verified,
|
|
3613
|
+
claimKind: result.claimValue.claimKind,
|
|
3614
|
+
receivableId: result.claimValue.receivableId,
|
|
3615
|
+
claimId: result.claimValue.claimId,
|
|
3616
|
+
currentStatus: result.claimValue.currentStatus,
|
|
3617
|
+
payerEntityId: result.claimValue.payerEntityId,
|
|
3618
|
+
payeeEntityId: result.claimValue.payeeEntityId,
|
|
3619
|
+
amountSat: result.claimValue.amountSat,
|
|
3620
|
+
bindingMode: result.report.fundingClaimTrust?.bindingMode,
|
|
3621
|
+
reasonCode: result.report.fundingClaimTrust?.reasonCode,
|
|
3622
|
+
supportedForm: result.report.fundingClaimTrust?.supportedForm,
|
|
3623
|
+
fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
|
|
3624
|
+
}),
|
|
3625
|
+
...result,
|
|
3626
|
+
});
|
|
890
3627
|
return;
|
|
891
3628
|
}
|
|
892
|
-
if (command === "
|
|
893
|
-
const result = await sdk.
|
|
894
|
-
currentMachineArtifactPath: requireArg("current-machine-artifact"),
|
|
3629
|
+
if (command === "receivable" && subcommand === "prepare-repayment") {
|
|
3630
|
+
const result = await sdk.receivables.prepareRepayment({
|
|
895
3631
|
definitionPath: getArg("definition-json"),
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
3632
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3633
|
+
previousStatePath: getArg("previous-state-json"),
|
|
3634
|
+
previousStateValue: parseJsonArg("previous-state-value"),
|
|
3635
|
+
nextStatePath: getArg("next-state-json"),
|
|
3636
|
+
nextStateValue: parseJsonArg("next-state-value"),
|
|
3637
|
+
stateId: getArg("state-id"),
|
|
3638
|
+
amount: getArg("amount") ? Number(getArg("amount")) : undefined,
|
|
3639
|
+
repaidAt: getArg("repaid-at"),
|
|
900
3640
|
});
|
|
901
3641
|
printJson({
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
3642
|
+
summaryText: formatReceivableTransitionSummary({
|
|
3643
|
+
phase: "prepare-repayment",
|
|
3644
|
+
verified: result.verified,
|
|
3645
|
+
transitionType: result.report.transitionTrust?.transitionType ?? "REPAY",
|
|
3646
|
+
receivableId: result.nextStateValue.receivableId,
|
|
3647
|
+
nextStateId: result.nextStateValue.stateId,
|
|
3648
|
+
holderEntityId: result.nextStateValue.holderEntityId,
|
|
3649
|
+
status: result.nextStateValue.status,
|
|
3650
|
+
outstandingAmount: result.nextStateValue.outstandingAmount,
|
|
3651
|
+
repaidAmount: result.nextStateValue.repaidAmount,
|
|
3652
|
+
stateHash: result.nextStateSummary.hash,
|
|
3653
|
+
}),
|
|
3654
|
+
...result,
|
|
908
3655
|
});
|
|
909
3656
|
return;
|
|
910
3657
|
}
|
|
911
|
-
if (command === "
|
|
912
|
-
const result = await sdk.
|
|
913
|
-
currentMachineArtifactPath: requireArg("current-machine-artifact"),
|
|
3658
|
+
if (command === "receivable" && subcommand === "prepare-repayment-claim") {
|
|
3659
|
+
const result = await sdk.receivables.prepareRepaymentClaim({
|
|
914
3660
|
definitionPath: getArg("definition-json"),
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
3661
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3662
|
+
currentStatePath: getArg("current-state-json"),
|
|
3663
|
+
currentStateValue: parseJsonArg("current-state-value"),
|
|
3664
|
+
stateHistoryPaths: getMultiArgs("state-history-json"),
|
|
3665
|
+
stateHistoryValues: parseJsonArgs("state-history-value"),
|
|
3666
|
+
repaymentClaimPath: getArg("repayment-claim-json"),
|
|
3667
|
+
repaymentClaimValue: parseJsonArg("repayment-claim-value"),
|
|
3668
|
+
claimId: getArg("claim-id"),
|
|
3669
|
+
payerEntityId: getArg("payer-entity-id"),
|
|
3670
|
+
payeeEntityId: getArg("payee-entity-id"),
|
|
3671
|
+
claimantXonly: getArg("claimant-xonly"),
|
|
3672
|
+
amountSat: getArg("amount-sat") ? Number(getArg("amount-sat")) : undefined,
|
|
3673
|
+
eventTimestamp: getArg("event-timestamp"),
|
|
3674
|
+
simfPath: getArg("simf"),
|
|
3675
|
+
artifactPath: getArg("artifact"),
|
|
3676
|
+
});
|
|
3677
|
+
printJson({
|
|
3678
|
+
summaryText: formatReceivableClaimSummary({
|
|
3679
|
+
phase: "prepare-repayment-claim",
|
|
3680
|
+
verified: result.verified,
|
|
3681
|
+
claimKind: result.claimValue.claimKind,
|
|
3682
|
+
receivableId: result.claimValue.receivableId,
|
|
3683
|
+
claimId: result.claimValue.claimId,
|
|
3684
|
+
currentStatus: result.claimValue.currentStatus,
|
|
3685
|
+
payerEntityId: result.claimValue.payerEntityId,
|
|
3686
|
+
payeeEntityId: result.claimValue.payeeEntityId,
|
|
3687
|
+
amountSat: result.claimValue.amountSat,
|
|
3688
|
+
bindingMode: result.report.repaymentClaimTrust?.bindingMode,
|
|
3689
|
+
reasonCode: result.report.repaymentClaimTrust?.reasonCode,
|
|
3690
|
+
supportedForm: result.report.repaymentClaimTrust?.supportedForm,
|
|
3691
|
+
fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
|
|
3692
|
+
}),
|
|
3693
|
+
...result,
|
|
3694
|
+
});
|
|
3695
|
+
return;
|
|
3696
|
+
}
|
|
3697
|
+
if (command === "receivable" && subcommand === "verify-repayment-claim") {
|
|
3698
|
+
const result = await sdk.receivables.verifyRepaymentClaim({
|
|
3699
|
+
artifactPath: getArg("artifact"),
|
|
3700
|
+
definitionPath: getArg("definition-json"),
|
|
3701
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3702
|
+
currentStatePath: getArg("current-state-json"),
|
|
3703
|
+
currentStateValue: parseJsonArg("current-state-value"),
|
|
3704
|
+
stateHistoryPaths: getMultiArgs("state-history-json"),
|
|
3705
|
+
stateHistoryValues: parseJsonArgs("state-history-value"),
|
|
3706
|
+
repaymentClaimPath: getArg("repayment-claim-json"),
|
|
3707
|
+
repaymentClaimValue: parseJsonArg("repayment-claim-value"),
|
|
3708
|
+
});
|
|
3709
|
+
printJson({
|
|
3710
|
+
summaryText: formatReceivableClaimSummary({
|
|
3711
|
+
phase: "verify-repayment-claim",
|
|
3712
|
+
verified: result.verified,
|
|
3713
|
+
claimKind: result.claimValue.claimKind,
|
|
3714
|
+
receivableId: result.claimValue.receivableId,
|
|
3715
|
+
claimId: result.claimValue.claimId,
|
|
3716
|
+
currentStatus: result.claimValue.currentStatus,
|
|
3717
|
+
payerEntityId: result.claimValue.payerEntityId,
|
|
3718
|
+
payeeEntityId: result.claimValue.payeeEntityId,
|
|
3719
|
+
amountSat: result.claimValue.amountSat,
|
|
3720
|
+
bindingMode: result.report.repaymentClaimTrust?.bindingMode,
|
|
3721
|
+
reasonCode: result.report.repaymentClaimTrust?.reasonCode,
|
|
3722
|
+
supportedForm: result.report.repaymentClaimTrust?.supportedForm,
|
|
3723
|
+
fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
|
|
3724
|
+
}),
|
|
3725
|
+
...result,
|
|
3726
|
+
});
|
|
3727
|
+
return;
|
|
3728
|
+
}
|
|
3729
|
+
if (command === "receivable" && subcommand === "inspect-repayment-claim") {
|
|
3730
|
+
const result = await sdk.receivables.inspectRepaymentClaim({
|
|
3731
|
+
artifactPath: requireArg("artifact"),
|
|
3732
|
+
definitionPath: getArg("definition-json"),
|
|
3733
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3734
|
+
currentStatePath: getArg("current-state-json"),
|
|
3735
|
+
currentStateValue: parseJsonArg("current-state-value"),
|
|
3736
|
+
stateHistoryPaths: getMultiArgs("state-history-json"),
|
|
3737
|
+
stateHistoryValues: parseJsonArgs("state-history-value"),
|
|
3738
|
+
repaymentClaimPath: getArg("repayment-claim-json"),
|
|
3739
|
+
repaymentClaimValue: parseJsonArg("repayment-claim-value"),
|
|
3740
|
+
payoutAddress: requireArg("payout-address"),
|
|
3741
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
3742
|
+
outputForm: parsePolicyOutputForm(),
|
|
3743
|
+
rawOutput: parseRawOutputFields(),
|
|
3744
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
919
3745
|
wallet: requireArg("wallet"),
|
|
920
3746
|
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
921
3747
|
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
922
3748
|
utxoPolicy: getArg("utxo-policy"),
|
|
923
3749
|
});
|
|
924
|
-
printJson(
|
|
3750
|
+
printJson({
|
|
3751
|
+
summaryText: formatReceivableClaimSummary({
|
|
3752
|
+
phase: "inspect-repayment-claim",
|
|
3753
|
+
verified: result.verified,
|
|
3754
|
+
claimKind: result.claimValue.claimKind,
|
|
3755
|
+
receivableId: result.claimValue.receivableId,
|
|
3756
|
+
claimId: result.claimValue.claimId,
|
|
3757
|
+
currentStatus: result.claimValue.currentStatus,
|
|
3758
|
+
payerEntityId: result.claimValue.payerEntityId,
|
|
3759
|
+
payeeEntityId: result.claimValue.payeeEntityId,
|
|
3760
|
+
amountSat: result.claimValue.amountSat,
|
|
3761
|
+
bindingMode: result.report.repaymentClaimTrust?.bindingMode,
|
|
3762
|
+
reasonCode: result.report.repaymentClaimTrust?.reasonCode,
|
|
3763
|
+
supportedForm: result.report.repaymentClaimTrust?.supportedForm,
|
|
3764
|
+
fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
|
|
3765
|
+
}),
|
|
3766
|
+
...result,
|
|
3767
|
+
});
|
|
925
3768
|
return;
|
|
926
3769
|
}
|
|
927
|
-
if (command === "
|
|
928
|
-
const result = await sdk.
|
|
929
|
-
|
|
3770
|
+
if (command === "receivable" && subcommand === "execute-repayment-claim") {
|
|
3771
|
+
const result = await sdk.receivables.executeRepaymentClaim({
|
|
3772
|
+
artifactPath: requireArg("artifact"),
|
|
930
3773
|
definitionPath: getArg("definition-json"),
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
3774
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3775
|
+
currentStatePath: getArg("current-state-json"),
|
|
3776
|
+
currentStateValue: parseJsonArg("current-state-value"),
|
|
3777
|
+
stateHistoryPaths: getMultiArgs("state-history-json"),
|
|
3778
|
+
stateHistoryValues: parseJsonArgs("state-history-value"),
|
|
3779
|
+
repaymentClaimPath: getArg("repayment-claim-json"),
|
|
3780
|
+
repaymentClaimValue: parseJsonArg("repayment-claim-value"),
|
|
3781
|
+
payoutAddress: requireArg("payout-address"),
|
|
3782
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
3783
|
+
outputForm: parsePolicyOutputForm(),
|
|
3784
|
+
rawOutput: parseRawOutputFields(),
|
|
3785
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
935
3786
|
wallet: requireArg("wallet"),
|
|
936
3787
|
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
937
3788
|
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
938
3789
|
utxoPolicy: getArg("utxo-policy"),
|
|
939
3790
|
broadcast: hasFlag("broadcast"),
|
|
940
3791
|
});
|
|
941
|
-
printJson(
|
|
3792
|
+
printJson({
|
|
3793
|
+
summaryText: formatReceivableClaimSummary({
|
|
3794
|
+
phase: "execute-repayment-claim",
|
|
3795
|
+
verified: result.verified,
|
|
3796
|
+
claimKind: result.claimValue.claimKind,
|
|
3797
|
+
receivableId: result.claimValue.receivableId,
|
|
3798
|
+
claimId: result.claimValue.claimId,
|
|
3799
|
+
currentStatus: result.claimValue.currentStatus,
|
|
3800
|
+
payerEntityId: result.claimValue.payerEntityId,
|
|
3801
|
+
payeeEntityId: result.claimValue.payeeEntityId,
|
|
3802
|
+
amountSat: result.claimValue.amountSat,
|
|
3803
|
+
bindingMode: result.report.repaymentClaimTrust?.bindingMode,
|
|
3804
|
+
reasonCode: result.report.repaymentClaimTrust?.reasonCode,
|
|
3805
|
+
supportedForm: result.report.repaymentClaimTrust?.supportedForm,
|
|
3806
|
+
fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
|
|
3807
|
+
}),
|
|
3808
|
+
...result,
|
|
3809
|
+
});
|
|
942
3810
|
return;
|
|
943
3811
|
}
|
|
944
|
-
if (command === "
|
|
945
|
-
const result = await sdk.
|
|
3812
|
+
if (command === "receivable" && subcommand === "verify-repayment") {
|
|
3813
|
+
const result = await sdk.receivables.verifyRepayment({
|
|
946
3814
|
definitionPath: getArg("definition-json"),
|
|
947
|
-
|
|
948
|
-
|
|
3815
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3816
|
+
previousStatePath: getArg("previous-state-json"),
|
|
3817
|
+
previousStateValue: parseJsonArg("previous-state-value"),
|
|
3818
|
+
nextStatePath: getArg("next-state-json"),
|
|
3819
|
+
nextStateValue: parseJsonArg("next-state-value"),
|
|
3820
|
+
});
|
|
3821
|
+
printJson({
|
|
3822
|
+
summaryText: formatReceivableTransitionSummary({
|
|
3823
|
+
phase: "verify-repayment",
|
|
3824
|
+
verified: result.verified,
|
|
3825
|
+
transitionType: result.report.transitionTrust?.transitionType ?? "REPAY",
|
|
3826
|
+
receivableId: result.nextStateValue.receivableId,
|
|
3827
|
+
nextStateId: result.nextStateValue.stateId,
|
|
3828
|
+
holderEntityId: result.nextStateValue.holderEntityId,
|
|
3829
|
+
status: result.nextStateValue.status,
|
|
3830
|
+
outstandingAmount: result.nextStateValue.outstandingAmount,
|
|
3831
|
+
repaidAmount: result.nextStateValue.repaidAmount,
|
|
3832
|
+
stateHash: result.nextStateSummary.hash,
|
|
3833
|
+
}),
|
|
3834
|
+
...result,
|
|
949
3835
|
});
|
|
950
|
-
printJson(result);
|
|
951
3836
|
return;
|
|
952
3837
|
}
|
|
953
|
-
if (command === "
|
|
954
|
-
const result = await sdk.
|
|
955
|
-
artifactPath: requireArg("artifact"),
|
|
3838
|
+
if (command === "receivable" && subcommand === "prepare-write-off") {
|
|
3839
|
+
const result = await sdk.receivables.prepareWriteOff({
|
|
956
3840
|
definitionPath: getArg("definition-json"),
|
|
957
|
-
|
|
3841
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3842
|
+
previousStatePath: getArg("previous-state-json"),
|
|
3843
|
+
previousStateValue: parseJsonArg("previous-state-value"),
|
|
3844
|
+
nextStatePath: getArg("next-state-json"),
|
|
3845
|
+
nextStateValue: parseJsonArg("next-state-value"),
|
|
3846
|
+
stateId: getArg("state-id"),
|
|
3847
|
+
defaultedAt: getArg("defaulted-at"),
|
|
3848
|
+
writeOffAmount: getArg("write-off-amount") ? Number(getArg("write-off-amount")) : undefined,
|
|
3849
|
+
});
|
|
3850
|
+
printJson({
|
|
3851
|
+
summaryText: formatReceivableTransitionSummary({
|
|
3852
|
+
phase: "prepare-write-off",
|
|
3853
|
+
verified: result.verified,
|
|
3854
|
+
transitionType: result.report.transitionTrust?.transitionType ?? "WRITE_OFF",
|
|
3855
|
+
receivableId: result.nextStateValue.receivableId,
|
|
3856
|
+
nextStateId: result.nextStateValue.stateId,
|
|
3857
|
+
holderEntityId: result.nextStateValue.holderEntityId,
|
|
3858
|
+
status: result.nextStateValue.status,
|
|
3859
|
+
outstandingAmount: result.nextStateValue.outstandingAmount,
|
|
3860
|
+
repaidAmount: result.nextStateValue.repaidAmount,
|
|
3861
|
+
stateHash: result.nextStateSummary.hash,
|
|
3862
|
+
}),
|
|
3863
|
+
...result,
|
|
3864
|
+
});
|
|
3865
|
+
return;
|
|
3866
|
+
}
|
|
3867
|
+
if (command === "receivable" && subcommand === "verify-write-off") {
|
|
3868
|
+
const result = await sdk.receivables.verifyWriteOff({
|
|
3869
|
+
definitionPath: getArg("definition-json"),
|
|
3870
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3871
|
+
previousStatePath: getArg("previous-state-json"),
|
|
3872
|
+
previousStateValue: parseJsonArg("previous-state-value"),
|
|
3873
|
+
nextStatePath: getArg("next-state-json"),
|
|
3874
|
+
nextStateValue: parseJsonArg("next-state-value"),
|
|
3875
|
+
});
|
|
3876
|
+
printJson({
|
|
3877
|
+
summaryText: formatReceivableTransitionSummary({
|
|
3878
|
+
phase: "verify-write-off",
|
|
3879
|
+
verified: result.verified,
|
|
3880
|
+
transitionType: result.report.transitionTrust?.transitionType ?? "WRITE_OFF",
|
|
3881
|
+
receivableId: result.nextStateValue.receivableId,
|
|
3882
|
+
nextStateId: result.nextStateValue.stateId,
|
|
3883
|
+
holderEntityId: result.nextStateValue.holderEntityId,
|
|
3884
|
+
status: result.nextStateValue.status,
|
|
3885
|
+
outstandingAmount: result.nextStateValue.outstandingAmount,
|
|
3886
|
+
repaidAmount: result.nextStateValue.repaidAmount,
|
|
3887
|
+
stateHash: result.nextStateSummary.hash,
|
|
3888
|
+
}),
|
|
3889
|
+
...result,
|
|
3890
|
+
});
|
|
3891
|
+
return;
|
|
3892
|
+
}
|
|
3893
|
+
if (command === "receivable" && subcommand === "prepare-closing") {
|
|
3894
|
+
const result = await sdk.receivables.prepareClosing({
|
|
3895
|
+
definitionPath: getArg("definition-json"),
|
|
3896
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3897
|
+
latestStatePath: getArg("latest-state-json"),
|
|
3898
|
+
latestStateValue: parseJsonArg("latest-state-value"),
|
|
3899
|
+
stateHistoryPaths: getMultiArgs("state-history-json"),
|
|
3900
|
+
stateHistoryValues: parseJsonArgs("state-history-value"),
|
|
3901
|
+
closingPath: getArg("closing-json"),
|
|
3902
|
+
closingValue: parseJsonArg("closing-value"),
|
|
3903
|
+
closingId: getArg("closing-id"),
|
|
3904
|
+
closedAt: getArg("closed-at"),
|
|
3905
|
+
closingReason: getArg("closing-reason"),
|
|
3906
|
+
});
|
|
3907
|
+
printJson({
|
|
3908
|
+
summaryText: formatReceivableClosingSummary({
|
|
3909
|
+
verified: result.verified,
|
|
3910
|
+
receivableId: result.closingValue.receivableId,
|
|
3911
|
+
latestStatus: result.closingValue.latestStatus,
|
|
3912
|
+
closingReason: result.closingValue.closingReason,
|
|
3913
|
+
closingHash: result.closingSummary.hash,
|
|
3914
|
+
fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
|
|
3915
|
+
}),
|
|
3916
|
+
...result,
|
|
3917
|
+
});
|
|
3918
|
+
return;
|
|
3919
|
+
}
|
|
3920
|
+
if (command === "receivable" && subcommand === "verify-closing") {
|
|
3921
|
+
const result = await sdk.receivables.verifyClosing({
|
|
3922
|
+
definitionPath: getArg("definition-json"),
|
|
3923
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3924
|
+
latestStatePath: getArg("latest-state-json"),
|
|
3925
|
+
latestStateValue: parseJsonArg("latest-state-value"),
|
|
3926
|
+
stateHistoryPaths: getMultiArgs("state-history-json"),
|
|
3927
|
+
stateHistoryValues: parseJsonArgs("state-history-value"),
|
|
3928
|
+
closingPath: getArg("closing-json"),
|
|
3929
|
+
closingValue: parseJsonArg("closing-value"),
|
|
3930
|
+
});
|
|
3931
|
+
printJson({
|
|
3932
|
+
summaryText: formatReceivableClosingSummary({
|
|
3933
|
+
verified: result.verified,
|
|
3934
|
+
receivableId: result.closingValue.receivableId,
|
|
3935
|
+
latestStatus: result.closingValue.latestStatus,
|
|
3936
|
+
closingReason: result.closingValue.closingReason,
|
|
3937
|
+
closingHash: result.closingSummary.hash,
|
|
3938
|
+
fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
|
|
3939
|
+
}),
|
|
3940
|
+
...result,
|
|
3941
|
+
});
|
|
3942
|
+
return;
|
|
3943
|
+
}
|
|
3944
|
+
if (command === "receivable" && subcommand === "verify-state-history") {
|
|
3945
|
+
const result = await sdk.receivables.verifyStateHistory({
|
|
3946
|
+
definitionPath: getArg("definition-json"),
|
|
3947
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3948
|
+
stateHistoryPaths: getMultiArgs("state-history-json"),
|
|
3949
|
+
stateHistoryValues: parseJsonArgs("state-history-value"),
|
|
3950
|
+
});
|
|
3951
|
+
printJson({
|
|
3952
|
+
summaryText: formatReceivableHistorySummary({
|
|
3953
|
+
verified: result.verified,
|
|
3954
|
+
receivableId: result.latestStateValue.receivableId,
|
|
3955
|
+
chainLength: result.report.stateLineageTrust?.chainLength ?? 0,
|
|
3956
|
+
latestStatus: result.report.stateLineageTrust?.latestStatus ?? result.latestStateValue.status,
|
|
3957
|
+
latestOrdinal: result.report.stateLineageTrust?.latestOrdinal ?? null,
|
|
3958
|
+
fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified ?? false,
|
|
3959
|
+
}),
|
|
3960
|
+
...result,
|
|
3961
|
+
});
|
|
3962
|
+
return;
|
|
3963
|
+
}
|
|
3964
|
+
if (command === "receivable" && subcommand === "export-evidence") {
|
|
3965
|
+
const result = await sdk.receivables.exportEvidence({
|
|
3966
|
+
definitionPath: getArg("definition-json"),
|
|
3967
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
3968
|
+
statePath: getArg("state-json"),
|
|
3969
|
+
stateValue: parseJsonArg("state-value"),
|
|
3970
|
+
stateHistoryPaths: getMultiArgs("state-history-json"),
|
|
3971
|
+
stateHistoryValues: parseJsonArgs("state-history-value"),
|
|
3972
|
+
fundingClaimPath: getArg("funding-claim-json"),
|
|
3973
|
+
fundingClaimValue: parseJsonArg("funding-claim-value"),
|
|
3974
|
+
repaymentClaimPath: getArg("repayment-claim-json"),
|
|
3975
|
+
repaymentClaimValue: parseJsonArg("repayment-claim-value"),
|
|
3976
|
+
closingPath: getArg("closing-json"),
|
|
3977
|
+
closingValue: parseJsonArg("closing-value"),
|
|
3978
|
+
verificationReportValue: parseJsonArg("verification-report-value"),
|
|
3979
|
+
});
|
|
3980
|
+
const evidenceStateValue = JSON.parse(result.state.canonicalJson);
|
|
3981
|
+
const evidenceClosingValue = result.closing
|
|
3982
|
+
? JSON.parse(result.closing.canonicalJson)
|
|
3983
|
+
: undefined;
|
|
3984
|
+
printJson({
|
|
3985
|
+
summaryText: formatReceivableEvidenceOrFinalitySummary({
|
|
3986
|
+
kind: "evidence",
|
|
3987
|
+
receivableId: evidenceStateValue.receivableId,
|
|
3988
|
+
holderEntityId: evidenceStateValue.holderEntityId,
|
|
3989
|
+
definitionHash: result.definition.hash,
|
|
3990
|
+
latestStateHash: result.state.hash,
|
|
3991
|
+
closingHash: result.closing?.hash ?? null,
|
|
3992
|
+
closingReason: evidenceClosingValue?.closingReason ?? null,
|
|
3993
|
+
lineageKind: result.trust.stateLineageTrust?.lineageKind ?? null,
|
|
3994
|
+
latestOrdinal: result.trust.stateLineageTrust?.latestOrdinal ?? null,
|
|
3995
|
+
fullLineageVerified: result.trust.stateLineageTrust?.fullLineageVerified ?? null,
|
|
3996
|
+
}),
|
|
3997
|
+
...result,
|
|
3998
|
+
});
|
|
3999
|
+
return;
|
|
4000
|
+
}
|
|
4001
|
+
if (command === "receivable" && subcommand === "export-finality-payload") {
|
|
4002
|
+
const result = await sdk.receivables.exportFinalityPayload({
|
|
4003
|
+
definitionPath: getArg("definition-json"),
|
|
4004
|
+
definitionValue: parseJsonArg("definition-value"),
|
|
4005
|
+
statePath: getArg("state-json"),
|
|
4006
|
+
stateValue: parseJsonArg("state-value"),
|
|
4007
|
+
stateHistoryPaths: getMultiArgs("state-history-json"),
|
|
4008
|
+
stateHistoryValues: parseJsonArgs("state-history-value"),
|
|
4009
|
+
fundingClaimPath: getArg("funding-claim-json"),
|
|
4010
|
+
fundingClaimValue: parseJsonArg("funding-claim-value"),
|
|
4011
|
+
repaymentClaimPath: getArg("repayment-claim-json"),
|
|
4012
|
+
repaymentClaimValue: parseJsonArg("repayment-claim-value"),
|
|
4013
|
+
closingPath: getArg("closing-json"),
|
|
4014
|
+
closingValue: parseJsonArg("closing-value"),
|
|
4015
|
+
verificationReportValue: parseJsonArg("verification-report-value"),
|
|
4016
|
+
});
|
|
4017
|
+
printJson({
|
|
4018
|
+
summaryText: formatReceivableEvidenceOrFinalitySummary({
|
|
4019
|
+
kind: "finality",
|
|
4020
|
+
receivableId: result.receivableId,
|
|
4021
|
+
holderEntityId: result.holderEntityId,
|
|
4022
|
+
definitionHash: result.definitionHash,
|
|
4023
|
+
latestStateHash: result.latestStateHash,
|
|
4024
|
+
closingHash: result.closingHash,
|
|
4025
|
+
closingReason: result.closingReason,
|
|
4026
|
+
lineageKind: result.trust.stateLineageTrust?.lineageKind ?? null,
|
|
4027
|
+
latestOrdinal: result.trust.stateLineageTrust?.latestOrdinal ?? null,
|
|
4028
|
+
fullLineageVerified: result.trust.stateLineageTrust?.fullLineageVerified ?? null,
|
|
4029
|
+
}),
|
|
4030
|
+
...result,
|
|
958
4031
|
});
|
|
959
|
-
printJson(result);
|
|
960
4032
|
return;
|
|
961
4033
|
}
|
|
962
4034
|
if (command === "contract" && subcommand === "wait-funding") {
|