@hazbase/simplicity 0.0.3 → 0.0.5

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/dist/cli.js CHANGED
@@ -8,6 +8,7 @@ const promises_1 = require("node:fs/promises");
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
9
  const artifact_1 = require("./core/artifact");
10
10
  const definition_1 = require("./core/definition");
11
+ const state_1 = require("./core/state");
11
12
  const presets_1 = require("./core/presets");
12
13
  const errors_1 = require("./core/errors");
13
14
  const SimplicityClient_1 = require("./client/SimplicityClient");
@@ -85,6 +86,25 @@ function parseDefinitionInput() {
85
86
  anchorMode,
86
87
  };
87
88
  }
89
+ function parseStateInput() {
90
+ const type = getArg("state-type");
91
+ const id = getArg("state-id");
92
+ const jsonPath = getArg("state-json");
93
+ const valueJson = getArg("state-value");
94
+ const schemaVersion = getArg("state-schema-version");
95
+ const anchorMode = getArg("state-anchor-mode");
96
+ if (!type && !id && !jsonPath && !valueJson && !schemaVersion && !anchorMode) {
97
+ return undefined;
98
+ }
99
+ return {
100
+ type: type ?? "",
101
+ id: id ?? "",
102
+ schemaVersion: schemaVersion ?? undefined,
103
+ jsonPath,
104
+ value: valueJson ? JSON.parse(valueJson) : undefined,
105
+ anchorMode,
106
+ };
107
+ }
88
108
  function resolveConfig() {
89
109
  return {
90
110
  network: getArg("network", "liquidtestnet"),
@@ -389,6 +409,18 @@ function formatArtifactHelp(artifact, preset, utxos) {
389
409
  ` source verified: ${artifact.definition.onChainAnchor?.sourceVerified === true ? "yes" : "no"}`,
390
410
  ].join("\n")
391
411
  : " (none)";
412
+ const state = artifact.state
413
+ ? [
414
+ ` type: ${artifact.state.stateType}`,
415
+ ` id: ${artifact.state.stateId}`,
416
+ ` schema version: ${artifact.state.schemaVersion}`,
417
+ ` hash: ${artifact.state.hash}`,
418
+ ` trust mode: ${artifact.state.trustMode}`,
419
+ ` anchor mode: ${artifact.state.anchorMode}`,
420
+ ` on-chain helper: ${artifact.state.onChainAnchor?.helper ?? "(none)"}`,
421
+ ` source verified: ${artifact.state.onChainAnchor?.sourceVerified === true ? "yes" : "no"}`,
422
+ ].join("\n")
423
+ : " (none)";
392
424
  const compileSource = artifact.source.simfPath ?? artifact.legacy?.simfTemplatePath ?? "(unknown)";
393
425
  const templateVars = artifact.source.templateVars ?? {};
394
426
  const inspectCommand = `simplicity-cli contract inspect --artifact ./artifact.json --wallet simplicity-test --privkey <privkey-hex> --to-address tex1...`;
@@ -410,6 +442,9 @@ function formatArtifactHelp(artifact, preset, utxos) {
410
442
  "Definition Anchor:",
411
443
  definition,
412
444
  "",
445
+ "State Anchor:",
446
+ state,
447
+ "",
413
448
  "Suggested Commands:",
414
449
  ` ${inspectCommand}`,
415
450
  ` ${executeCommand}`,
@@ -451,7 +486,7 @@ async function main() {
451
486
  const subcommand = process.argv[3];
452
487
  const sdk = (0, SimplicityClient_1.createSimplicityClient)(resolveConfig());
453
488
  if (!command) {
454
- throw new Error("Usage: simplicity-cli <compile|presets|preset|contract|artifact|definition|gasless> ...");
489
+ throw new Error("Usage: simplicity-cli <compile|presets|preset|contract|artifact|definition|state|bond|gasless> ...");
455
490
  }
456
491
  if (command === "compile") {
457
492
  const result = await sdk.compileFromFile({
@@ -459,6 +494,7 @@ async function main() {
459
494
  templateVars: parseAssignments(getMultiArgs("template-var")),
460
495
  artifactPath: getArg("artifact"),
461
496
  definition: parseDefinitionInput(),
497
+ state: parseStateInput(),
462
498
  });
463
499
  printJson({ artifact: result.artifact, deployment: result.deployment() });
464
500
  return;
@@ -497,6 +533,40 @@ async function main() {
497
533
  });
498
534
  return;
499
535
  }
536
+ if (command === "state" && subcommand === "show") {
537
+ const state = await (0, state_1.loadStateInput)({
538
+ type: requireArg("type"),
539
+ id: requireArg("id"),
540
+ jsonPath: getArg("json-path"),
541
+ value: getArg("value") ? JSON.parse(getArg("value")) : undefined,
542
+ schemaVersion: getArg("schema-version"),
543
+ });
544
+ printJson({
545
+ ...state,
546
+ anchorRecommendation: "Use --state-anchor-mode on-chain-constant-committed with a blessed custom .simf helper for on-chain enforcement",
547
+ });
548
+ return;
549
+ }
550
+ if (command === "state" && subcommand === "verify") {
551
+ const verification = await sdk.verifyStateAgainstArtifact({
552
+ artifactPath: requireArg("artifact"),
553
+ type: getArg("type"),
554
+ id: getArg("id"),
555
+ expectedType: getArg("expected-type"),
556
+ expectedId: getArg("expected-id"),
557
+ jsonPath: getArg("json-path"),
558
+ value: getArg("value") ? JSON.parse(getArg("value")) : undefined,
559
+ schemaVersion: getArg("schema-version"),
560
+ });
561
+ printJson({
562
+ verified: verification.ok,
563
+ reason: verification.reason,
564
+ state: verification.state,
565
+ artifactState: verification.artifactState ?? null,
566
+ trust: verification.trust,
567
+ });
568
+ return;
569
+ }
500
570
  if (command === "presets" && subcommand === "list") {
501
571
  printJson((0, presets_1.listPresets)().map((preset) => (0, presets_1.describePreset)(preset)));
502
572
  return;
@@ -543,6 +613,7 @@ async function main() {
543
613
  params,
544
614
  artifactPath: getArg("artifact"),
545
615
  definition: parseDefinitionInput(),
616
+ state: parseStateInput(),
546
617
  });
547
618
  printJson({ artifact: result.artifact, deployment: result.deployment() });
548
619
  return;
@@ -572,6 +643,322 @@ async function main() {
572
643
  });
573
644
  return;
574
645
  }
646
+ if (command === "bond" && subcommand === "define") {
647
+ const result = await sdk.bonds.defineBond({
648
+ definitionPath: getArg("definition-json"),
649
+ issuancePath: getArg("issuance-json"),
650
+ simfPath: getArg("simf"),
651
+ artifactPath: getArg("artifact"),
652
+ });
653
+ printJson({ artifact: result.artifact, deployment: result.deployment() });
654
+ return;
655
+ }
656
+ if (command === "bond" && subcommand === "verify") {
657
+ const result = await sdk.bonds.verifyBond({
658
+ artifactPath: requireArg("artifact"),
659
+ definitionPath: getArg("definition-json"),
660
+ issuancePath: getArg("issuance-json"),
661
+ });
662
+ printJson(result);
663
+ return;
664
+ }
665
+ if (command === "bond" && subcommand === "redeem") {
666
+ const preview = await sdk.bonds.buildBondRedemption({
667
+ definitionPath: getArg("definition-json"),
668
+ previousIssuancePath: getArg("previous-issuance-json"),
669
+ amount: Number(requireArg("amount")),
670
+ redeemedAt: requireArg("redeemed-at"),
671
+ });
672
+ const nextIssuanceOut = getArg("next-issuance-out");
673
+ if (nextIssuanceOut) {
674
+ const resolved = node_path_1.default.resolve(nextIssuanceOut);
675
+ 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");
677
+ }
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
+ printJson({
687
+ artifact: result.artifact,
688
+ deployment: result.deployment(),
689
+ previousHash: preview.previousHash,
690
+ nextHash: preview.nextHash,
691
+ transition: preview.transition,
692
+ nextIssuanceState: preview.next,
693
+ nextIssuanceOut: nextIssuanceOut ? node_path_1.default.resolve(nextIssuanceOut) : undefined,
694
+ });
695
+ return;
696
+ }
697
+ if (command === "bond" && subcommand === "verify-transition") {
698
+ const result = await sdk.bonds.verifyBondTransition({
699
+ previousIssuancePath: getArg("previous-issuance-json"),
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({
707
+ definitionPath: getArg("definition-json"),
708
+ previousIssuancePath: getArg("previous-issuance-json"),
709
+ nextIssuancePath: getArg("next-issuance-json"),
710
+ simfPath: getArg("simf"),
711
+ artifactPath: getArg("artifact"),
712
+ });
713
+ printJson({
714
+ artifact: result.compiled.artifact,
715
+ deployment: result.compiled.deployment(),
716
+ previousHash: result.previousHash,
717
+ nextHash: result.nextHash,
718
+ transition: result.transition,
719
+ payload: result.payload,
720
+ });
721
+ return;
722
+ }
723
+ if (command === "bond" && subcommand === "compile-redemption-machine") {
724
+ const result = await sdk.bonds.compileBondRedemptionMachine({
725
+ definitionPath: getArg("definition-json"),
726
+ previousIssuancePath: getArg("previous-issuance-json"),
727
+ nextIssuancePath: getArg("next-issuance-json"),
728
+ nextStateSimfPath: getArg("next-state-simf"),
729
+ nextAmountSat: getArg("next-amount-sat") ? Number(getArg("next-amount-sat")) : undefined,
730
+ maxFeeSat: getArg("max-fee-sat") ? Number(getArg("max-fee-sat")) : undefined,
731
+ simfPath: getArg("simf"),
732
+ artifactPath: getArg("artifact"),
733
+ });
734
+ printJson({
735
+ artifact: result.compiled.artifact,
736
+ deployment: result.compiled.deployment(),
737
+ previousHash: result.previousHash,
738
+ nextHash: result.nextHash,
739
+ redeemAmount: result.redeemAmount,
740
+ transitionKind: result.transitionKind,
741
+ nextStateContractAddress: result.nextStateContractAddress,
742
+ nextStateContractAddressHash: result.nextStateContractAddressHash,
743
+ settlementDescriptor: result.settlementDescriptor,
744
+ settlementDescriptorHash: result.settlementDescriptorHash,
745
+ transition: result.transition,
746
+ payload: result.payload,
747
+ });
748
+ return;
749
+ }
750
+ if (command === "bond" && subcommand === "verify-machine") {
751
+ const result = await sdk.bonds.verifyBondRedemptionMachineArtifact({
752
+ artifactPath: requireArg("artifact"),
753
+ definitionPath: getArg("definition-json"),
754
+ previousIssuancePath: getArg("previous-issuance-json"),
755
+ nextIssuancePath: getArg("next-issuance-json"),
756
+ nextStateSimfPath: getArg("next-state-simf"),
757
+ nextAmountSat: getArg("next-amount-sat") ? Number(getArg("next-amount-sat")) : undefined,
758
+ maxFeeSat: getArg("max-fee-sat") ? Number(getArg("max-fee-sat")) : undefined,
759
+ });
760
+ printJson(result);
761
+ return;
762
+ }
763
+ if (command === "bond" && subcommand === "settlement-payload") {
764
+ const result = await sdk.bonds.buildBondSettlementPayload({
765
+ definitionPath: getArg("definition-json"),
766
+ previousIssuancePath: getArg("previous-issuance-json"),
767
+ nextIssuancePath: getArg("next-issuance-json"),
768
+ nextStateSimfPath: getArg("next-state-simf"),
769
+ nextAmountSat: Number(requireArg("next-amount-sat")),
770
+ maxFeeSat: getArg("max-fee-sat") ? Number(getArg("max-fee-sat")) : undefined,
771
+ });
772
+ printJson(result);
773
+ return;
774
+ }
775
+ if (command === "bond" && subcommand === "verify-settlement") {
776
+ const result = await sdk.bonds.verifyBondSettlementDescriptor({
777
+ descriptorPath: getArg("descriptor-json"),
778
+ definitionPath: getArg("definition-json"),
779
+ previousIssuancePath: getArg("previous-issuance-json"),
780
+ nextIssuancePath: getArg("next-issuance-json"),
781
+ nextStateSimfPath: getArg("next-state-simf"),
782
+ nextAmountSat: getArg("next-amount-sat") ? Number(getArg("next-amount-sat")) : undefined,
783
+ maxFeeSat: getArg("max-fee-sat") ? Number(getArg("max-fee-sat")) : undefined,
784
+ });
785
+ printJson(result);
786
+ return;
787
+ }
788
+ if (command === "bond" && subcommand === "plan-rollover") {
789
+ const result = await sdk.bonds.buildBondRolloverPlan({
790
+ currentArtifactPath: requireArg("current-artifact"),
791
+ definitionPath: getArg("definition-json"),
792
+ previousIssuancePath: getArg("previous-issuance-json"),
793
+ nextIssuancePath: getArg("next-issuance-json"),
794
+ nextSimfPath: getArg("next-simf"),
795
+ nextArtifactPath: getArg("next-artifact"),
796
+ });
797
+ printJson({
798
+ currentArtifact: result.currentArtifact,
799
+ nextArtifact: result.nextCompiled.artifact,
800
+ nextDeployment: result.nextCompiled.deployment(),
801
+ nextContractAddress: result.nextContractAddress,
802
+ transitionPayload: result.transitionPayload,
803
+ });
804
+ return;
805
+ }
806
+ if (command === "bond" && subcommand === "plan-machine-rollover") {
807
+ const result = await sdk.bonds.buildBondMachineRolloverPlan({
808
+ currentArtifactPath: requireArg("current-artifact"),
809
+ definitionPath: getArg("definition-json"),
810
+ previousIssuancePath: getArg("previous-issuance-json"),
811
+ nextIssuancePath: getArg("next-issuance-json"),
812
+ nextStateSimfPath: getArg("next-state-simf"),
813
+ machineSimfPath: getArg("machine-simf"),
814
+ machineArtifactPath: getArg("machine-artifact"),
815
+ });
816
+ printJson({
817
+ currentArtifact: result.currentArtifact,
818
+ machineArtifact: result.machineCompiled.compiled.artifact,
819
+ machineDeployment: result.machineCompiled.compiled.deployment(),
820
+ machineVerification: result.machineVerification,
821
+ nextContractAddress: result.nextContractAddress,
822
+ transitionPayload: result.transitionPayload,
823
+ });
824
+ return;
825
+ }
826
+ if (command === "bond" && subcommand === "inspect-rollover") {
827
+ const result = await sdk.bonds.inspectBondStateRollover({
828
+ currentArtifactPath: requireArg("current-artifact"),
829
+ definitionPath: getArg("definition-json"),
830
+ previousIssuancePath: getArg("previous-issuance-json"),
831
+ nextIssuancePath: getArg("next-issuance-json"),
832
+ nextSimfPath: getArg("next-simf"),
833
+ nextArtifactPath: getArg("next-artifact"),
834
+ wallet: requireArg("wallet"),
835
+ signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
836
+ feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
837
+ utxoPolicy: getArg("utxo-policy"),
838
+ });
839
+ printJson(result);
840
+ return;
841
+ }
842
+ if (command === "bond" && subcommand === "inspect-machine-rollover") {
843
+ const result = await sdk.bonds.inspectBondMachineRollover({
844
+ currentArtifactPath: requireArg("current-artifact"),
845
+ definitionPath: getArg("definition-json"),
846
+ previousIssuancePath: getArg("previous-issuance-json"),
847
+ nextIssuancePath: getArg("next-issuance-json"),
848
+ machineSimfPath: getArg("machine-simf"),
849
+ machineArtifactPath: getArg("machine-artifact"),
850
+ wallet: requireArg("wallet"),
851
+ signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
852
+ feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
853
+ utxoPolicy: getArg("utxo-policy"),
854
+ });
855
+ printJson(result);
856
+ return;
857
+ }
858
+ if (command === "bond" && subcommand === "execute-rollover") {
859
+ const result = await sdk.bonds.executeBondStateRollover({
860
+ currentArtifactPath: requireArg("current-artifact"),
861
+ definitionPath: getArg("definition-json"),
862
+ previousIssuancePath: getArg("previous-issuance-json"),
863
+ nextIssuancePath: getArg("next-issuance-json"),
864
+ nextSimfPath: getArg("next-simf"),
865
+ nextArtifactPath: getArg("next-artifact"),
866
+ wallet: requireArg("wallet"),
867
+ signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
868
+ feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
869
+ utxoPolicy: getArg("utxo-policy"),
870
+ broadcast: hasFlag("broadcast"),
871
+ });
872
+ printJson(result);
873
+ return;
874
+ }
875
+ if (command === "bond" && subcommand === "execute-machine-rollover") {
876
+ const result = await sdk.bonds.executeBondMachineRollover({
877
+ currentArtifactPath: requireArg("current-artifact"),
878
+ definitionPath: getArg("definition-json"),
879
+ previousIssuancePath: getArg("previous-issuance-json"),
880
+ nextIssuancePath: getArg("next-issuance-json"),
881
+ machineSimfPath: getArg("machine-simf"),
882
+ machineArtifactPath: getArg("machine-artifact"),
883
+ wallet: requireArg("wallet"),
884
+ signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
885
+ feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
886
+ utxoPolicy: getArg("utxo-policy"),
887
+ broadcast: hasFlag("broadcast"),
888
+ });
889
+ printJson(result);
890
+ return;
891
+ }
892
+ if (command === "bond" && subcommand === "plan-machine-settlement") {
893
+ const result = await sdk.bonds.buildBondMachineSettlementPlan({
894
+ currentMachineArtifactPath: requireArg("current-machine-artifact"),
895
+ definitionPath: getArg("definition-json"),
896
+ previousIssuancePath: getArg("previous-issuance-json"),
897
+ nextIssuancePath: getArg("next-issuance-json"),
898
+ nextSimfPath: getArg("next-simf"),
899
+ nextArtifactPath: getArg("next-artifact"),
900
+ });
901
+ printJson({
902
+ currentMachineArtifact: result.currentMachineArtifact,
903
+ machineVerification: result.machineVerification,
904
+ nextArtifact: result.nextCompiled.artifact,
905
+ nextDeployment: result.nextCompiled.deployment(),
906
+ nextContractAddress: result.nextContractAddress,
907
+ transitionPayload: result.transitionPayload,
908
+ });
909
+ return;
910
+ }
911
+ if (command === "bond" && subcommand === "inspect-machine-settlement") {
912
+ const result = await sdk.bonds.inspectBondMachineSettlement({
913
+ currentMachineArtifactPath: requireArg("current-machine-artifact"),
914
+ definitionPath: getArg("definition-json"),
915
+ previousIssuancePath: getArg("previous-issuance-json"),
916
+ nextIssuancePath: getArg("next-issuance-json"),
917
+ nextSimfPath: getArg("next-simf"),
918
+ nextArtifactPath: getArg("next-artifact"),
919
+ wallet: requireArg("wallet"),
920
+ signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
921
+ feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
922
+ utxoPolicy: getArg("utxo-policy"),
923
+ });
924
+ printJson(result);
925
+ return;
926
+ }
927
+ if (command === "bond" && subcommand === "execute-machine-settlement") {
928
+ const result = await sdk.bonds.executeBondMachineSettlement({
929
+ currentMachineArtifactPath: requireArg("current-machine-artifact"),
930
+ definitionPath: getArg("definition-json"),
931
+ previousIssuancePath: getArg("previous-issuance-json"),
932
+ nextIssuancePath: getArg("next-issuance-json"),
933
+ nextSimfPath: getArg("next-simf"),
934
+ nextArtifactPath: getArg("next-artifact"),
935
+ wallet: requireArg("wallet"),
936
+ signer: { type: "schnorrPrivkeyHex", privkeyHex: requireArg("privkey") },
937
+ feeSat: getArg("fee-sat") ? Number(getArg("fee-sat")) : undefined,
938
+ utxoPolicy: getArg("utxo-policy"),
939
+ broadcast: hasFlag("broadcast"),
940
+ });
941
+ printJson(result);
942
+ return;
943
+ }
944
+ if (command === "bond" && subcommand === "transition-payload") {
945
+ const result = await sdk.bonds.buildBondTransitionPayload({
946
+ definitionPath: getArg("definition-json"),
947
+ previousIssuancePath: getArg("previous-issuance-json"),
948
+ nextIssuancePath: getArg("next-issuance-json"),
949
+ });
950
+ printJson(result);
951
+ return;
952
+ }
953
+ if (command === "bond" && subcommand === "payload") {
954
+ const result = await sdk.bonds.buildBondPayload({
955
+ artifactPath: requireArg("artifact"),
956
+ definitionPath: getArg("definition-json"),
957
+ issuancePath: getArg("issuance-json"),
958
+ });
959
+ printJson(result);
960
+ return;
961
+ }
575
962
  if (command === "contract" && subcommand === "wait-funding") {
576
963
  const compiled = await sdk.loadArtifact(requireArg("artifact"));
577
964
  const utxos = await compiled.at().waitForFunding({
@@ -1,4 +1,4 @@
1
- import { ArtifactDefinitionMetadata, DeploymentInfo, SimplicityArtifact, SimplicityClientConfig } from "../core/types";
1
+ import { ArtifactDefinitionMetadata, ArtifactStateMetadata, DeploymentInfo, SimplicityArtifact, SimplicityClientConfig } from "../core/types";
2
2
  import { DeployedContract } from "./DeployedContract";
3
3
  export declare class CompiledContract {
4
4
  private readonly config;
@@ -8,6 +8,7 @@ export declare class CompiledContract {
8
8
  get cmr(): string;
9
9
  get program(): string;
10
10
  definition(): ArtifactDefinitionMetadata | null;
11
+ state(): ArtifactStateMetadata | null;
11
12
  deployment(): DeploymentInfo;
12
13
  saveArtifact(path: string): Promise<void>;
13
14
  at(addressOverride?: string): DeployedContract;
@@ -22,6 +22,9 @@ class CompiledContract {
22
22
  definition() {
23
23
  return this.artifact.definition ?? null;
24
24
  }
25
+ state() {
26
+ return this.artifact.state ?? null;
27
+ }
25
28
  deployment() {
26
29
  return {
27
30
  contractAddress: this.artifact.compiled.contractAddress,
@@ -1,5 +1,6 @@
1
1
  import { verifyDefinitionAgainstArtifact } from "../core/definition";
2
- import { ArtifactDefinitionMetadata, ContractUtxo, ExecuteCallInput, ExecuteResult, GaslessExecuteInput, GaslessExecuteResult, InspectCallInput, InspectResult, SimplicityArtifact, SimplicityClientConfig, WaitForFundingInput } from "../core/types";
2
+ import { verifyStateAgainstArtifact } from "../core/state";
3
+ import { ArtifactDefinitionMetadata, ArtifactStateMetadata, ContractUtxo, ExecuteCallInput, ExecuteResult, GaslessExecuteInput, GaslessExecuteResult, InspectCallInput, InspectResult, SimplicityArtifact, SimplicityClientConfig, WaitForFundingInput } from "../core/types";
3
4
  export declare class DeployedContract {
4
5
  private readonly config;
5
6
  readonly artifact: SimplicityArtifact;
@@ -23,4 +24,17 @@ export declare class DeployedContract {
23
24
  reason?: string;
24
25
  trust: Awaited<ReturnType<typeof verifyDefinitionAgainstArtifact>>["trust"];
25
26
  }>;
27
+ getTrustedState(input: {
28
+ jsonPath?: string;
29
+ value?: unknown;
30
+ type?: string;
31
+ id?: string;
32
+ schemaVersion?: string;
33
+ }): Promise<{
34
+ verified: boolean;
35
+ state: Awaited<ReturnType<typeof verifyStateAgainstArtifact>>["state"];
36
+ artifactState: ArtifactStateMetadata | null;
37
+ reason?: string;
38
+ trust: Awaited<ReturnType<typeof verifyStateAgainstArtifact>>["trust"];
39
+ }>;
26
40
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DeployedContract = void 0;
4
4
  const executor_1 = require("../core/executor");
5
5
  const definition_1 = require("../core/definition");
6
+ const state_1 = require("../core/state");
6
7
  const executor_2 = require("../core/executor");
7
8
  class DeployedContract {
8
9
  config;
@@ -61,5 +62,26 @@ class DeployedContract {
61
62
  trust: verification.trust,
62
63
  };
63
64
  }
65
+ async getTrustedState(input) {
66
+ const verification = await (0, state_1.verifyStateAgainstArtifact)({
67
+ artifact: this.artifact,
68
+ state: {
69
+ type: input.type ?? this.artifact.state?.stateType ?? "",
70
+ id: input.id ?? this.artifact.state?.stateId ?? "",
71
+ schemaVersion: input.schemaVersion,
72
+ jsonPath: input.jsonPath,
73
+ value: input.value,
74
+ },
75
+ expectedType: this.artifact.state?.stateType,
76
+ expectedId: this.artifact.state?.stateId,
77
+ });
78
+ return {
79
+ verified: verification.ok,
80
+ state: verification.state,
81
+ artifactState: verification.artifactState ?? null,
82
+ reason: verification.reason,
83
+ trust: verification.trust,
84
+ };
85
+ }
64
86
  }
65
87
  exports.DeployedContract = DeployedContract;