@hazbase/simplicity 0.0.5 → 0.1.1
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 +645 -148
- package/dist/cli.js +2125 -159
- package/dist/client/SimplicityClient.d.ts +64 -290
- package/dist/client/SimplicityClient.js +65 -23
- package/dist/core/executor.js +67 -92
- package/dist/core/outputBinding.d.ts +61 -0
- package/dist/core/outputBinding.js +552 -0
- package/dist/core/schnorr.d.ts +5 -0
- package/dist/core/schnorr.js +34 -0
- package/dist/core/types.d.ts +553 -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 +33 -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/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 +8583 -721
- package/dist/domain/bond.js +1272 -31
- package/dist/domain/bondSettlementValidation.d.ts +2 -0
- package/dist/domain/bondSettlementValidation.js +28 -0
- package/dist/domain/bondValidation.d.ts +6 -0
- package/dist/domain/bondValidation.js +65 -3
- package/dist/domain/fund.d.ts +2069 -0
- package/dist/domain/fund.js +1384 -0
- package/dist/domain/fundValidation.d.ts +122 -0
- package/dist/domain/fundValidation.js +635 -0
- package/dist/domain/policies.d.ts +1051 -0
- package/dist/domain/policies.js +1605 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +85 -21
- package/package.json +15 -2
package/dist/cli.js
CHANGED
|
@@ -44,10 +44,85 @@ function requireArg(name) {
|
|
|
44
44
|
function parseAssignments(values) {
|
|
45
45
|
return Object.fromEntries(values.map((entry) => {
|
|
46
46
|
const [key, raw] = entry.split("=", 2);
|
|
47
|
+
if (raw === "true")
|
|
48
|
+
return [key, true];
|
|
49
|
+
if (raw === "false")
|
|
50
|
+
return [key, false];
|
|
47
51
|
const asNumber = Number(raw);
|
|
48
52
|
return [key, Number.isFinite(asNumber) && String(asNumber) === raw ? asNumber : raw];
|
|
49
53
|
}));
|
|
50
54
|
}
|
|
55
|
+
function parsePolicyReceiver(prefix) {
|
|
56
|
+
const mode = getArg(`${prefix}-mode`) ?? (getArg(`${prefix}-address`) ? "plain" : "policy");
|
|
57
|
+
if (mode === "plain") {
|
|
58
|
+
return { mode: "plain", address: requireArg(`${prefix}-address`) };
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
mode: "policy",
|
|
62
|
+
recipientXonly: requireArg(`${prefix}-recipient-xonly`),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function parsePolicyOutputForm() {
|
|
66
|
+
const assetForm = getArg("asset-form");
|
|
67
|
+
const amountForm = getArg("amount-form");
|
|
68
|
+
const nonceForm = getArg("nonce-form");
|
|
69
|
+
const rangeProofForm = getArg("range-proof-form");
|
|
70
|
+
if (!assetForm && !amountForm && !nonceForm && !rangeProofForm) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
...(assetForm ? { assetForm } : {}),
|
|
75
|
+
...(amountForm ? { amountForm } : {}),
|
|
76
|
+
...(nonceForm ? { nonceForm } : {}),
|
|
77
|
+
...(rangeProofForm ? { rangeProofForm } : {}),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function parseRawOutputFields() {
|
|
81
|
+
const assetBytesHex = getArg("asset-bytes-hex");
|
|
82
|
+
const amountBytesHex = getArg("amount-bytes-hex");
|
|
83
|
+
const nonceBytesHex = getArg("nonce-bytes-hex");
|
|
84
|
+
const scriptPubKeyHex = getArg("script-pubkey-hex");
|
|
85
|
+
const scriptPubKeyHashHex = getArg("script-pubkey-hash-hex");
|
|
86
|
+
const rangeProofHex = getArg("range-proof-hex-raw");
|
|
87
|
+
const rangeProofHashHex = getArg("range-proof-hash-hex");
|
|
88
|
+
if (!assetBytesHex
|
|
89
|
+
&& !amountBytesHex
|
|
90
|
+
&& !nonceBytesHex
|
|
91
|
+
&& !scriptPubKeyHex
|
|
92
|
+
&& !scriptPubKeyHashHex
|
|
93
|
+
&& !rangeProofHex
|
|
94
|
+
&& !rangeProofHashHex) {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
...(assetBytesHex ? { assetBytesHex } : {}),
|
|
99
|
+
...(amountBytesHex ? { amountBytesHex } : {}),
|
|
100
|
+
...(nonceBytesHex ? { nonceBytesHex } : {}),
|
|
101
|
+
...(scriptPubKeyHex !== undefined ? { scriptPubKeyHex } : {}),
|
|
102
|
+
...(scriptPubKeyHashHex ? { scriptPubKeyHashHex } : {}),
|
|
103
|
+
...(rangeProofHex !== undefined ? { rangeProofHex } : {}),
|
|
104
|
+
...(rangeProofHashHex ? { rangeProofHashHex } : {}),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function parsePolicyTemplateInput() {
|
|
108
|
+
const templateId = getArg("template-id");
|
|
109
|
+
const templateManifest = getArg("template-manifest");
|
|
110
|
+
const templateManifestValue = getArg("template-manifest-value");
|
|
111
|
+
if (!templateId && !templateManifest && !templateManifestValue) {
|
|
112
|
+
throw new Error("Missing required arg: --template-id or --template-manifest or --template-manifest-value");
|
|
113
|
+
}
|
|
114
|
+
const templateJson = getArg("template-json");
|
|
115
|
+
const parsedManifestValue = templateManifestValue ? JSON.parse(templateManifestValue) : undefined;
|
|
116
|
+
return {
|
|
117
|
+
...(templateId ? { templateId } : {}),
|
|
118
|
+
...(templateManifest ? { manifestPath: templateManifest } : {}),
|
|
119
|
+
...(parsedManifestValue ? { manifestValue: parsedManifestValue } : {}),
|
|
120
|
+
...(templateJson ? { jsonPath: templateJson } : templateId ? { value: { policyTemplateId: templateId } } : {}),
|
|
121
|
+
...(getArg("state-simf") ? { stateSimfPath: getArg("state-simf") } : {}),
|
|
122
|
+
...(getArg("direct-state-simf") ? { directStateSimfPath: getArg("direct-state-simf") } : {}),
|
|
123
|
+
...(getArg("machine-simf") ? { transferMachineSimfPath: getArg("machine-simf") } : {}),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
51
126
|
function parseWitnessAssignments(values) {
|
|
52
127
|
return Object.fromEntries(values.map((entry) => {
|
|
53
128
|
const [left, value] = entry.split("=", 2);
|
|
@@ -130,6 +205,496 @@ function resolveConfig() {
|
|
|
130
205
|
function printJson(value) {
|
|
131
206
|
process.stdout.write(`${JSON.stringify(value, null, 2)}\n`);
|
|
132
207
|
}
|
|
208
|
+
function formatPolicyOutputBindingSummary(outputBinding) {
|
|
209
|
+
const lines = [
|
|
210
|
+
`mode=${outputBinding.mode}`,
|
|
211
|
+
`committed=${outputBinding.committed}`,
|
|
212
|
+
`runtimeBound=${outputBinding.runtimeBound}`,
|
|
213
|
+
`sdkVerified=${outputBinding.sdkVerified}`,
|
|
214
|
+
`amountRuntimeBound=${outputBinding.amountRuntimeBound}`,
|
|
215
|
+
`nextOutputHashRuntimeBound=${outputBinding.nextOutputHashRuntimeBound}`,
|
|
216
|
+
`nextOutputScriptRuntimeBound=${outputBinding.nextOutputScriptRuntimeBound}`,
|
|
217
|
+
];
|
|
218
|
+
if (outputBinding.supportedForm)
|
|
219
|
+
lines.push(`supportedForm=${outputBinding.supportedForm}`);
|
|
220
|
+
if (outputBinding.reasonCode)
|
|
221
|
+
lines.push(`reasonCode=${outputBinding.reasonCode}`);
|
|
222
|
+
if (outputBinding.nextOutputHash)
|
|
223
|
+
lines.push(`nextOutputHash=${outputBinding.nextOutputHash}`);
|
|
224
|
+
if (outputBinding.autoDerived !== undefined)
|
|
225
|
+
lines.push(`autoDerived=${outputBinding.autoDerived}`);
|
|
226
|
+
if (outputBinding.fallbackReason)
|
|
227
|
+
lines.push(`fallbackReason=${outputBinding.fallbackReason}`);
|
|
228
|
+
if (outputBinding.bindingInputs) {
|
|
229
|
+
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})`);
|
|
230
|
+
if (outputBinding.bindingInputs.rawOutputComponents) {
|
|
231
|
+
lines.push(`rawOutputComponents(scriptPubKey=${outputBinding.bindingInputs.rawOutputComponents.scriptPubKey}, rangeProof=${outputBinding.bindingInputs.rawOutputComponents.rangeProof})`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return lines.join("\n");
|
|
235
|
+
}
|
|
236
|
+
function formatPolicyVerificationSummary(input) {
|
|
237
|
+
const lines = [
|
|
238
|
+
`ok=${input.ok ?? true}`,
|
|
239
|
+
`propagationMode=${input.propagationMode}`,
|
|
240
|
+
`enforcement=${input.enforcement}`,
|
|
241
|
+
`plainExitAllowed=${input.plainExitAllowed}`,
|
|
242
|
+
`nextPolicyRequired=${input.nextPolicyRequired}`,
|
|
243
|
+
`nextPolicyPresent=${input.nextPolicyPresent}`,
|
|
244
|
+
];
|
|
245
|
+
if (input.reason)
|
|
246
|
+
lines.push(`reason=${input.reason}`);
|
|
247
|
+
if (input.outputBinding) {
|
|
248
|
+
lines.push("outputBinding:");
|
|
249
|
+
lines.push(indent(formatPolicyOutputBindingSummary(input.outputBinding), 2));
|
|
250
|
+
}
|
|
251
|
+
return lines.join("\n");
|
|
252
|
+
}
|
|
253
|
+
function formatPolicyEvidenceSummary(input) {
|
|
254
|
+
const lines = [
|
|
255
|
+
`templateHash=${input.templateHash}`,
|
|
256
|
+
`stateHash=${input.stateHash}`,
|
|
257
|
+
`transferHash=${input.transferHash ?? "(none)"}`,
|
|
258
|
+
`enforcement=${input.enforcement}`,
|
|
259
|
+
`sourceVerificationMode=${input.sourceVerificationMode}`,
|
|
260
|
+
];
|
|
261
|
+
if (input.outputBinding) {
|
|
262
|
+
lines.push("outputBinding:");
|
|
263
|
+
lines.push(indent(formatPolicyOutputBindingSummary(input.outputBinding), 2));
|
|
264
|
+
}
|
|
265
|
+
return lines.join("\n");
|
|
266
|
+
}
|
|
267
|
+
function formatPolicyInspectOrExecuteSummary(input) {
|
|
268
|
+
const lines = [
|
|
269
|
+
`mode=${input.mode}`,
|
|
270
|
+
`propagationMode=${input.propagationMode}`,
|
|
271
|
+
`enforcement=${input.enforcement}`,
|
|
272
|
+
`plainExitAllowed=${input.plainExitAllowed}`,
|
|
273
|
+
`nextPolicyRequired=${input.nextPolicyRequired}`,
|
|
274
|
+
`nextPolicyPresent=${input.nextPolicyPresent}`,
|
|
275
|
+
];
|
|
276
|
+
if (input.summaryHash)
|
|
277
|
+
lines.push(`summaryHash=${input.summaryHash}`);
|
|
278
|
+
if (input.txId)
|
|
279
|
+
lines.push(`txId=${input.txId}`);
|
|
280
|
+
if (input.broadcasted !== undefined)
|
|
281
|
+
lines.push(`broadcasted=${input.broadcasted}`);
|
|
282
|
+
if (input.outputBinding) {
|
|
283
|
+
lines.push("outputBinding:");
|
|
284
|
+
lines.push(indent(formatPolicyOutputBindingSummary(input.outputBinding), 2));
|
|
285
|
+
}
|
|
286
|
+
return lines.join("\n");
|
|
287
|
+
}
|
|
288
|
+
function formatPolicyIssueSummary(input) {
|
|
289
|
+
return [
|
|
290
|
+
`propagationMode=${input.propagationMode}`,
|
|
291
|
+
`policyHash=${input.policyHash}`,
|
|
292
|
+
`contractAddress=${input.contractAddress}`,
|
|
293
|
+
`amountSat=${input.amountSat}`,
|
|
294
|
+
`assetId=${input.assetId}`,
|
|
295
|
+
`recipient=${input.recipient}`,
|
|
296
|
+
].join("\n");
|
|
297
|
+
}
|
|
298
|
+
function formatPolicyOutputDescriptorBuildSummary(input) {
|
|
299
|
+
const lines = [
|
|
300
|
+
`mode=${input.mode}`,
|
|
301
|
+
`nextContractAddress=${input.nextContractAddress}`,
|
|
302
|
+
`nextAmountSat=${input.nextAmountSat}`,
|
|
303
|
+
`assetId=${input.assetId}`,
|
|
304
|
+
];
|
|
305
|
+
if (input.supportedForm)
|
|
306
|
+
lines.push(`supportedForm=${input.supportedForm}`);
|
|
307
|
+
if (input.reasonCode)
|
|
308
|
+
lines.push(`reasonCode=${input.reasonCode}`);
|
|
309
|
+
if (input.nextOutputScriptHash)
|
|
310
|
+
lines.push(`nextOutputScriptHash=${input.nextOutputScriptHash}`);
|
|
311
|
+
if (input.nextOutputHash)
|
|
312
|
+
lines.push(`nextOutputHash=${input.nextOutputHash}`);
|
|
313
|
+
if (input.autoDerived !== undefined)
|
|
314
|
+
lines.push(`autoDerived=${input.autoDerived}`);
|
|
315
|
+
if (input.fallbackReason)
|
|
316
|
+
lines.push(`fallbackReason=${input.fallbackReason}`);
|
|
317
|
+
return lines.join("\n");
|
|
318
|
+
}
|
|
319
|
+
function formatPolicyBindingSupportSummary(input) {
|
|
320
|
+
const lines = ["supportedForms:"];
|
|
321
|
+
for (const form of input.supportedForms) {
|
|
322
|
+
lines.push(indent([
|
|
323
|
+
`form=${form.form}`,
|
|
324
|
+
`autoDerived=${form.autoDerived}`,
|
|
325
|
+
`description=${form.description}`,
|
|
326
|
+
].join("\n"), 2));
|
|
327
|
+
}
|
|
328
|
+
if (input.unsupportedOutputFeatures && input.unsupportedOutputFeatures.length > 0) {
|
|
329
|
+
lines.push("unsupportedOutputFeatures:");
|
|
330
|
+
for (const feature of input.unsupportedOutputFeatures) {
|
|
331
|
+
lines.push(indent([
|
|
332
|
+
`feature=${feature.feature}`,
|
|
333
|
+
`fallbackReasonCode=${feature.fallbackReasonCode}`,
|
|
334
|
+
`manualHashSupported=${feature.manualHashSupported}`,
|
|
335
|
+
`description=${feature.description}`,
|
|
336
|
+
].join("\n"), 2));
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
lines.push("outputBindingModes:");
|
|
340
|
+
for (const [mode, details] of Object.entries(input.outputBindingModes)) {
|
|
341
|
+
lines.push(indent([
|
|
342
|
+
`mode=${mode}`,
|
|
343
|
+
`runtimeBinding=${details.runtimeBinding}`,
|
|
344
|
+
`description=${details.description}`,
|
|
345
|
+
`fallbackBehavior=${details.fallbackBehavior}`,
|
|
346
|
+
].join("\n"), 2));
|
|
347
|
+
}
|
|
348
|
+
lines.push(`autoDeriveConditions=assetInput(${input.autoDeriveConditions.assetInput.join(", ")}), amountForm=${input.autoDeriveConditions.amountForm}, nonceForm=${input.autoDeriveConditions.nonceForm}, rangeProofForm=${input.autoDeriveConditions.rangeProofForm}`);
|
|
349
|
+
if (input.autoDeriveConditions.rawOutputFields?.length) {
|
|
350
|
+
lines.push(`rawOutputFields=${input.autoDeriveConditions.rawOutputFields.join(",")}`);
|
|
351
|
+
}
|
|
352
|
+
if (input.autoDeriveConditions.rawOutputFieldAlternatives) {
|
|
353
|
+
for (const [name, fields] of Object.entries(input.autoDeriveConditions.rawOutputFieldAlternatives)) {
|
|
354
|
+
lines.push(`rawOutputFieldAlternatives.${name}=${fields.join("|")}`);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
if (input.autoDeriveConditions.outputHashExclusions?.length) {
|
|
358
|
+
lines.push(`outputHashExclusions=${input.autoDeriveConditions.outputHashExclusions.join(",")}`);
|
|
359
|
+
}
|
|
360
|
+
lines.push(`manualHashPath.supported=${input.manualHashPath.supported}`);
|
|
361
|
+
lines.push(`manualHashPath.description=${input.manualHashPath.description}`);
|
|
362
|
+
lines.push(`fallback.defaultMode=${input.fallbackBehavior.defaultMode}`);
|
|
363
|
+
lines.push(`fallback.reasonCodes=${input.fallbackBehavior.reasonCodes.join(",")}`);
|
|
364
|
+
lines.push(`validation.local=${input.publicValidationMatrix.local.join(" | ")}`);
|
|
365
|
+
lines.push(`validation.testnet=${input.publicValidationMatrix.testnet.join(" | ")}`);
|
|
366
|
+
if (input.nonGoals.length > 0) {
|
|
367
|
+
lines.push("nonGoals:");
|
|
368
|
+
for (const goal of input.nonGoals) {
|
|
369
|
+
lines.push(indent(goal, 2));
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return lines.join("\n");
|
|
373
|
+
}
|
|
374
|
+
function formatOutputBindingSupportEvaluationSummary(input) {
|
|
375
|
+
const lines = [
|
|
376
|
+
`requestedBindingMode=${input.requestedBindingMode}`,
|
|
377
|
+
`resolvedBindingMode=${input.resolvedBindingMode}`,
|
|
378
|
+
`supportedForm=${input.supportedForm}`,
|
|
379
|
+
`reasonCode=${input.reasonCode}`,
|
|
380
|
+
`autoDerived=${input.autoDerived}`,
|
|
381
|
+
`assetId=${input.assetId}`,
|
|
382
|
+
`explicitAssetInputSupported=${input.explicitAssetInputSupported}`,
|
|
383
|
+
`manualHashSupplied=${input.manualHashSupplied}`,
|
|
384
|
+
`nextOutputScriptAvailable=${input.nextOutputScriptAvailable}`,
|
|
385
|
+
`rawOutputProvided=${input.rawOutputProvided === true}`,
|
|
386
|
+
`outputForm(assetForm=${input.outputForm.assetForm}, amountForm=${input.outputForm.amountForm}, nonceForm=${input.outputForm.nonceForm}, rangeProofForm=${input.outputForm.rangeProofForm})`,
|
|
387
|
+
];
|
|
388
|
+
if (input.fallbackReason)
|
|
389
|
+
lines.push(`fallbackReason=${input.fallbackReason}`);
|
|
390
|
+
if (input.rawOutputComponents) {
|
|
391
|
+
lines.push(`rawOutputComponents(scriptPubKey=${input.rawOutputComponents.scriptPubKey}, rangeProof=${input.rawOutputComponents.rangeProof})`);
|
|
392
|
+
}
|
|
393
|
+
if (input.unsupportedFeatures.length > 0) {
|
|
394
|
+
lines.push(`unsupportedFeatures=${input.unsupportedFeatures.join(",")}`);
|
|
395
|
+
}
|
|
396
|
+
return lines.join("\n");
|
|
397
|
+
}
|
|
398
|
+
function formatBondBindingMetadataSummary(input) {
|
|
399
|
+
const lines = [];
|
|
400
|
+
if (input.bindingMode)
|
|
401
|
+
lines.push(`bindingMode=${input.bindingMode}`);
|
|
402
|
+
if (input.supportedForm)
|
|
403
|
+
lines.push(`supportedForm=${input.supportedForm}`);
|
|
404
|
+
if (input.reasonCode)
|
|
405
|
+
lines.push(`reasonCode=${input.reasonCode}`);
|
|
406
|
+
if (input.nextOutputHash)
|
|
407
|
+
lines.push(`nextOutputHash=${input.nextOutputHash}`);
|
|
408
|
+
if (input.autoDerived !== undefined)
|
|
409
|
+
lines.push(`autoDerived=${input.autoDerived}`);
|
|
410
|
+
if (input.fallbackReason)
|
|
411
|
+
lines.push(`fallbackReason=${input.fallbackReason}`);
|
|
412
|
+
if (input.bindingInputs) {
|
|
413
|
+
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})`);
|
|
414
|
+
if (input.bindingInputs.rawOutputComponents) {
|
|
415
|
+
lines.push(`rawOutputComponents(scriptPubKey=${input.bindingInputs.rawOutputComponents.scriptPubKey}, rangeProof=${input.bindingInputs.rawOutputComponents.rangeProof})`);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
return lines.join("\n");
|
|
419
|
+
}
|
|
420
|
+
function formatBondDefinitionOrVerificationSummary(input) {
|
|
421
|
+
return [
|
|
422
|
+
input.contractAddress ? `contractAddress=${input.contractAddress}` : undefined,
|
|
423
|
+
input.cmr ? `cmr=${input.cmr}` : undefined,
|
|
424
|
+
input.artifactPath ? `artifactPath=${input.artifactPath}` : undefined,
|
|
425
|
+
input.definitionHash ? `definitionHash=${input.definitionHash}` : undefined,
|
|
426
|
+
input.issuanceHash ? `issuanceHash=${input.issuanceHash}` : undefined,
|
|
427
|
+
input.definitionOk !== undefined ? `definitionOk=${input.definitionOk}` : undefined,
|
|
428
|
+
input.issuanceOk !== undefined ? `issuanceOk=${input.issuanceOk}` : undefined,
|
|
429
|
+
input.principalInvariantValid !== undefined
|
|
430
|
+
? `principalInvariantValid=${input.principalInvariantValid}`
|
|
431
|
+
: undefined,
|
|
432
|
+
input.definitionTrustMode ? `definitionTrustMode=${input.definitionTrustMode}` : undefined,
|
|
433
|
+
input.issuanceTrustMode ? `issuanceTrustMode=${input.issuanceTrustMode}` : undefined,
|
|
434
|
+
]
|
|
435
|
+
.filter(Boolean)
|
|
436
|
+
.join("\n");
|
|
437
|
+
}
|
|
438
|
+
function formatBondSettlementSummary(input) {
|
|
439
|
+
const lines = [
|
|
440
|
+
input.ok !== undefined ? `ok=${input.ok}` : undefined,
|
|
441
|
+
input.reason ? `reason=${input.reason}` : undefined,
|
|
442
|
+
`descriptorHash=${input.descriptorHash}`,
|
|
443
|
+
`bindingMode=${input.bindingMode}`,
|
|
444
|
+
input.previousStateHash ? `previousStateHash=${input.previousStateHash}` : undefined,
|
|
445
|
+
input.nextStateHash ? `nextStateHash=${input.nextStateHash}` : undefined,
|
|
446
|
+
input.nextContractAddress ? `nextContractAddress=${input.nextContractAddress}` : undefined,
|
|
447
|
+
input.nextAmountSat !== undefined ? `nextAmountSat=${input.nextAmountSat}` : undefined,
|
|
448
|
+
input.maxFeeSat !== undefined ? `maxFeeSat=${input.maxFeeSat}` : undefined,
|
|
449
|
+
].filter(Boolean);
|
|
450
|
+
const binding = formatBondBindingMetadataSummary({
|
|
451
|
+
bindingMode: input.bindingMode,
|
|
452
|
+
supportedForm: input.supportedForm,
|
|
453
|
+
reasonCode: input.reasonCode,
|
|
454
|
+
autoDerived: input.autoDerived,
|
|
455
|
+
fallbackReason: input.fallbackReason,
|
|
456
|
+
nextOutputHash: input.nextOutputHash,
|
|
457
|
+
bindingInputs: input.bindingInputs,
|
|
458
|
+
});
|
|
459
|
+
return binding ? `${lines.join("\n")}\n${binding}` : lines.join("\n");
|
|
460
|
+
}
|
|
461
|
+
function formatBondRedemptionSummary(input) {
|
|
462
|
+
const lines = [
|
|
463
|
+
`phase=${input.phase}`,
|
|
464
|
+
`mode=${input.mode}`,
|
|
465
|
+
input.nextStatus ? `nextStatus=${input.nextStatus}` : undefined,
|
|
466
|
+
`descriptorHash=${input.descriptorHash}`,
|
|
467
|
+
input.nextStateHash ? `nextStateHash=${input.nextStateHash}` : undefined,
|
|
468
|
+
input.nextContractAddress ? `nextContractAddress=${input.nextContractAddress}` : undefined,
|
|
469
|
+
input.nextAmountSat !== undefined ? `nextAmountSat=${input.nextAmountSat}` : undefined,
|
|
470
|
+
input.summaryHash ? `summaryHash=${input.summaryHash}` : undefined,
|
|
471
|
+
input.txId ? `txId=${input.txId}` : undefined,
|
|
472
|
+
input.broadcasted !== undefined ? `broadcasted=${input.broadcasted}` : undefined,
|
|
473
|
+
input.verified !== undefined ? `verified=${input.verified}` : undefined,
|
|
474
|
+
].filter(Boolean);
|
|
475
|
+
if (input.bindingMetadata) {
|
|
476
|
+
const bindingMetadata = formatBondBindingMetadataSummary(input.bindingMetadata);
|
|
477
|
+
if (bindingMetadata)
|
|
478
|
+
lines.push(bindingMetadata);
|
|
479
|
+
}
|
|
480
|
+
if (input.outputBindingTrust) {
|
|
481
|
+
lines.push([
|
|
482
|
+
`outputBinding.mode=${input.outputBindingTrust.mode}`,
|
|
483
|
+
`outputBinding.nextContractAddressCommitted=${input.outputBindingTrust.nextContractAddressCommitted}`,
|
|
484
|
+
input.outputBindingTrust.expectedOutputDescriptorCommitted !== undefined
|
|
485
|
+
? `outputBinding.expectedOutputDescriptorCommitted=${input.outputBindingTrust.expectedOutputDescriptorCommitted}`
|
|
486
|
+
: undefined,
|
|
487
|
+
input.outputBindingTrust.settlementDescriptorCommitted !== undefined
|
|
488
|
+
? `outputBinding.settlementDescriptorCommitted=${input.outputBindingTrust.settlementDescriptorCommitted}`
|
|
489
|
+
: undefined,
|
|
490
|
+
`outputBinding.outputCountRuntimeBound=${input.outputBindingTrust.outputCountRuntimeBound}`,
|
|
491
|
+
`outputBinding.feeIndexRuntimeBound=${input.outputBindingTrust.feeIndexRuntimeBound}`,
|
|
492
|
+
`outputBinding.amountRuntimeBound=${input.outputBindingTrust.amountRuntimeBound}`,
|
|
493
|
+
`outputBinding.nextOutputHashRuntimeBound=${input.outputBindingTrust.nextOutputHashRuntimeBound}`,
|
|
494
|
+
`outputBinding.nextOutputScriptRuntimeBound=${input.outputBindingTrust.nextOutputScriptRuntimeBound}`,
|
|
495
|
+
input.outputBindingTrust.supportedForm
|
|
496
|
+
? `outputBinding.supportedForm=${input.outputBindingTrust.supportedForm}`
|
|
497
|
+
: undefined,
|
|
498
|
+
input.outputBindingTrust.reasonCode
|
|
499
|
+
? `outputBinding.reasonCode=${input.outputBindingTrust.reasonCode}`
|
|
500
|
+
: undefined,
|
|
501
|
+
input.outputBindingTrust.nextOutputHash
|
|
502
|
+
? `outputBinding.nextOutputHash=${input.outputBindingTrust.nextOutputHash}`
|
|
503
|
+
: undefined,
|
|
504
|
+
input.outputBindingTrust.autoDerived !== undefined
|
|
505
|
+
? `outputBinding.autoDerived=${input.outputBindingTrust.autoDerived}`
|
|
506
|
+
: undefined,
|
|
507
|
+
input.outputBindingTrust.fallbackReason
|
|
508
|
+
? `outputBinding.fallbackReason=${input.outputBindingTrust.fallbackReason}`
|
|
509
|
+
: undefined,
|
|
510
|
+
]
|
|
511
|
+
.filter(Boolean)
|
|
512
|
+
.join("\n"));
|
|
513
|
+
if (input.outputBindingTrust.bindingInputs) {
|
|
514
|
+
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})`);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
return lines.join("\n");
|
|
518
|
+
}
|
|
519
|
+
function formatBondClosingSummary(input) {
|
|
520
|
+
const lines = [
|
|
521
|
+
`phase=${input.phase}`,
|
|
522
|
+
input.closingHash ? `closingHash=${input.closingHash}` : undefined,
|
|
523
|
+
input.closedAt ? `closedAt=${input.closedAt}` : undefined,
|
|
524
|
+
input.closingReason ? `closingReason=${input.closingReason}` : undefined,
|
|
525
|
+
input.finalSettlementDescriptorHash
|
|
526
|
+
? `finalSettlementDescriptorHash=${input.finalSettlementDescriptorHash}`
|
|
527
|
+
: undefined,
|
|
528
|
+
input.summaryHash ? `summaryHash=${input.summaryHash}` : undefined,
|
|
529
|
+
input.txId ? `txId=${input.txId}` : undefined,
|
|
530
|
+
input.broadcasted !== undefined ? `broadcasted=${input.broadcasted}` : undefined,
|
|
531
|
+
input.verified !== undefined ? `verified=${input.verified}` : undefined,
|
|
532
|
+
].filter(Boolean);
|
|
533
|
+
if (input.checks) {
|
|
534
|
+
lines.push(`checks=${Object.entries(input.checks)
|
|
535
|
+
.map(([key, value]) => `${key}:${value}`)
|
|
536
|
+
.join(",")}`);
|
|
537
|
+
}
|
|
538
|
+
return lines.join("\n");
|
|
539
|
+
}
|
|
540
|
+
function formatBondEvidenceSummary(input) {
|
|
541
|
+
return [
|
|
542
|
+
`definitionHash=${input.definitionHash}`,
|
|
543
|
+
`issuanceHash=${input.issuanceHash}`,
|
|
544
|
+
input.settlementHash ? `settlementHash=${input.settlementHash}` : undefined,
|
|
545
|
+
input.closingHash ? `closingHash=${input.closingHash}` : undefined,
|
|
546
|
+
input.renderedSourceHash ? `renderedSourceHash=${input.renderedSourceHash}` : undefined,
|
|
547
|
+
input.sourceVerificationMode ? `sourceVerificationMode=${input.sourceVerificationMode}` : undefined,
|
|
548
|
+
]
|
|
549
|
+
.filter(Boolean)
|
|
550
|
+
.join("\n");
|
|
551
|
+
}
|
|
552
|
+
function formatBondFinalityPayloadSummary(input) {
|
|
553
|
+
return [
|
|
554
|
+
`bondId=${input.bondId}`,
|
|
555
|
+
`issuanceId=${input.issuanceId}`,
|
|
556
|
+
`definitionHash=${input.definitionHash}`,
|
|
557
|
+
`issuanceStateHash=${input.issuanceStateHash}`,
|
|
558
|
+
input.settlementDescriptorHash ? `settlementDescriptorHash=${input.settlementDescriptorHash}` : undefined,
|
|
559
|
+
input.closingDescriptorHash ? `closingDescriptorHash=${input.closingDescriptorHash}` : undefined,
|
|
560
|
+
`contractAddress=${input.contractAddress}`,
|
|
561
|
+
`cmr=${input.cmr}`,
|
|
562
|
+
`bindingMode=${input.bindingMode}`,
|
|
563
|
+
]
|
|
564
|
+
.filter(Boolean)
|
|
565
|
+
.join("\n");
|
|
566
|
+
}
|
|
567
|
+
function formatFundOutputBindingSummary(outputBinding) {
|
|
568
|
+
const lines = [
|
|
569
|
+
`mode=${outputBinding.mode}`,
|
|
570
|
+
outputBinding.requestedMode ? `requestedMode=${outputBinding.requestedMode}` : undefined,
|
|
571
|
+
`nextReceiverRuntimeCommitted=${outputBinding.nextReceiverRuntimeCommitted}`,
|
|
572
|
+
`outputCountRuntimeBound=${outputBinding.outputCountRuntimeBound}`,
|
|
573
|
+
`feeIndexRuntimeBound=${outputBinding.feeIndexRuntimeBound}`,
|
|
574
|
+
`nextOutputHashRuntimeBound=${outputBinding.nextOutputHashRuntimeBound ?? false}`,
|
|
575
|
+
`nextOutputScriptRuntimeBound=${outputBinding.nextOutputScriptRuntimeBound}`,
|
|
576
|
+
`amountRuntimeBound=${outputBinding.amountRuntimeBound}`,
|
|
577
|
+
outputBinding.supportedForm ? `supportedForm=${outputBinding.supportedForm}` : undefined,
|
|
578
|
+
outputBinding.reasonCode ? `reasonCode=${outputBinding.reasonCode}` : undefined,
|
|
579
|
+
outputBinding.autoDerived !== undefined ? `autoDerived=${outputBinding.autoDerived}` : undefined,
|
|
580
|
+
outputBinding.fallbackReason ? `fallbackReason=${outputBinding.fallbackReason}` : undefined,
|
|
581
|
+
].filter(Boolean);
|
|
582
|
+
if (outputBinding.bindingInputs) {
|
|
583
|
+
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})`);
|
|
584
|
+
if (outputBinding.bindingInputs.rawOutputComponents) {
|
|
585
|
+
lines.push(`rawOutputComponents(scriptPubKey=${outputBinding.bindingInputs.rawOutputComponents.scriptPubKey}, rangeProof=${outputBinding.bindingInputs.rawOutputComponents.rangeProof})`);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
return lines.join("\n");
|
|
589
|
+
}
|
|
590
|
+
function formatFundDefinitionSummary(input) {
|
|
591
|
+
return [
|
|
592
|
+
`ok=${input.ok ?? true}`,
|
|
593
|
+
`fundId=${input.fundId}`,
|
|
594
|
+
`managerEntityId=${input.managerEntityId}`,
|
|
595
|
+
`currencyAssetId=${input.currencyAssetId}`,
|
|
596
|
+
input.jurisdiction ? `jurisdiction=${input.jurisdiction}` : undefined,
|
|
597
|
+
input.vintage ? `vintage=${input.vintage}` : undefined,
|
|
598
|
+
]
|
|
599
|
+
.filter(Boolean)
|
|
600
|
+
.join("\n");
|
|
601
|
+
}
|
|
602
|
+
function formatFundCapitalCallSummary(input) {
|
|
603
|
+
const lines = [
|
|
604
|
+
`phase=${input.phase}`,
|
|
605
|
+
input.ok !== undefined ? `ok=${input.ok}` : undefined,
|
|
606
|
+
`callId=${input.callId}`,
|
|
607
|
+
`status=${input.status}`,
|
|
608
|
+
`amount=${input.amount}`,
|
|
609
|
+
`assetId=${input.assetId}`,
|
|
610
|
+
input.contractAddress ? `contractAddress=${input.contractAddress}` : undefined,
|
|
611
|
+
input.summaryHash ? `summaryHash=${input.summaryHash}` : undefined,
|
|
612
|
+
input.positionReceiptHash ? `positionReceiptHash=${input.positionReceiptHash}` : undefined,
|
|
613
|
+
input.txId ? `txId=${input.txId}` : undefined,
|
|
614
|
+
input.broadcasted !== undefined ? `broadcasted=${input.broadcasted}` : undefined,
|
|
615
|
+
input.reason ? `reason=${input.reason}` : undefined,
|
|
616
|
+
].filter(Boolean);
|
|
617
|
+
if (input.outputBinding) {
|
|
618
|
+
lines.push("outputBinding:");
|
|
619
|
+
lines.push(indent(formatFundOutputBindingSummary(input.outputBinding), 2));
|
|
620
|
+
}
|
|
621
|
+
return lines.join("\n");
|
|
622
|
+
}
|
|
623
|
+
function formatFundDistributionSummary(input) {
|
|
624
|
+
const lines = [
|
|
625
|
+
`phase=${input.phase}`,
|
|
626
|
+
input.ok !== undefined ? `ok=${input.ok}` : undefined,
|
|
627
|
+
`distributionId=${input.distributionId}`,
|
|
628
|
+
`positionId=${input.positionId}`,
|
|
629
|
+
`amountSat=${input.amountSat}`,
|
|
630
|
+
`assetId=${input.assetId}`,
|
|
631
|
+
input.contractAddress ? `contractAddress=${input.contractAddress}` : undefined,
|
|
632
|
+
input.summaryHash ? `summaryHash=${input.summaryHash}` : undefined,
|
|
633
|
+
input.txId ? `txId=${input.txId}` : undefined,
|
|
634
|
+
input.broadcasted !== undefined ? `broadcasted=${input.broadcasted}` : undefined,
|
|
635
|
+
input.reason ? `reason=${input.reason}` : undefined,
|
|
636
|
+
].filter(Boolean);
|
|
637
|
+
if (input.outputBinding) {
|
|
638
|
+
lines.push("outputBinding:");
|
|
639
|
+
lines.push(indent(formatFundOutputBindingSummary(input.outputBinding), 2));
|
|
640
|
+
}
|
|
641
|
+
return lines.join("\n");
|
|
642
|
+
}
|
|
643
|
+
function formatFundReceiptReconcileSummary(input) {
|
|
644
|
+
return [
|
|
645
|
+
`positionId=${input.positionId}`,
|
|
646
|
+
`distributionCount=${input.distributionCount}`,
|
|
647
|
+
`distributedAmount=${input.distributedAmount}`,
|
|
648
|
+
`fundedAmount=${input.fundedAmount}`,
|
|
649
|
+
`status=${input.status}`,
|
|
650
|
+
`receiptHash=${input.receiptHash}`,
|
|
651
|
+
input.sequence !== undefined ? `sequence=${input.sequence}` : undefined,
|
|
652
|
+
input.envelopeHash ? `envelopeHash=${input.envelopeHash}` : undefined,
|
|
653
|
+
].join("\n");
|
|
654
|
+
}
|
|
655
|
+
function formatFundClosingSummary(input) {
|
|
656
|
+
return [
|
|
657
|
+
`ok=${input.ok ?? true}`,
|
|
658
|
+
`closingHash=${input.closingHash}`,
|
|
659
|
+
`closedAt=${input.closedAt}`,
|
|
660
|
+
`closingReason=${input.closingReason}`,
|
|
661
|
+
`positionId=${input.positionId}`,
|
|
662
|
+
`distributionCount=${input.distributionCount}`,
|
|
663
|
+
input.reason ? `reason=${input.reason}` : undefined,
|
|
664
|
+
]
|
|
665
|
+
.filter(Boolean)
|
|
666
|
+
.join("\n");
|
|
667
|
+
}
|
|
668
|
+
function formatFundEvidenceSummary(input) {
|
|
669
|
+
return [
|
|
670
|
+
`definitionHash=${input.definitionHash}`,
|
|
671
|
+
input.capitalCallHash ? `capitalCallHash=${input.capitalCallHash}` : undefined,
|
|
672
|
+
input.positionReceiptHash ? `positionReceiptHash=${input.positionReceiptHash}` : undefined,
|
|
673
|
+
input.positionReceiptEnvelopeHash ? `positionReceiptEnvelopeHash=${input.positionReceiptEnvelopeHash}` : undefined,
|
|
674
|
+
input.distributionHash ? `distributionHash=${input.distributionHash}` : undefined,
|
|
675
|
+
input.closingHash ? `closingHash=${input.closingHash}` : undefined,
|
|
676
|
+
`sourceVerificationMode=${input.sourceVerificationMode}`,
|
|
677
|
+
]
|
|
678
|
+
.filter(Boolean)
|
|
679
|
+
.join("\n");
|
|
680
|
+
}
|
|
681
|
+
function formatFundFinalitySummary(input) {
|
|
682
|
+
return [
|
|
683
|
+
`fundId=${input.fundId}`,
|
|
684
|
+
`lpId=${input.lpId}`,
|
|
685
|
+
input.callId ? `callId=${input.callId}` : undefined,
|
|
686
|
+
input.positionId ? `positionId=${input.positionId}` : undefined,
|
|
687
|
+
`definitionHash=${input.definitionHash}`,
|
|
688
|
+
input.capitalCallStateHash ? `capitalCallStateHash=${input.capitalCallStateHash}` : undefined,
|
|
689
|
+
input.positionReceiptHash ? `positionReceiptHash=${input.positionReceiptHash}` : undefined,
|
|
690
|
+
input.positionReceiptEnvelopeHash ? `positionReceiptEnvelopeHash=${input.positionReceiptEnvelopeHash}` : undefined,
|
|
691
|
+
input.distributionHash ? `distributionHash=${input.distributionHash}` : undefined,
|
|
692
|
+
input.closingHash ? `closingHash=${input.closingHash}` : undefined,
|
|
693
|
+
`bindingMode=${input.bindingMode}`,
|
|
694
|
+
]
|
|
695
|
+
.filter(Boolean)
|
|
696
|
+
.join("\n");
|
|
697
|
+
}
|
|
133
698
|
function indent(text, spaces = 2) {
|
|
134
699
|
const prefix = " ".repeat(spaces);
|
|
135
700
|
return text
|
|
@@ -486,7 +1051,7 @@ async function main() {
|
|
|
486
1051
|
const subcommand = process.argv[3];
|
|
487
1052
|
const sdk = (0, SimplicityClient_1.createSimplicityClient)(resolveConfig());
|
|
488
1053
|
if (!command) {
|
|
489
|
-
throw new Error("Usage: simplicity-cli <compile|presets|preset|contract|artifact|definition|state|bond|gasless> ...");
|
|
1054
|
+
throw new Error("Usage: simplicity-cli <compile|presets|preset|contract|artifact|definition|state|binding|policy|bond|fund|gasless> ...");
|
|
490
1055
|
}
|
|
491
1056
|
if (command === "compile") {
|
|
492
1057
|
const result = await sdk.compileFromFile({
|
|
@@ -567,6 +1132,393 @@ async function main() {
|
|
|
567
1132
|
});
|
|
568
1133
|
return;
|
|
569
1134
|
}
|
|
1135
|
+
if (command === "policy" && subcommand === "issue") {
|
|
1136
|
+
const result = await sdk.policies.issue({
|
|
1137
|
+
recipient: parsePolicyReceiver("recipient"),
|
|
1138
|
+
template: parsePolicyTemplateInput(),
|
|
1139
|
+
params: parseAssignments(getMultiArgs("param")),
|
|
1140
|
+
amountSat: Number(requireArg("amount-sat")),
|
|
1141
|
+
assetId: requireArg("asset-id"),
|
|
1142
|
+
propagationMode: getArg("propagation-mode", "required"),
|
|
1143
|
+
artifactPath: getArg("artifact"),
|
|
1144
|
+
});
|
|
1145
|
+
const stateOut = getArg("state-out");
|
|
1146
|
+
if (stateOut) {
|
|
1147
|
+
const resolved = node_path_1.default.resolve(stateOut);
|
|
1148
|
+
await (0, promises_1.mkdir)(node_path_1.default.dirname(resolved), { recursive: true });
|
|
1149
|
+
await (0, promises_1.writeFile)(resolved, `${JSON.stringify(result.state, null, 2)}\n`, "utf8");
|
|
1150
|
+
}
|
|
1151
|
+
printJson({
|
|
1152
|
+
summary: {
|
|
1153
|
+
propagationMode: result.state.propagationMode,
|
|
1154
|
+
policyHash: result.policyHash,
|
|
1155
|
+
contractAddress: result.compiled.deployment().contractAddress,
|
|
1156
|
+
amountSat: result.state.amountSat,
|
|
1157
|
+
assetId: result.state.assetId,
|
|
1158
|
+
recipient: result.state.recipient,
|
|
1159
|
+
},
|
|
1160
|
+
summaryText: formatPolicyIssueSummary({
|
|
1161
|
+
propagationMode: result.state.propagationMode,
|
|
1162
|
+
policyHash: result.policyHash,
|
|
1163
|
+
contractAddress: result.compiled.deployment().contractAddress,
|
|
1164
|
+
amountSat: result.state.amountSat,
|
|
1165
|
+
assetId: result.state.assetId,
|
|
1166
|
+
recipient: result.state.recipient,
|
|
1167
|
+
}),
|
|
1168
|
+
artifact: result.compiled.artifact,
|
|
1169
|
+
deployment: result.compiled.deployment(),
|
|
1170
|
+
state: result.state,
|
|
1171
|
+
policyTemplate: result.policyTemplate,
|
|
1172
|
+
policyHash: result.policyHash,
|
|
1173
|
+
stateOut: stateOut ? node_path_1.default.resolve(stateOut) : undefined,
|
|
1174
|
+
});
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
if (command === "policy" && subcommand === "list-templates") {
|
|
1178
|
+
printJson(sdk.policies.listTemplates());
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1181
|
+
if (command === "binding" && subcommand === "describe-support") {
|
|
1182
|
+
const result = sdk.outputBinding.describeSupport();
|
|
1183
|
+
printJson({
|
|
1184
|
+
summaryText: formatPolicyBindingSupportSummary(result),
|
|
1185
|
+
...result,
|
|
1186
|
+
});
|
|
1187
|
+
return;
|
|
1188
|
+
}
|
|
1189
|
+
if (command === "binding" && subcommand === "evaluate-support") {
|
|
1190
|
+
const result = sdk.outputBinding.evaluateSupport({
|
|
1191
|
+
assetId: requireArg("asset-id"),
|
|
1192
|
+
requestedBindingMode: getArg("output-binding-mode") ?? "descriptor-bound",
|
|
1193
|
+
outputForm: parsePolicyOutputForm(),
|
|
1194
|
+
rawOutput: parseRawOutputFields(),
|
|
1195
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
1196
|
+
nextOutputScriptAvailable: hasFlag("without-script-hash") ? false : true,
|
|
1197
|
+
});
|
|
1198
|
+
printJson({
|
|
1199
|
+
...result,
|
|
1200
|
+
summaryText: formatOutputBindingSupportEvaluationSummary(result),
|
|
1201
|
+
});
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1204
|
+
if (command === "policy" && subcommand === "verify-state") {
|
|
1205
|
+
const result = await sdk.policies.verifyState({
|
|
1206
|
+
artifactPath: requireArg("artifact"),
|
|
1207
|
+
template: parsePolicyTemplateInput(),
|
|
1208
|
+
statePath: getArg("state-json"),
|
|
1209
|
+
stateValue: getArg("state-value") ? JSON.parse(getArg("state-value")) : undefined,
|
|
1210
|
+
});
|
|
1211
|
+
printJson({
|
|
1212
|
+
summaryText: formatPolicyVerificationSummary({
|
|
1213
|
+
ok: result.ok,
|
|
1214
|
+
reason: result.reason,
|
|
1215
|
+
propagationMode: result.report.propagationMode,
|
|
1216
|
+
enforcement: result.report.enforcement,
|
|
1217
|
+
plainExitAllowed: result.report.plainExitAllowed,
|
|
1218
|
+
nextPolicyRequired: result.report.nextPolicyRequired,
|
|
1219
|
+
nextPolicyPresent: result.report.nextPolicyPresent,
|
|
1220
|
+
outputBinding: result.report.outputBinding,
|
|
1221
|
+
}),
|
|
1222
|
+
...result,
|
|
1223
|
+
});
|
|
1224
|
+
return;
|
|
1225
|
+
}
|
|
1226
|
+
if (command === "policy" && subcommand === "describe-template") {
|
|
1227
|
+
const templateManifest = getArg("template-manifest");
|
|
1228
|
+
const templateManifestValue = getArg("template-manifest-value");
|
|
1229
|
+
const templateId = getArg("template-id");
|
|
1230
|
+
const result = templateManifest || templateManifestValue || !templateId
|
|
1231
|
+
? await sdk.policies.loadTemplateManifest({
|
|
1232
|
+
templateId: templateId || undefined,
|
|
1233
|
+
propagationMode: getArg("propagation-mode"),
|
|
1234
|
+
manifestPath: templateManifest || undefined,
|
|
1235
|
+
manifestValue: templateManifestValue ? JSON.parse(templateManifestValue) : undefined,
|
|
1236
|
+
})
|
|
1237
|
+
: sdk.policies.describeTemplate({
|
|
1238
|
+
templateId,
|
|
1239
|
+
propagationMode: getArg("propagation-mode"),
|
|
1240
|
+
});
|
|
1241
|
+
printJson(result);
|
|
1242
|
+
return;
|
|
1243
|
+
}
|
|
1244
|
+
if (command === "policy" && subcommand === "validate-template-params") {
|
|
1245
|
+
const templateManifest = getArg("template-manifest");
|
|
1246
|
+
const templateManifestValue = getArg("template-manifest-value");
|
|
1247
|
+
const manifest = templateManifest || templateManifestValue
|
|
1248
|
+
? await sdk.policies.loadTemplateManifest({
|
|
1249
|
+
templateId: getArg("template-id") || undefined,
|
|
1250
|
+
propagationMode: getArg("propagation-mode"),
|
|
1251
|
+
manifestPath: templateManifest || undefined,
|
|
1252
|
+
manifestValue: templateManifestValue ? JSON.parse(templateManifestValue) : undefined,
|
|
1253
|
+
})
|
|
1254
|
+
: undefined;
|
|
1255
|
+
const result = sdk.policies.validateTemplateParams({
|
|
1256
|
+
templateId: getArg("template-id") || manifest?.templateId,
|
|
1257
|
+
manifestValue: manifest,
|
|
1258
|
+
propagationMode: getArg("propagation-mode"),
|
|
1259
|
+
params: parseAssignments(getMultiArgs("param")),
|
|
1260
|
+
});
|
|
1261
|
+
printJson({ ok: true, params: result });
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
if (command === "policy" && subcommand === "build-output-descriptor") {
|
|
1265
|
+
const result = await sdk.policies.buildOutputDescriptor({
|
|
1266
|
+
nextCompiledContractAddress: requireArg("next-contract-address"),
|
|
1267
|
+
nextAmountSat: Number(requireArg("next-amount-sat")),
|
|
1268
|
+
assetId: requireArg("asset-id"),
|
|
1269
|
+
maxFeeSat: getArg("max-fee-sat") ? Number(getArg("max-fee-sat")) : undefined,
|
|
1270
|
+
nextOutputIndex: getArg("next-output-index") ? Number(getArg("next-output-index")) : undefined,
|
|
1271
|
+
feeIndex: getArg("fee-index") ? Number(getArg("fee-index")) : undefined,
|
|
1272
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
1273
|
+
outputForm: parsePolicyOutputForm(),
|
|
1274
|
+
rawOutput: parseRawOutputFields(),
|
|
1275
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
1276
|
+
});
|
|
1277
|
+
printJson({
|
|
1278
|
+
summary: {
|
|
1279
|
+
mode: result.descriptor.outputBindingMode,
|
|
1280
|
+
nextContractAddress: result.descriptor.nextContractAddress,
|
|
1281
|
+
nextOutputScriptHash: result.descriptor.nextOutputScriptHash ?? null,
|
|
1282
|
+
nextOutputHash: result.descriptor.nextOutputHash ?? null,
|
|
1283
|
+
nextAmountSat: result.descriptor.nextAmountSat,
|
|
1284
|
+
assetId: result.descriptor.assetId,
|
|
1285
|
+
supportedForm: result.supportedForm,
|
|
1286
|
+
reasonCode: result.reasonCode,
|
|
1287
|
+
autoDerived: result.autoDerivedNextOutputHash,
|
|
1288
|
+
fallbackReason: result.fallbackReason ?? null,
|
|
1289
|
+
},
|
|
1290
|
+
summaryText: formatPolicyOutputDescriptorBuildSummary({
|
|
1291
|
+
mode: result.descriptor.outputBindingMode,
|
|
1292
|
+
nextContractAddress: result.descriptor.nextContractAddress,
|
|
1293
|
+
nextOutputScriptHash: result.descriptor.nextOutputScriptHash,
|
|
1294
|
+
nextOutputHash: result.descriptor.nextOutputHash,
|
|
1295
|
+
nextAmountSat: result.descriptor.nextAmountSat,
|
|
1296
|
+
assetId: result.descriptor.assetId,
|
|
1297
|
+
supportedForm: result.supportedForm,
|
|
1298
|
+
reasonCode: result.reasonCode,
|
|
1299
|
+
autoDerived: result.autoDerivedNextOutputHash,
|
|
1300
|
+
fallbackReason: result.fallbackReason,
|
|
1301
|
+
}),
|
|
1302
|
+
descriptor: result.descriptor,
|
|
1303
|
+
descriptorSummary: result.summary,
|
|
1304
|
+
supportedForm: result.supportedForm,
|
|
1305
|
+
autoDerivedNextOutputHash: result.autoDerivedNextOutputHash,
|
|
1306
|
+
reasonCode: result.reasonCode,
|
|
1307
|
+
bindingInputs: result.bindingInputs,
|
|
1308
|
+
fallbackReason: result.fallbackReason ?? null,
|
|
1309
|
+
});
|
|
1310
|
+
return;
|
|
1311
|
+
}
|
|
1312
|
+
if (command === "policy" && subcommand === "prepare-transfer") {
|
|
1313
|
+
const result = await sdk.policies.prepareTransfer({
|
|
1314
|
+
currentArtifactPath: requireArg("current-artifact"),
|
|
1315
|
+
template: parsePolicyTemplateInput(),
|
|
1316
|
+
currentStatePath: getArg("current-state-json"),
|
|
1317
|
+
currentStateValue: getArg("current-state-value") ? JSON.parse(getArg("current-state-value")) : undefined,
|
|
1318
|
+
nextReceiver: parsePolicyReceiver("next"),
|
|
1319
|
+
nextAmountSat: Number(requireArg("next-amount-sat")),
|
|
1320
|
+
nextParams: parseAssignments(getMultiArgs("next-param")),
|
|
1321
|
+
propagationMode: getArg("propagation-mode"),
|
|
1322
|
+
nextArtifactPath: getArg("next-artifact"),
|
|
1323
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
1324
|
+
nextOutputForm: parsePolicyOutputForm(),
|
|
1325
|
+
nextRawOutput: parseRawOutputFields(),
|
|
1326
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
1327
|
+
});
|
|
1328
|
+
const nextStateOut = getArg("next-state-out");
|
|
1329
|
+
if (nextStateOut && result.nextState) {
|
|
1330
|
+
const resolved = node_path_1.default.resolve(nextStateOut);
|
|
1331
|
+
await (0, promises_1.mkdir)(node_path_1.default.dirname(resolved), { recursive: true });
|
|
1332
|
+
await (0, promises_1.writeFile)(resolved, `${JSON.stringify(result.nextState, null, 2)}\n`, "utf8");
|
|
1333
|
+
}
|
|
1334
|
+
const prepareOutputBinding = result.verificationReport.outputBinding;
|
|
1335
|
+
printJson({
|
|
1336
|
+
summary: {
|
|
1337
|
+
mode: "prepare",
|
|
1338
|
+
enforcement: result.verificationReport.enforcement,
|
|
1339
|
+
propagationMode: result.verificationReport.propagationMode,
|
|
1340
|
+
plainExitAllowed: result.verificationReport.plainExitAllowed,
|
|
1341
|
+
nextPolicyRequired: result.verificationReport.nextPolicyRequired,
|
|
1342
|
+
nextPolicyPresent: result.verificationReport.nextPolicyPresent,
|
|
1343
|
+
outputBinding: prepareOutputBinding ?? null,
|
|
1344
|
+
summaryHash: result.transferSummary.hash,
|
|
1345
|
+
},
|
|
1346
|
+
summaryText: formatPolicyInspectOrExecuteSummary({
|
|
1347
|
+
mode: "prepare",
|
|
1348
|
+
propagationMode: result.verificationReport.propagationMode,
|
|
1349
|
+
enforcement: result.verificationReport.enforcement,
|
|
1350
|
+
plainExitAllowed: result.verificationReport.plainExitAllowed,
|
|
1351
|
+
nextPolicyRequired: result.verificationReport.nextPolicyRequired,
|
|
1352
|
+
nextPolicyPresent: result.verificationReport.nextPolicyPresent,
|
|
1353
|
+
outputBinding: prepareOutputBinding,
|
|
1354
|
+
summaryHash: result.transferSummary.hash,
|
|
1355
|
+
}),
|
|
1356
|
+
...result,
|
|
1357
|
+
nextStateOut: nextStateOut && result.nextState ? node_path_1.default.resolve(nextStateOut) : undefined,
|
|
1358
|
+
});
|
|
1359
|
+
return;
|
|
1360
|
+
}
|
|
1361
|
+
if (command === "policy" && subcommand === "verify-transfer") {
|
|
1362
|
+
const result = await sdk.policies.verifyTransfer({
|
|
1363
|
+
template: parsePolicyTemplateInput(),
|
|
1364
|
+
currentArtifactPath: requireArg("current-artifact"),
|
|
1365
|
+
currentStatePath: getArg("current-state-json"),
|
|
1366
|
+
currentStateValue: getArg("current-state-value") ? JSON.parse(getArg("current-state-value")) : undefined,
|
|
1367
|
+
transferDescriptorValue: getArg("transfer-value") ? JSON.parse(getArg("transfer-value")) : undefined,
|
|
1368
|
+
nextStatePath: getArg("next-state-json"),
|
|
1369
|
+
nextStateValue: getArg("next-state-value") ? JSON.parse(getArg("next-state-value")) : undefined,
|
|
1370
|
+
});
|
|
1371
|
+
printJson({
|
|
1372
|
+
summary: {
|
|
1373
|
+
ok: result.ok,
|
|
1374
|
+
reason: result.reason,
|
|
1375
|
+
enforcement: result.verificationReport.enforcement,
|
|
1376
|
+
propagationMode: result.verificationReport.propagationMode,
|
|
1377
|
+
plainExitAllowed: result.verificationReport.plainExitAllowed,
|
|
1378
|
+
nextPolicyRequired: result.verificationReport.nextPolicyRequired,
|
|
1379
|
+
nextPolicyPresent: result.verificationReport.nextPolicyPresent,
|
|
1380
|
+
outputBinding: result.verificationReport.outputBinding ?? null,
|
|
1381
|
+
},
|
|
1382
|
+
summaryText: formatPolicyVerificationSummary({
|
|
1383
|
+
ok: result.ok,
|
|
1384
|
+
reason: result.reason,
|
|
1385
|
+
propagationMode: result.verificationReport.propagationMode,
|
|
1386
|
+
enforcement: result.verificationReport.enforcement,
|
|
1387
|
+
plainExitAllowed: result.verificationReport.plainExitAllowed,
|
|
1388
|
+
nextPolicyRequired: result.verificationReport.nextPolicyRequired,
|
|
1389
|
+
nextPolicyPresent: result.verificationReport.nextPolicyPresent,
|
|
1390
|
+
outputBinding: result.verificationReport.outputBinding,
|
|
1391
|
+
}),
|
|
1392
|
+
...result,
|
|
1393
|
+
});
|
|
1394
|
+
return;
|
|
1395
|
+
}
|
|
1396
|
+
if (command === "policy" && subcommand === "inspect-transfer") {
|
|
1397
|
+
const result = await sdk.policies.inspectTransfer({
|
|
1398
|
+
currentArtifactPath: requireArg("current-artifact"),
|
|
1399
|
+
template: parsePolicyTemplateInput(),
|
|
1400
|
+
currentStatePath: getArg("current-state-json"),
|
|
1401
|
+
currentStateValue: getArg("current-state-value") ? JSON.parse(getArg("current-state-value")) : undefined,
|
|
1402
|
+
nextReceiver: parsePolicyReceiver("next"),
|
|
1403
|
+
nextAmountSat: Number(requireArg("next-amount-sat")),
|
|
1404
|
+
nextParams: parseAssignments(getMultiArgs("next-param")),
|
|
1405
|
+
propagationMode: getArg("propagation-mode"),
|
|
1406
|
+
nextArtifactPath: getArg("next-artifact"),
|
|
1407
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
1408
|
+
nextOutputForm: parsePolicyOutputForm(),
|
|
1409
|
+
nextRawOutput: parseRawOutputFields(),
|
|
1410
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
1411
|
+
wallet: requireArg("wallet"),
|
|
1412
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
1413
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
1414
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
1415
|
+
});
|
|
1416
|
+
const inspectOutputBinding = result.prepared.verificationReport.outputBinding;
|
|
1417
|
+
printJson({
|
|
1418
|
+
summary: {
|
|
1419
|
+
mode: result.mode,
|
|
1420
|
+
enforcement: result.prepared.verificationReport.enforcement,
|
|
1421
|
+
propagationMode: result.prepared.verificationReport.propagationMode,
|
|
1422
|
+
plainExitAllowed: result.prepared.verificationReport.plainExitAllowed,
|
|
1423
|
+
nextPolicyRequired: result.prepared.verificationReport.nextPolicyRequired,
|
|
1424
|
+
nextPolicyPresent: result.prepared.verificationReport.nextPolicyPresent,
|
|
1425
|
+
outputBinding: inspectOutputBinding ?? null,
|
|
1426
|
+
summaryHash: result.inspect.summaryHash,
|
|
1427
|
+
},
|
|
1428
|
+
summaryText: formatPolicyInspectOrExecuteSummary({
|
|
1429
|
+
mode: result.mode,
|
|
1430
|
+
propagationMode: result.prepared.verificationReport.propagationMode,
|
|
1431
|
+
enforcement: result.prepared.verificationReport.enforcement,
|
|
1432
|
+
plainExitAllowed: result.prepared.verificationReport.plainExitAllowed,
|
|
1433
|
+
nextPolicyRequired: result.prepared.verificationReport.nextPolicyRequired,
|
|
1434
|
+
nextPolicyPresent: result.prepared.verificationReport.nextPolicyPresent,
|
|
1435
|
+
outputBinding: inspectOutputBinding,
|
|
1436
|
+
summaryHash: result.inspect.summaryHash,
|
|
1437
|
+
}),
|
|
1438
|
+
...result,
|
|
1439
|
+
});
|
|
1440
|
+
return;
|
|
1441
|
+
}
|
|
1442
|
+
if (command === "policy" && subcommand === "execute-transfer") {
|
|
1443
|
+
const result = await sdk.policies.executeTransfer({
|
|
1444
|
+
currentArtifactPath: requireArg("current-artifact"),
|
|
1445
|
+
template: parsePolicyTemplateInput(),
|
|
1446
|
+
currentStatePath: getArg("current-state-json"),
|
|
1447
|
+
currentStateValue: getArg("current-state-value") ? JSON.parse(getArg("current-state-value")) : undefined,
|
|
1448
|
+
nextReceiver: parsePolicyReceiver("next"),
|
|
1449
|
+
nextAmountSat: Number(requireArg("next-amount-sat")),
|
|
1450
|
+
nextParams: parseAssignments(getMultiArgs("next-param")),
|
|
1451
|
+
propagationMode: getArg("propagation-mode"),
|
|
1452
|
+
nextArtifactPath: getArg("next-artifact"),
|
|
1453
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
1454
|
+
nextOutputForm: parsePolicyOutputForm(),
|
|
1455
|
+
nextRawOutput: parseRawOutputFields(),
|
|
1456
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
1457
|
+
wallet: requireArg("wallet"),
|
|
1458
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
1459
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
1460
|
+
broadcast: hasFlag("broadcast"),
|
|
1461
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
1462
|
+
});
|
|
1463
|
+
const executeOutputBinding = result.prepared.verificationReport.outputBinding;
|
|
1464
|
+
printJson({
|
|
1465
|
+
summary: {
|
|
1466
|
+
mode: result.mode,
|
|
1467
|
+
enforcement: result.prepared.verificationReport.enforcement,
|
|
1468
|
+
propagationMode: result.prepared.verificationReport.propagationMode,
|
|
1469
|
+
plainExitAllowed: result.prepared.verificationReport.plainExitAllowed,
|
|
1470
|
+
nextPolicyRequired: result.prepared.verificationReport.nextPolicyRequired,
|
|
1471
|
+
nextPolicyPresent: result.prepared.verificationReport.nextPolicyPresent,
|
|
1472
|
+
outputBinding: executeOutputBinding ?? null,
|
|
1473
|
+
summaryHash: result.execution.summaryHash,
|
|
1474
|
+
txId: result.execution.txId ?? null,
|
|
1475
|
+
broadcasted: result.execution.broadcasted,
|
|
1476
|
+
},
|
|
1477
|
+
summaryText: formatPolicyInspectOrExecuteSummary({
|
|
1478
|
+
mode: result.mode,
|
|
1479
|
+
propagationMode: result.prepared.verificationReport.propagationMode,
|
|
1480
|
+
enforcement: result.prepared.verificationReport.enforcement,
|
|
1481
|
+
plainExitAllowed: result.prepared.verificationReport.plainExitAllowed,
|
|
1482
|
+
nextPolicyRequired: result.prepared.verificationReport.nextPolicyRequired,
|
|
1483
|
+
nextPolicyPresent: result.prepared.verificationReport.nextPolicyPresent,
|
|
1484
|
+
outputBinding: executeOutputBinding,
|
|
1485
|
+
summaryHash: result.execution.summaryHash,
|
|
1486
|
+
txId: result.execution.txId,
|
|
1487
|
+
broadcasted: result.execution.broadcasted,
|
|
1488
|
+
}),
|
|
1489
|
+
...result,
|
|
1490
|
+
});
|
|
1491
|
+
return;
|
|
1492
|
+
}
|
|
1493
|
+
if (command === "policy" && subcommand === "export-evidence") {
|
|
1494
|
+
const result = await sdk.policies.exportEvidence({
|
|
1495
|
+
artifactPath: requireArg("artifact"),
|
|
1496
|
+
template: parsePolicyTemplateInput(),
|
|
1497
|
+
statePath: getArg("state-json"),
|
|
1498
|
+
stateValue: getArg("state-value") ? JSON.parse(getArg("state-value")) : undefined,
|
|
1499
|
+
transferDescriptorValue: getArg("transfer-value") ? JSON.parse(getArg("transfer-value")) : undefined,
|
|
1500
|
+
});
|
|
1501
|
+
printJson({
|
|
1502
|
+
summary: {
|
|
1503
|
+
templateHash: result.template.hash,
|
|
1504
|
+
stateHash: result.state.hash,
|
|
1505
|
+
transferHash: result.transfer?.hash ?? null,
|
|
1506
|
+
enforcement: result.report.enforcement,
|
|
1507
|
+
outputBinding: result.report.outputBinding ?? null,
|
|
1508
|
+
sourceVerificationMode: result.sourceVerificationMode,
|
|
1509
|
+
},
|
|
1510
|
+
summaryText: formatPolicyEvidenceSummary({
|
|
1511
|
+
templateHash: result.template.hash,
|
|
1512
|
+
stateHash: result.state.hash,
|
|
1513
|
+
transferHash: result.transfer?.hash ?? null,
|
|
1514
|
+
enforcement: result.report.enforcement,
|
|
1515
|
+
outputBinding: result.report.outputBinding ?? null,
|
|
1516
|
+
sourceVerificationMode: result.sourceVerificationMode,
|
|
1517
|
+
}),
|
|
1518
|
+
...result,
|
|
1519
|
+
});
|
|
1520
|
+
return;
|
|
1521
|
+
}
|
|
570
1522
|
if (command === "presets" && subcommand === "list") {
|
|
571
1523
|
printJson((0, presets_1.listPresets)().map((preset) => (0, presets_1.describePreset)(preset)));
|
|
572
1524
|
return;
|
|
@@ -644,111 +1596,264 @@ async function main() {
|
|
|
644
1596
|
return;
|
|
645
1597
|
}
|
|
646
1598
|
if (command === "bond" && subcommand === "define") {
|
|
647
|
-
const result = await sdk.bonds.
|
|
1599
|
+
const result = await sdk.bonds.define({
|
|
648
1600
|
definitionPath: getArg("definition-json"),
|
|
649
1601
|
issuancePath: getArg("issuance-json"),
|
|
650
1602
|
simfPath: getArg("simf"),
|
|
651
1603
|
artifactPath: getArg("artifact"),
|
|
652
1604
|
});
|
|
653
|
-
printJson({
|
|
1605
|
+
printJson({
|
|
1606
|
+
artifact: result.artifact,
|
|
1607
|
+
deployment: result.deployment(),
|
|
1608
|
+
summary: {
|
|
1609
|
+
artifactPath: getArg("artifact") ? node_path_1.default.resolve(getArg("artifact")) : undefined,
|
|
1610
|
+
contractAddress: result.artifact.compiled.contractAddress,
|
|
1611
|
+
cmr: result.artifact.compiled.cmr,
|
|
1612
|
+
definitionHash: result.artifact.definition?.hash,
|
|
1613
|
+
issuanceHash: result.artifact.state?.hash,
|
|
1614
|
+
},
|
|
1615
|
+
summaryText: formatBondDefinitionOrVerificationSummary({
|
|
1616
|
+
artifactPath: getArg("artifact") ? node_path_1.default.resolve(getArg("artifact")) : undefined,
|
|
1617
|
+
contractAddress: result.artifact.compiled.contractAddress,
|
|
1618
|
+
cmr: result.artifact.compiled.cmr,
|
|
1619
|
+
definitionHash: result.artifact.definition?.hash,
|
|
1620
|
+
issuanceHash: result.artifact.state?.hash,
|
|
1621
|
+
}),
|
|
1622
|
+
});
|
|
1623
|
+
return;
|
|
1624
|
+
}
|
|
1625
|
+
if (command === "bond" && subcommand === "issue") {
|
|
1626
|
+
const result = await sdk.bonds.issue({
|
|
1627
|
+
definitionPath: getArg("definition-json"),
|
|
1628
|
+
issuancePath: getArg("issuance-json"),
|
|
1629
|
+
simfPath: getArg("simf"),
|
|
1630
|
+
artifactPath: getArg("artifact"),
|
|
1631
|
+
});
|
|
1632
|
+
printJson({
|
|
1633
|
+
artifact: result.artifact,
|
|
1634
|
+
deployment: result.deployment(),
|
|
1635
|
+
summary: {
|
|
1636
|
+
artifactPath: getArg("artifact") ? node_path_1.default.resolve(getArg("artifact")) : undefined,
|
|
1637
|
+
contractAddress: result.artifact.compiled.contractAddress,
|
|
1638
|
+
cmr: result.artifact.compiled.cmr,
|
|
1639
|
+
definitionHash: result.artifact.definition?.hash,
|
|
1640
|
+
issuanceHash: result.artifact.state?.hash,
|
|
1641
|
+
},
|
|
1642
|
+
summaryText: formatBondDefinitionOrVerificationSummary({
|
|
1643
|
+
artifactPath: getArg("artifact") ? node_path_1.default.resolve(getArg("artifact")) : undefined,
|
|
1644
|
+
contractAddress: result.artifact.compiled.contractAddress,
|
|
1645
|
+
cmr: result.artifact.compiled.cmr,
|
|
1646
|
+
definitionHash: result.artifact.definition?.hash,
|
|
1647
|
+
issuanceHash: result.artifact.state?.hash,
|
|
1648
|
+
}),
|
|
1649
|
+
});
|
|
654
1650
|
return;
|
|
655
1651
|
}
|
|
656
1652
|
if (command === "bond" && subcommand === "verify") {
|
|
657
|
-
const result = await sdk.bonds.
|
|
1653
|
+
const result = await sdk.bonds.verify({
|
|
658
1654
|
artifactPath: requireArg("artifact"),
|
|
659
1655
|
definitionPath: getArg("definition-json"),
|
|
660
1656
|
issuancePath: getArg("issuance-json"),
|
|
661
1657
|
});
|
|
662
|
-
printJson(
|
|
1658
|
+
printJson({
|
|
1659
|
+
...result,
|
|
1660
|
+
summary: {
|
|
1661
|
+
artifactPath: node_path_1.default.resolve(requireArg("artifact")),
|
|
1662
|
+
contractAddress: result.artifact.compiled.contractAddress,
|
|
1663
|
+
cmr: result.artifact.compiled.cmr,
|
|
1664
|
+
definitionHash: result.definition.definition.hash,
|
|
1665
|
+
issuanceHash: result.issuance.state.hash,
|
|
1666
|
+
definitionOk: result.definition.ok,
|
|
1667
|
+
issuanceOk: result.issuance.ok,
|
|
1668
|
+
principalInvariantValid: result.crossChecks.principalInvariantValid,
|
|
1669
|
+
definitionTrustMode: result.definition.trust.effectiveMode,
|
|
1670
|
+
issuanceTrustMode: result.issuance.trust.effectiveMode,
|
|
1671
|
+
},
|
|
1672
|
+
summaryText: formatBondDefinitionOrVerificationSummary({
|
|
1673
|
+
artifactPath: node_path_1.default.resolve(requireArg("artifact")),
|
|
1674
|
+
contractAddress: result.artifact.compiled.contractAddress,
|
|
1675
|
+
cmr: result.artifact.compiled.cmr,
|
|
1676
|
+
definitionHash: result.definition.definition.hash,
|
|
1677
|
+
issuanceHash: result.issuance.state.hash,
|
|
1678
|
+
definitionOk: result.definition.ok,
|
|
1679
|
+
issuanceOk: result.issuance.ok,
|
|
1680
|
+
principalInvariantValid: result.crossChecks.principalInvariantValid,
|
|
1681
|
+
definitionTrustMode: result.definition.trust.effectiveMode,
|
|
1682
|
+
issuanceTrustMode: result.issuance.trust.effectiveMode,
|
|
1683
|
+
}),
|
|
1684
|
+
});
|
|
663
1685
|
return;
|
|
664
1686
|
}
|
|
665
|
-
if (command === "bond" && subcommand === "
|
|
666
|
-
const
|
|
1687
|
+
if (command === "bond" && subcommand === "prepare-redemption") {
|
|
1688
|
+
const result = await sdk.bonds.prepareRedemption({
|
|
667
1689
|
definitionPath: getArg("definition-json"),
|
|
668
1690
|
previousIssuancePath: getArg("previous-issuance-json"),
|
|
669
1691
|
amount: Number(requireArg("amount")),
|
|
670
1692
|
redeemedAt: requireArg("redeemed-at"),
|
|
1693
|
+
nextStateSimfPath: getArg("next-state-simf"),
|
|
1694
|
+
nextAmountSat: Number(requireArg("next-amount-sat")),
|
|
1695
|
+
maxFeeSat: getArg("max-fee-sat") ? Number(getArg("max-fee-sat")) : undefined,
|
|
1696
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
1697
|
+
outputForm: parsePolicyOutputForm(),
|
|
1698
|
+
rawOutput: parseRawOutputFields(),
|
|
1699
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
671
1700
|
});
|
|
672
1701
|
const nextIssuanceOut = getArg("next-issuance-out");
|
|
673
1702
|
if (nextIssuanceOut) {
|
|
674
1703
|
const resolved = node_path_1.default.resolve(nextIssuanceOut);
|
|
675
1704
|
await (0, promises_1.mkdir)(node_path_1.default.dirname(resolved), { recursive: true });
|
|
676
|
-
await (0, promises_1.writeFile)(`${resolved}`, `${JSON.stringify(preview.next, null, 2)}\n`, "utf8");
|
|
1705
|
+
await (0, promises_1.writeFile)(`${resolved}`, `${JSON.stringify(result.preview.next, null, 2)}\n`, "utf8");
|
|
677
1706
|
}
|
|
678
|
-
const result = await sdk.bonds.redeemBond({
|
|
679
|
-
definitionPath: getArg("definition-json"),
|
|
680
|
-
previousIssuancePath: getArg("previous-issuance-json"),
|
|
681
|
-
amount: Number(requireArg("amount")),
|
|
682
|
-
redeemedAt: requireArg("redeemed-at"),
|
|
683
|
-
simfPath: getArg("simf"),
|
|
684
|
-
artifactPath: getArg("artifact"),
|
|
685
|
-
});
|
|
686
1707
|
printJson({
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
previousHash: preview.previousHash,
|
|
690
|
-
nextHash: preview.nextHash,
|
|
691
|
-
transition: preview.transition,
|
|
692
|
-
nextIssuanceState: preview.next,
|
|
1708
|
+
...result,
|
|
1709
|
+
nextIssuanceState: result.preview.next,
|
|
693
1710
|
nextIssuanceOut: nextIssuanceOut ? node_path_1.default.resolve(nextIssuanceOut) : undefined,
|
|
1711
|
+
summary: {
|
|
1712
|
+
mode: result.settlement.descriptor.outputBindingMode,
|
|
1713
|
+
nextStatus: result.preview.next.status,
|
|
1714
|
+
descriptorHash: result.settlement.descriptorHash,
|
|
1715
|
+
nextStateHash: result.settlement.nextStateHash,
|
|
1716
|
+
nextContractAddress: result.settlement.nextContractAddress,
|
|
1717
|
+
nextAmountSat: result.settlement.nextAmountSat,
|
|
1718
|
+
supportedForm: result.settlement.supportedForm,
|
|
1719
|
+
reasonCode: result.settlement.reasonCode,
|
|
1720
|
+
autoDerived: result.settlement.autoDerivedNextOutputHash,
|
|
1721
|
+
fallbackReason: result.settlement.fallbackReason,
|
|
1722
|
+
nextOutputHash: result.settlement.expectedOutputDescriptor?.nextOutputHash,
|
|
1723
|
+
bindingInputs: result.settlement.bindingInputs ?? null,
|
|
1724
|
+
},
|
|
1725
|
+
summaryText: formatBondRedemptionSummary({
|
|
1726
|
+
phase: "prepare",
|
|
1727
|
+
mode: result.settlement.descriptor.outputBindingMode ?? "none",
|
|
1728
|
+
nextStatus: result.preview.next.status,
|
|
1729
|
+
descriptorHash: result.settlement.descriptorHash,
|
|
1730
|
+
nextStateHash: result.settlement.nextStateHash,
|
|
1731
|
+
nextContractAddress: result.settlement.nextContractAddress,
|
|
1732
|
+
nextAmountSat: result.settlement.nextAmountSat,
|
|
1733
|
+
bindingMetadata: {
|
|
1734
|
+
bindingMode: result.settlement.descriptor.outputBindingMode,
|
|
1735
|
+
supportedForm: result.settlement.supportedForm,
|
|
1736
|
+
reasonCode: result.settlement.reasonCode,
|
|
1737
|
+
nextOutputHash: result.settlement.expectedOutputDescriptor?.nextOutputHash,
|
|
1738
|
+
autoDerived: result.settlement.autoDerivedNextOutputHash,
|
|
1739
|
+
fallbackReason: result.settlement.fallbackReason,
|
|
1740
|
+
bindingInputs: result.settlement.bindingInputs,
|
|
1741
|
+
},
|
|
1742
|
+
}),
|
|
694
1743
|
});
|
|
695
1744
|
return;
|
|
696
1745
|
}
|
|
697
|
-
if (command === "bond" && subcommand === "
|
|
698
|
-
const result = await sdk.bonds.
|
|
699
|
-
|
|
700
|
-
nextIssuancePath: getArg("next-issuance-json"),
|
|
701
|
-
});
|
|
702
|
-
printJson(result);
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
|
-
if (command === "bond" && subcommand === "compile-transition") {
|
|
706
|
-
const result = await sdk.bonds.compileBondTransition({
|
|
1746
|
+
if (command === "bond" && subcommand === "inspect-redemption") {
|
|
1747
|
+
const result = await sdk.bonds.inspectRedemption({
|
|
1748
|
+
currentArtifactPath: requireArg("current-artifact"),
|
|
707
1749
|
definitionPath: getArg("definition-json"),
|
|
708
1750
|
previousIssuancePath: getArg("previous-issuance-json"),
|
|
709
1751
|
nextIssuancePath: getArg("next-issuance-json"),
|
|
710
|
-
|
|
711
|
-
|
|
1752
|
+
nextStateSimfPath: getArg("next-state-simf"),
|
|
1753
|
+
machineSimfPath: getArg("machine-simf"),
|
|
1754
|
+
machineArtifactPath: getArg("machine-artifact"),
|
|
1755
|
+
nextAmountSat: getArg("next-amount-sat") ? Number(getArg("next-amount-sat")) : undefined,
|
|
1756
|
+
maxFeeSat: getArg("max-fee-sat") ? Number(getArg("max-fee-sat")) : undefined,
|
|
1757
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
1758
|
+
outputForm: parsePolicyOutputForm(),
|
|
1759
|
+
rawOutput: parseRawOutputFields(),
|
|
1760
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
1761
|
+
wallet: requireArg("wallet"),
|
|
1762
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
1763
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
1764
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
712
1765
|
});
|
|
713
1766
|
printJson({
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
1767
|
+
...result,
|
|
1768
|
+
summary: {
|
|
1769
|
+
mode: result.mode,
|
|
1770
|
+
nextStatus: result.settlement.descriptor.nextStatus,
|
|
1771
|
+
descriptorHash: result.settlement.descriptorHash,
|
|
1772
|
+
nextStateHash: result.settlement.nextStateHash,
|
|
1773
|
+
nextContractAddress: result.plan.nextContractAddress,
|
|
1774
|
+
nextAmountSat: result.settlement.nextAmountSat,
|
|
1775
|
+
summaryHash: result.inspect.summaryHash,
|
|
1776
|
+
},
|
|
1777
|
+
summaryText: formatBondRedemptionSummary({
|
|
1778
|
+
phase: "inspect",
|
|
1779
|
+
mode: result.mode,
|
|
1780
|
+
nextStatus: result.settlement.descriptor.nextStatus,
|
|
1781
|
+
descriptorHash: result.settlement.descriptorHash,
|
|
1782
|
+
nextStateHash: result.settlement.nextStateHash,
|
|
1783
|
+
nextContractAddress: result.plan.nextContractAddress,
|
|
1784
|
+
nextAmountSat: result.settlement.nextAmountSat,
|
|
1785
|
+
summaryHash: result.inspect.summaryHash,
|
|
1786
|
+
bindingMetadata: {
|
|
1787
|
+
bindingMode: result.settlement.descriptor.outputBindingMode,
|
|
1788
|
+
supportedForm: result.settlement.supportedForm,
|
|
1789
|
+
reasonCode: result.settlement.reasonCode,
|
|
1790
|
+
nextOutputHash: result.settlement.expectedOutputDescriptor?.nextOutputHash,
|
|
1791
|
+
autoDerived: result.settlement.autoDerivedNextOutputHash,
|
|
1792
|
+
fallbackReason: result.settlement.fallbackReason,
|
|
1793
|
+
bindingInputs: result.settlement.bindingInputs,
|
|
1794
|
+
},
|
|
1795
|
+
}),
|
|
720
1796
|
});
|
|
721
1797
|
return;
|
|
722
1798
|
}
|
|
723
|
-
if (command === "bond" && subcommand === "
|
|
724
|
-
const result = await sdk.bonds.
|
|
1799
|
+
if (command === "bond" && subcommand === "execute-redemption") {
|
|
1800
|
+
const result = await sdk.bonds.executeRedemption({
|
|
1801
|
+
currentArtifactPath: requireArg("current-artifact"),
|
|
725
1802
|
definitionPath: getArg("definition-json"),
|
|
726
1803
|
previousIssuancePath: getArg("previous-issuance-json"),
|
|
727
1804
|
nextIssuancePath: getArg("next-issuance-json"),
|
|
728
1805
|
nextStateSimfPath: getArg("next-state-simf"),
|
|
1806
|
+
machineSimfPath: getArg("machine-simf"),
|
|
1807
|
+
machineArtifactPath: getArg("machine-artifact"),
|
|
729
1808
|
nextAmountSat: getArg("next-amount-sat") ? Number(getArg("next-amount-sat")) : undefined,
|
|
730
1809
|
maxFeeSat: getArg("max-fee-sat") ? Number(getArg("max-fee-sat")) : undefined,
|
|
731
|
-
|
|
732
|
-
|
|
1810
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
1811
|
+
outputForm: parsePolicyOutputForm(),
|
|
1812
|
+
rawOutput: parseRawOutputFields(),
|
|
1813
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
1814
|
+
wallet: requireArg("wallet"),
|
|
1815
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
1816
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
1817
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
1818
|
+
broadcast: hasFlag("broadcast"),
|
|
733
1819
|
});
|
|
734
1820
|
printJson({
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
1821
|
+
...result,
|
|
1822
|
+
summary: {
|
|
1823
|
+
mode: result.mode,
|
|
1824
|
+
nextStatus: result.settlement.descriptor.nextStatus,
|
|
1825
|
+
descriptorHash: result.settlement.descriptorHash,
|
|
1826
|
+
nextStateHash: result.settlement.nextStateHash,
|
|
1827
|
+
nextContractAddress: result.plan.nextContractAddress,
|
|
1828
|
+
nextAmountSat: result.settlement.nextAmountSat,
|
|
1829
|
+
txId: result.execution.txId ?? null,
|
|
1830
|
+
broadcasted: Boolean(result.execution.txId),
|
|
1831
|
+
},
|
|
1832
|
+
summaryText: formatBondRedemptionSummary({
|
|
1833
|
+
phase: "execute",
|
|
1834
|
+
mode: result.mode,
|
|
1835
|
+
nextStatus: result.settlement.descriptor.nextStatus,
|
|
1836
|
+
descriptorHash: result.settlement.descriptorHash,
|
|
1837
|
+
nextStateHash: result.settlement.nextStateHash,
|
|
1838
|
+
nextContractAddress: result.plan.nextContractAddress,
|
|
1839
|
+
nextAmountSat: result.settlement.nextAmountSat,
|
|
1840
|
+
txId: result.execution.txId,
|
|
1841
|
+
broadcasted: Boolean(result.execution.txId),
|
|
1842
|
+
bindingMetadata: {
|
|
1843
|
+
bindingMode: result.settlement.descriptor.outputBindingMode,
|
|
1844
|
+
supportedForm: result.settlement.supportedForm,
|
|
1845
|
+
reasonCode: result.settlement.reasonCode,
|
|
1846
|
+
nextOutputHash: result.settlement.expectedOutputDescriptor?.nextOutputHash,
|
|
1847
|
+
autoDerived: result.settlement.autoDerivedNextOutputHash,
|
|
1848
|
+
fallbackReason: result.settlement.fallbackReason,
|
|
1849
|
+
bindingInputs: result.settlement.bindingInputs,
|
|
1850
|
+
},
|
|
1851
|
+
}),
|
|
747
1852
|
});
|
|
748
1853
|
return;
|
|
749
1854
|
}
|
|
750
|
-
if (command === "bond" && subcommand === "verify-
|
|
751
|
-
const result = await sdk.bonds.
|
|
1855
|
+
if (command === "bond" && subcommand === "verify-redemption") {
|
|
1856
|
+
const result = await sdk.bonds.verifyRedemption({
|
|
752
1857
|
artifactPath: requireArg("artifact"),
|
|
753
1858
|
definitionPath: getArg("definition-json"),
|
|
754
1859
|
previousIssuancePath: getArg("previous-issuance-json"),
|
|
@@ -756,207 +1861,1068 @@ async function main() {
|
|
|
756
1861
|
nextStateSimfPath: getArg("next-state-simf"),
|
|
757
1862
|
nextAmountSat: getArg("next-amount-sat") ? Number(getArg("next-amount-sat")) : undefined,
|
|
758
1863
|
maxFeeSat: getArg("max-fee-sat") ? Number(getArg("max-fee-sat")) : undefined,
|
|
1864
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
1865
|
+
outputForm: parsePolicyOutputForm(),
|
|
1866
|
+
rawOutput: parseRawOutputFields(),
|
|
1867
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
1868
|
+
});
|
|
1869
|
+
const outputBindingTrust = "outputBindingTrust" in result ? result.outputBindingTrust : undefined;
|
|
1870
|
+
printJson({
|
|
1871
|
+
...result,
|
|
1872
|
+
summary: {
|
|
1873
|
+
verified: result.verified,
|
|
1874
|
+
mode: result.mode,
|
|
1875
|
+
descriptorHash: result.settlement.descriptorHash,
|
|
1876
|
+
nextStateHash: result.settlement.nextStateHash,
|
|
1877
|
+
nextAmountSat: result.settlement.nextAmountSat,
|
|
1878
|
+
supportedForm: result.outputBindingMetadata?.supportedForm ?? null,
|
|
1879
|
+
reasonCode: result.outputBindingMetadata?.reasonCode ?? null,
|
|
1880
|
+
autoDerived: result.outputBindingMetadata?.autoDerived ?? null,
|
|
1881
|
+
fallbackReason: result.outputBindingMetadata?.fallbackReason ?? null,
|
|
1882
|
+
nextOutputHash: result.settlement.expectedOutputDescriptor?.nextOutputHash ?? null,
|
|
1883
|
+
bindingInputs: result.outputBindingMetadata?.bindingInputs ?? null,
|
|
1884
|
+
outputBindingTrust: outputBindingTrust ?? null,
|
|
1885
|
+
},
|
|
1886
|
+
summaryText: formatBondRedemptionSummary({
|
|
1887
|
+
phase: "verify",
|
|
1888
|
+
mode: result.mode,
|
|
1889
|
+
descriptorHash: result.settlement.descriptorHash,
|
|
1890
|
+
nextStateHash: result.settlement.nextStateHash,
|
|
1891
|
+
nextAmountSat: result.settlement.nextAmountSat,
|
|
1892
|
+
verified: result.verified,
|
|
1893
|
+
bindingMetadata: {
|
|
1894
|
+
bindingMode: result.settlement.descriptor.outputBindingMode,
|
|
1895
|
+
supportedForm: result.outputBindingMetadata?.supportedForm,
|
|
1896
|
+
reasonCode: result.outputBindingMetadata?.reasonCode,
|
|
1897
|
+
nextOutputHash: result.settlement.expectedOutputDescriptor?.nextOutputHash,
|
|
1898
|
+
autoDerived: result.outputBindingMetadata?.autoDerived,
|
|
1899
|
+
fallbackReason: result.outputBindingMetadata?.fallbackReason,
|
|
1900
|
+
bindingInputs: result.outputBindingMetadata?.bindingInputs,
|
|
1901
|
+
},
|
|
1902
|
+
outputBindingTrust,
|
|
1903
|
+
}),
|
|
759
1904
|
});
|
|
760
|
-
printJson(result);
|
|
761
1905
|
return;
|
|
762
1906
|
}
|
|
763
|
-
if (command === "bond" && subcommand === "settlement
|
|
764
|
-
const result = await sdk.bonds.
|
|
1907
|
+
if (command === "bond" && subcommand === "build-settlement") {
|
|
1908
|
+
const result = await sdk.bonds.buildSettlement({
|
|
765
1909
|
definitionPath: getArg("definition-json"),
|
|
766
1910
|
previousIssuancePath: getArg("previous-issuance-json"),
|
|
767
1911
|
nextIssuancePath: getArg("next-issuance-json"),
|
|
768
1912
|
nextStateSimfPath: getArg("next-state-simf"),
|
|
1913
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
769
1914
|
nextAmountSat: Number(requireArg("next-amount-sat")),
|
|
770
1915
|
maxFeeSat: getArg("max-fee-sat") ? Number(getArg("max-fee-sat")) : undefined,
|
|
1916
|
+
outputForm: parsePolicyOutputForm(),
|
|
1917
|
+
rawOutput: parseRawOutputFields(),
|
|
1918
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
1919
|
+
});
|
|
1920
|
+
printJson({
|
|
1921
|
+
...result,
|
|
1922
|
+
summary: {
|
|
1923
|
+
descriptorHash: result.descriptorHash,
|
|
1924
|
+
bindingMode: result.descriptor.outputBindingMode,
|
|
1925
|
+
previousStateHash: result.previousStateHash,
|
|
1926
|
+
nextStateHash: result.nextStateHash,
|
|
1927
|
+
nextContractAddress: result.nextContractAddress,
|
|
1928
|
+
nextAmountSat: result.nextAmountSat,
|
|
1929
|
+
maxFeeSat: result.maxFeeSat,
|
|
1930
|
+
supportedForm: result.supportedForm,
|
|
1931
|
+
reasonCode: result.reasonCode,
|
|
1932
|
+
autoDerived: result.autoDerivedNextOutputHash,
|
|
1933
|
+
fallbackReason: result.fallbackReason,
|
|
1934
|
+
nextOutputHash: result.expectedOutputDescriptor?.nextOutputHash,
|
|
1935
|
+
bindingInputs: result.bindingInputs ?? null,
|
|
1936
|
+
},
|
|
1937
|
+
summaryText: formatBondSettlementSummary({
|
|
1938
|
+
descriptorHash: result.descriptorHash,
|
|
1939
|
+
bindingMode: result.descriptor.outputBindingMode ?? "none",
|
|
1940
|
+
previousStateHash: result.previousStateHash,
|
|
1941
|
+
nextStateHash: result.nextStateHash,
|
|
1942
|
+
nextContractAddress: result.nextContractAddress,
|
|
1943
|
+
nextAmountSat: result.nextAmountSat,
|
|
1944
|
+
maxFeeSat: result.maxFeeSat,
|
|
1945
|
+
supportedForm: result.supportedForm,
|
|
1946
|
+
reasonCode: result.reasonCode,
|
|
1947
|
+
autoDerived: result.autoDerivedNextOutputHash,
|
|
1948
|
+
fallbackReason: result.fallbackReason,
|
|
1949
|
+
nextOutputHash: result.expectedOutputDescriptor?.nextOutputHash,
|
|
1950
|
+
bindingInputs: result.bindingInputs ?? undefined,
|
|
1951
|
+
}),
|
|
771
1952
|
});
|
|
772
|
-
printJson(result);
|
|
773
1953
|
return;
|
|
774
1954
|
}
|
|
775
1955
|
if (command === "bond" && subcommand === "verify-settlement") {
|
|
776
|
-
const result = await sdk.bonds.
|
|
1956
|
+
const result = await sdk.bonds.verifySettlement({
|
|
777
1957
|
descriptorPath: getArg("descriptor-json"),
|
|
778
1958
|
definitionPath: getArg("definition-json"),
|
|
779
1959
|
previousIssuancePath: getArg("previous-issuance-json"),
|
|
780
1960
|
nextIssuancePath: getArg("next-issuance-json"),
|
|
781
1961
|
nextStateSimfPath: getArg("next-state-simf"),
|
|
1962
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
782
1963
|
nextAmountSat: getArg("next-amount-sat") ? Number(getArg("next-amount-sat")) : undefined,
|
|
783
1964
|
maxFeeSat: getArg("max-fee-sat") ? Number(getArg("max-fee-sat")) : undefined,
|
|
1965
|
+
outputForm: parsePolicyOutputForm(),
|
|
1966
|
+
rawOutput: parseRawOutputFields(),
|
|
1967
|
+
});
|
|
1968
|
+
printJson({
|
|
1969
|
+
...result,
|
|
1970
|
+
summary: {
|
|
1971
|
+
ok: result.ok,
|
|
1972
|
+
reason: result.reason,
|
|
1973
|
+
descriptorHash: result.hash,
|
|
1974
|
+
bindingMode: result.descriptor.outputBindingMode,
|
|
1975
|
+
previousStateHash: result.descriptor.previousStateHash,
|
|
1976
|
+
nextStateHash: result.descriptor.nextStateHash,
|
|
1977
|
+
nextContractAddress: result.descriptor.nextContractAddress,
|
|
1978
|
+
nextAmountSat: result.descriptor.nextAmountSat,
|
|
1979
|
+
maxFeeSat: result.descriptor.maxFeeSat,
|
|
1980
|
+
supportedForm: result.supportedForm,
|
|
1981
|
+
reasonCode: result.reasonCode,
|
|
1982
|
+
autoDerived: result.autoDerivedNextOutputHash,
|
|
1983
|
+
fallbackReason: result.fallbackReason,
|
|
1984
|
+
bindingInputs: result.bindingInputs ?? null,
|
|
1985
|
+
},
|
|
1986
|
+
summaryText: formatBondSettlementSummary({
|
|
1987
|
+
ok: result.ok,
|
|
1988
|
+
reason: result.reason,
|
|
1989
|
+
descriptorHash: result.hash,
|
|
1990
|
+
bindingMode: result.descriptor.outputBindingMode ?? "none",
|
|
1991
|
+
previousStateHash: result.descriptor.previousStateHash,
|
|
1992
|
+
nextStateHash: result.descriptor.nextStateHash,
|
|
1993
|
+
nextContractAddress: result.descriptor.nextContractAddress,
|
|
1994
|
+
nextAmountSat: result.descriptor.nextAmountSat,
|
|
1995
|
+
maxFeeSat: result.descriptor.maxFeeSat,
|
|
1996
|
+
supportedForm: result.supportedForm,
|
|
1997
|
+
reasonCode: result.reasonCode,
|
|
1998
|
+
autoDerived: result.autoDerivedNextOutputHash,
|
|
1999
|
+
fallbackReason: result.fallbackReason,
|
|
2000
|
+
bindingInputs: result.bindingInputs ?? undefined,
|
|
2001
|
+
}),
|
|
784
2002
|
});
|
|
785
|
-
printJson(result);
|
|
786
2003
|
return;
|
|
787
2004
|
}
|
|
788
|
-
if (command === "bond" && subcommand === "
|
|
789
|
-
const result = await sdk.bonds.
|
|
790
|
-
currentArtifactPath: requireArg("current-artifact"),
|
|
2005
|
+
if (command === "bond" && subcommand === "prepare-closing") {
|
|
2006
|
+
const result = await sdk.bonds.prepareClosing({
|
|
791
2007
|
definitionPath: getArg("definition-json"),
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
2008
|
+
redeemedIssuancePath: getArg("redeemed-issuance-json"),
|
|
2009
|
+
settlementDescriptorPath: getArg("settlement-descriptor-json"),
|
|
2010
|
+
closedAt: requireArg("closed-at"),
|
|
2011
|
+
closingReason: getArg("closing-reason"),
|
|
796
2012
|
});
|
|
797
2013
|
printJson({
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
2014
|
+
...result,
|
|
2015
|
+
summary: {
|
|
2016
|
+
closingHash: result.closingHash,
|
|
2017
|
+
closedAt: result.closing.closedAt,
|
|
2018
|
+
closingReason: result.closing.closingReason,
|
|
2019
|
+
finalSettlementDescriptorHash: result.closing.finalSettlementDescriptorHash,
|
|
2020
|
+
},
|
|
2021
|
+
summaryText: formatBondClosingSummary({
|
|
2022
|
+
phase: "prepare",
|
|
2023
|
+
closingHash: result.closingHash,
|
|
2024
|
+
closedAt: result.closing.closedAt,
|
|
2025
|
+
closingReason: result.closing.closingReason,
|
|
2026
|
+
finalSettlementDescriptorHash: result.closing.finalSettlementDescriptorHash,
|
|
2027
|
+
}),
|
|
803
2028
|
});
|
|
804
2029
|
return;
|
|
805
2030
|
}
|
|
806
|
-
if (command === "bond" && subcommand === "
|
|
807
|
-
const result = await sdk.bonds.
|
|
2031
|
+
if (command === "bond" && subcommand === "inspect-closing") {
|
|
2032
|
+
const result = await sdk.bonds.inspectClosing({
|
|
808
2033
|
currentArtifactPath: requireArg("current-artifact"),
|
|
809
2034
|
definitionPath: getArg("definition-json"),
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
2035
|
+
redeemedIssuancePath: getArg("redeemed-issuance-json"),
|
|
2036
|
+
settlementDescriptorPath: getArg("settlement-descriptor-json"),
|
|
2037
|
+
closedIssuanceSimfPath: getArg("closed-issuance-simf"),
|
|
2038
|
+
closingArtifactPath: getArg("closing-artifact"),
|
|
2039
|
+
closedAt: requireArg("closed-at"),
|
|
2040
|
+
closingReason: getArg("closing-reason"),
|
|
2041
|
+
wallet: requireArg("wallet"),
|
|
2042
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
2043
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
2044
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
815
2045
|
});
|
|
816
2046
|
printJson({
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
2047
|
+
...result,
|
|
2048
|
+
summary: {
|
|
2049
|
+
closingHash: result.plan.closingHash,
|
|
2050
|
+
closedAt: result.plan.closingDescriptor.closedAt,
|
|
2051
|
+
closingReason: result.plan.closingDescriptor.closingReason,
|
|
2052
|
+
finalSettlementDescriptorHash: result.plan.closingDescriptor.finalSettlementDescriptorHash,
|
|
2053
|
+
summaryHash: result.inspect.summaryHash,
|
|
2054
|
+
},
|
|
2055
|
+
summaryText: formatBondClosingSummary({
|
|
2056
|
+
phase: "inspect",
|
|
2057
|
+
closingHash: result.plan.closingHash,
|
|
2058
|
+
closedAt: result.plan.closingDescriptor.closedAt,
|
|
2059
|
+
closingReason: result.plan.closingDescriptor.closingReason,
|
|
2060
|
+
finalSettlementDescriptorHash: result.plan.closingDescriptor.finalSettlementDescriptorHash,
|
|
2061
|
+
summaryHash: result.inspect.summaryHash,
|
|
2062
|
+
}),
|
|
823
2063
|
});
|
|
824
2064
|
return;
|
|
825
2065
|
}
|
|
826
|
-
if (command === "bond" && subcommand === "
|
|
827
|
-
const result = await sdk.bonds.
|
|
2066
|
+
if (command === "bond" && subcommand === "execute-closing") {
|
|
2067
|
+
const result = await sdk.bonds.executeClosing({
|
|
828
2068
|
currentArtifactPath: requireArg("current-artifact"),
|
|
829
2069
|
definitionPath: getArg("definition-json"),
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
2070
|
+
redeemedIssuancePath: getArg("redeemed-issuance-json"),
|
|
2071
|
+
settlementDescriptorPath: getArg("settlement-descriptor-json"),
|
|
2072
|
+
closedIssuanceSimfPath: getArg("closed-issuance-simf"),
|
|
2073
|
+
closingArtifactPath: getArg("closing-artifact"),
|
|
2074
|
+
closedAt: requireArg("closed-at"),
|
|
2075
|
+
closingReason: getArg("closing-reason"),
|
|
834
2076
|
wallet: requireArg("wallet"),
|
|
835
2077
|
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
836
2078
|
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
837
2079
|
utxoPolicy: getArg("utxo-policy"),
|
|
2080
|
+
broadcast: hasFlag("broadcast"),
|
|
2081
|
+
});
|
|
2082
|
+
printJson({
|
|
2083
|
+
...result,
|
|
2084
|
+
summary: {
|
|
2085
|
+
closingHash: result.plan.closingHash,
|
|
2086
|
+
closedAt: result.plan.closingDescriptor.closedAt,
|
|
2087
|
+
closingReason: result.plan.closingDescriptor.closingReason,
|
|
2088
|
+
finalSettlementDescriptorHash: result.plan.closingDescriptor.finalSettlementDescriptorHash,
|
|
2089
|
+
txId: result.execution.txId ?? null,
|
|
2090
|
+
broadcasted: Boolean(result.execution.txId),
|
|
2091
|
+
},
|
|
2092
|
+
summaryText: formatBondClosingSummary({
|
|
2093
|
+
phase: "execute",
|
|
2094
|
+
closingHash: result.plan.closingHash,
|
|
2095
|
+
closedAt: result.plan.closingDescriptor.closedAt,
|
|
2096
|
+
closingReason: result.plan.closingDescriptor.closingReason,
|
|
2097
|
+
finalSettlementDescriptorHash: result.plan.closingDescriptor.finalSettlementDescriptorHash,
|
|
2098
|
+
txId: result.execution.txId,
|
|
2099
|
+
broadcasted: Boolean(result.execution.txId),
|
|
2100
|
+
}),
|
|
838
2101
|
});
|
|
839
|
-
printJson(result);
|
|
840
2102
|
return;
|
|
841
2103
|
}
|
|
842
|
-
if (command === "bond" && subcommand === "
|
|
843
|
-
const
|
|
844
|
-
|
|
2104
|
+
if (command === "bond" && subcommand === "verify-closing") {
|
|
2105
|
+
const closedIssuancePath = getArg("closed-issuance-json");
|
|
2106
|
+
const closedIssuanceValue = getArg("closed-issuance-value")
|
|
2107
|
+
? JSON.parse(getArg("closed-issuance-value"))
|
|
2108
|
+
: undefined;
|
|
2109
|
+
const closingDescriptorValue = getArg("closing-descriptor-value")
|
|
2110
|
+
? JSON.parse(getArg("closing-descriptor-value"))
|
|
2111
|
+
: undefined;
|
|
2112
|
+
const result = await sdk.bonds.verifyClosing({
|
|
845
2113
|
definitionPath: getArg("definition-json"),
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
2114
|
+
redeemedIssuancePath: getArg("redeemed-issuance-json"),
|
|
2115
|
+
closedIssuancePath,
|
|
2116
|
+
closedIssuanceValue,
|
|
2117
|
+
settlementDescriptorPath: getArg("settlement-descriptor-json"),
|
|
2118
|
+
closingDescriptorValue,
|
|
2119
|
+
});
|
|
2120
|
+
printJson({
|
|
2121
|
+
...result,
|
|
2122
|
+
summary: {
|
|
2123
|
+
verified: result.verified,
|
|
2124
|
+
closedAt: result.closed.closedAt,
|
|
2125
|
+
closingReason: result.closed.closingReason,
|
|
2126
|
+
finalSettlementDescriptorHash: result.closed.finalSettlementDescriptorHash,
|
|
2127
|
+
checks: result.checks,
|
|
2128
|
+
},
|
|
2129
|
+
summaryText: formatBondClosingSummary({
|
|
2130
|
+
phase: "verify",
|
|
2131
|
+
verified: result.verified,
|
|
2132
|
+
closedAt: result.closed.closedAt,
|
|
2133
|
+
closingReason: result.closed.closingReason,
|
|
2134
|
+
finalSettlementDescriptorHash: result.closed.finalSettlementDescriptorHash,
|
|
2135
|
+
checks: result.checks,
|
|
2136
|
+
}),
|
|
2137
|
+
});
|
|
2138
|
+
return;
|
|
2139
|
+
}
|
|
2140
|
+
if (command === "bond" && subcommand === "export-evidence") {
|
|
2141
|
+
const settlementDescriptorValue = getArg("settlement-descriptor-value")
|
|
2142
|
+
? JSON.parse(getArg("settlement-descriptor-value"))
|
|
2143
|
+
: undefined;
|
|
2144
|
+
const transitionValue = getArg("transition-value")
|
|
2145
|
+
? JSON.parse(getArg("transition-value"))
|
|
2146
|
+
: undefined;
|
|
2147
|
+
const result = await sdk.bonds.exportEvidence({
|
|
2148
|
+
artifactPath: requireArg("artifact"),
|
|
2149
|
+
definitionPath: getArg("definition-json"),
|
|
2150
|
+
issuancePath: getArg("issuance-json"),
|
|
2151
|
+
settlementDescriptorValue,
|
|
2152
|
+
transitionValue,
|
|
2153
|
+
});
|
|
2154
|
+
printJson({
|
|
2155
|
+
...result,
|
|
2156
|
+
summary: {
|
|
2157
|
+
definitionHash: result.definition.hash,
|
|
2158
|
+
issuanceHash: result.issuance.hash,
|
|
2159
|
+
settlementHash: result.settlement?.hash ?? null,
|
|
2160
|
+
closingHash: result.closing?.hash ?? null,
|
|
2161
|
+
renderedSourceHash: result.renderedSourceHash ?? null,
|
|
2162
|
+
sourceVerificationMode: result.sourceVerificationMode,
|
|
2163
|
+
},
|
|
2164
|
+
summaryText: formatBondEvidenceSummary({
|
|
2165
|
+
definitionHash: result.definition.hash,
|
|
2166
|
+
issuanceHash: result.issuance.hash,
|
|
2167
|
+
settlementHash: result.settlement?.hash ?? null,
|
|
2168
|
+
closingHash: result.closing?.hash ?? null,
|
|
2169
|
+
renderedSourceHash: result.renderedSourceHash ?? null,
|
|
2170
|
+
sourceVerificationMode: result.sourceVerificationMode,
|
|
2171
|
+
}),
|
|
2172
|
+
});
|
|
2173
|
+
return;
|
|
2174
|
+
}
|
|
2175
|
+
if (command === "bond" && subcommand === "export-finality-payload") {
|
|
2176
|
+
const settlementDescriptorValue = getArg("settlement-descriptor-value")
|
|
2177
|
+
? JSON.parse(getArg("settlement-descriptor-value"))
|
|
2178
|
+
: undefined;
|
|
2179
|
+
const closingDescriptorValue = getArg("closing-descriptor-value")
|
|
2180
|
+
? JSON.parse(getArg("closing-descriptor-value"))
|
|
2181
|
+
: undefined;
|
|
2182
|
+
const result = await sdk.bonds.exportFinalityPayload({
|
|
2183
|
+
artifactPath: requireArg("artifact"),
|
|
2184
|
+
definitionPath: getArg("definition-json"),
|
|
2185
|
+
issuancePath: getArg("issuance-json"),
|
|
2186
|
+
settlementDescriptorValue,
|
|
2187
|
+
closingDescriptorValue,
|
|
2188
|
+
});
|
|
2189
|
+
printJson({
|
|
2190
|
+
...result,
|
|
2191
|
+
summary: {
|
|
2192
|
+
bondId: result.payload.bondId,
|
|
2193
|
+
issuanceId: result.payload.issuanceId,
|
|
2194
|
+
definitionHash: result.payload.definitionHash,
|
|
2195
|
+
issuanceStateHash: result.payload.issuanceStateHash,
|
|
2196
|
+
settlementDescriptorHash: result.evidenceSummary.settlementHash,
|
|
2197
|
+
closingDescriptorHash: result.evidenceSummary.closingHash,
|
|
2198
|
+
contractAddress: result.payload.contractAddress,
|
|
2199
|
+
cmr: result.payload.cmr,
|
|
2200
|
+
bindingMode: result.bindingMode,
|
|
2201
|
+
},
|
|
2202
|
+
summaryText: formatBondFinalityPayloadSummary({
|
|
2203
|
+
bondId: result.payload.bondId,
|
|
2204
|
+
issuanceId: result.payload.issuanceId,
|
|
2205
|
+
definitionHash: result.payload.definitionHash,
|
|
2206
|
+
issuanceStateHash: result.payload.issuanceStateHash,
|
|
2207
|
+
settlementDescriptorHash: result.evidenceSummary.settlementHash,
|
|
2208
|
+
closingDescriptorHash: result.evidenceSummary.closingHash,
|
|
2209
|
+
contractAddress: result.payload.contractAddress,
|
|
2210
|
+
cmr: result.payload.cmr,
|
|
2211
|
+
bindingMode: result.bindingMode,
|
|
2212
|
+
}),
|
|
2213
|
+
});
|
|
2214
|
+
return;
|
|
2215
|
+
}
|
|
2216
|
+
if (command === "fund" && subcommand === "define") {
|
|
2217
|
+
const result = await sdk.funds.define({
|
|
2218
|
+
definitionPath: getArg("definition-json"),
|
|
2219
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2220
|
+
});
|
|
2221
|
+
printJson({
|
|
2222
|
+
summaryText: formatFundDefinitionSummary({
|
|
2223
|
+
ok: result.ok,
|
|
2224
|
+
fundId: result.definitionValue.fundId,
|
|
2225
|
+
managerEntityId: result.definitionValue.managerEntityId,
|
|
2226
|
+
currencyAssetId: result.definitionValue.currencyAssetId,
|
|
2227
|
+
jurisdiction: result.definitionValue.jurisdiction,
|
|
2228
|
+
vintage: result.definitionValue.vintage,
|
|
2229
|
+
}),
|
|
2230
|
+
...result,
|
|
2231
|
+
});
|
|
2232
|
+
return;
|
|
2233
|
+
}
|
|
2234
|
+
if (command === "fund" && subcommand === "verify") {
|
|
2235
|
+
const result = await sdk.funds.verify({
|
|
2236
|
+
definitionPath: getArg("definition-json"),
|
|
2237
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2238
|
+
});
|
|
2239
|
+
printJson({
|
|
2240
|
+
summaryText: formatFundDefinitionSummary({
|
|
2241
|
+
ok: result.ok,
|
|
2242
|
+
fundId: result.definitionValue.fundId,
|
|
2243
|
+
managerEntityId: result.definitionValue.managerEntityId,
|
|
2244
|
+
currencyAssetId: result.definitionValue.currencyAssetId,
|
|
2245
|
+
jurisdiction: result.definitionValue.jurisdiction,
|
|
2246
|
+
vintage: result.definitionValue.vintage,
|
|
2247
|
+
}),
|
|
2248
|
+
...result,
|
|
2249
|
+
});
|
|
2250
|
+
return;
|
|
2251
|
+
}
|
|
2252
|
+
if (command === "fund" && subcommand === "prepare-capital-call") {
|
|
2253
|
+
const result = await sdk.funds.prepareCapitalCall({
|
|
2254
|
+
definitionPath: getArg("definition-json"),
|
|
2255
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2256
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
2257
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
2258
|
+
openSimfPath: getArg("open-simf") ?? getArg("simf"),
|
|
2259
|
+
refundOnlySimfPath: getArg("refund-only-simf"),
|
|
2260
|
+
openArtifactPath: getArg("open-artifact") ?? getArg("artifact"),
|
|
2261
|
+
refundOnlyArtifactPath: getArg("refund-only-artifact"),
|
|
2262
|
+
});
|
|
2263
|
+
printJson({
|
|
2264
|
+
summary: {
|
|
2265
|
+
callId: result.capitalCallValue.callId,
|
|
2266
|
+
status: result.capitalCallValue.status,
|
|
2267
|
+
amount: result.capitalCallValue.amount,
|
|
2268
|
+
assetId: result.capitalCallValue.currencyAssetId,
|
|
2269
|
+
openContractAddress: result.openCompiled.deployment().contractAddress,
|
|
2270
|
+
refundOnlyContractAddress: result.refundOnlyCompiled.deployment().contractAddress,
|
|
2271
|
+
},
|
|
2272
|
+
summaryText: formatFundCapitalCallSummary({
|
|
2273
|
+
phase: "prepare",
|
|
2274
|
+
callId: result.capitalCallValue.callId,
|
|
2275
|
+
status: result.capitalCallValue.status,
|
|
2276
|
+
amount: result.capitalCallValue.amount,
|
|
2277
|
+
assetId: result.capitalCallValue.currencyAssetId,
|
|
2278
|
+
contractAddress: result.openCompiled.deployment().contractAddress,
|
|
2279
|
+
}),
|
|
2280
|
+
...result,
|
|
2281
|
+
});
|
|
2282
|
+
return;
|
|
2283
|
+
}
|
|
2284
|
+
if (command === "fund" && subcommand === "verify-capital-call") {
|
|
2285
|
+
const result = await sdk.funds.verifyCapitalCall({
|
|
2286
|
+
artifactPath: getArg("artifact"),
|
|
2287
|
+
definitionPath: getArg("definition-json"),
|
|
2288
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2289
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
2290
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
2291
|
+
});
|
|
2292
|
+
printJson({
|
|
2293
|
+
summary: {
|
|
2294
|
+
ok: result.ok,
|
|
2295
|
+
reason: result.reason,
|
|
2296
|
+
callId: result.capitalCallValue.callId,
|
|
2297
|
+
status: result.capitalCallValue.status,
|
|
2298
|
+
amount: result.capitalCallValue.amount,
|
|
2299
|
+
assetId: result.capitalCallValue.currencyAssetId,
|
|
2300
|
+
},
|
|
2301
|
+
summaryText: formatFundCapitalCallSummary({
|
|
2302
|
+
phase: "verify",
|
|
2303
|
+
ok: result.ok,
|
|
2304
|
+
reason: result.reason,
|
|
2305
|
+
callId: result.capitalCallValue.callId,
|
|
2306
|
+
status: result.capitalCallValue.status,
|
|
2307
|
+
amount: result.capitalCallValue.amount,
|
|
2308
|
+
assetId: result.capitalCallValue.currencyAssetId,
|
|
2309
|
+
}),
|
|
2310
|
+
...result,
|
|
2311
|
+
});
|
|
2312
|
+
return;
|
|
2313
|
+
}
|
|
2314
|
+
if (command === "fund" && subcommand === "inspect-capital-call-claim") {
|
|
2315
|
+
const result = await sdk.funds.inspectCapitalCallClaim({
|
|
2316
|
+
artifactPath: requireArg("artifact"),
|
|
2317
|
+
definitionPath: getArg("definition-json"),
|
|
2318
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2319
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
2320
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
2321
|
+
payoutAddress: requireArg("payout-address"),
|
|
2322
|
+
positionId: getArg("position-id"),
|
|
2323
|
+
claimedAt: getArg("claimed-at"),
|
|
2324
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
2325
|
+
outputForm: parsePolicyOutputForm(),
|
|
2326
|
+
rawOutput: parseRawOutputFields(),
|
|
2327
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
850
2328
|
wallet: requireArg("wallet"),
|
|
851
2329
|
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
852
2330
|
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
853
2331
|
utxoPolicy: getArg("utxo-policy"),
|
|
854
2332
|
});
|
|
855
|
-
printJson(
|
|
2333
|
+
printJson({
|
|
2334
|
+
summary: {
|
|
2335
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2336
|
+
status: result.claimedCapitalCall.status,
|
|
2337
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2338
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2339
|
+
summaryHash: result.inspect.summaryHash,
|
|
2340
|
+
positionReceiptHash: result.report.receiptTrust?.positionReceiptHash ?? null,
|
|
2341
|
+
positionReceiptEnvelopeHash: result.positionReceiptEnvelope ? result.positionReceiptEnvelopeSummary?.hash ?? null : null,
|
|
2342
|
+
outputBinding: result.report.outputBindingTrust ?? null,
|
|
2343
|
+
},
|
|
2344
|
+
summaryText: formatFundCapitalCallSummary({
|
|
2345
|
+
phase: "inspect-claim",
|
|
2346
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2347
|
+
status: result.claimedCapitalCall.status,
|
|
2348
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2349
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2350
|
+
summaryHash: result.inspect.summaryHash,
|
|
2351
|
+
positionReceiptHash: result.report.receiptTrust?.positionReceiptHash,
|
|
2352
|
+
outputBinding: result.report.outputBindingTrust,
|
|
2353
|
+
}),
|
|
2354
|
+
...result,
|
|
2355
|
+
});
|
|
856
2356
|
return;
|
|
857
2357
|
}
|
|
858
|
-
if (command === "
|
|
859
|
-
const result = await sdk.
|
|
860
|
-
|
|
2358
|
+
if (command === "fund" && subcommand === "execute-capital-call-claim") {
|
|
2359
|
+
const result = await sdk.funds.executeCapitalCallClaim({
|
|
2360
|
+
artifactPath: requireArg("artifact"),
|
|
861
2361
|
definitionPath: getArg("definition-json"),
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
2362
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2363
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
2364
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
2365
|
+
payoutAddress: requireArg("payout-address"),
|
|
2366
|
+
positionId: getArg("position-id"),
|
|
2367
|
+
claimedAt: getArg("claimed-at"),
|
|
2368
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
2369
|
+
outputForm: parsePolicyOutputForm(),
|
|
2370
|
+
rawOutput: parseRawOutputFields(),
|
|
2371
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
866
2372
|
wallet: requireArg("wallet"),
|
|
867
2373
|
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
868
2374
|
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
869
2375
|
utxoPolicy: getArg("utxo-policy"),
|
|
870
2376
|
broadcast: hasFlag("broadcast"),
|
|
871
2377
|
});
|
|
872
|
-
printJson(
|
|
2378
|
+
printJson({
|
|
2379
|
+
summary: {
|
|
2380
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2381
|
+
status: result.claimedCapitalCall.status,
|
|
2382
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2383
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2384
|
+
txId: result.execution.txId ?? null,
|
|
2385
|
+
broadcasted: result.execution.broadcasted,
|
|
2386
|
+
positionReceiptHash: result.report.receiptTrust?.positionReceiptHash ?? null,
|
|
2387
|
+
outputBinding: result.report.outputBindingTrust ?? null,
|
|
2388
|
+
},
|
|
2389
|
+
summaryText: formatFundCapitalCallSummary({
|
|
2390
|
+
phase: "execute-claim",
|
|
2391
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2392
|
+
status: result.claimedCapitalCall.status,
|
|
2393
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2394
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2395
|
+
txId: result.execution.txId,
|
|
2396
|
+
broadcasted: result.execution.broadcasted,
|
|
2397
|
+
positionReceiptHash: result.report.receiptTrust?.positionReceiptHash,
|
|
2398
|
+
outputBinding: result.report.outputBindingTrust,
|
|
2399
|
+
}),
|
|
2400
|
+
...result,
|
|
2401
|
+
});
|
|
873
2402
|
return;
|
|
874
2403
|
}
|
|
875
|
-
if (command === "
|
|
876
|
-
const result = await sdk.
|
|
877
|
-
|
|
2404
|
+
if (command === "fund" && subcommand === "inspect-capital-call-rollover") {
|
|
2405
|
+
const result = await sdk.funds.inspectCapitalCallRollover({
|
|
2406
|
+
artifactPath: requireArg("artifact"),
|
|
2407
|
+
refundOnlyArtifactPath: requireArg("refund-only-artifact"),
|
|
878
2408
|
definitionPath: getArg("definition-json"),
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
machineArtifactPath: getArg("machine-artifact"),
|
|
2409
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2410
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
2411
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
883
2412
|
wallet: requireArg("wallet"),
|
|
884
2413
|
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
885
2414
|
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
886
2415
|
utxoPolicy: getArg("utxo-policy"),
|
|
887
|
-
broadcast: hasFlag("broadcast"),
|
|
888
2416
|
});
|
|
889
|
-
printJson(
|
|
2417
|
+
printJson({
|
|
2418
|
+
summary: {
|
|
2419
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2420
|
+
status: result.rolledOverCapitalCall.status,
|
|
2421
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2422
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2423
|
+
summaryHash: result.inspect.summaryHash,
|
|
2424
|
+
refundOnlyContractAddress: result.refundOnlyArtifact.compiled.contractAddress,
|
|
2425
|
+
},
|
|
2426
|
+
summaryText: formatFundCapitalCallSummary({
|
|
2427
|
+
phase: "inspect-rollover",
|
|
2428
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2429
|
+
status: result.rolledOverCapitalCall.status,
|
|
2430
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2431
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2432
|
+
summaryHash: result.inspect.summaryHash,
|
|
2433
|
+
contractAddress: result.refundOnlyArtifact.compiled.contractAddress,
|
|
2434
|
+
}),
|
|
2435
|
+
...result,
|
|
2436
|
+
});
|
|
890
2437
|
return;
|
|
891
2438
|
}
|
|
892
|
-
if (command === "
|
|
893
|
-
const result = await sdk.
|
|
894
|
-
|
|
2439
|
+
if (command === "fund" && subcommand === "execute-capital-call-rollover") {
|
|
2440
|
+
const result = await sdk.funds.executeCapitalCallRollover({
|
|
2441
|
+
artifactPath: requireArg("artifact"),
|
|
2442
|
+
refundOnlyArtifactPath: requireArg("refund-only-artifact"),
|
|
895
2443
|
definitionPath: getArg("definition-json"),
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
2444
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2445
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
2446
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
2447
|
+
wallet: requireArg("wallet"),
|
|
2448
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
2449
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
2450
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
2451
|
+
broadcast: hasFlag("broadcast"),
|
|
900
2452
|
});
|
|
901
2453
|
printJson({
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
2454
|
+
summary: {
|
|
2455
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2456
|
+
status: result.rolledOverCapitalCall.status,
|
|
2457
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2458
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2459
|
+
txId: result.execution.txId ?? null,
|
|
2460
|
+
broadcasted: result.execution.broadcasted,
|
|
2461
|
+
refundOnlyContractAddress: result.refundOnlyArtifact.compiled.contractAddress,
|
|
2462
|
+
},
|
|
2463
|
+
summaryText: formatFundCapitalCallSummary({
|
|
2464
|
+
phase: "execute-rollover",
|
|
2465
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2466
|
+
status: result.rolledOverCapitalCall.status,
|
|
2467
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2468
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2469
|
+
txId: result.execution.txId,
|
|
2470
|
+
broadcasted: result.execution.broadcasted,
|
|
2471
|
+
contractAddress: result.refundOnlyArtifact.compiled.contractAddress,
|
|
2472
|
+
}),
|
|
2473
|
+
...result,
|
|
908
2474
|
});
|
|
909
2475
|
return;
|
|
910
2476
|
}
|
|
911
|
-
if (command === "
|
|
912
|
-
const result = await sdk.
|
|
913
|
-
|
|
2477
|
+
if (command === "fund" && subcommand === "inspect-capital-call-refund") {
|
|
2478
|
+
const result = await sdk.funds.inspectCapitalCallRefund({
|
|
2479
|
+
artifactPath: requireArg("artifact"),
|
|
914
2480
|
definitionPath: getArg("definition-json"),
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
2481
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2482
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
2483
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
2484
|
+
refundAddress: requireArg("refund-address"),
|
|
2485
|
+
refundedAt: getArg("refunded-at"),
|
|
919
2486
|
wallet: requireArg("wallet"),
|
|
920
2487
|
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
921
2488
|
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
922
2489
|
utxoPolicy: getArg("utxo-policy"),
|
|
923
2490
|
});
|
|
924
|
-
printJson(
|
|
2491
|
+
printJson({
|
|
2492
|
+
summary: {
|
|
2493
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2494
|
+
status: result.refundedCapitalCall.status,
|
|
2495
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2496
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2497
|
+
summaryHash: result.inspect.summaryHash,
|
|
2498
|
+
},
|
|
2499
|
+
summaryText: formatFundCapitalCallSummary({
|
|
2500
|
+
phase: "inspect-refund",
|
|
2501
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2502
|
+
status: result.refundedCapitalCall.status,
|
|
2503
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2504
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2505
|
+
summaryHash: result.inspect.summaryHash,
|
|
2506
|
+
}),
|
|
2507
|
+
...result,
|
|
2508
|
+
});
|
|
925
2509
|
return;
|
|
926
2510
|
}
|
|
927
|
-
if (command === "
|
|
928
|
-
const result = await sdk.
|
|
929
|
-
|
|
2511
|
+
if (command === "fund" && subcommand === "execute-capital-call-refund") {
|
|
2512
|
+
const result = await sdk.funds.executeCapitalCallRefund({
|
|
2513
|
+
artifactPath: requireArg("artifact"),
|
|
930
2514
|
definitionPath: getArg("definition-json"),
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
2515
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2516
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
2517
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
2518
|
+
refundAddress: requireArg("refund-address"),
|
|
2519
|
+
refundedAt: getArg("refunded-at"),
|
|
935
2520
|
wallet: requireArg("wallet"),
|
|
936
2521
|
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
937
2522
|
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
938
2523
|
utxoPolicy: getArg("utxo-policy"),
|
|
939
2524
|
broadcast: hasFlag("broadcast"),
|
|
940
2525
|
});
|
|
941
|
-
printJson(
|
|
2526
|
+
printJson({
|
|
2527
|
+
summary: {
|
|
2528
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2529
|
+
status: result.refundedCapitalCall.status,
|
|
2530
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2531
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2532
|
+
txId: result.execution.txId ?? null,
|
|
2533
|
+
broadcasted: result.execution.broadcasted,
|
|
2534
|
+
},
|
|
2535
|
+
summaryText: formatFundCapitalCallSummary({
|
|
2536
|
+
phase: "execute-refund",
|
|
2537
|
+
callId: result.verified.capitalCallValue.callId,
|
|
2538
|
+
status: result.refundedCapitalCall.status,
|
|
2539
|
+
amount: result.verified.capitalCallValue.amount,
|
|
2540
|
+
assetId: result.verified.capitalCallValue.currencyAssetId,
|
|
2541
|
+
txId: result.execution.txId,
|
|
2542
|
+
broadcasted: result.execution.broadcasted,
|
|
2543
|
+
}),
|
|
2544
|
+
...result,
|
|
2545
|
+
});
|
|
942
2546
|
return;
|
|
943
2547
|
}
|
|
944
|
-
if (command === "
|
|
945
|
-
const result = await sdk.
|
|
2548
|
+
if (command === "fund" && subcommand === "prepare-distribution") {
|
|
2549
|
+
const result = await sdk.funds.prepareDistribution({
|
|
946
2550
|
definitionPath: getArg("definition-json"),
|
|
947
|
-
|
|
948
|
-
|
|
2551
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2552
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
2553
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
2554
|
+
distributionPath: getArg("distribution-json"),
|
|
2555
|
+
distributionValue: getArg("distribution-value") ? JSON.parse(getArg("distribution-value")) : undefined,
|
|
2556
|
+
distributionId: getArg("distribution-id"),
|
|
2557
|
+
assetId: getArg("asset-id"),
|
|
2558
|
+
amountSat: getArg("amount-sat") ? Number(getArg("amount-sat")) : undefined,
|
|
2559
|
+
approvedAt: getArg("approved-at"),
|
|
2560
|
+
simfPath: getArg("simf"),
|
|
2561
|
+
artifactPath: getArg("artifact"),
|
|
2562
|
+
});
|
|
2563
|
+
printJson({
|
|
2564
|
+
summary: {
|
|
2565
|
+
distributionId: result.distributionValue.distributionId,
|
|
2566
|
+
positionId: result.distributionValue.positionId,
|
|
2567
|
+
amountSat: result.distributionValue.amountSat,
|
|
2568
|
+
assetId: result.distributionValue.assetId,
|
|
2569
|
+
contractAddress: result.compiled.deployment().contractAddress,
|
|
2570
|
+
},
|
|
2571
|
+
summaryText: formatFundDistributionSummary({
|
|
2572
|
+
phase: "prepare",
|
|
2573
|
+
distributionId: result.distributionValue.distributionId,
|
|
2574
|
+
positionId: result.distributionValue.positionId,
|
|
2575
|
+
amountSat: result.distributionValue.amountSat,
|
|
2576
|
+
assetId: result.distributionValue.assetId,
|
|
2577
|
+
contractAddress: result.compiled.deployment().contractAddress,
|
|
2578
|
+
}),
|
|
2579
|
+
...result,
|
|
2580
|
+
});
|
|
2581
|
+
return;
|
|
2582
|
+
}
|
|
2583
|
+
if (command === "fund" && subcommand === "sign-position-receipt") {
|
|
2584
|
+
const result = await sdk.funds.signPositionReceipt({
|
|
2585
|
+
definitionPath: getArg("definition-json"),
|
|
2586
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2587
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
2588
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
2589
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
2590
|
+
signedAt: getArg("signed-at"),
|
|
2591
|
+
});
|
|
2592
|
+
printJson({
|
|
2593
|
+
summary: {
|
|
2594
|
+
positionId: result.positionReceiptValue.positionId,
|
|
2595
|
+
sequence: result.positionReceiptEnvelope.receipt.sequence,
|
|
2596
|
+
receiptHash: result.positionReceiptSummary.hash,
|
|
2597
|
+
envelopeHash: result.positionReceiptEnvelopeSummary.hash,
|
|
2598
|
+
},
|
|
2599
|
+
summaryText: [
|
|
2600
|
+
`positionId=${result.positionReceiptValue.positionId}`,
|
|
2601
|
+
`sequence=${result.positionReceiptEnvelope.receipt.sequence}`,
|
|
2602
|
+
`receiptHash=${result.positionReceiptSummary.hash}`,
|
|
2603
|
+
`envelopeHash=${result.positionReceiptEnvelopeSummary.hash}`,
|
|
2604
|
+
].join("\n"),
|
|
2605
|
+
...result,
|
|
2606
|
+
});
|
|
2607
|
+
return;
|
|
2608
|
+
}
|
|
2609
|
+
if (command === "fund" && subcommand === "verify-position-receipt") {
|
|
2610
|
+
const result = await sdk.funds.verifyPositionReceipt({
|
|
2611
|
+
definitionPath: getArg("definition-json"),
|
|
2612
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2613
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
2614
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
2615
|
+
});
|
|
2616
|
+
printJson({
|
|
2617
|
+
summary: {
|
|
2618
|
+
verified: result.verified,
|
|
2619
|
+
positionId: result.positionReceiptValue.receipt.positionId,
|
|
2620
|
+
sequence: result.positionReceiptValue.receipt.sequence,
|
|
2621
|
+
receiptHash: result.positionReceiptSummary.hash,
|
|
2622
|
+
envelopeHash: result.positionReceiptEnvelopeSummary.hash,
|
|
2623
|
+
},
|
|
2624
|
+
summaryText: [
|
|
2625
|
+
`verified=${result.verified}`,
|
|
2626
|
+
`positionId=${result.positionReceiptValue.receipt.positionId}`,
|
|
2627
|
+
`sequence=${result.positionReceiptValue.receipt.sequence}`,
|
|
2628
|
+
`receiptHash=${result.positionReceiptSummary.hash}`,
|
|
2629
|
+
`envelopeHash=${result.positionReceiptEnvelopeSummary.hash}`,
|
|
2630
|
+
].join("\n"),
|
|
2631
|
+
...result,
|
|
949
2632
|
});
|
|
950
|
-
printJson(result);
|
|
951
2633
|
return;
|
|
952
2634
|
}
|
|
953
|
-
if (command === "
|
|
954
|
-
const
|
|
2635
|
+
if (command === "fund" && subcommand === "reconcile-position") {
|
|
2636
|
+
const distributionJsons = getMultiArgs("distribution-json");
|
|
2637
|
+
const distributionValues = getMultiArgs("distribution-value").map((value) => JSON.parse(value));
|
|
2638
|
+
const result = await sdk.funds.reconcilePosition({
|
|
2639
|
+
definitionPath: getArg("definition-json"),
|
|
2640
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2641
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
2642
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
2643
|
+
distributionPaths: distributionJsons.length > 0 ? distributionJsons : undefined,
|
|
2644
|
+
distributionValues: distributionValues.length > 0 ? distributionValues : undefined,
|
|
2645
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
2646
|
+
signedAt: getArg("signed-at"),
|
|
2647
|
+
});
|
|
2648
|
+
printJson({
|
|
2649
|
+
summary: {
|
|
2650
|
+
positionId: result.reconciledReceiptValue.positionId,
|
|
2651
|
+
distributionCount: result.distributionCount,
|
|
2652
|
+
distributedAmount: result.totalDistributedAmount,
|
|
2653
|
+
fundedAmount: result.reconciledReceiptValue.fundedAmount,
|
|
2654
|
+
status: result.reconciledReceiptValue.status,
|
|
2655
|
+
receiptHash: result.reconciledReceiptSummary.hash,
|
|
2656
|
+
sequence: result.reconciledReceiptValue.sequence,
|
|
2657
|
+
envelopeHash: result.reconciledReceiptEnvelopeSummary.hash,
|
|
2658
|
+
},
|
|
2659
|
+
summaryText: formatFundReceiptReconcileSummary({
|
|
2660
|
+
positionId: result.reconciledReceiptValue.positionId,
|
|
2661
|
+
distributionCount: result.distributionCount,
|
|
2662
|
+
distributedAmount: result.totalDistributedAmount,
|
|
2663
|
+
fundedAmount: result.reconciledReceiptValue.fundedAmount,
|
|
2664
|
+
status: result.reconciledReceiptValue.status,
|
|
2665
|
+
receiptHash: result.reconciledReceiptSummary.hash,
|
|
2666
|
+
sequence: result.reconciledReceiptValue.sequence,
|
|
2667
|
+
envelopeHash: result.reconciledReceiptEnvelopeSummary.hash,
|
|
2668
|
+
}),
|
|
2669
|
+
...result,
|
|
2670
|
+
});
|
|
2671
|
+
return;
|
|
2672
|
+
}
|
|
2673
|
+
if (command === "fund" && subcommand === "verify-distribution") {
|
|
2674
|
+
const result = await sdk.funds.verifyDistribution({
|
|
2675
|
+
artifactPath: getArg("artifact"),
|
|
2676
|
+
definitionPath: getArg("definition-json"),
|
|
2677
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2678
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
2679
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
2680
|
+
distributionPath: getArg("distribution-json"),
|
|
2681
|
+
distributionValue: getArg("distribution-value") ? JSON.parse(getArg("distribution-value")) : undefined,
|
|
2682
|
+
});
|
|
2683
|
+
printJson({
|
|
2684
|
+
summary: {
|
|
2685
|
+
ok: result.ok,
|
|
2686
|
+
reason: result.reason,
|
|
2687
|
+
distributionId: result.distributionValue.distributionId,
|
|
2688
|
+
positionId: result.distributionValue.positionId,
|
|
2689
|
+
amountSat: result.distributionValue.amountSat,
|
|
2690
|
+
assetId: result.distributionValue.assetId,
|
|
2691
|
+
},
|
|
2692
|
+
summaryText: formatFundDistributionSummary({
|
|
2693
|
+
phase: "verify",
|
|
2694
|
+
ok: result.ok,
|
|
2695
|
+
reason: result.reason,
|
|
2696
|
+
distributionId: result.distributionValue.distributionId,
|
|
2697
|
+
positionId: result.distributionValue.positionId,
|
|
2698
|
+
amountSat: result.distributionValue.amountSat,
|
|
2699
|
+
assetId: result.distributionValue.assetId,
|
|
2700
|
+
}),
|
|
2701
|
+
...result,
|
|
2702
|
+
});
|
|
2703
|
+
return;
|
|
2704
|
+
}
|
|
2705
|
+
if (command === "fund" && subcommand === "inspect-distribution-claim") {
|
|
2706
|
+
const result = await sdk.funds.inspectDistributionClaim({
|
|
955
2707
|
artifactPath: requireArg("artifact"),
|
|
956
2708
|
definitionPath: getArg("definition-json"),
|
|
957
|
-
|
|
2709
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2710
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
2711
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
2712
|
+
distributionPath: getArg("distribution-json"),
|
|
2713
|
+
distributionValue: getArg("distribution-value") ? JSON.parse(getArg("distribution-value")) : undefined,
|
|
2714
|
+
payoutAddress: requireArg("payout-address"),
|
|
2715
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
2716
|
+
outputForm: parsePolicyOutputForm(),
|
|
2717
|
+
rawOutput: parseRawOutputFields(),
|
|
2718
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
2719
|
+
wallet: requireArg("wallet"),
|
|
2720
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
2721
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
2722
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
2723
|
+
});
|
|
2724
|
+
printJson({
|
|
2725
|
+
summary: {
|
|
2726
|
+
distributionId: result.verified.distributionValue.distributionId,
|
|
2727
|
+
positionId: result.verified.distributionValue.positionId,
|
|
2728
|
+
amountSat: result.verified.distributionValue.amountSat,
|
|
2729
|
+
assetId: result.verified.distributionValue.assetId,
|
|
2730
|
+
summaryHash: result.inspect.summaryHash,
|
|
2731
|
+
outputBinding: result.report.outputBindingTrust ?? null,
|
|
2732
|
+
},
|
|
2733
|
+
summaryText: formatFundDistributionSummary({
|
|
2734
|
+
phase: "inspect-claim",
|
|
2735
|
+
distributionId: result.verified.distributionValue.distributionId,
|
|
2736
|
+
positionId: result.verified.distributionValue.positionId,
|
|
2737
|
+
amountSat: result.verified.distributionValue.amountSat,
|
|
2738
|
+
assetId: result.verified.distributionValue.assetId,
|
|
2739
|
+
summaryHash: result.inspect.summaryHash,
|
|
2740
|
+
outputBinding: result.report.outputBindingTrust,
|
|
2741
|
+
}),
|
|
2742
|
+
...result,
|
|
2743
|
+
});
|
|
2744
|
+
return;
|
|
2745
|
+
}
|
|
2746
|
+
if (command === "fund" && subcommand === "execute-distribution-claim") {
|
|
2747
|
+
const result = await sdk.funds.executeDistributionClaim({
|
|
2748
|
+
artifactPath: requireArg("artifact"),
|
|
2749
|
+
definitionPath: getArg("definition-json"),
|
|
2750
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2751
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
2752
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
2753
|
+
distributionPath: getArg("distribution-json"),
|
|
2754
|
+
distributionValue: getArg("distribution-value") ? JSON.parse(getArg("distribution-value")) : undefined,
|
|
2755
|
+
payoutAddress: requireArg("payout-address"),
|
|
2756
|
+
nextOutputHash: getArg("next-output-hash") || undefined,
|
|
2757
|
+
outputForm: parsePolicyOutputForm(),
|
|
2758
|
+
rawOutput: parseRawOutputFields(),
|
|
2759
|
+
outputBindingMode: getArg("output-binding-mode"),
|
|
2760
|
+
wallet: requireArg("wallet"),
|
|
2761
|
+
signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
|
|
2762
|
+
feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
|
|
2763
|
+
utxoPolicy: getArg("utxo-policy"),
|
|
2764
|
+
broadcast: hasFlag("broadcast"),
|
|
2765
|
+
});
|
|
2766
|
+
printJson({
|
|
2767
|
+
summary: {
|
|
2768
|
+
distributionId: result.verified.distributionValue.distributionId,
|
|
2769
|
+
positionId: result.verified.distributionValue.positionId,
|
|
2770
|
+
amountSat: result.verified.distributionValue.amountSat,
|
|
2771
|
+
assetId: result.verified.distributionValue.assetId,
|
|
2772
|
+
txId: result.execution.txId ?? null,
|
|
2773
|
+
broadcasted: result.execution.broadcasted,
|
|
2774
|
+
outputBinding: result.report.outputBindingTrust ?? null,
|
|
2775
|
+
},
|
|
2776
|
+
summaryText: formatFundDistributionSummary({
|
|
2777
|
+
phase: "execute-claim",
|
|
2778
|
+
distributionId: result.verified.distributionValue.distributionId,
|
|
2779
|
+
positionId: result.verified.distributionValue.positionId,
|
|
2780
|
+
amountSat: result.verified.distributionValue.amountSat,
|
|
2781
|
+
assetId: result.verified.distributionValue.assetId,
|
|
2782
|
+
txId: result.execution.txId,
|
|
2783
|
+
broadcasted: result.execution.broadcasted,
|
|
2784
|
+
outputBinding: result.report.outputBindingTrust,
|
|
2785
|
+
}),
|
|
2786
|
+
...result,
|
|
2787
|
+
});
|
|
2788
|
+
return;
|
|
2789
|
+
}
|
|
2790
|
+
if (command === "fund" && subcommand === "prepare-closing") {
|
|
2791
|
+
const result = await sdk.funds.prepareClosing({
|
|
2792
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
2793
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
2794
|
+
closingPath: getArg("closing-json"),
|
|
2795
|
+
closingValue: getArg("closing-value") ? JSON.parse(getArg("closing-value")) : undefined,
|
|
2796
|
+
closingId: getArg("closing-id"),
|
|
2797
|
+
finalDistributionHashes: getMultiArgs("final-distribution-hash"),
|
|
2798
|
+
closedAt: getArg("closed-at"),
|
|
2799
|
+
closingReason: getArg("closing-reason"),
|
|
2800
|
+
});
|
|
2801
|
+
printJson({
|
|
2802
|
+
summary: {
|
|
2803
|
+
closingHash: result.closingHash,
|
|
2804
|
+
closedAt: result.closingValue.closedAt,
|
|
2805
|
+
closingReason: result.closingValue.closingReason,
|
|
2806
|
+
positionId: result.closingValue.positionId,
|
|
2807
|
+
distributionCount: result.closingValue.finalDistributionHashes.length,
|
|
2808
|
+
},
|
|
2809
|
+
summaryText: formatFundClosingSummary({
|
|
2810
|
+
closingHash: result.closingHash,
|
|
2811
|
+
closedAt: result.closingValue.closedAt,
|
|
2812
|
+
closingReason: result.closingValue.closingReason,
|
|
2813
|
+
positionId: result.closingValue.positionId,
|
|
2814
|
+
distributionCount: result.closingValue.finalDistributionHashes.length,
|
|
2815
|
+
}),
|
|
2816
|
+
...result,
|
|
2817
|
+
});
|
|
2818
|
+
return;
|
|
2819
|
+
}
|
|
2820
|
+
if (command === "fund" && subcommand === "verify-closing") {
|
|
2821
|
+
const result = await sdk.funds.verifyClosing({
|
|
2822
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
2823
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
2824
|
+
closingPath: getArg("closing-json"),
|
|
2825
|
+
closingValue: getArg("closing-value") ? JSON.parse(getArg("closing-value")) : undefined,
|
|
2826
|
+
});
|
|
2827
|
+
printJson({
|
|
2828
|
+
summary: {
|
|
2829
|
+
verified: result.verified,
|
|
2830
|
+
closingHash: result.closingSummary.hash,
|
|
2831
|
+
closedAt: result.closingValue.closedAt,
|
|
2832
|
+
closingReason: result.closingValue.closingReason,
|
|
2833
|
+
positionId: result.closingValue.positionId,
|
|
2834
|
+
distributionCount: result.closingValue.finalDistributionHashes.length,
|
|
2835
|
+
},
|
|
2836
|
+
summaryText: formatFundClosingSummary({
|
|
2837
|
+
ok: result.verified,
|
|
2838
|
+
closingHash: result.closingSummary.hash,
|
|
2839
|
+
closedAt: result.closingValue.closedAt,
|
|
2840
|
+
closingReason: result.closingValue.closingReason,
|
|
2841
|
+
positionId: result.closingValue.positionId,
|
|
2842
|
+
distributionCount: result.closingValue.finalDistributionHashes.length,
|
|
2843
|
+
}),
|
|
2844
|
+
...result,
|
|
2845
|
+
});
|
|
2846
|
+
return;
|
|
2847
|
+
}
|
|
2848
|
+
if (command === "fund" && subcommand === "export-evidence") {
|
|
2849
|
+
const result = await sdk.funds.exportEvidence({
|
|
2850
|
+
artifactPath: getArg("artifact"),
|
|
2851
|
+
definitionPath: getArg("definition-json"),
|
|
2852
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2853
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
2854
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
2855
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
2856
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
2857
|
+
distributionPath: getArg("distribution-json"),
|
|
2858
|
+
distributionValue: getArg("distribution-value") ? JSON.parse(getArg("distribution-value")) : undefined,
|
|
2859
|
+
closingPath: getArg("closing-json"),
|
|
2860
|
+
closingValue: getArg("closing-value") ? JSON.parse(getArg("closing-value")) : undefined,
|
|
2861
|
+
verificationReportValue: getArg("verification-report-value") ? JSON.parse(getArg("verification-report-value")) : undefined,
|
|
2862
|
+
});
|
|
2863
|
+
printJson({
|
|
2864
|
+
summary: {
|
|
2865
|
+
definitionHash: result.definition.hash,
|
|
2866
|
+
capitalCallHash: result.capitalCall?.hash ?? null,
|
|
2867
|
+
positionReceiptHash: result.positionReceipt?.hash ?? null,
|
|
2868
|
+
distributionHash: result.distribution?.hash ?? null,
|
|
2869
|
+
closingHash: result.closing?.hash ?? null,
|
|
2870
|
+
sourceVerificationMode: result.sourceVerificationMode,
|
|
2871
|
+
},
|
|
2872
|
+
summaryText: formatFundEvidenceSummary({
|
|
2873
|
+
definitionHash: result.definition.hash,
|
|
2874
|
+
capitalCallHash: result.capitalCall?.hash ?? null,
|
|
2875
|
+
positionReceiptHash: result.positionReceipt?.hash ?? null,
|
|
2876
|
+
distributionHash: result.distribution?.hash ?? null,
|
|
2877
|
+
closingHash: result.closing?.hash ?? null,
|
|
2878
|
+
sourceVerificationMode: result.sourceVerificationMode,
|
|
2879
|
+
}),
|
|
2880
|
+
...result,
|
|
2881
|
+
});
|
|
2882
|
+
return;
|
|
2883
|
+
}
|
|
2884
|
+
if (command === "fund" && subcommand === "export-finality-payload") {
|
|
2885
|
+
const result = await sdk.funds.exportFinalityPayload({
|
|
2886
|
+
artifactPath: getArg("artifact"),
|
|
2887
|
+
definitionPath: getArg("definition-json"),
|
|
2888
|
+
definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
|
|
2889
|
+
capitalCallPath: getArg("capital-call-json"),
|
|
2890
|
+
capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
|
|
2891
|
+
positionReceiptPath: getArg("position-receipt-json"),
|
|
2892
|
+
positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
|
|
2893
|
+
distributionPath: getArg("distribution-json"),
|
|
2894
|
+
distributionValue: getArg("distribution-value") ? JSON.parse(getArg("distribution-value")) : undefined,
|
|
2895
|
+
closingPath: getArg("closing-json"),
|
|
2896
|
+
closingValue: getArg("closing-value") ? JSON.parse(getArg("closing-value")) : undefined,
|
|
2897
|
+
verificationReportValue: getArg("verification-report-value") ? JSON.parse(getArg("verification-report-value")) : undefined,
|
|
2898
|
+
});
|
|
2899
|
+
printJson({
|
|
2900
|
+
summary: {
|
|
2901
|
+
fundId: result.fundId,
|
|
2902
|
+
lpId: result.lpId,
|
|
2903
|
+
callId: result.callId ?? null,
|
|
2904
|
+
positionId: result.positionId ?? null,
|
|
2905
|
+
definitionHash: result.definitionHash,
|
|
2906
|
+
capitalCallStateHash: result.capitalCallStateHash ?? null,
|
|
2907
|
+
positionReceiptHash: result.positionReceiptHash ?? null,
|
|
2908
|
+
distributionHash: result.distributionHash ?? null,
|
|
2909
|
+
closingHash: result.closingHash ?? null,
|
|
2910
|
+
bindingMode: result.bindingMode,
|
|
2911
|
+
},
|
|
2912
|
+
summaryText: formatFundFinalitySummary({
|
|
2913
|
+
fundId: result.fundId,
|
|
2914
|
+
lpId: result.lpId,
|
|
2915
|
+
callId: result.callId,
|
|
2916
|
+
positionId: result.positionId,
|
|
2917
|
+
definitionHash: result.definitionHash,
|
|
2918
|
+
capitalCallStateHash: result.capitalCallStateHash,
|
|
2919
|
+
positionReceiptHash: result.positionReceiptHash,
|
|
2920
|
+
distributionHash: result.distributionHash,
|
|
2921
|
+
closingHash: result.closingHash,
|
|
2922
|
+
bindingMode: result.bindingMode,
|
|
2923
|
+
}),
|
|
2924
|
+
...result,
|
|
958
2925
|
});
|
|
959
|
-
printJson(result);
|
|
960
2926
|
return;
|
|
961
2927
|
}
|
|
962
2928
|
if (command === "contract" && subcommand === "wait-funding") {
|