@meshsdk/contract 1.7.2 → 1.7.4

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/index.cjs CHANGED
@@ -22,7 +22,6 @@ var src_exports = {};
22
22
  __export(src_exports, {
23
23
  MeshEscrowBlueprint: () => MeshEscrowBlueprint,
24
24
  MeshEscrowContract: () => MeshEscrowContract,
25
- MeshGiftCardBlueprint: () => MeshGiftCardBlueprint,
26
25
  MeshGiftCardContract: () => MeshGiftCardContract,
27
26
  MeshHelloWorldBlueprint: () => MeshHelloWorldBlueprint,
28
27
  MeshHelloWorldContract: () => MeshHelloWorldContract,
@@ -32,7 +31,6 @@ __export(src_exports, {
32
31
  MeshPaymentSplitterContract: () => MeshPaymentSplitterContract,
33
32
  MeshSwapBlueprint: () => MeshSwapBlueprint,
34
33
  MeshSwapContract: () => MeshSwapContract,
35
- MeshVestingBlueprint: () => MeshVestingBlueprint,
36
34
  MeshVestingContract: () => MeshVestingContract,
37
35
  activeEscrowDatum: () => activeEscrowDatum,
38
36
  initiateEscrowDatum: () => initiateEscrowDatum,
@@ -54,12 +52,15 @@ var MeshTxInitiator = class {
54
52
  wallet;
55
53
  stakeCredential;
56
54
  networkId = 0;
55
+ version = 2;
56
+ languageVersion = "V2";
57
57
  constructor({
58
58
  mesh,
59
59
  fetcher,
60
60
  wallet,
61
61
  networkId = 0,
62
- stakeCredential
62
+ stakeCredential,
63
+ version = 2
63
64
  }) {
64
65
  this.mesh = mesh;
65
66
  if (fetcher) {
@@ -77,6 +78,14 @@ var MeshTxInitiator = class {
77
78
  if (stakeCredential) {
78
79
  this.stakeCredential = this.stakeCredential;
79
80
  }
81
+ this.version = version;
82
+ switch (this.version) {
83
+ case 1:
84
+ this.languageVersion = "V2";
85
+ break;
86
+ default:
87
+ this.languageVersion = "V3";
88
+ }
80
89
  }
81
90
  signSubmitReset = async () => {
82
91
  const signedTx = this.mesh.completeSigning();
@@ -456,7 +465,6 @@ var MeshEscrowContract = class extends MeshTxInitiator {
456
465
  scriptCbor = (0, import_core_csl2.applyParamsToScript)(plutus_default.validators[0].compiledCode, []);
457
466
  constructor(inputs) {
458
467
  super(inputs);
459
- this.mesh.setNetwork(inputs.networkId === 1 ? "mainnet" : "preprod");
460
468
  }
461
469
  initiateEscrow = async (escrowAmount) => {
462
470
  const { utxos, walletAddress } = await this.getWalletInfoForTx();
@@ -488,8 +496,14 @@ var MeshEscrowContract = class extends MeshTxInitiator {
488
496
  recipientAddressObj,
489
497
  recipientAmount
490
498
  ] = inputDatum.fields;
491
- const initiatorAddress = (0, import_core.serializeAddressObj)(initiatorAddressObj);
492
- const recipientAddress = (0, import_core.serializeAddressObj)(recipientAddressObj);
499
+ const initiatorAddress = (0, import_core.serializeAddressObj)(
500
+ initiatorAddressObj,
501
+ this.networkId
502
+ );
503
+ const recipientAddress = (0, import_core.serializeAddressObj)(
504
+ recipientAddressObj,
505
+ this.networkId
506
+ );
493
507
  const initiatorToReceive = import_common.MeshValue.fromValue(initiatorAmount).toAssets();
494
508
  const recipientToReceive = import_common.MeshValue.fromValue(
495
509
  recipientAmount
@@ -562,8 +576,14 @@ var MeshEscrowContract = class extends MeshTxInitiator {
562
576
  recipientAddressObj,
563
577
  recipientAmount
564
578
  ] = inputDatum.fields;
565
- const initiatorAddress = (0, import_core.serializeAddressObj)(initiatorAddressObj);
566
- const recipientAddress = (0, import_core.serializeAddressObj)(recipientAddressObj);
579
+ const initiatorAddress = (0, import_core.serializeAddressObj)(
580
+ initiatorAddressObj,
581
+ this.networkId
582
+ );
583
+ const recipientAddress = (0, import_core.serializeAddressObj)(
584
+ recipientAddressObj,
585
+ this.networkId
586
+ );
567
587
  const initiatorToReceive = import_common.MeshValue.fromValue(recipientAmount).toAssets();
568
588
  const recipientToReceive = import_common.MeshValue.fromValue(initiatorAmount).toAssets();
569
589
  await this.mesh.spendingPlutusScriptV2().txIn(
@@ -589,7 +609,7 @@ var import_common3 = require("@meshsdk/common");
589
609
  var import_core2 = require("@meshsdk/core");
590
610
  var import_core_csl3 = require("@meshsdk/core-csl");
591
611
 
592
- // src/giftcard/aiken-workspace/plutus.json
612
+ // src/giftcard/aiken-workspace-v1/plutus.json
593
613
  var plutus_default2 = {
594
614
  preamble: {
595
615
  title: "meshjs/giftcard",
@@ -729,22 +749,201 @@ var plutus_default2 = {
729
749
  }
730
750
  };
731
751
 
752
+ // src/giftcard/aiken-workspace-v2/plutus.json
753
+ var plutus_default3 = {
754
+ preamble: {
755
+ title: "meshjs/giftcard",
756
+ description: "Aiken contracts for project 'meshjs/giftcard'",
757
+ version: "0.0.0",
758
+ plutusVersion: "v3",
759
+ compiler: {
760
+ name: "Aiken",
761
+ version: "v1.1.0+unknown"
762
+ },
763
+ license: "Apache-2.0"
764
+ },
765
+ validators: [
766
+ {
767
+ title: "oneshot.gift_card.mint",
768
+ redeemer: {
769
+ title: "rdmr",
770
+ schema: {
771
+ $ref: "#/definitions/oneshot~1Action"
772
+ }
773
+ },
774
+ parameters: [
775
+ {
776
+ title: "token_name",
777
+ schema: {
778
+ $ref: "#/definitions/ByteArray"
779
+ }
780
+ },
781
+ {
782
+ title: "utxo_ref",
783
+ schema: {
784
+ $ref: "#/definitions/cardano~1transaction~1OutputReference"
785
+ }
786
+ }
787
+ ],
788
+ compiledCode: "5901ae01010032323232323232232225333005323232323253323300b3001300c3754004264646464a66601e600a0022a66602460226ea801c540085854ccc03cc00c00454ccc048c044dd50038a8010b0b18079baa006132323232533301430170021323253330133009301437540162a666026601260286ea8c8cc004004018894ccc0600045300103d87a80001323253330173375e603860326ea80080504cdd2a40006603600497ae0133004004001301c002301a00115333013300700113371e00402229405854ccc04ccdc3800a4002266e3c0080445281bad3014002375c60240022c602a00264a666020600860226ea800452f5bded8c026eacc054c048dd500099198008009bab3015301630163016301600322533301400114c103d87a80001323232325333015337220140042a66602a66e3c0280084cdd2a4000660326e980052f5c02980103d87a80001330060060033756602c0066eb8c050008c060008c058004dd6180980098079baa007370e90011bae3010300d37540046e1d200016300e300f002300d001300d002300b0013007375400229309b2b1bae0015734aae7555cf2ab9f5740ae855d11",
789
+ hash: "401c967008d42885400991f9225715e1c3a8e43757b1fd36a1328195"
790
+ },
791
+ {
792
+ title: "oneshot.gift_card.else",
793
+ parameters: [
794
+ {
795
+ title: "token_name",
796
+ schema: {
797
+ $ref: "#/definitions/ByteArray"
798
+ }
799
+ },
800
+ {
801
+ title: "utxo_ref",
802
+ schema: {
803
+ $ref: "#/definitions/cardano~1transaction~1OutputReference"
804
+ }
805
+ }
806
+ ],
807
+ compiledCode: "5901ae01010032323232323232232225333005323232323253323300b3001300c3754004264646464a66601e600a0022a66602460226ea801c540085854ccc03cc00c00454ccc048c044dd50038a8010b0b18079baa006132323232533301430170021323253330133009301437540162a666026601260286ea8c8cc004004018894ccc0600045300103d87a80001323253330173375e603860326ea80080504cdd2a40006603600497ae0133004004001301c002301a00115333013300700113371e00402229405854ccc04ccdc3800a4002266e3c0080445281bad3014002375c60240022c602a00264a666020600860226ea800452f5bded8c026eacc054c048dd500099198008009bab3015301630163016301600322533301400114c103d87a80001323232325333015337220140042a66602a66e3c0280084cdd2a4000660326e980052f5c02980103d87a80001330060060033756602c0066eb8c050008c060008c058004dd6180980098079baa007370e90011bae3010300d37540046e1d200016300e300f002300d001300d002300b0013007375400229309b2b1bae0015734aae7555cf2ab9f5740ae855d11",
808
+ hash: "401c967008d42885400991f9225715e1c3a8e43757b1fd36a1328195"
809
+ },
810
+ {
811
+ title: "oneshot.redeem.spend",
812
+ datum: {
813
+ title: "_d",
814
+ schema: {
815
+ $ref: "#/definitions/Data"
816
+ }
817
+ },
818
+ redeemer: {
819
+ title: "_r",
820
+ schema: {
821
+ $ref: "#/definitions/Data"
822
+ }
823
+ },
824
+ parameters: [
825
+ {
826
+ title: "token_name",
827
+ schema: {
828
+ $ref: "#/definitions/ByteArray"
829
+ }
830
+ },
831
+ {
832
+ title: "policy_id",
833
+ schema: {
834
+ $ref: "#/definitions/ByteArray"
835
+ }
836
+ }
837
+ ],
838
+ compiledCode: "59011501010032323232323232232232253330063232323232533300b3370e900118061baa001132323232325333013301600213253330113370e6eb4c04c009200113371e00201e2940dd718088008b180a00099299980799b8748008c040dd50008a5eb7bdb1804dd5980a18089baa001323300100137566028602a602a602a602a60226ea8020894ccc04c004530103d87a80001323232325333014337220200042a66602866e3c0400084cdd2a4000660306e980052f5c02980103d87a80001330060060033756602a0066eb8c04c008c05c008c054004c048c04c008c044004c034dd50008b1807980800118070009807001180600098041baa00114984d958dd70009bae0015734aae7555cf2ab9f5740ae855d101",
839
+ hash: "b2386630f1b210c58d0e46f132e931b362c3f373685118018e4d956f"
840
+ },
841
+ {
842
+ title: "oneshot.redeem.else",
843
+ parameters: [
844
+ {
845
+ title: "token_name",
846
+ schema: {
847
+ $ref: "#/definitions/ByteArray"
848
+ }
849
+ },
850
+ {
851
+ title: "policy_id",
852
+ schema: {
853
+ $ref: "#/definitions/ByteArray"
854
+ }
855
+ }
856
+ ],
857
+ compiledCode: "59011501010032323232323232232232253330063232323232533300b3370e900118061baa001132323232325333013301600213253330113370e6eb4c04c009200113371e00201e2940dd718088008b180a00099299980799b8748008c040dd50008a5eb7bdb1804dd5980a18089baa001323300100137566028602a602a602a602a60226ea8020894ccc04c004530103d87a80001323232325333014337220200042a66602866e3c0400084cdd2a4000660306e980052f5c02980103d87a80001330060060033756602a0066eb8c04c008c05c008c054004c048c04c008c044004c034dd50008b1807980800118070009807001180600098041baa00114984d958dd70009bae0015734aae7555cf2ab9f5740ae855d101",
858
+ hash: "b2386630f1b210c58d0e46f132e931b362c3f373685118018e4d956f"
859
+ }
860
+ ],
861
+ definitions: {
862
+ ByteArray: {
863
+ dataType: "bytes"
864
+ },
865
+ Data: {
866
+ title: "Data",
867
+ description: "Any Plutus data."
868
+ },
869
+ Int: {
870
+ dataType: "integer"
871
+ },
872
+ "cardano/transaction/OutputReference": {
873
+ title: "OutputReference",
874
+ description: "An `OutputReference` is a unique reference to an output on-chain. The `output_index`\n corresponds to the position in the output list of the transaction (identified by its id)\n that produced that output",
875
+ anyOf: [
876
+ {
877
+ title: "OutputReference",
878
+ dataType: "constructor",
879
+ index: 0,
880
+ fields: [
881
+ {
882
+ title: "transaction_id",
883
+ $ref: "#/definitions/ByteArray"
884
+ },
885
+ {
886
+ title: "output_index",
887
+ $ref: "#/definitions/Int"
888
+ }
889
+ ]
890
+ }
891
+ ]
892
+ },
893
+ "oneshot/Action": {
894
+ title: "Action",
895
+ anyOf: [
896
+ {
897
+ title: "Mint",
898
+ dataType: "constructor",
899
+ index: 0,
900
+ fields: []
901
+ },
902
+ {
903
+ title: "Burn",
904
+ dataType: "constructor",
905
+ index: 1,
906
+ fields: []
907
+ }
908
+ ]
909
+ }
910
+ }
911
+ };
912
+
732
913
  // src/giftcard/offchain.ts
733
- var MeshGiftCardBlueprint = plutus_default2;
734
914
  var MeshGiftCardContract = class extends MeshTxInitiator {
735
915
  tokenNameHex = "";
736
916
  paramUtxo = { outputIndex: 0, txHash: "" };
737
917
  giftCardCbor = (tokenNameHex, utxoTxHash, utxoTxId) => {
918
+ let scriptCbor;
919
+ let utxo;
920
+ switch (this.version) {
921
+ case 2:
922
+ scriptCbor = plutus_default3.validators[0].compiledCode;
923
+ utxo = (0, import_common3.outputReference)(utxoTxHash, utxoTxId);
924
+ break;
925
+ default:
926
+ scriptCbor = plutus_default2.validators[0].compiledCode;
927
+ utxo = (0, import_common3.txOutRef)(utxoTxHash, utxoTxId);
928
+ break;
929
+ }
738
930
  return (0, import_core_csl3.applyParamsToScript)(
739
- plutus_default2.validators[0].compiledCode,
740
- [(0, import_common3.builtinByteString)(tokenNameHex), (0, import_common3.txOutRef)(utxoTxHash, utxoTxId)],
931
+ scriptCbor,
932
+ [(0, import_common3.builtinByteString)(tokenNameHex), utxo],
741
933
  "JSON"
742
934
  );
743
935
  };
744
- redeemCbor = (tokenNameHex, policyId) => (0, import_core_csl3.applyParamsToScript)(plutus_default2.validators[1].compiledCode, [
745
- tokenNameHex,
746
- policyId
747
- ]);
936
+ redeemCbor = (tokenNameHex, policyId) => {
937
+ let scriptCbor;
938
+ switch (this.version) {
939
+ case 2:
940
+ scriptCbor = plutus_default3.validators[2].compiledCode;
941
+ break;
942
+ default:
943
+ scriptCbor = plutus_default2.validators[1].compiledCode;
944
+ }
945
+ return (0, import_core_csl3.applyParamsToScript)(scriptCbor, [tokenNameHex, policyId]);
946
+ };
748
947
  constructor(inputs, tokenNameHex, paramUtxo) {
749
948
  super(inputs);
750
949
  if (tokenNameHex) {
@@ -753,7 +952,6 @@ var MeshGiftCardContract = class extends MeshTxInitiator {
753
952
  if (paramUtxo) {
754
953
  this.paramUtxo = paramUtxo;
755
954
  }
756
- this.mesh.setNetwork(inputs.networkId === 1 ? "mainnet" : "preprod");
757
955
  }
758
956
  createGiftCard = async (tokenName2, giftValue) => {
759
957
  const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
@@ -766,10 +964,13 @@ var MeshGiftCardContract = class extends MeshTxInitiator {
766
964
  firstUtxo.input.txHash,
767
965
  firstUtxo.input.outputIndex
768
966
  );
769
- const giftCardPolicy = (0, import_core2.resolveScriptHash)(giftCardScript, "V2");
967
+ const giftCardPolicy = (0, import_core2.resolveScriptHash)(
968
+ giftCardScript,
969
+ this.languageVersion
970
+ );
770
971
  const redeemScript = {
771
972
  code: this.redeemCbor(tokenNameHex, giftCardPolicy),
772
- version: "V2"
973
+ version: this.languageVersion
773
974
  };
774
975
  const redeemAddr = (0, import_core2.serializePlutusScript)(
775
976
  redeemScript,
@@ -781,7 +982,7 @@ var MeshGiftCardContract = class extends MeshTxInitiator {
781
982
  firstUtxo.input.outputIndex,
782
983
  firstUtxo.output.amount,
783
984
  firstUtxo.output.address
784
- ).mintPlutusScriptV2().mint("1", giftCardPolicy, tokenNameHex).mintingScript(giftCardScript).mintRedeemerValue((0, import_common3.mConStr0)([])).txOut(redeemAddr, [
985
+ ).mintPlutusScript(this.languageVersion).mint("1", giftCardPolicy, tokenNameHex).mintingScript(giftCardScript).mintRedeemerValue((0, import_common3.mConStr0)([])).txOut(redeemAddr, [
785
986
  ...giftValue,
786
987
  { unit: giftCardPolicy + tokenNameHex, quantity: "1" }
787
988
  ]).txOutInlineDatumValue([
@@ -811,14 +1012,17 @@ var MeshGiftCardContract = class extends MeshTxInitiator {
811
1012
  paramTxHash,
812
1013
  paramTxId
813
1014
  );
814
- const giftCardPolicy = (0, import_core2.resolveScriptHash)(giftCardScript, "V2");
1015
+ const giftCardPolicy = (0, import_core2.resolveScriptHash)(
1016
+ giftCardScript,
1017
+ this.languageVersion
1018
+ );
815
1019
  const redeemScript = this.redeemCbor(tokenNameHex, giftCardPolicy);
816
- await this.mesh.spendingPlutusScriptV2().txIn(
1020
+ await this.mesh.spendingPlutusScript(this.languageVersion).txIn(
817
1021
  giftCardUtxo.input.txHash,
818
1022
  giftCardUtxo.input.outputIndex,
819
1023
  giftCardUtxo.output.amount,
820
1024
  giftCardUtxo.output.address
821
- ).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue("").txInScript(redeemScript).mintPlutusScriptV2().mint("-1", giftCardPolicy, tokenNameHex).mintingScript(giftCardScript).mintRedeemerValue((0, import_common3.mConStr1)([])).changeAddress(walletAddress).txInCollateral(
1025
+ ).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue("").txInScript(redeemScript).mintPlutusScript(this.languageVersion).mint("-1", giftCardPolicy, tokenNameHex).mintingScript(giftCardScript).mintRedeemerValue((0, import_common3.mConStr1)([])).changeAddress(walletAddress).txInCollateral(
822
1026
  collateral.input.txHash,
823
1027
  collateral.input.outputIndex,
824
1028
  collateral.output.amount,
@@ -836,7 +1040,7 @@ var import_core3 = require("@meshsdk/core");
836
1040
  var import_core_csl4 = require("@meshsdk/core-csl");
837
1041
 
838
1042
  // src/hello-world/aiken-workspace/plutus.json
839
- var plutus_default3 = {
1043
+ var plutus_default4 = {
840
1044
  preamble: {
841
1045
  title: "meshjs/aiken",
842
1046
  description: "Aiken on MeshJS",
@@ -907,12 +1111,11 @@ var plutus_default3 = {
907
1111
  };
908
1112
 
909
1113
  // src/hello-world/offchain.ts
910
- var MeshHelloWorldBlueprint = plutus_default3;
1114
+ var MeshHelloWorldBlueprint = plutus_default4;
911
1115
  var MeshHelloWorldContract = class extends MeshTxInitiator {
912
- scriptCbor = (0, import_core_csl4.applyParamsToScript)(plutus_default3.validators[0].compiledCode, []);
1116
+ scriptCbor = (0, import_core_csl4.applyParamsToScript)(plutus_default4.validators[0].compiledCode, []);
913
1117
  constructor(inputs) {
914
1118
  super(inputs);
915
- this.mesh.setNetwork(inputs.networkId === 1 ? "mainnet" : "preprod");
916
1119
  }
917
1120
  getScript = () => {
918
1121
  const { address } = (0, import_core3.serializePlutusScript)(
@@ -958,7 +1161,7 @@ var import_core4 = require("@meshsdk/core");
958
1161
  var import_core_csl5 = require("@meshsdk/core-csl");
959
1162
 
960
1163
  // src/marketplace/aiken-workspace/plutus.json
961
- var plutus_default4 = {
1164
+ var plutus_default5 = {
962
1165
  preamble: {
963
1166
  title: "meshjs/marketplace",
964
1167
  description: "Aiken contracts for project 'meshjs/marketplace'",
@@ -1164,7 +1367,7 @@ var plutus_default4 = {
1164
1367
  };
1165
1368
 
1166
1369
  // src/marketplace/offchain.ts
1167
- var MeshMarketplaceBlueprint = plutus_default4;
1370
+ var MeshMarketplaceBlueprint = plutus_default5;
1168
1371
  var marketplaceDatum = (sellerAddress, lovelaceFee, assetHex) => {
1169
1372
  const { pubKeyHash, stakeCredentialHash } = (0, import_core4.deserializeAddress)(sellerAddress);
1170
1373
  const { policyId, assetName } = (0, import_common6.parseAssetUnit)(assetHex);
@@ -1185,14 +1388,13 @@ var MeshMarketplaceContract = class extends MeshTxInitiator {
1185
1388
  this.feePercentageBasisPoint = feePercentageBasisPoint;
1186
1389
  const { pubKeyHash, stakeCredentialHash } = (0, import_core4.deserializeAddress)(ownerAddress);
1187
1390
  this.scriptCbor = (0, import_core_csl5.applyParamsToScript)(
1188
- plutus_default4.validators[0].compiledCode,
1391
+ plutus_default5.validators[0].compiledCode,
1189
1392
  [
1190
1393
  (0, import_common6.pubKeyAddress)(pubKeyHash, stakeCredentialHash),
1191
1394
  (0, import_common6.integer)(feePercentageBasisPoint)
1192
1395
  ],
1193
1396
  "JSON"
1194
1397
  );
1195
- this.mesh.setNetwork(inputs.networkId === 1 ? "mainnet" : "preprod");
1196
1398
  }
1197
1399
  listAsset = async (asset, price) => {
1198
1400
  const { utxos, walletAddress } = await this.getWalletInfoForTx();
@@ -1258,7 +1460,10 @@ var MeshMarketplaceContract = class extends MeshTxInitiator {
1258
1460
  }
1259
1461
  const sellerToReceiveLovelace = inputDatum.fields[1].int + Number(inputLovelace);
1260
1462
  if (sellerToReceiveLovelace > 0) {
1261
- const sellerAddress = (0, import_core4.serializeAddressObj)(inputDatum.fields[0]);
1463
+ const sellerAddress = (0, import_core4.serializeAddressObj)(
1464
+ inputDatum.fields[0],
1465
+ this.networkId
1466
+ );
1262
1467
  const sellerToReceive = [
1263
1468
  {
1264
1469
  unit: "lovelace",
@@ -1306,7 +1511,7 @@ var import_core5 = require("@meshsdk/core");
1306
1511
  var import_core_csl6 = require("@meshsdk/core-csl");
1307
1512
 
1308
1513
  // src/payment-splitter/aiken-workspace/plutus.json
1309
- var plutus_default5 = {
1514
+ var plutus_default6 = {
1310
1515
  preamble: {
1311
1516
  title: "fabianbormann/payment-splitter",
1312
1517
  description: "Aiken contracts for project 'fabianbormann/payment-splitter'",
@@ -1391,7 +1596,7 @@ var plutus_default5 = {
1391
1596
  };
1392
1597
 
1393
1598
  // src/payment-splitter/offchain.ts
1394
- var MeshPaymentSplitterBlueprint = plutus_default5;
1599
+ var MeshPaymentSplitterBlueprint = plutus_default6;
1395
1600
  var MeshPaymentSplitterContract = class extends MeshTxInitiator {
1396
1601
  wrapPayees = (payees) => (0, import_common8.list)(
1397
1602
  payees.map(
@@ -1399,7 +1604,7 @@ var MeshPaymentSplitterContract = class extends MeshTxInitiator {
1399
1604
  )
1400
1605
  );
1401
1606
  scriptCbor = () => (0, import_core_csl6.applyParamsToScript)(
1402
- plutus_default5.validators[0].compiledCode,
1607
+ plutus_default6.validators[0].compiledCode,
1403
1608
  [this.wrapPayees(this.payees)],
1404
1609
  "JSON"
1405
1610
  );
@@ -1421,7 +1626,6 @@ var MeshPaymentSplitterContract = class extends MeshTxInitiator {
1421
1626
  "Wallet not provided. Therefore the payment address will not be added to the payees list which makes it impossible to trigger the payout."
1422
1627
  );
1423
1628
  }
1424
- this.mesh.setNetwork(inputs.networkId === 1 ? "mainnet" : "preprod");
1425
1629
  }
1426
1630
  sendLovelaceToSplitter = async (lovelaceAmount) => {
1427
1631
  if (this.wallet === null || this.wallet === void 0) {
@@ -1507,7 +1711,7 @@ var import_core6 = require("@meshsdk/core");
1507
1711
  var import_core_csl7 = require("@meshsdk/core-csl");
1508
1712
 
1509
1713
  // src/swap/aiken-workspace/plutus.json
1510
- var plutus_default6 = {
1714
+ var plutus_default7 = {
1511
1715
  preamble: {
1512
1716
  title: "meshjs/swap",
1513
1717
  description: "Aiken contracts for project 'meshjs/swap'",
@@ -1713,9 +1917,9 @@ var plutus_default6 = {
1713
1917
  };
1714
1918
 
1715
1919
  // src/swap/offchain.ts
1716
- var MeshSwapBlueprint = plutus_default6;
1920
+ var MeshSwapBlueprint = plutus_default7;
1717
1921
  var MeshSwapContract = class extends MeshTxInitiator {
1718
- scriptCbor = (0, import_core_csl7.applyParamsToScript)(plutus_default6.validators[0].compiledCode, []);
1922
+ scriptCbor = (0, import_core_csl7.applyParamsToScript)(plutus_default7.validators[0].compiledCode, []);
1719
1923
  scriptAddress;
1720
1924
  constructor(inputs) {
1721
1925
  super(inputs);
@@ -1724,7 +1928,6 @@ var MeshSwapContract = class extends MeshTxInitiator {
1724
1928
  void 0,
1725
1929
  inputs.networkId
1726
1930
  ).address;
1727
- this.mesh.setNetwork(inputs.networkId === 1 ? "mainnet" : "preprod");
1728
1931
  }
1729
1932
  initiateSwap = async (toProvide, toReceive) => {
1730
1933
  const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
@@ -1747,7 +1950,10 @@ var MeshSwapContract = class extends MeshTxInitiator {
1747
1950
  const inlineDatum = (0, import_core6.deserializeDatum)(
1748
1951
  swapUtxo.output.plutusData
1749
1952
  );
1750
- const initiatorAddress = (0, import_core6.serializeAddressObj)(inlineDatum.fields[0]);
1953
+ const initiatorAddress = (0, import_core6.serializeAddressObj)(
1954
+ inlineDatum.fields[0],
1955
+ this.networkId
1956
+ );
1751
1957
  const initiatorToReceive = inlineDatum.fields[2];
1752
1958
  await this.mesh.spendingPlutusScriptV2().txIn(
1753
1959
  swapUtxo.input.txHash,
@@ -1770,7 +1976,10 @@ var MeshSwapContract = class extends MeshTxInitiator {
1770
1976
  const inlineDatum = (0, import_core6.deserializeDatum)(
1771
1977
  swapUtxo.output.plutusData
1772
1978
  );
1773
- const initiatorAddress = (0, import_core6.serializeAddressObj)(inlineDatum.fields[0]);
1979
+ const initiatorAddress = (0, import_core6.serializeAddressObj)(
1980
+ inlineDatum.fields[0],
1981
+ this.networkId
1982
+ );
1774
1983
  await this.mesh.spendingPlutusScriptV2().txIn(
1775
1984
  swapUtxo.input.txHash,
1776
1985
  swapUtxo.input.outputIndex,
@@ -1794,8 +2003,8 @@ var import_common12 = require("@meshsdk/common");
1794
2003
  var import_core7 = require("@meshsdk/core");
1795
2004
  var import_core_csl8 = require("@meshsdk/core-csl");
1796
2005
 
1797
- // src/vesting/aiken-workspace/plutus.json
1798
- var plutus_default7 = {
2006
+ // src/vesting/aiken-workspace-v1/plutus.json
2007
+ var plutus_default8 = {
1799
2008
  preamble: {
1800
2009
  title: "meshjs/vesting",
1801
2010
  description: "Aiken contracts for project 'meshjs/vesting'",
@@ -1867,18 +2076,111 @@ var plutus_default7 = {
1867
2076
  }
1868
2077
  };
1869
2078
 
2079
+ // src/vesting/aiken-workspace-v2/plutus.json
2080
+ var plutus_default9 = {
2081
+ preamble: {
2082
+ title: "meshjs/vesting",
2083
+ description: "Aiken contracts for project 'meshjs/vesting'",
2084
+ version: "0.0.0",
2085
+ plutusVersion: "v3",
2086
+ compiler: {
2087
+ name: "Aiken",
2088
+ version: "v1.1.0+unknown"
2089
+ },
2090
+ license: "Apache-2.0"
2091
+ },
2092
+ validators: [
2093
+ {
2094
+ title: "vesting.vesting.spend",
2095
+ datum: {
2096
+ title: "datum_opt",
2097
+ schema: {
2098
+ $ref: "#/definitions/vesting~1VestingDatum"
2099
+ }
2100
+ },
2101
+ redeemer: {
2102
+ title: "_redeemer",
2103
+ schema: {
2104
+ $ref: "#/definitions/Data"
2105
+ }
2106
+ },
2107
+ compiledCode: "5901a7010100323232323232322533300232323232325332330083001300937540042646464a66601666e1d2000300c37540022646464a66601c660026eb0c008c040dd50059bae3013301430103754006294454ccc038cc004dd6180118081baa00b375c60266028602860206ea800c4c8cc88c8c8c8c8c94ccc058c03cc05cdd5001099299980b802099b88007001002375a603660306ea80080044c94ccc058c03cc05cdd5001099299980b802001099b89007001375a603660306ea8008004528180c8011806180a1baa3018301900133016301700133016333012300b30133754602e603000298103d87a80004c0103d87980004bd7018099baa3003301337540046028602a602a602a602a602a602a602a60226ea8030dd6980098089baa0042301400114a044646600200200644a66602800229404c94ccc048cdc79bae301700200414a2266006006002602e00246024602660266026602660266026602660260026020601a6ea800458c03cc040008c038004c028dd50011b874800858c02cc030008c028004c028008c020004c010dd50008a4c26cacae6955ceaab9e5573eae815d0aba21",
2108
+ hash: "d13324c13a48b69d67ccfc88e3e87f046f4417f57f5c740d515249fb"
2109
+ },
2110
+ {
2111
+ title: "vesting.vesting.else",
2112
+ compiledCode: "5901a7010100323232323232322533300232323232325332330083001300937540042646464a66601666e1d2000300c37540022646464a66601c660026eb0c008c040dd50059bae3013301430103754006294454ccc038cc004dd6180118081baa00b375c60266028602860206ea800c4c8cc88c8c8c8c8c94ccc058c03cc05cdd5001099299980b802099b88007001002375a603660306ea80080044c94ccc058c03cc05cdd5001099299980b802001099b89007001375a603660306ea8008004528180c8011806180a1baa3018301900133016301700133016333012300b30133754602e603000298103d87a80004c0103d87980004bd7018099baa3003301337540046028602a602a602a602a602a602a602a60226ea8030dd6980098089baa0042301400114a044646600200200644a66602800229404c94ccc048cdc79bae301700200414a2266006006002602e00246024602660266026602660266026602660260026020601a6ea800458c03cc040008c038004c028dd50011b874800858c02cc030008c028004c028008c020004c010dd50008a4c26cacae6955ceaab9e5573eae815d0aba21",
2113
+ hash: "d13324c13a48b69d67ccfc88e3e87f046f4417f57f5c740d515249fb"
2114
+ }
2115
+ ],
2116
+ definitions: {
2117
+ ByteArray: {
2118
+ dataType: "bytes"
2119
+ },
2120
+ Data: {
2121
+ title: "Data",
2122
+ description: "Any Plutus data."
2123
+ },
2124
+ Int: {
2125
+ dataType: "integer"
2126
+ },
2127
+ "vesting/VestingDatum": {
2128
+ title: "VestingDatum",
2129
+ anyOf: [
2130
+ {
2131
+ title: "VestingDatum",
2132
+ dataType: "constructor",
2133
+ index: 0,
2134
+ fields: [
2135
+ {
2136
+ title: "lock_until",
2137
+ description: "POSIX time in milliseconds, e.g. 1672843961000",
2138
+ $ref: "#/definitions/Int"
2139
+ },
2140
+ {
2141
+ title: "owner",
2142
+ description: "Owner's credentials",
2143
+ $ref: "#/definitions/ByteArray"
2144
+ },
2145
+ {
2146
+ title: "beneficiary",
2147
+ description: "Beneficiary's credentials",
2148
+ $ref: "#/definitions/ByteArray"
2149
+ }
2150
+ ]
2151
+ }
2152
+ ]
2153
+ }
2154
+ }
2155
+ };
2156
+
1870
2157
  // src/vesting/offchain.ts
1871
- var MeshVestingBlueprint = plutus_default7;
1872
2158
  var MeshVestingContract = class extends MeshTxInitiator {
1873
- scriptCbor = (0, import_core_csl8.applyParamsToScript)(plutus_default7.validators[0].compiledCode, []);
1874
2159
  constructor(inputs) {
1875
2160
  super(inputs);
1876
- this.mesh.setNetwork(inputs.networkId === 1 ? "mainnet" : "preprod");
1877
2161
  }
2162
+ getScriptCbor = () => {
2163
+ let scriptCbor;
2164
+ switch (this.version) {
2165
+ case 2:
2166
+ scriptCbor = (0, import_core_csl8.applyParamsToScript)(
2167
+ plutus_default9.validators[0].compiledCode,
2168
+ []
2169
+ );
2170
+ break;
2171
+ default:
2172
+ scriptCbor = (0, import_core_csl8.applyParamsToScript)(
2173
+ plutus_default8.validators[0].compiledCode,
2174
+ []
2175
+ );
2176
+ break;
2177
+ }
2178
+ return scriptCbor;
2179
+ };
1878
2180
  depositFund = async (amount, lockUntilTimeStampMs, beneficiary) => {
1879
2181
  const { utxos, walletAddress } = await this.getWalletInfoForTx();
1880
2182
  const scriptAddr = (0, import_core7.serializePlutusScript)(
1881
- { code: this.scriptCbor, version: "V2" },
2183
+ { code: this.getScriptCbor(), version: this.languageVersion },
1882
2184
  void 0,
1883
2185
  this.networkId
1884
2186
  ).address;
@@ -1896,8 +2198,9 @@ var MeshVestingContract = class extends MeshTxInitiator {
1896
2198
  withdrawFund = async (vestingUtxo) => {
1897
2199
  const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
1898
2200
  const { input: collateralInput, output: collateralOutput } = collateral;
2201
+ const scriptCbor = this.getScriptCbor();
1899
2202
  const scriptAddr = (0, import_core7.serializePlutusScript)(
1900
- { code: this.scriptCbor, version: "V2" },
2203
+ { code: scriptCbor, version: this.languageVersion },
1901
2204
  void 0,
1902
2205
  this.networkId
1903
2206
  ).address;
@@ -1909,12 +2212,12 @@ var MeshVestingContract = class extends MeshTxInitiator {
1909
2212
  Math.min(datum.fields[0].int, Date.now() - 15e3),
1910
2213
  this.networkId === 0 ? import_common12.SLOT_CONFIG_NETWORK.preprod : import_common12.SLOT_CONFIG_NETWORK.mainnet
1911
2214
  ) + 1;
1912
- await this.mesh.spendingPlutusScriptV2().txIn(
2215
+ await this.mesh.spendingPlutusScript(this.languageVersion).txIn(
1913
2216
  vestingUtxo.input.txHash,
1914
2217
  vestingUtxo.input.outputIndex,
1915
2218
  vestingUtxo.output.amount,
1916
2219
  scriptAddr
1917
- ).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue("").txInScript(this.scriptCbor).txOut(walletAddress, []).txInCollateral(
2220
+ ).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue("").txInScript(scriptCbor).txOut(walletAddress, []).txInCollateral(
1918
2221
  collateralInput.txHash,
1919
2222
  collateralInput.outputIndex,
1920
2223
  collateralOutput.amount,
@@ -1923,14 +2226,13 @@ var MeshVestingContract = class extends MeshTxInitiator {
1923
2226
  return this.mesh.txHex;
1924
2227
  };
1925
2228
  getUtxoByTxHash = async (txHash) => {
1926
- return await this._getUtxoByTxHash(txHash, this.scriptCbor);
2229
+ return await this._getUtxoByTxHash(txHash, this.getScriptCbor());
1927
2230
  };
1928
2231
  };
1929
2232
  // Annotate the CommonJS export names for ESM import in node:
1930
2233
  0 && (module.exports = {
1931
2234
  MeshEscrowBlueprint,
1932
2235
  MeshEscrowContract,
1933
- MeshGiftCardBlueprint,
1934
2236
  MeshGiftCardContract,
1935
2237
  MeshHelloWorldBlueprint,
1936
2238
  MeshHelloWorldContract,
@@ -1940,7 +2242,6 @@ var MeshVestingContract = class extends MeshTxInitiator {
1940
2242
  MeshPaymentSplitterContract,
1941
2243
  MeshSwapBlueprint,
1942
2244
  MeshSwapContract,
1943
- MeshVestingBlueprint,
1944
2245
  MeshVestingContract,
1945
2246
  activeEscrowDatum,
1946
2247
  initiateEscrowDatum,