@hazbase/simplicity 0.1.1 → 0.2.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.
Files changed (39) hide show
  1. package/README.md +143 -1531
  2. package/dist/cli.js +1128 -1
  3. package/dist/client/SimplicityClient.d.ts +30 -3
  4. package/dist/client/SimplicityClient.js +28 -0
  5. package/dist/core/lineage.d.ts +18 -0
  6. package/dist/core/lineage.js +30 -0
  7. package/dist/core/reporting.d.ts +22 -0
  8. package/dist/core/reporting.js +40 -0
  9. package/dist/core/schnorr.d.ts +3 -3
  10. package/dist/core/schnorr.js +19 -7
  11. package/dist/core/types.d.ts +256 -5
  12. package/dist/docs/definitions/fund-capital-call-refund-only.simf +36 -2
  13. package/dist/docs/definitions/receivable-definition.json +10 -0
  14. package/dist/docs/definitions/receivable-funding-claim.json +13 -0
  15. package/dist/docs/definitions/receivable-funding-claim.simf +58 -0
  16. package/dist/docs/definitions/receivable-repayment-claim-partial.json +13 -0
  17. package/dist/docs/definitions/receivable-repayment-claim.json +13 -0
  18. package/dist/docs/definitions/receivable-repayment-claim.simf +59 -0
  19. package/dist/docs/definitions/receivable-state-funded.json +21 -0
  20. package/dist/docs/definitions/receivable-state-originated.json +20 -0
  21. package/dist/docs/definitions/receivable-state-partially-repaid.json +21 -0
  22. package/dist/docs/definitions/receivable-state-repaid.json +21 -0
  23. package/dist/domain/bond.d.ts +82 -15
  24. package/dist/domain/bond.js +159 -10
  25. package/dist/domain/bondValidation.d.ts +31 -1
  26. package/dist/domain/bondValidation.js +73 -9
  27. package/dist/domain/fund.d.ts +451 -68
  28. package/dist/domain/fund.js +460 -88
  29. package/dist/domain/fundValidation.d.ts +33 -3
  30. package/dist/domain/fundValidation.js +137 -5
  31. package/dist/domain/policies.d.ts +13 -0
  32. package/dist/domain/policies.js +50 -30
  33. package/dist/domain/receivable.d.ts +825 -0
  34. package/dist/domain/receivable.js +1385 -0
  35. package/dist/domain/receivableValidation.d.ts +150 -0
  36. package/dist/domain/receivableValidation.js +874 -0
  37. package/dist/index.d.ts +5 -3
  38. package/dist/index.js +55 -3
  39. package/package.json +6 -1
package/dist/cli.js CHANGED
@@ -35,6 +35,13 @@ function getMultiArgs(name) {
35
35
  function hasFlag(name) {
36
36
  return process.argv.includes(`--${name}`);
37
37
  }
38
+ function parseJsonArg(name) {
39
+ const value = getArg(name);
40
+ return value ? JSON.parse(value) : undefined;
41
+ }
42
+ function parseJsonArgs(name) {
43
+ return getMultiArgs(name).map((value) => JSON.parse(value));
44
+ }
38
45
  function requireArg(name) {
39
46
  const value = getArg(name);
40
47
  if (!value)
@@ -545,6 +552,20 @@ function formatBondEvidenceSummary(input) {
545
552
  input.closingHash ? `closingHash=${input.closingHash}` : undefined,
546
553
  input.renderedSourceHash ? `renderedSourceHash=${input.renderedSourceHash}` : undefined,
547
554
  input.sourceVerificationMode ? `sourceVerificationMode=${input.sourceVerificationMode}` : undefined,
555
+ input.lineageKind ? `lineageKind=${input.lineageKind}` : undefined,
556
+ input.latestOrdinal !== undefined && input.latestOrdinal !== null ? `latestOrdinal=${input.latestOrdinal}` : undefined,
557
+ input.allHashLinksVerified !== undefined && input.allHashLinksVerified !== null
558
+ ? `allHashLinksVerified=${input.allHashLinksVerified}`
559
+ : undefined,
560
+ input.identityConsistent !== undefined && input.identityConsistent !== null
561
+ ? `identityConsistent=${input.identityConsistent}`
562
+ : undefined,
563
+ input.fullLineageVerified !== undefined && input.fullLineageVerified !== null
564
+ ? `fullLineageVerified=${input.fullLineageVerified}`
565
+ : undefined,
566
+ input.fullHistoryVerified !== undefined && input.fullHistoryVerified !== null
567
+ ? `fullHistoryVerified=${input.fullHistoryVerified}`
568
+ : undefined,
548
569
  ]
549
570
  .filter(Boolean)
550
571
  .join("\n");
@@ -560,6 +581,36 @@ function formatBondFinalityPayloadSummary(input) {
560
581
  `contractAddress=${input.contractAddress}`,
561
582
  `cmr=${input.cmr}`,
562
583
  `bindingMode=${input.bindingMode}`,
584
+ input.lineageKind ? `lineageKind=${input.lineageKind}` : undefined,
585
+ input.latestOrdinal !== undefined && input.latestOrdinal !== null ? `latestOrdinal=${input.latestOrdinal}` : undefined,
586
+ input.allHashLinksVerified !== undefined && input.allHashLinksVerified !== null
587
+ ? `allHashLinksVerified=${input.allHashLinksVerified}`
588
+ : undefined,
589
+ input.identityConsistent !== undefined && input.identityConsistent !== null
590
+ ? `identityConsistent=${input.identityConsistent}`
591
+ : undefined,
592
+ input.fullLineageVerified !== undefined && input.fullLineageVerified !== null
593
+ ? `fullLineageVerified=${input.fullLineageVerified}`
594
+ : undefined,
595
+ input.fullHistoryVerified !== undefined && input.fullHistoryVerified !== null
596
+ ? `fullHistoryVerified=${input.fullHistoryVerified}`
597
+ : undefined,
598
+ ]
599
+ .filter(Boolean)
600
+ .join("\n");
601
+ }
602
+ function formatBondIssuanceHistorySummary(input) {
603
+ return [
604
+ input.verified !== undefined ? `verified=${input.verified}` : undefined,
605
+ `issuanceId=${input.issuanceId}`,
606
+ `chainLength=${input.chainLength}`,
607
+ input.latestStatus ? `latestStatus=${input.latestStatus}` : undefined,
608
+ input.latestOrdinal !== undefined && input.latestOrdinal !== null ? `latestOrdinal=${input.latestOrdinal}` : undefined,
609
+ `startsAtGenesis=${input.startsAtGenesis}`,
610
+ input.allHashLinksVerified !== undefined ? `allHashLinksVerified=${input.allHashLinksVerified}` : undefined,
611
+ input.identityConsistent !== undefined ? `identityConsistent=${input.identityConsistent}` : undefined,
612
+ input.fullLineageVerified !== undefined ? `fullLineageVerified=${input.fullLineageVerified}` : undefined,
613
+ `fullHistoryVerified=${input.fullHistoryVerified}`,
563
614
  ]
564
615
  .filter(Boolean)
565
616
  .join("\n");
@@ -660,11 +711,40 @@ function formatFundClosingSummary(input) {
660
711
  `closingReason=${input.closingReason}`,
661
712
  `positionId=${input.positionId}`,
662
713
  `distributionCount=${input.distributionCount}`,
714
+ input.continuityVerified !== undefined ? `continuityVerified=${input.continuityVerified}` : undefined,
715
+ input.lineageKind ? `lineageKind=${input.lineageKind}` : undefined,
716
+ input.latestOrdinal !== undefined && input.latestOrdinal !== null ? `latestOrdinal=${input.latestOrdinal}` : undefined,
717
+ input.allHashLinksVerified !== undefined && input.allHashLinksVerified !== null
718
+ ? `allHashLinksVerified=${input.allHashLinksVerified}`
719
+ : undefined,
720
+ input.identityConsistent !== undefined && input.identityConsistent !== null
721
+ ? `identityConsistent=${input.identityConsistent}`
722
+ : undefined,
723
+ input.fullLineageVerified !== undefined && input.fullLineageVerified !== null
724
+ ? `fullLineageVerified=${input.fullLineageVerified}`
725
+ : undefined,
726
+ input.fullChainVerified !== undefined ? `fullChainVerified=${input.fullChainVerified}` : undefined,
663
727
  input.reason ? `reason=${input.reason}` : undefined,
664
728
  ]
665
729
  .filter(Boolean)
666
730
  .join("\n");
667
731
  }
732
+ function formatFundReceiptChainSummary(input) {
733
+ return [
734
+ input.verified !== undefined ? `verified=${input.verified}` : undefined,
735
+ `positionId=${input.positionId}`,
736
+ `chainLength=${input.chainLength}`,
737
+ input.latestSequence !== undefined && input.latestSequence !== null ? `latestSequence=${input.latestSequence}` : undefined,
738
+ input.latestOrdinal !== undefined && input.latestOrdinal !== null ? `latestOrdinal=${input.latestOrdinal}` : undefined,
739
+ `startsAtGenesis=${input.startsAtGenesis}`,
740
+ input.allHashLinksVerified !== undefined ? `allHashLinksVerified=${input.allHashLinksVerified}` : undefined,
741
+ input.identityConsistent !== undefined ? `identityConsistent=${input.identityConsistent}` : undefined,
742
+ input.fullLineageVerified !== undefined ? `fullLineageVerified=${input.fullLineageVerified}` : undefined,
743
+ `fullChainVerified=${input.fullChainVerified}`,
744
+ ]
745
+ .filter(Boolean)
746
+ .join("\n");
747
+ }
668
748
  function formatFundEvidenceSummary(input) {
669
749
  return [
670
750
  `definitionHash=${input.definitionHash}`,
@@ -674,6 +754,20 @@ function formatFundEvidenceSummary(input) {
674
754
  input.distributionHash ? `distributionHash=${input.distributionHash}` : undefined,
675
755
  input.closingHash ? `closingHash=${input.closingHash}` : undefined,
676
756
  `sourceVerificationMode=${input.sourceVerificationMode}`,
757
+ input.lineageKind ? `lineageKind=${input.lineageKind}` : undefined,
758
+ input.latestOrdinal !== undefined && input.latestOrdinal !== null ? `latestOrdinal=${input.latestOrdinal}` : undefined,
759
+ input.allHashLinksVerified !== undefined && input.allHashLinksVerified !== null
760
+ ? `allHashLinksVerified=${input.allHashLinksVerified}`
761
+ : undefined,
762
+ input.identityConsistent !== undefined && input.identityConsistent !== null
763
+ ? `identityConsistent=${input.identityConsistent}`
764
+ : undefined,
765
+ input.fullLineageVerified !== undefined && input.fullLineageVerified !== null
766
+ ? `fullLineageVerified=${input.fullLineageVerified}`
767
+ : undefined,
768
+ input.fullChainVerified !== undefined && input.fullChainVerified !== null
769
+ ? `fullChainVerified=${input.fullChainVerified}`
770
+ : undefined,
677
771
  ]
678
772
  .filter(Boolean)
679
773
  .join("\n");
@@ -691,6 +785,114 @@ function formatFundFinalitySummary(input) {
691
785
  input.distributionHash ? `distributionHash=${input.distributionHash}` : undefined,
692
786
  input.closingHash ? `closingHash=${input.closingHash}` : undefined,
693
787
  `bindingMode=${input.bindingMode}`,
788
+ input.lineageKind ? `lineageKind=${input.lineageKind}` : undefined,
789
+ input.latestOrdinal !== undefined && input.latestOrdinal !== null ? `latestOrdinal=${input.latestOrdinal}` : undefined,
790
+ input.allHashLinksVerified !== undefined && input.allHashLinksVerified !== null
791
+ ? `allHashLinksVerified=${input.allHashLinksVerified}`
792
+ : undefined,
793
+ input.identityConsistent !== undefined && input.identityConsistent !== null
794
+ ? `identityConsistent=${input.identityConsistent}`
795
+ : undefined,
796
+ input.fullLineageVerified !== undefined && input.fullLineageVerified !== null
797
+ ? `fullLineageVerified=${input.fullLineageVerified}`
798
+ : undefined,
799
+ input.fullChainVerified !== undefined && input.fullChainVerified !== null
800
+ ? `fullChainVerified=${input.fullChainVerified}`
801
+ : undefined,
802
+ ]
803
+ .filter(Boolean)
804
+ .join("\n");
805
+ }
806
+ function formatReceivableDefinitionSummary(input) {
807
+ return [
808
+ input.ok !== undefined ? `ok=${input.ok}` : undefined,
809
+ `receivableId=${input.receivableId}`,
810
+ `originatorEntityId=${input.originatorEntityId}`,
811
+ `debtorEntityId=${input.debtorEntityId}`,
812
+ `currencyAssetId=${input.currencyAssetId}`,
813
+ `faceValue=${input.faceValue}`,
814
+ `dueDate=${input.dueDate}`,
815
+ ]
816
+ .filter(Boolean)
817
+ .join("\n");
818
+ }
819
+ function formatReceivableTransitionSummary(input) {
820
+ return [
821
+ `phase=${input.phase}`,
822
+ `verified=${input.verified}`,
823
+ `transitionType=${input.transitionType}`,
824
+ `receivableId=${input.receivableId}`,
825
+ `nextStateId=${input.nextStateId}`,
826
+ `holderEntityId=${input.holderEntityId}`,
827
+ `status=${input.status}`,
828
+ `outstandingAmount=${input.outstandingAmount}`,
829
+ `repaidAmount=${input.repaidAmount}`,
830
+ `stateHash=${input.stateHash}`,
831
+ ].join("\n");
832
+ }
833
+ function formatReceivableClaimSummary(input) {
834
+ return [
835
+ `phase=${input.phase}`,
836
+ `verified=${input.verified}`,
837
+ `claimKind=${input.claimKind}`,
838
+ `receivableId=${input.receivableId}`,
839
+ `claimId=${input.claimId}`,
840
+ `currentStatus=${input.currentStatus}`,
841
+ `payerEntityId=${input.payerEntityId}`,
842
+ `payeeEntityId=${input.payeeEntityId}`,
843
+ `amountSat=${input.amountSat}`,
844
+ input.claimantAuthoritySource ? `claimantAuthoritySource=${input.claimantAuthoritySource}` : undefined,
845
+ input.roleSeparatedAuthorization !== undefined
846
+ ? `roleSeparatedAuthorization=${input.roleSeparatedAuthorization}`
847
+ : undefined,
848
+ input.bindingMode ? `bindingMode=${input.bindingMode}` : undefined,
849
+ input.reasonCode ? `reasonCode=${input.reasonCode}` : undefined,
850
+ input.supportedForm ? `supportedForm=${input.supportedForm}` : undefined,
851
+ input.fullLineageVerified !== undefined ? `fullLineageVerified=${input.fullLineageVerified}` : undefined,
852
+ ]
853
+ .filter(Boolean)
854
+ .join("\n");
855
+ }
856
+ function formatReceivableHistorySummary(input) {
857
+ return [
858
+ `verified=${input.verified}`,
859
+ `receivableId=${input.receivableId}`,
860
+ `chainLength=${input.chainLength}`,
861
+ `latestStatus=${input.latestStatus}`,
862
+ input.latestOrdinal !== null ? `latestOrdinal=${input.latestOrdinal}` : undefined,
863
+ `fullLineageVerified=${input.fullLineageVerified}`,
864
+ ]
865
+ .filter(Boolean)
866
+ .join("\n");
867
+ }
868
+ function formatReceivableClosingSummary(input) {
869
+ return [
870
+ `verified=${input.verified}`,
871
+ `receivableId=${input.receivableId}`,
872
+ `latestStatus=${input.latestStatus}`,
873
+ `closingReason=${input.closingReason}`,
874
+ `closingHash=${input.closingHash}`,
875
+ input.fullLineageVerified !== undefined ? `fullLineageVerified=${input.fullLineageVerified}` : undefined,
876
+ ]
877
+ .filter(Boolean)
878
+ .join("\n");
879
+ }
880
+ function formatReceivableEvidenceOrFinalitySummary(input) {
881
+ return [
882
+ `kind=${input.kind}`,
883
+ `receivableId=${input.receivableId}`,
884
+ `holderEntityId=${input.holderEntityId}`,
885
+ `definitionHash=${input.definitionHash}`,
886
+ `latestStateHash=${input.latestStateHash}`,
887
+ input.closingHash ? `closingHash=${input.closingHash}` : undefined,
888
+ input.closingReason ? `closingReason=${input.closingReason}` : undefined,
889
+ input.lineageKind ? `lineageKind=${input.lineageKind}` : undefined,
890
+ input.latestOrdinal !== undefined && input.latestOrdinal !== null
891
+ ? `latestOrdinal=${input.latestOrdinal}`
892
+ : undefined,
893
+ input.fullLineageVerified !== undefined && input.fullLineageVerified !== null
894
+ ? `fullLineageVerified=${input.fullLineageVerified}`
895
+ : undefined,
694
896
  ]
695
897
  .filter(Boolean)
696
898
  .join("\n");
@@ -1051,7 +1253,7 @@ async function main() {
1051
1253
  const subcommand = process.argv[3];
1052
1254
  const sdk = (0, SimplicityClient_1.createSimplicityClient)(resolveConfig());
1053
1255
  if (!command) {
1054
- throw new Error("Usage: simplicity-cli <compile|presets|preset|contract|artifact|definition|state|binding|policy|bond|fund|gasless> ...");
1256
+ throw new Error("Usage: simplicity-cli <compile|presets|preset|contract|artifact|definition|state|binding|policy|bond|fund|receivable|gasless> ...");
1055
1257
  }
1056
1258
  if (command === "compile") {
1057
1259
  const result = await sdk.compileFromFile({
@@ -1684,6 +1886,44 @@ async function main() {
1684
1886
  });
1685
1887
  return;
1686
1888
  }
1889
+ if (command === "bond" && subcommand === "verify-issuance-history") {
1890
+ const issuanceHistoryPaths = getMultiArgs("issuance-history-json");
1891
+ const issuanceHistoryValues = getMultiArgs("issuance-history-value").map((value) => JSON.parse(value));
1892
+ const result = await sdk.bonds.verifyIssuanceHistory({
1893
+ definitionPath: getArg("definition-json"),
1894
+ definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
1895
+ issuanceHistoryPaths: issuanceHistoryPaths.length > 0 ? issuanceHistoryPaths : undefined,
1896
+ issuanceHistoryValues: issuanceHistoryValues.length > 0 ? issuanceHistoryValues : undefined,
1897
+ });
1898
+ printJson({
1899
+ summary: {
1900
+ verified: result.verified,
1901
+ issuanceId: result.issuanceHistoryValues.at(-1)?.issuanceId ?? null,
1902
+ chainLength: result.report.issuanceLineageTrust?.chainLength ?? 0,
1903
+ latestStatus: result.report.issuanceLineageTrust?.latestStatus ?? null,
1904
+ latestOrdinal: result.report.issuanceLineageTrust?.latestOrdinal ?? null,
1905
+ startsAtGenesis: result.report.issuanceLineageTrust?.startsAtGenesis ?? false,
1906
+ allHashLinksVerified: result.report.issuanceLineageTrust?.allHashLinksVerified ?? false,
1907
+ identityConsistent: result.report.issuanceLineageTrust?.identityConsistent ?? false,
1908
+ fullLineageVerified: result.report.issuanceLineageTrust?.fullLineageVerified ?? false,
1909
+ fullHistoryVerified: result.report.issuanceLineageTrust?.fullHistoryVerified ?? false,
1910
+ },
1911
+ summaryText: formatBondIssuanceHistorySummary({
1912
+ verified: result.verified,
1913
+ issuanceId: result.issuanceHistoryValues.at(-1)?.issuanceId ?? "unknown",
1914
+ chainLength: result.report.issuanceLineageTrust?.chainLength ?? 0,
1915
+ latestStatus: result.report.issuanceLineageTrust?.latestStatus ?? null,
1916
+ latestOrdinal: result.report.issuanceLineageTrust?.latestOrdinal ?? null,
1917
+ startsAtGenesis: result.report.issuanceLineageTrust?.startsAtGenesis ?? false,
1918
+ allHashLinksVerified: result.report.issuanceLineageTrust?.allHashLinksVerified ?? false,
1919
+ identityConsistent: result.report.issuanceLineageTrust?.identityConsistent ?? false,
1920
+ fullLineageVerified: result.report.issuanceLineageTrust?.fullLineageVerified ?? false,
1921
+ fullHistoryVerified: result.report.issuanceLineageTrust?.fullHistoryVerified ?? false,
1922
+ }),
1923
+ ...result,
1924
+ });
1925
+ return;
1926
+ }
1687
1927
  if (command === "bond" && subcommand === "prepare-redemption") {
1688
1928
  const result = await sdk.bonds.prepareRedemption({
1689
1929
  definitionPath: getArg("definition-json"),
@@ -2138,6 +2378,8 @@ async function main() {
2138
2378
  return;
2139
2379
  }
2140
2380
  if (command === "bond" && subcommand === "export-evidence") {
2381
+ const issuanceHistoryPaths = getMultiArgs("issuance-history-json");
2382
+ const issuanceHistoryValues = getMultiArgs("issuance-history-value").map((value) => JSON.parse(value));
2141
2383
  const settlementDescriptorValue = getArg("settlement-descriptor-value")
2142
2384
  ? JSON.parse(getArg("settlement-descriptor-value"))
2143
2385
  : undefined;
@@ -2148,6 +2390,8 @@ async function main() {
2148
2390
  artifactPath: requireArg("artifact"),
2149
2391
  definitionPath: getArg("definition-json"),
2150
2392
  issuancePath: getArg("issuance-json"),
2393
+ issuanceHistoryPaths: issuanceHistoryPaths.length > 0 ? issuanceHistoryPaths : undefined,
2394
+ issuanceHistoryValues: issuanceHistoryValues.length > 0 ? issuanceHistoryValues : undefined,
2151
2395
  settlementDescriptorValue,
2152
2396
  transitionValue,
2153
2397
  });
@@ -2160,6 +2404,12 @@ async function main() {
2160
2404
  closingHash: result.closing?.hash ?? null,
2161
2405
  renderedSourceHash: result.renderedSourceHash ?? null,
2162
2406
  sourceVerificationMode: result.sourceVerificationMode,
2407
+ lineageKind: result.trust.issuanceLineageTrust?.lineageKind ?? null,
2408
+ latestOrdinal: result.trust.issuanceLineageTrust?.latestOrdinal ?? null,
2409
+ allHashLinksVerified: result.trust.issuanceLineageTrust?.allHashLinksVerified ?? null,
2410
+ identityConsistent: result.trust.issuanceLineageTrust?.identityConsistent ?? null,
2411
+ fullLineageVerified: result.trust.issuanceLineageTrust?.fullLineageVerified ?? null,
2412
+ fullHistoryVerified: result.trust.issuanceLineageTrust?.fullHistoryVerified ?? null,
2163
2413
  },
2164
2414
  summaryText: formatBondEvidenceSummary({
2165
2415
  definitionHash: result.definition.hash,
@@ -2168,11 +2418,19 @@ async function main() {
2168
2418
  closingHash: result.closing?.hash ?? null,
2169
2419
  renderedSourceHash: result.renderedSourceHash ?? null,
2170
2420
  sourceVerificationMode: result.sourceVerificationMode,
2421
+ lineageKind: result.trust.issuanceLineageTrust?.lineageKind ?? null,
2422
+ latestOrdinal: result.trust.issuanceLineageTrust?.latestOrdinal ?? null,
2423
+ allHashLinksVerified: result.trust.issuanceLineageTrust?.allHashLinksVerified ?? null,
2424
+ identityConsistent: result.trust.issuanceLineageTrust?.identityConsistent ?? null,
2425
+ fullLineageVerified: result.trust.issuanceLineageTrust?.fullLineageVerified ?? null,
2426
+ fullHistoryVerified: result.trust.issuanceLineageTrust?.fullHistoryVerified ?? null,
2171
2427
  }),
2172
2428
  });
2173
2429
  return;
2174
2430
  }
2175
2431
  if (command === "bond" && subcommand === "export-finality-payload") {
2432
+ const issuanceHistoryPaths = getMultiArgs("issuance-history-json");
2433
+ const issuanceHistoryValues = getMultiArgs("issuance-history-value").map((value) => JSON.parse(value));
2176
2434
  const settlementDescriptorValue = getArg("settlement-descriptor-value")
2177
2435
  ? JSON.parse(getArg("settlement-descriptor-value"))
2178
2436
  : undefined;
@@ -2183,6 +2441,8 @@ async function main() {
2183
2441
  artifactPath: requireArg("artifact"),
2184
2442
  definitionPath: getArg("definition-json"),
2185
2443
  issuancePath: getArg("issuance-json"),
2444
+ issuanceHistoryPaths: issuanceHistoryPaths.length > 0 ? issuanceHistoryPaths : undefined,
2445
+ issuanceHistoryValues: issuanceHistoryValues.length > 0 ? issuanceHistoryValues : undefined,
2186
2446
  settlementDescriptorValue,
2187
2447
  closingDescriptorValue,
2188
2448
  });
@@ -2198,6 +2458,12 @@ async function main() {
2198
2458
  contractAddress: result.payload.contractAddress,
2199
2459
  cmr: result.payload.cmr,
2200
2460
  bindingMode: result.bindingMode,
2461
+ lineageKind: result.trust.issuanceLineageTrust?.lineageKind ?? null,
2462
+ latestOrdinal: result.trust.issuanceLineageTrust?.latestOrdinal ?? null,
2463
+ allHashLinksVerified: result.trust.issuanceLineageTrust?.allHashLinksVerified ?? null,
2464
+ identityConsistent: result.trust.issuanceLineageTrust?.identityConsistent ?? null,
2465
+ fullLineageVerified: result.trust.issuanceLineageTrust?.fullLineageVerified ?? null,
2466
+ fullHistoryVerified: result.trust.issuanceLineageTrust?.fullHistoryVerified ?? null,
2201
2467
  },
2202
2468
  summaryText: formatBondFinalityPayloadSummary({
2203
2469
  bondId: result.payload.bondId,
@@ -2209,6 +2475,12 @@ async function main() {
2209
2475
  contractAddress: result.payload.contractAddress,
2210
2476
  cmr: result.payload.cmr,
2211
2477
  bindingMode: result.bindingMode,
2478
+ lineageKind: result.trust.issuanceLineageTrust?.lineageKind ?? null,
2479
+ latestOrdinal: result.trust.issuanceLineageTrust?.latestOrdinal ?? null,
2480
+ allHashLinksVerified: result.trust.issuanceLineageTrust?.allHashLinksVerified ?? null,
2481
+ identityConsistent: result.trust.issuanceLineageTrust?.identityConsistent ?? null,
2482
+ fullLineageVerified: result.trust.issuanceLineageTrust?.fullLineageVerified ?? null,
2483
+ fullHistoryVerified: result.trust.issuanceLineageTrust?.fullHistoryVerified ?? null,
2212
2484
  }),
2213
2485
  });
2214
2486
  return;
@@ -2483,6 +2755,10 @@ async function main() {
2483
2755
  capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
2484
2756
  refundAddress: requireArg("refund-address"),
2485
2757
  refundedAt: getArg("refunded-at"),
2758
+ nextOutputHash: getArg("next-output-hash") || undefined,
2759
+ outputForm: parsePolicyOutputForm(),
2760
+ rawOutput: parseRawOutputFields(),
2761
+ outputBindingMode: getArg("output-binding-mode"),
2486
2762
  wallet: requireArg("wallet"),
2487
2763
  signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
2488
2764
  feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
@@ -2495,6 +2771,7 @@ async function main() {
2495
2771
  amount: result.verified.capitalCallValue.amount,
2496
2772
  assetId: result.verified.capitalCallValue.currencyAssetId,
2497
2773
  summaryHash: result.inspect.summaryHash,
2774
+ outputBinding: result.report.outputBindingTrust ?? null,
2498
2775
  },
2499
2776
  summaryText: formatFundCapitalCallSummary({
2500
2777
  phase: "inspect-refund",
@@ -2503,6 +2780,7 @@ async function main() {
2503
2780
  amount: result.verified.capitalCallValue.amount,
2504
2781
  assetId: result.verified.capitalCallValue.currencyAssetId,
2505
2782
  summaryHash: result.inspect.summaryHash,
2783
+ outputBinding: result.report.outputBindingTrust,
2506
2784
  }),
2507
2785
  ...result,
2508
2786
  });
@@ -2517,6 +2795,10 @@ async function main() {
2517
2795
  capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
2518
2796
  refundAddress: requireArg("refund-address"),
2519
2797
  refundedAt: getArg("refunded-at"),
2798
+ nextOutputHash: getArg("next-output-hash") || undefined,
2799
+ outputForm: parsePolicyOutputForm(),
2800
+ rawOutput: parseRawOutputFields(),
2801
+ outputBindingMode: getArg("output-binding-mode"),
2520
2802
  wallet: requireArg("wallet"),
2521
2803
  signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
2522
2804
  feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
@@ -2531,6 +2813,7 @@ async function main() {
2531
2813
  assetId: result.verified.capitalCallValue.currencyAssetId,
2532
2814
  txId: result.execution.txId ?? null,
2533
2815
  broadcasted: result.execution.broadcasted,
2816
+ outputBinding: result.report.outputBindingTrust ?? null,
2534
2817
  },
2535
2818
  summaryText: formatFundCapitalCallSummary({
2536
2819
  phase: "execute-refund",
@@ -2540,6 +2823,7 @@ async function main() {
2540
2823
  assetId: result.verified.capitalCallValue.currencyAssetId,
2541
2824
  txId: result.execution.txId,
2542
2825
  broadcasted: result.execution.broadcasted,
2826
+ outputBinding: result.report.outputBindingTrust,
2543
2827
  }),
2544
2828
  ...result,
2545
2829
  });
@@ -2607,11 +2891,19 @@ async function main() {
2607
2891
  return;
2608
2892
  }
2609
2893
  if (command === "fund" && subcommand === "verify-position-receipt") {
2894
+ const positionReceiptChainPaths = getMultiArgs("position-receipt-chain-json");
2895
+ const positionReceiptChainValues = getMultiArgs("position-receipt-chain-value").map((value) => JSON.parse(value));
2610
2896
  const result = await sdk.funds.verifyPositionReceipt({
2611
2897
  definitionPath: getArg("definition-json"),
2612
2898
  definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
2613
2899
  positionReceiptPath: getArg("position-receipt-json"),
2614
2900
  positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
2901
+ previousPositionReceiptPath: getArg("previous-position-receipt-json"),
2902
+ previousPositionReceiptValue: getArg("previous-position-receipt-value")
2903
+ ? JSON.parse(getArg("previous-position-receipt-value"))
2904
+ : undefined,
2905
+ positionReceiptChainPaths: positionReceiptChainPaths.length > 0 ? positionReceiptChainPaths : undefined,
2906
+ positionReceiptChainValues: positionReceiptChainValues.length > 0 ? positionReceiptChainValues : undefined,
2615
2907
  });
2616
2908
  printJson({
2617
2909
  summary: {
@@ -2620,6 +2912,14 @@ async function main() {
2620
2912
  sequence: result.positionReceiptValue.receipt.sequence,
2621
2913
  receiptHash: result.positionReceiptSummary.hash,
2622
2914
  envelopeHash: result.positionReceiptEnvelopeSummary.hash,
2915
+ continuityVerified: result.report.receiptTrust?.continuityVerified ?? null,
2916
+ lineageKind: result.report.receiptChainTrust?.lineageKind ?? null,
2917
+ latestOrdinal: result.report.receiptChainTrust?.latestOrdinal ?? null,
2918
+ allHashLinksVerified: result.report.receiptChainTrust?.allHashLinksVerified ?? null,
2919
+ identityConsistent: result.report.receiptChainTrust?.identityConsistent ?? null,
2920
+ fullLineageVerified: result.report.receiptChainTrust?.fullLineageVerified ?? null,
2921
+ chainLength: result.report.receiptChainTrust?.chainLength ?? null,
2922
+ fullChainVerified: result.report.receiptChainTrust?.fullChainVerified ?? null,
2623
2923
  },
2624
2924
  summaryText: [
2625
2925
  `verified=${result.verified}`,
@@ -2627,11 +2927,57 @@ async function main() {
2627
2927
  `sequence=${result.positionReceiptValue.receipt.sequence}`,
2628
2928
  `receiptHash=${result.positionReceiptSummary.hash}`,
2629
2929
  `envelopeHash=${result.positionReceiptEnvelopeSummary.hash}`,
2930
+ `continuityVerified=${result.report.receiptTrust?.continuityVerified ?? false}`,
2931
+ `lineageKind=${result.report.receiptChainTrust?.lineageKind ?? "receipt-chain"}`,
2932
+ `latestOrdinal=${result.report.receiptChainTrust?.latestOrdinal ?? result.positionReceiptValue.receipt.sequence}`,
2933
+ `allHashLinksVerified=${result.report.receiptChainTrust?.allHashLinksVerified ?? false}`,
2934
+ `identityConsistent=${result.report.receiptChainTrust?.identityConsistent ?? false}`,
2935
+ `fullLineageVerified=${result.report.receiptChainTrust?.fullLineageVerified ?? false}`,
2936
+ `chainLength=${result.report.receiptChainTrust?.chainLength ?? 0}`,
2937
+ `fullChainVerified=${result.report.receiptChainTrust?.fullChainVerified ?? false}`,
2630
2938
  ].join("\n"),
2631
2939
  ...result,
2632
2940
  });
2633
2941
  return;
2634
2942
  }
2943
+ if (command === "fund" && subcommand === "verify-position-receipt-chain") {
2944
+ const positionReceiptChainPaths = getMultiArgs("position-receipt-chain-json");
2945
+ const positionReceiptChainValues = getMultiArgs("position-receipt-chain-value").map((value) => JSON.parse(value));
2946
+ const result = await sdk.funds.verifyPositionReceiptChain({
2947
+ definitionPath: getArg("definition-json"),
2948
+ definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
2949
+ positionReceiptChainPaths: positionReceiptChainPaths.length > 0 ? positionReceiptChainPaths : undefined,
2950
+ positionReceiptChainValues: positionReceiptChainValues.length > 0 ? positionReceiptChainValues : undefined,
2951
+ });
2952
+ printJson({
2953
+ summary: {
2954
+ verified: result.verified,
2955
+ positionId: result.positionReceiptValue.receipt.positionId,
2956
+ chainLength: result.report.receiptChainTrust?.chainLength ?? 0,
2957
+ latestSequence: result.report.receiptChainTrust?.latestSequence ?? null,
2958
+ latestOrdinal: result.report.receiptChainTrust?.latestOrdinal ?? null,
2959
+ startsAtGenesis: result.report.receiptChainTrust?.startsAtGenesis ?? false,
2960
+ allHashLinksVerified: result.report.receiptChainTrust?.allHashLinksVerified ?? false,
2961
+ identityConsistent: result.report.receiptChainTrust?.identityConsistent ?? false,
2962
+ fullLineageVerified: result.report.receiptChainTrust?.fullLineageVerified ?? false,
2963
+ fullChainVerified: result.report.receiptChainTrust?.fullChainVerified ?? false,
2964
+ },
2965
+ summaryText: formatFundReceiptChainSummary({
2966
+ verified: result.verified,
2967
+ positionId: result.positionReceiptValue.receipt.positionId,
2968
+ chainLength: result.report.receiptChainTrust?.chainLength ?? 0,
2969
+ latestSequence: result.report.receiptChainTrust?.latestSequence ?? null,
2970
+ latestOrdinal: result.report.receiptChainTrust?.latestOrdinal ?? null,
2971
+ startsAtGenesis: result.report.receiptChainTrust?.startsAtGenesis ?? false,
2972
+ allHashLinksVerified: result.report.receiptChainTrust?.allHashLinksVerified ?? false,
2973
+ identityConsistent: result.report.receiptChainTrust?.identityConsistent ?? false,
2974
+ fullLineageVerified: result.report.receiptChainTrust?.fullLineageVerified ?? false,
2975
+ fullChainVerified: result.report.receiptChainTrust?.fullChainVerified ?? false,
2976
+ }),
2977
+ ...result,
2978
+ });
2979
+ return;
2980
+ }
2635
2981
  if (command === "fund" && subcommand === "reconcile-position") {
2636
2982
  const distributionJsons = getMultiArgs("distribution-json");
2637
2983
  const distributionValues = getMultiArgs("distribution-value").map((value) => JSON.parse(value));
@@ -2788,9 +3134,19 @@ async function main() {
2788
3134
  return;
2789
3135
  }
2790
3136
  if (command === "fund" && subcommand === "prepare-closing") {
3137
+ const positionReceiptChainPaths = getMultiArgs("position-receipt-chain-json");
3138
+ const positionReceiptChainValues = getMultiArgs("position-receipt-chain-value").map((value) => JSON.parse(value));
2791
3139
  const result = await sdk.funds.prepareClosing({
3140
+ definitionPath: getArg("definition-json"),
3141
+ definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
2792
3142
  positionReceiptPath: getArg("position-receipt-json"),
2793
3143
  positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
3144
+ previousPositionReceiptPath: getArg("previous-position-receipt-json"),
3145
+ previousPositionReceiptValue: getArg("previous-position-receipt-value")
3146
+ ? JSON.parse(getArg("previous-position-receipt-value"))
3147
+ : undefined,
3148
+ positionReceiptChainPaths: positionReceiptChainPaths.length > 0 ? positionReceiptChainPaths : undefined,
3149
+ positionReceiptChainValues: positionReceiptChainValues.length > 0 ? positionReceiptChainValues : undefined,
2794
3150
  closingPath: getArg("closing-json"),
2795
3151
  closingValue: getArg("closing-value") ? JSON.parse(getArg("closing-value")) : undefined,
2796
3152
  closingId: getArg("closing-id"),
@@ -2805,6 +3161,13 @@ async function main() {
2805
3161
  closingReason: result.closingValue.closingReason,
2806
3162
  positionId: result.closingValue.positionId,
2807
3163
  distributionCount: result.closingValue.finalDistributionHashes.length,
3164
+ continuityVerified: result.report.receiptTrust?.continuityVerified ?? null,
3165
+ lineageKind: result.report.receiptChainTrust?.lineageKind ?? null,
3166
+ latestOrdinal: result.report.receiptChainTrust?.latestOrdinal ?? null,
3167
+ allHashLinksVerified: result.report.receiptChainTrust?.allHashLinksVerified ?? null,
3168
+ identityConsistent: result.report.receiptChainTrust?.identityConsistent ?? null,
3169
+ fullLineageVerified: result.report.receiptChainTrust?.fullLineageVerified ?? null,
3170
+ fullChainVerified: result.report.receiptChainTrust?.fullChainVerified ?? null,
2808
3171
  },
2809
3172
  summaryText: formatFundClosingSummary({
2810
3173
  closingHash: result.closingHash,
@@ -2812,15 +3175,32 @@ async function main() {
2812
3175
  closingReason: result.closingValue.closingReason,
2813
3176
  positionId: result.closingValue.positionId,
2814
3177
  distributionCount: result.closingValue.finalDistributionHashes.length,
3178
+ continuityVerified: result.report.receiptTrust?.continuityVerified ?? false,
3179
+ lineageKind: result.report.receiptChainTrust?.lineageKind ?? null,
3180
+ latestOrdinal: result.report.receiptChainTrust?.latestOrdinal ?? null,
3181
+ allHashLinksVerified: result.report.receiptChainTrust?.allHashLinksVerified ?? null,
3182
+ identityConsistent: result.report.receiptChainTrust?.identityConsistent ?? null,
3183
+ fullLineageVerified: result.report.receiptChainTrust?.fullLineageVerified ?? null,
3184
+ fullChainVerified: result.report.receiptChainTrust?.fullChainVerified ?? false,
2815
3185
  }),
2816
3186
  ...result,
2817
3187
  });
2818
3188
  return;
2819
3189
  }
2820
3190
  if (command === "fund" && subcommand === "verify-closing") {
3191
+ const positionReceiptChainPaths = getMultiArgs("position-receipt-chain-json");
3192
+ const positionReceiptChainValues = getMultiArgs("position-receipt-chain-value").map((value) => JSON.parse(value));
2821
3193
  const result = await sdk.funds.verifyClosing({
3194
+ definitionPath: getArg("definition-json"),
3195
+ definitionValue: getArg("definition-value") ? JSON.parse(getArg("definition-value")) : undefined,
2822
3196
  positionReceiptPath: getArg("position-receipt-json"),
2823
3197
  positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
3198
+ previousPositionReceiptPath: getArg("previous-position-receipt-json"),
3199
+ previousPositionReceiptValue: getArg("previous-position-receipt-value")
3200
+ ? JSON.parse(getArg("previous-position-receipt-value"))
3201
+ : undefined,
3202
+ positionReceiptChainPaths: positionReceiptChainPaths.length > 0 ? positionReceiptChainPaths : undefined,
3203
+ positionReceiptChainValues: positionReceiptChainValues.length > 0 ? positionReceiptChainValues : undefined,
2824
3204
  closingPath: getArg("closing-json"),
2825
3205
  closingValue: getArg("closing-value") ? JSON.parse(getArg("closing-value")) : undefined,
2826
3206
  });
@@ -2832,6 +3212,13 @@ async function main() {
2832
3212
  closingReason: result.closingValue.closingReason,
2833
3213
  positionId: result.closingValue.positionId,
2834
3214
  distributionCount: result.closingValue.finalDistributionHashes.length,
3215
+ continuityVerified: result.report.receiptTrust?.continuityVerified ?? null,
3216
+ lineageKind: result.report.receiptChainTrust?.lineageKind ?? null,
3217
+ latestOrdinal: result.report.receiptChainTrust?.latestOrdinal ?? null,
3218
+ allHashLinksVerified: result.report.receiptChainTrust?.allHashLinksVerified ?? null,
3219
+ identityConsistent: result.report.receiptChainTrust?.identityConsistent ?? null,
3220
+ fullLineageVerified: result.report.receiptChainTrust?.fullLineageVerified ?? null,
3221
+ fullChainVerified: result.report.receiptChainTrust?.fullChainVerified ?? null,
2835
3222
  },
2836
3223
  summaryText: formatFundClosingSummary({
2837
3224
  ok: result.verified,
@@ -2840,12 +3227,21 @@ async function main() {
2840
3227
  closingReason: result.closingValue.closingReason,
2841
3228
  positionId: result.closingValue.positionId,
2842
3229
  distributionCount: result.closingValue.finalDistributionHashes.length,
3230
+ continuityVerified: result.report.receiptTrust?.continuityVerified ?? false,
3231
+ lineageKind: result.report.receiptChainTrust?.lineageKind ?? null,
3232
+ latestOrdinal: result.report.receiptChainTrust?.latestOrdinal ?? null,
3233
+ allHashLinksVerified: result.report.receiptChainTrust?.allHashLinksVerified ?? null,
3234
+ identityConsistent: result.report.receiptChainTrust?.identityConsistent ?? null,
3235
+ fullLineageVerified: result.report.receiptChainTrust?.fullLineageVerified ?? null,
3236
+ fullChainVerified: result.report.receiptChainTrust?.fullChainVerified ?? false,
2843
3237
  }),
2844
3238
  ...result,
2845
3239
  });
2846
3240
  return;
2847
3241
  }
2848
3242
  if (command === "fund" && subcommand === "export-evidence") {
3243
+ const positionReceiptChainPaths = getMultiArgs("position-receipt-chain-json");
3244
+ const positionReceiptChainValues = getMultiArgs("position-receipt-chain-value").map((value) => JSON.parse(value));
2849
3245
  const result = await sdk.funds.exportEvidence({
2850
3246
  artifactPath: getArg("artifact"),
2851
3247
  definitionPath: getArg("definition-json"),
@@ -2854,6 +3250,12 @@ async function main() {
2854
3250
  capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
2855
3251
  positionReceiptPath: getArg("position-receipt-json"),
2856
3252
  positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
3253
+ previousPositionReceiptPath: getArg("previous-position-receipt-json"),
3254
+ previousPositionReceiptValue: getArg("previous-position-receipt-value")
3255
+ ? JSON.parse(getArg("previous-position-receipt-value"))
3256
+ : undefined,
3257
+ positionReceiptChainPaths: positionReceiptChainPaths.length > 0 ? positionReceiptChainPaths : undefined,
3258
+ positionReceiptChainValues: positionReceiptChainValues.length > 0 ? positionReceiptChainValues : undefined,
2857
3259
  distributionPath: getArg("distribution-json"),
2858
3260
  distributionValue: getArg("distribution-value") ? JSON.parse(getArg("distribution-value")) : undefined,
2859
3261
  closingPath: getArg("closing-json"),
@@ -2868,20 +3270,35 @@ async function main() {
2868
3270
  distributionHash: result.distribution?.hash ?? null,
2869
3271
  closingHash: result.closing?.hash ?? null,
2870
3272
  sourceVerificationMode: result.sourceVerificationMode,
3273
+ lineageKind: result.trust.receiptChainTrust?.lineageKind ?? null,
3274
+ latestOrdinal: result.trust.receiptChainTrust?.latestOrdinal ?? null,
3275
+ allHashLinksVerified: result.trust.receiptChainTrust?.allHashLinksVerified ?? null,
3276
+ identityConsistent: result.trust.receiptChainTrust?.identityConsistent ?? null,
3277
+ fullLineageVerified: result.trust.receiptChainTrust?.fullLineageVerified ?? null,
3278
+ fullChainVerified: result.trust.receiptChainTrust?.fullChainVerified ?? null,
2871
3279
  },
2872
3280
  summaryText: formatFundEvidenceSummary({
2873
3281
  definitionHash: result.definition.hash,
2874
3282
  capitalCallHash: result.capitalCall?.hash ?? null,
2875
3283
  positionReceiptHash: result.positionReceipt?.hash ?? null,
3284
+ positionReceiptEnvelopeHash: result.positionReceiptEnvelope?.hash ?? null,
2876
3285
  distributionHash: result.distribution?.hash ?? null,
2877
3286
  closingHash: result.closing?.hash ?? null,
2878
3287
  sourceVerificationMode: result.sourceVerificationMode,
3288
+ lineageKind: result.trust.receiptChainTrust?.lineageKind ?? null,
3289
+ latestOrdinal: result.trust.receiptChainTrust?.latestOrdinal ?? null,
3290
+ allHashLinksVerified: result.trust.receiptChainTrust?.allHashLinksVerified ?? null,
3291
+ identityConsistent: result.trust.receiptChainTrust?.identityConsistent ?? null,
3292
+ fullLineageVerified: result.trust.receiptChainTrust?.fullLineageVerified ?? null,
3293
+ fullChainVerified: result.trust.receiptChainTrust?.fullChainVerified ?? null,
2879
3294
  }),
2880
3295
  ...result,
2881
3296
  });
2882
3297
  return;
2883
3298
  }
2884
3299
  if (command === "fund" && subcommand === "export-finality-payload") {
3300
+ const positionReceiptChainPaths = getMultiArgs("position-receipt-chain-json");
3301
+ const positionReceiptChainValues = getMultiArgs("position-receipt-chain-value").map((value) => JSON.parse(value));
2885
3302
  const result = await sdk.funds.exportFinalityPayload({
2886
3303
  artifactPath: getArg("artifact"),
2887
3304
  definitionPath: getArg("definition-json"),
@@ -2890,6 +3307,12 @@ async function main() {
2890
3307
  capitalCallValue: getArg("capital-call-value") ? JSON.parse(getArg("capital-call-value")) : undefined,
2891
3308
  positionReceiptPath: getArg("position-receipt-json"),
2892
3309
  positionReceiptValue: getArg("position-receipt-value") ? JSON.parse(getArg("position-receipt-value")) : undefined,
3310
+ previousPositionReceiptPath: getArg("previous-position-receipt-json"),
3311
+ previousPositionReceiptValue: getArg("previous-position-receipt-value")
3312
+ ? JSON.parse(getArg("previous-position-receipt-value"))
3313
+ : undefined,
3314
+ positionReceiptChainPaths: positionReceiptChainPaths.length > 0 ? positionReceiptChainPaths : undefined,
3315
+ positionReceiptChainValues: positionReceiptChainValues.length > 0 ? positionReceiptChainValues : undefined,
2893
3316
  distributionPath: getArg("distribution-json"),
2894
3317
  distributionValue: getArg("distribution-value") ? JSON.parse(getArg("distribution-value")) : undefined,
2895
3318
  closingPath: getArg("closing-json"),
@@ -2908,6 +3331,12 @@ async function main() {
2908
3331
  distributionHash: result.distributionHash ?? null,
2909
3332
  closingHash: result.closingHash ?? null,
2910
3333
  bindingMode: result.bindingMode,
3334
+ lineageKind: result.trust.receiptChainTrust?.lineageKind ?? null,
3335
+ latestOrdinal: result.trust.receiptChainTrust?.latestOrdinal ?? null,
3336
+ allHashLinksVerified: result.trust.receiptChainTrust?.allHashLinksVerified ?? null,
3337
+ identityConsistent: result.trust.receiptChainTrust?.identityConsistent ?? null,
3338
+ fullLineageVerified: result.trust.receiptChainTrust?.fullLineageVerified ?? null,
3339
+ fullChainVerified: result.trust.receiptChainTrust?.fullChainVerified ?? null,
2911
3340
  },
2912
3341
  summaryText: formatFundFinalitySummary({
2913
3342
  fundId: result.fundId,
@@ -2917,9 +3346,707 @@ async function main() {
2917
3346
  definitionHash: result.definitionHash,
2918
3347
  capitalCallStateHash: result.capitalCallStateHash,
2919
3348
  positionReceiptHash: result.positionReceiptHash,
3349
+ positionReceiptEnvelopeHash: result.positionReceiptEnvelopeHash,
2920
3350
  distributionHash: result.distributionHash,
2921
3351
  closingHash: result.closingHash,
2922
3352
  bindingMode: result.bindingMode,
3353
+ lineageKind: result.trust.receiptChainTrust?.lineageKind ?? null,
3354
+ latestOrdinal: result.trust.receiptChainTrust?.latestOrdinal ?? null,
3355
+ allHashLinksVerified: result.trust.receiptChainTrust?.allHashLinksVerified ?? null,
3356
+ identityConsistent: result.trust.receiptChainTrust?.identityConsistent ?? null,
3357
+ fullLineageVerified: result.trust.receiptChainTrust?.fullLineageVerified ?? null,
3358
+ fullChainVerified: result.trust.receiptChainTrust?.fullChainVerified ?? null,
3359
+ }),
3360
+ ...result,
3361
+ });
3362
+ return;
3363
+ }
3364
+ if (command === "receivable" && subcommand === "define") {
3365
+ const result = await sdk.receivables.define({
3366
+ definitionPath: getArg("definition-json"),
3367
+ definitionValue: parseJsonArg("definition-value"),
3368
+ });
3369
+ printJson({
3370
+ summaryText: formatReceivableDefinitionSummary({
3371
+ ok: result.ok,
3372
+ receivableId: result.definitionValue.receivableId,
3373
+ originatorEntityId: result.definitionValue.originatorEntityId,
3374
+ debtorEntityId: result.definitionValue.debtorEntityId,
3375
+ currencyAssetId: result.definitionValue.currencyAssetId,
3376
+ faceValue: result.definitionValue.faceValue,
3377
+ dueDate: result.definitionValue.dueDate,
3378
+ }),
3379
+ ...result,
3380
+ });
3381
+ return;
3382
+ }
3383
+ if (command === "receivable" && subcommand === "verify") {
3384
+ const result = await sdk.receivables.verify({
3385
+ definitionPath: getArg("definition-json"),
3386
+ definitionValue: parseJsonArg("definition-value"),
3387
+ statePath: getArg("state-json"),
3388
+ stateValue: parseJsonArg("state-value"),
3389
+ });
3390
+ printJson({
3391
+ summaryText: formatReceivableDefinitionSummary({
3392
+ ok: result.verified,
3393
+ receivableId: result.definitionValue.receivableId,
3394
+ originatorEntityId: result.definitionValue.originatorEntityId,
3395
+ debtorEntityId: result.definitionValue.debtorEntityId,
3396
+ currencyAssetId: result.definitionValue.currencyAssetId,
3397
+ faceValue: result.definitionValue.faceValue,
3398
+ dueDate: result.definitionValue.dueDate,
3399
+ }),
3400
+ ...result,
3401
+ });
3402
+ return;
3403
+ }
3404
+ if (command === "receivable" && subcommand === "load") {
3405
+ const result = await sdk.receivables.load({
3406
+ definitionPath: getArg("definition-json"),
3407
+ definitionValue: parseJsonArg("definition-value"),
3408
+ statePath: getArg("state-json"),
3409
+ stateValue: parseJsonArg("state-value"),
3410
+ });
3411
+ printJson({
3412
+ summaryText: formatReceivableDefinitionSummary({
3413
+ receivableId: result.definitionValue.receivableId,
3414
+ originatorEntityId: result.definitionValue.originatorEntityId,
3415
+ debtorEntityId: result.definitionValue.debtorEntityId,
3416
+ currencyAssetId: result.definitionValue.currencyAssetId,
3417
+ faceValue: result.definitionValue.faceValue,
3418
+ dueDate: result.definitionValue.dueDate,
3419
+ }),
3420
+ ...result,
3421
+ });
3422
+ return;
3423
+ }
3424
+ if (command === "receivable" && subcommand === "prepare-funding") {
3425
+ const result = await sdk.receivables.prepareFunding({
3426
+ definitionPath: getArg("definition-json"),
3427
+ definitionValue: parseJsonArg("definition-value"),
3428
+ previousStatePath: getArg("previous-state-json"),
3429
+ previousStateValue: parseJsonArg("previous-state-value"),
3430
+ nextStatePath: getArg("next-state-json"),
3431
+ nextStateValue: parseJsonArg("next-state-value"),
3432
+ stateId: getArg("state-id"),
3433
+ holderEntityId: getArg("holder-entity-id"),
3434
+ holderClaimantXonly: getArg("holder-claimant-xonly"),
3435
+ fundedAt: getArg("funded-at"),
3436
+ });
3437
+ printJson({
3438
+ summaryText: formatReceivableTransitionSummary({
3439
+ phase: "prepare-funding",
3440
+ verified: result.verified,
3441
+ transitionType: result.report.transitionTrust?.transitionType ?? "FUND",
3442
+ receivableId: result.nextStateValue.receivableId,
3443
+ nextStateId: result.nextStateValue.stateId,
3444
+ holderEntityId: result.nextStateValue.holderEntityId,
3445
+ status: result.nextStateValue.status,
3446
+ outstandingAmount: result.nextStateValue.outstandingAmount,
3447
+ repaidAmount: result.nextStateValue.repaidAmount,
3448
+ stateHash: result.nextStateSummary.hash,
3449
+ }),
3450
+ ...result,
3451
+ });
3452
+ return;
3453
+ }
3454
+ if (command === "receivable" && subcommand === "verify-funding") {
3455
+ const result = await sdk.receivables.verifyFunding({
3456
+ definitionPath: getArg("definition-json"),
3457
+ definitionValue: parseJsonArg("definition-value"),
3458
+ previousStatePath: getArg("previous-state-json"),
3459
+ previousStateValue: parseJsonArg("previous-state-value"),
3460
+ nextStatePath: getArg("next-state-json"),
3461
+ nextStateValue: parseJsonArg("next-state-value"),
3462
+ });
3463
+ printJson({
3464
+ summaryText: formatReceivableTransitionSummary({
3465
+ phase: "verify-funding",
3466
+ verified: result.verified,
3467
+ transitionType: result.report.transitionTrust?.transitionType ?? "FUND",
3468
+ receivableId: result.nextStateValue.receivableId,
3469
+ nextStateId: result.nextStateValue.stateId,
3470
+ holderEntityId: result.nextStateValue.holderEntityId,
3471
+ status: result.nextStateValue.status,
3472
+ outstandingAmount: result.nextStateValue.outstandingAmount,
3473
+ repaidAmount: result.nextStateValue.repaidAmount,
3474
+ stateHash: result.nextStateSummary.hash,
3475
+ }),
3476
+ ...result,
3477
+ });
3478
+ return;
3479
+ }
3480
+ if (command === "receivable" && subcommand === "prepare-funding-claim") {
3481
+ const result = await sdk.receivables.prepareFundingClaim({
3482
+ definitionPath: getArg("definition-json"),
3483
+ definitionValue: parseJsonArg("definition-value"),
3484
+ currentStatePath: getArg("current-state-json"),
3485
+ currentStateValue: parseJsonArg("current-state-value"),
3486
+ stateHistoryPaths: getMultiArgs("state-history-json"),
3487
+ stateHistoryValues: parseJsonArgs("state-history-value"),
3488
+ fundingClaimPath: getArg("funding-claim-json"),
3489
+ fundingClaimValue: parseJsonArg("funding-claim-value"),
3490
+ claimId: getArg("claim-id"),
3491
+ payerEntityId: getArg("payer-entity-id"),
3492
+ payeeEntityId: getArg("payee-entity-id"),
3493
+ claimantXonly: getArg("claimant-xonly"),
3494
+ amountSat: getArg("amount-sat") ? Number(getArg("amount-sat")) : undefined,
3495
+ eventTimestamp: getArg("event-timestamp"),
3496
+ simfPath: getArg("simf"),
3497
+ artifactPath: getArg("artifact"),
3498
+ });
3499
+ printJson({
3500
+ summaryText: formatReceivableClaimSummary({
3501
+ phase: "prepare-funding-claim",
3502
+ verified: result.verified,
3503
+ claimKind: result.claimValue.claimKind,
3504
+ receivableId: result.claimValue.receivableId,
3505
+ claimId: result.claimValue.claimId,
3506
+ currentStatus: result.claimValue.currentStatus,
3507
+ payerEntityId: result.claimValue.payerEntityId,
3508
+ payeeEntityId: result.claimValue.payeeEntityId,
3509
+ amountSat: result.claimValue.amountSat,
3510
+ claimantAuthoritySource: result.report.fundingClaimTrust?.claimantAuthoritySource,
3511
+ roleSeparatedAuthorization: result.report.fundingClaimTrust?.roleSeparatedAuthorization,
3512
+ bindingMode: result.report.fundingClaimTrust?.bindingMode,
3513
+ reasonCode: result.report.fundingClaimTrust?.reasonCode,
3514
+ supportedForm: result.report.fundingClaimTrust?.supportedForm,
3515
+ fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
3516
+ }),
3517
+ ...result,
3518
+ });
3519
+ return;
3520
+ }
3521
+ if (command === "receivable" && subcommand === "verify-funding-claim") {
3522
+ const result = await sdk.receivables.verifyFundingClaim({
3523
+ artifactPath: getArg("artifact"),
3524
+ definitionPath: getArg("definition-json"),
3525
+ definitionValue: parseJsonArg("definition-value"),
3526
+ currentStatePath: getArg("current-state-json"),
3527
+ currentStateValue: parseJsonArg("current-state-value"),
3528
+ stateHistoryPaths: getMultiArgs("state-history-json"),
3529
+ stateHistoryValues: parseJsonArgs("state-history-value"),
3530
+ fundingClaimPath: getArg("funding-claim-json"),
3531
+ fundingClaimValue: parseJsonArg("funding-claim-value"),
3532
+ });
3533
+ printJson({
3534
+ summaryText: formatReceivableClaimSummary({
3535
+ phase: "verify-funding-claim",
3536
+ verified: result.verified,
3537
+ claimKind: result.claimValue.claimKind,
3538
+ receivableId: result.claimValue.receivableId,
3539
+ claimId: result.claimValue.claimId,
3540
+ currentStatus: result.claimValue.currentStatus,
3541
+ payerEntityId: result.claimValue.payerEntityId,
3542
+ payeeEntityId: result.claimValue.payeeEntityId,
3543
+ amountSat: result.claimValue.amountSat,
3544
+ claimantAuthoritySource: result.report.fundingClaimTrust?.claimantAuthoritySource,
3545
+ roleSeparatedAuthorization: result.report.fundingClaimTrust?.roleSeparatedAuthorization,
3546
+ bindingMode: result.report.fundingClaimTrust?.bindingMode,
3547
+ reasonCode: result.report.fundingClaimTrust?.reasonCode,
3548
+ supportedForm: result.report.fundingClaimTrust?.supportedForm,
3549
+ fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
3550
+ }),
3551
+ ...result,
3552
+ });
3553
+ return;
3554
+ }
3555
+ if (command === "receivable" && subcommand === "inspect-funding-claim") {
3556
+ const result = await sdk.receivables.inspectFundingClaim({
3557
+ artifactPath: requireArg("artifact"),
3558
+ definitionPath: getArg("definition-json"),
3559
+ definitionValue: parseJsonArg("definition-value"),
3560
+ currentStatePath: getArg("current-state-json"),
3561
+ currentStateValue: parseJsonArg("current-state-value"),
3562
+ stateHistoryPaths: getMultiArgs("state-history-json"),
3563
+ stateHistoryValues: parseJsonArgs("state-history-value"),
3564
+ fundingClaimPath: getArg("funding-claim-json"),
3565
+ fundingClaimValue: parseJsonArg("funding-claim-value"),
3566
+ payoutAddress: requireArg("payout-address"),
3567
+ nextOutputHash: getArg("next-output-hash") || undefined,
3568
+ outputForm: parsePolicyOutputForm(),
3569
+ rawOutput: parseRawOutputFields(),
3570
+ outputBindingMode: getArg("output-binding-mode"),
3571
+ wallet: requireArg("wallet"),
3572
+ signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
3573
+ feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
3574
+ utxoPolicy: getArg("utxo-policy"),
3575
+ });
3576
+ printJson({
3577
+ summaryText: formatReceivableClaimSummary({
3578
+ phase: "inspect-funding-claim",
3579
+ verified: result.verified,
3580
+ claimKind: result.claimValue.claimKind,
3581
+ receivableId: result.claimValue.receivableId,
3582
+ claimId: result.claimValue.claimId,
3583
+ currentStatus: result.claimValue.currentStatus,
3584
+ payerEntityId: result.claimValue.payerEntityId,
3585
+ payeeEntityId: result.claimValue.payeeEntityId,
3586
+ amountSat: result.claimValue.amountSat,
3587
+ claimantAuthoritySource: result.report.fundingClaimTrust?.claimantAuthoritySource,
3588
+ roleSeparatedAuthorization: result.report.fundingClaimTrust?.roleSeparatedAuthorization,
3589
+ bindingMode: result.report.fundingClaimTrust?.bindingMode,
3590
+ reasonCode: result.report.fundingClaimTrust?.reasonCode,
3591
+ supportedForm: result.report.fundingClaimTrust?.supportedForm,
3592
+ fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
3593
+ }),
3594
+ ...result,
3595
+ });
3596
+ return;
3597
+ }
3598
+ if (command === "receivable" && subcommand === "execute-funding-claim") {
3599
+ const result = await sdk.receivables.executeFundingClaim({
3600
+ artifactPath: requireArg("artifact"),
3601
+ definitionPath: getArg("definition-json"),
3602
+ definitionValue: parseJsonArg("definition-value"),
3603
+ currentStatePath: getArg("current-state-json"),
3604
+ currentStateValue: parseJsonArg("current-state-value"),
3605
+ stateHistoryPaths: getMultiArgs("state-history-json"),
3606
+ stateHistoryValues: parseJsonArgs("state-history-value"),
3607
+ fundingClaimPath: getArg("funding-claim-json"),
3608
+ fundingClaimValue: parseJsonArg("funding-claim-value"),
3609
+ payoutAddress: requireArg("payout-address"),
3610
+ nextOutputHash: getArg("next-output-hash") || undefined,
3611
+ outputForm: parsePolicyOutputForm(),
3612
+ rawOutput: parseRawOutputFields(),
3613
+ outputBindingMode: getArg("output-binding-mode"),
3614
+ wallet: requireArg("wallet"),
3615
+ signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
3616
+ feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
3617
+ utxoPolicy: getArg("utxo-policy"),
3618
+ broadcast: hasFlag("broadcast"),
3619
+ });
3620
+ printJson({
3621
+ summaryText: formatReceivableClaimSummary({
3622
+ phase: "execute-funding-claim",
3623
+ verified: result.verified,
3624
+ claimKind: result.claimValue.claimKind,
3625
+ receivableId: result.claimValue.receivableId,
3626
+ claimId: result.claimValue.claimId,
3627
+ currentStatus: result.claimValue.currentStatus,
3628
+ payerEntityId: result.claimValue.payerEntityId,
3629
+ payeeEntityId: result.claimValue.payeeEntityId,
3630
+ amountSat: result.claimValue.amountSat,
3631
+ claimantAuthoritySource: result.report.fundingClaimTrust?.claimantAuthoritySource,
3632
+ roleSeparatedAuthorization: result.report.fundingClaimTrust?.roleSeparatedAuthorization,
3633
+ bindingMode: result.report.fundingClaimTrust?.bindingMode,
3634
+ reasonCode: result.report.fundingClaimTrust?.reasonCode,
3635
+ supportedForm: result.report.fundingClaimTrust?.supportedForm,
3636
+ fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
3637
+ }),
3638
+ ...result,
3639
+ });
3640
+ return;
3641
+ }
3642
+ if (command === "receivable" && subcommand === "prepare-repayment") {
3643
+ const result = await sdk.receivables.prepareRepayment({
3644
+ definitionPath: getArg("definition-json"),
3645
+ definitionValue: parseJsonArg("definition-value"),
3646
+ previousStatePath: getArg("previous-state-json"),
3647
+ previousStateValue: parseJsonArg("previous-state-value"),
3648
+ nextStatePath: getArg("next-state-json"),
3649
+ nextStateValue: parseJsonArg("next-state-value"),
3650
+ stateId: getArg("state-id"),
3651
+ amount: getArg("amount") ? Number(getArg("amount")) : undefined,
3652
+ repaidAt: getArg("repaid-at"),
3653
+ });
3654
+ printJson({
3655
+ summaryText: formatReceivableTransitionSummary({
3656
+ phase: "prepare-repayment",
3657
+ verified: result.verified,
3658
+ transitionType: result.report.transitionTrust?.transitionType ?? "REPAY",
3659
+ receivableId: result.nextStateValue.receivableId,
3660
+ nextStateId: result.nextStateValue.stateId,
3661
+ holderEntityId: result.nextStateValue.holderEntityId,
3662
+ status: result.nextStateValue.status,
3663
+ outstandingAmount: result.nextStateValue.outstandingAmount,
3664
+ repaidAmount: result.nextStateValue.repaidAmount,
3665
+ stateHash: result.nextStateSummary.hash,
3666
+ }),
3667
+ ...result,
3668
+ });
3669
+ return;
3670
+ }
3671
+ if (command === "receivable" && subcommand === "prepare-repayment-claim") {
3672
+ const result = await sdk.receivables.prepareRepaymentClaim({
3673
+ definitionPath: getArg("definition-json"),
3674
+ definitionValue: parseJsonArg("definition-value"),
3675
+ currentStatePath: getArg("current-state-json"),
3676
+ currentStateValue: parseJsonArg("current-state-value"),
3677
+ stateHistoryPaths: getMultiArgs("state-history-json"),
3678
+ stateHistoryValues: parseJsonArgs("state-history-value"),
3679
+ repaymentClaimPath: getArg("repayment-claim-json"),
3680
+ repaymentClaimValue: parseJsonArg("repayment-claim-value"),
3681
+ claimId: getArg("claim-id"),
3682
+ payerEntityId: getArg("payer-entity-id"),
3683
+ payeeEntityId: getArg("payee-entity-id"),
3684
+ claimantXonly: getArg("claimant-xonly"),
3685
+ amountSat: getArg("amount-sat") ? Number(getArg("amount-sat")) : undefined,
3686
+ eventTimestamp: getArg("event-timestamp"),
3687
+ simfPath: getArg("simf"),
3688
+ artifactPath: getArg("artifact"),
3689
+ });
3690
+ printJson({
3691
+ summaryText: formatReceivableClaimSummary({
3692
+ phase: "prepare-repayment-claim",
3693
+ verified: result.verified,
3694
+ claimKind: result.claimValue.claimKind,
3695
+ receivableId: result.claimValue.receivableId,
3696
+ claimId: result.claimValue.claimId,
3697
+ currentStatus: result.claimValue.currentStatus,
3698
+ payerEntityId: result.claimValue.payerEntityId,
3699
+ payeeEntityId: result.claimValue.payeeEntityId,
3700
+ amountSat: result.claimValue.amountSat,
3701
+ claimantAuthoritySource: result.report.repaymentClaimTrust?.claimantAuthoritySource,
3702
+ roleSeparatedAuthorization: result.report.repaymentClaimTrust?.roleSeparatedAuthorization,
3703
+ bindingMode: result.report.repaymentClaimTrust?.bindingMode,
3704
+ reasonCode: result.report.repaymentClaimTrust?.reasonCode,
3705
+ supportedForm: result.report.repaymentClaimTrust?.supportedForm,
3706
+ fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
3707
+ }),
3708
+ ...result,
3709
+ });
3710
+ return;
3711
+ }
3712
+ if (command === "receivable" && subcommand === "verify-repayment-claim") {
3713
+ const result = await sdk.receivables.verifyRepaymentClaim({
3714
+ artifactPath: getArg("artifact"),
3715
+ definitionPath: getArg("definition-json"),
3716
+ definitionValue: parseJsonArg("definition-value"),
3717
+ currentStatePath: getArg("current-state-json"),
3718
+ currentStateValue: parseJsonArg("current-state-value"),
3719
+ stateHistoryPaths: getMultiArgs("state-history-json"),
3720
+ stateHistoryValues: parseJsonArgs("state-history-value"),
3721
+ repaymentClaimPath: getArg("repayment-claim-json"),
3722
+ repaymentClaimValue: parseJsonArg("repayment-claim-value"),
3723
+ });
3724
+ printJson({
3725
+ summaryText: formatReceivableClaimSummary({
3726
+ phase: "verify-repayment-claim",
3727
+ verified: result.verified,
3728
+ claimKind: result.claimValue.claimKind,
3729
+ receivableId: result.claimValue.receivableId,
3730
+ claimId: result.claimValue.claimId,
3731
+ currentStatus: result.claimValue.currentStatus,
3732
+ payerEntityId: result.claimValue.payerEntityId,
3733
+ payeeEntityId: result.claimValue.payeeEntityId,
3734
+ amountSat: result.claimValue.amountSat,
3735
+ claimantAuthoritySource: result.report.repaymentClaimTrust?.claimantAuthoritySource,
3736
+ roleSeparatedAuthorization: result.report.repaymentClaimTrust?.roleSeparatedAuthorization,
3737
+ bindingMode: result.report.repaymentClaimTrust?.bindingMode,
3738
+ reasonCode: result.report.repaymentClaimTrust?.reasonCode,
3739
+ supportedForm: result.report.repaymentClaimTrust?.supportedForm,
3740
+ fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
3741
+ }),
3742
+ ...result,
3743
+ });
3744
+ return;
3745
+ }
3746
+ if (command === "receivable" && subcommand === "inspect-repayment-claim") {
3747
+ const result = await sdk.receivables.inspectRepaymentClaim({
3748
+ artifactPath: requireArg("artifact"),
3749
+ definitionPath: getArg("definition-json"),
3750
+ definitionValue: parseJsonArg("definition-value"),
3751
+ currentStatePath: getArg("current-state-json"),
3752
+ currentStateValue: parseJsonArg("current-state-value"),
3753
+ stateHistoryPaths: getMultiArgs("state-history-json"),
3754
+ stateHistoryValues: parseJsonArgs("state-history-value"),
3755
+ repaymentClaimPath: getArg("repayment-claim-json"),
3756
+ repaymentClaimValue: parseJsonArg("repayment-claim-value"),
3757
+ payoutAddress: requireArg("payout-address"),
3758
+ nextOutputHash: getArg("next-output-hash") || undefined,
3759
+ outputForm: parsePolicyOutputForm(),
3760
+ rawOutput: parseRawOutputFields(),
3761
+ outputBindingMode: getArg("output-binding-mode"),
3762
+ wallet: requireArg("wallet"),
3763
+ signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
3764
+ feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
3765
+ utxoPolicy: getArg("utxo-policy"),
3766
+ });
3767
+ printJson({
3768
+ summaryText: formatReceivableClaimSummary({
3769
+ phase: "inspect-repayment-claim",
3770
+ verified: result.verified,
3771
+ claimKind: result.claimValue.claimKind,
3772
+ receivableId: result.claimValue.receivableId,
3773
+ claimId: result.claimValue.claimId,
3774
+ currentStatus: result.claimValue.currentStatus,
3775
+ payerEntityId: result.claimValue.payerEntityId,
3776
+ payeeEntityId: result.claimValue.payeeEntityId,
3777
+ amountSat: result.claimValue.amountSat,
3778
+ claimantAuthoritySource: result.report.repaymentClaimTrust?.claimantAuthoritySource,
3779
+ roleSeparatedAuthorization: result.report.repaymentClaimTrust?.roleSeparatedAuthorization,
3780
+ bindingMode: result.report.repaymentClaimTrust?.bindingMode,
3781
+ reasonCode: result.report.repaymentClaimTrust?.reasonCode,
3782
+ supportedForm: result.report.repaymentClaimTrust?.supportedForm,
3783
+ fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
3784
+ }),
3785
+ ...result,
3786
+ });
3787
+ return;
3788
+ }
3789
+ if (command === "receivable" && subcommand === "execute-repayment-claim") {
3790
+ const result = await sdk.receivables.executeRepaymentClaim({
3791
+ artifactPath: requireArg("artifact"),
3792
+ definitionPath: getArg("definition-json"),
3793
+ definitionValue: parseJsonArg("definition-value"),
3794
+ currentStatePath: getArg("current-state-json"),
3795
+ currentStateValue: parseJsonArg("current-state-value"),
3796
+ stateHistoryPaths: getMultiArgs("state-history-json"),
3797
+ stateHistoryValues: parseJsonArgs("state-history-value"),
3798
+ repaymentClaimPath: getArg("repayment-claim-json"),
3799
+ repaymentClaimValue: parseJsonArg("repayment-claim-value"),
3800
+ payoutAddress: requireArg("payout-address"),
3801
+ nextOutputHash: getArg("next-output-hash") || undefined,
3802
+ outputForm: parsePolicyOutputForm(),
3803
+ rawOutput: parseRawOutputFields(),
3804
+ outputBindingMode: getArg("output-binding-mode"),
3805
+ wallet: requireArg("wallet"),
3806
+ signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
3807
+ feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
3808
+ utxoPolicy: getArg("utxo-policy"),
3809
+ broadcast: hasFlag("broadcast"),
3810
+ });
3811
+ printJson({
3812
+ summaryText: formatReceivableClaimSummary({
3813
+ phase: "execute-repayment-claim",
3814
+ verified: result.verified,
3815
+ claimKind: result.claimValue.claimKind,
3816
+ receivableId: result.claimValue.receivableId,
3817
+ claimId: result.claimValue.claimId,
3818
+ currentStatus: result.claimValue.currentStatus,
3819
+ payerEntityId: result.claimValue.payerEntityId,
3820
+ payeeEntityId: result.claimValue.payeeEntityId,
3821
+ amountSat: result.claimValue.amountSat,
3822
+ claimantAuthoritySource: result.report.repaymentClaimTrust?.claimantAuthoritySource,
3823
+ roleSeparatedAuthorization: result.report.repaymentClaimTrust?.roleSeparatedAuthorization,
3824
+ bindingMode: result.report.repaymentClaimTrust?.bindingMode,
3825
+ reasonCode: result.report.repaymentClaimTrust?.reasonCode,
3826
+ supportedForm: result.report.repaymentClaimTrust?.supportedForm,
3827
+ fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
3828
+ }),
3829
+ ...result,
3830
+ });
3831
+ return;
3832
+ }
3833
+ if (command === "receivable" && subcommand === "verify-repayment") {
3834
+ const result = await sdk.receivables.verifyRepayment({
3835
+ definitionPath: getArg("definition-json"),
3836
+ definitionValue: parseJsonArg("definition-value"),
3837
+ previousStatePath: getArg("previous-state-json"),
3838
+ previousStateValue: parseJsonArg("previous-state-value"),
3839
+ nextStatePath: getArg("next-state-json"),
3840
+ nextStateValue: parseJsonArg("next-state-value"),
3841
+ });
3842
+ printJson({
3843
+ summaryText: formatReceivableTransitionSummary({
3844
+ phase: "verify-repayment",
3845
+ verified: result.verified,
3846
+ transitionType: result.report.transitionTrust?.transitionType ?? "REPAY",
3847
+ receivableId: result.nextStateValue.receivableId,
3848
+ nextStateId: result.nextStateValue.stateId,
3849
+ holderEntityId: result.nextStateValue.holderEntityId,
3850
+ status: result.nextStateValue.status,
3851
+ outstandingAmount: result.nextStateValue.outstandingAmount,
3852
+ repaidAmount: result.nextStateValue.repaidAmount,
3853
+ stateHash: result.nextStateSummary.hash,
3854
+ }),
3855
+ ...result,
3856
+ });
3857
+ return;
3858
+ }
3859
+ if (command === "receivable" && subcommand === "prepare-write-off") {
3860
+ const result = await sdk.receivables.prepareWriteOff({
3861
+ definitionPath: getArg("definition-json"),
3862
+ definitionValue: parseJsonArg("definition-value"),
3863
+ previousStatePath: getArg("previous-state-json"),
3864
+ previousStateValue: parseJsonArg("previous-state-value"),
3865
+ nextStatePath: getArg("next-state-json"),
3866
+ nextStateValue: parseJsonArg("next-state-value"),
3867
+ stateId: getArg("state-id"),
3868
+ defaultedAt: getArg("defaulted-at"),
3869
+ writeOffAmount: getArg("write-off-amount") ? Number(getArg("write-off-amount")) : undefined,
3870
+ });
3871
+ printJson({
3872
+ summaryText: formatReceivableTransitionSummary({
3873
+ phase: "prepare-write-off",
3874
+ verified: result.verified,
3875
+ transitionType: result.report.transitionTrust?.transitionType ?? "WRITE_OFF",
3876
+ receivableId: result.nextStateValue.receivableId,
3877
+ nextStateId: result.nextStateValue.stateId,
3878
+ holderEntityId: result.nextStateValue.holderEntityId,
3879
+ status: result.nextStateValue.status,
3880
+ outstandingAmount: result.nextStateValue.outstandingAmount,
3881
+ repaidAmount: result.nextStateValue.repaidAmount,
3882
+ stateHash: result.nextStateSummary.hash,
3883
+ }),
3884
+ ...result,
3885
+ });
3886
+ return;
3887
+ }
3888
+ if (command === "receivable" && subcommand === "verify-write-off") {
3889
+ const result = await sdk.receivables.verifyWriteOff({
3890
+ definitionPath: getArg("definition-json"),
3891
+ definitionValue: parseJsonArg("definition-value"),
3892
+ previousStatePath: getArg("previous-state-json"),
3893
+ previousStateValue: parseJsonArg("previous-state-value"),
3894
+ nextStatePath: getArg("next-state-json"),
3895
+ nextStateValue: parseJsonArg("next-state-value"),
3896
+ });
3897
+ printJson({
3898
+ summaryText: formatReceivableTransitionSummary({
3899
+ phase: "verify-write-off",
3900
+ verified: result.verified,
3901
+ transitionType: result.report.transitionTrust?.transitionType ?? "WRITE_OFF",
3902
+ receivableId: result.nextStateValue.receivableId,
3903
+ nextStateId: result.nextStateValue.stateId,
3904
+ holderEntityId: result.nextStateValue.holderEntityId,
3905
+ status: result.nextStateValue.status,
3906
+ outstandingAmount: result.nextStateValue.outstandingAmount,
3907
+ repaidAmount: result.nextStateValue.repaidAmount,
3908
+ stateHash: result.nextStateSummary.hash,
3909
+ }),
3910
+ ...result,
3911
+ });
3912
+ return;
3913
+ }
3914
+ if (command === "receivable" && subcommand === "prepare-closing") {
3915
+ const result = await sdk.receivables.prepareClosing({
3916
+ definitionPath: getArg("definition-json"),
3917
+ definitionValue: parseJsonArg("definition-value"),
3918
+ latestStatePath: getArg("latest-state-json"),
3919
+ latestStateValue: parseJsonArg("latest-state-value"),
3920
+ stateHistoryPaths: getMultiArgs("state-history-json"),
3921
+ stateHistoryValues: parseJsonArgs("state-history-value"),
3922
+ closingPath: getArg("closing-json"),
3923
+ closingValue: parseJsonArg("closing-value"),
3924
+ closingId: getArg("closing-id"),
3925
+ closedAt: getArg("closed-at"),
3926
+ closingReason: getArg("closing-reason"),
3927
+ });
3928
+ printJson({
3929
+ summaryText: formatReceivableClosingSummary({
3930
+ verified: result.verified,
3931
+ receivableId: result.closingValue.receivableId,
3932
+ latestStatus: result.closingValue.latestStatus,
3933
+ closingReason: result.closingValue.closingReason,
3934
+ closingHash: result.closingSummary.hash,
3935
+ fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
3936
+ }),
3937
+ ...result,
3938
+ });
3939
+ return;
3940
+ }
3941
+ if (command === "receivable" && subcommand === "verify-closing") {
3942
+ const result = await sdk.receivables.verifyClosing({
3943
+ definitionPath: getArg("definition-json"),
3944
+ definitionValue: parseJsonArg("definition-value"),
3945
+ latestStatePath: getArg("latest-state-json"),
3946
+ latestStateValue: parseJsonArg("latest-state-value"),
3947
+ stateHistoryPaths: getMultiArgs("state-history-json"),
3948
+ stateHistoryValues: parseJsonArgs("state-history-value"),
3949
+ closingPath: getArg("closing-json"),
3950
+ closingValue: parseJsonArg("closing-value"),
3951
+ });
3952
+ printJson({
3953
+ summaryText: formatReceivableClosingSummary({
3954
+ verified: result.verified,
3955
+ receivableId: result.closingValue.receivableId,
3956
+ latestStatus: result.closingValue.latestStatus,
3957
+ closingReason: result.closingValue.closingReason,
3958
+ closingHash: result.closingSummary.hash,
3959
+ fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified,
3960
+ }),
3961
+ ...result,
3962
+ });
3963
+ return;
3964
+ }
3965
+ if (command === "receivable" && subcommand === "verify-state-history") {
3966
+ const result = await sdk.receivables.verifyStateHistory({
3967
+ definitionPath: getArg("definition-json"),
3968
+ definitionValue: parseJsonArg("definition-value"),
3969
+ stateHistoryPaths: getMultiArgs("state-history-json"),
3970
+ stateHistoryValues: parseJsonArgs("state-history-value"),
3971
+ });
3972
+ printJson({
3973
+ summaryText: formatReceivableHistorySummary({
3974
+ verified: result.verified,
3975
+ receivableId: result.latestStateValue.receivableId,
3976
+ chainLength: result.report.stateLineageTrust?.chainLength ?? 0,
3977
+ latestStatus: result.report.stateLineageTrust?.latestStatus ?? result.latestStateValue.status,
3978
+ latestOrdinal: result.report.stateLineageTrust?.latestOrdinal ?? null,
3979
+ fullLineageVerified: result.report.stateLineageTrust?.fullLineageVerified ?? false,
3980
+ }),
3981
+ ...result,
3982
+ });
3983
+ return;
3984
+ }
3985
+ if (command === "receivable" && subcommand === "export-evidence") {
3986
+ const result = await sdk.receivables.exportEvidence({
3987
+ definitionPath: getArg("definition-json"),
3988
+ definitionValue: parseJsonArg("definition-value"),
3989
+ statePath: getArg("state-json"),
3990
+ stateValue: parseJsonArg("state-value"),
3991
+ stateHistoryPaths: getMultiArgs("state-history-json"),
3992
+ stateHistoryValues: parseJsonArgs("state-history-value"),
3993
+ fundingClaimPath: getArg("funding-claim-json"),
3994
+ fundingClaimValue: parseJsonArg("funding-claim-value"),
3995
+ repaymentClaimPath: getArg("repayment-claim-json"),
3996
+ repaymentClaimValue: parseJsonArg("repayment-claim-value"),
3997
+ closingPath: getArg("closing-json"),
3998
+ closingValue: parseJsonArg("closing-value"),
3999
+ verificationReportValue: parseJsonArg("verification-report-value"),
4000
+ });
4001
+ const evidenceStateValue = JSON.parse(result.state.canonicalJson);
4002
+ const evidenceClosingValue = result.closing
4003
+ ? JSON.parse(result.closing.canonicalJson)
4004
+ : undefined;
4005
+ printJson({
4006
+ summaryText: formatReceivableEvidenceOrFinalitySummary({
4007
+ kind: "evidence",
4008
+ receivableId: evidenceStateValue.receivableId,
4009
+ holderEntityId: evidenceStateValue.holderEntityId,
4010
+ definitionHash: result.definition.hash,
4011
+ latestStateHash: result.state.hash,
4012
+ closingHash: result.closing?.hash ?? null,
4013
+ closingReason: evidenceClosingValue?.closingReason ?? null,
4014
+ lineageKind: result.trust.stateLineageTrust?.lineageKind ?? null,
4015
+ latestOrdinal: result.trust.stateLineageTrust?.latestOrdinal ?? null,
4016
+ fullLineageVerified: result.trust.stateLineageTrust?.fullLineageVerified ?? null,
4017
+ }),
4018
+ ...result,
4019
+ });
4020
+ return;
4021
+ }
4022
+ if (command === "receivable" && subcommand === "export-finality-payload") {
4023
+ const result = await sdk.receivables.exportFinalityPayload({
4024
+ definitionPath: getArg("definition-json"),
4025
+ definitionValue: parseJsonArg("definition-value"),
4026
+ statePath: getArg("state-json"),
4027
+ stateValue: parseJsonArg("state-value"),
4028
+ stateHistoryPaths: getMultiArgs("state-history-json"),
4029
+ stateHistoryValues: parseJsonArgs("state-history-value"),
4030
+ fundingClaimPath: getArg("funding-claim-json"),
4031
+ fundingClaimValue: parseJsonArg("funding-claim-value"),
4032
+ repaymentClaimPath: getArg("repayment-claim-json"),
4033
+ repaymentClaimValue: parseJsonArg("repayment-claim-value"),
4034
+ closingPath: getArg("closing-json"),
4035
+ closingValue: parseJsonArg("closing-value"),
4036
+ verificationReportValue: parseJsonArg("verification-report-value"),
4037
+ });
4038
+ printJson({
4039
+ summaryText: formatReceivableEvidenceOrFinalitySummary({
4040
+ kind: "finality",
4041
+ receivableId: result.receivableId,
4042
+ holderEntityId: result.holderEntityId,
4043
+ definitionHash: result.definitionHash,
4044
+ latestStateHash: result.latestStateHash,
4045
+ closingHash: result.closingHash,
4046
+ closingReason: result.closingReason,
4047
+ lineageKind: result.trust.stateLineageTrust?.lineageKind ?? null,
4048
+ latestOrdinal: result.trust.stateLineageTrust?.latestOrdinal ?? null,
4049
+ fullLineageVerified: result.trust.stateLineageTrust?.fullLineageVerified ?? null,
2923
4050
  }),
2924
4051
  ...result,
2925
4052
  });