@meshsdk/contract 1.7.2 → 1.7.3

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.js CHANGED
@@ -25,12 +25,15 @@ var MeshTxInitiator = class {
25
25
  wallet;
26
26
  stakeCredential;
27
27
  networkId = 0;
28
+ version = 2;
29
+ languageVersion = "V2";
28
30
  constructor({
29
31
  mesh,
30
32
  fetcher,
31
33
  wallet,
32
34
  networkId = 0,
33
- stakeCredential
35
+ stakeCredential,
36
+ version = 2
34
37
  }) {
35
38
  this.mesh = mesh;
36
39
  if (fetcher) {
@@ -48,6 +51,14 @@ var MeshTxInitiator = class {
48
51
  if (stakeCredential) {
49
52
  this.stakeCredential = this.stakeCredential;
50
53
  }
54
+ this.version = version;
55
+ switch (this.version) {
56
+ case 1:
57
+ this.languageVersion = "V2";
58
+ break;
59
+ default:
60
+ this.languageVersion = "V3";
61
+ }
51
62
  }
52
63
  signSubmitReset = async () => {
53
64
  const signedTx = this.mesh.completeSigning();
@@ -427,7 +438,6 @@ var MeshEscrowContract = class extends MeshTxInitiator {
427
438
  scriptCbor = applyParamsToScript(plutus_default.validators[0].compiledCode, []);
428
439
  constructor(inputs) {
429
440
  super(inputs);
430
- this.mesh.setNetwork(inputs.networkId === 1 ? "mainnet" : "preprod");
431
441
  }
432
442
  initiateEscrow = async (escrowAmount) => {
433
443
  const { utxos, walletAddress } = await this.getWalletInfoForTx();
@@ -459,8 +469,14 @@ var MeshEscrowContract = class extends MeshTxInitiator {
459
469
  recipientAddressObj,
460
470
  recipientAmount
461
471
  ] = inputDatum.fields;
462
- const initiatorAddress = serializeAddressObj(initiatorAddressObj);
463
- const recipientAddress = serializeAddressObj(recipientAddressObj);
472
+ const initiatorAddress = serializeAddressObj(
473
+ initiatorAddressObj,
474
+ this.networkId
475
+ );
476
+ const recipientAddress = serializeAddressObj(
477
+ recipientAddressObj,
478
+ this.networkId
479
+ );
464
480
  const initiatorToReceive = MeshValue.fromValue(initiatorAmount).toAssets();
465
481
  const recipientToReceive = MeshValue.fromValue(
466
482
  recipientAmount
@@ -533,8 +549,14 @@ var MeshEscrowContract = class extends MeshTxInitiator {
533
549
  recipientAddressObj,
534
550
  recipientAmount
535
551
  ] = inputDatum.fields;
536
- const initiatorAddress = serializeAddressObj(initiatorAddressObj);
537
- const recipientAddress = serializeAddressObj(recipientAddressObj);
552
+ const initiatorAddress = serializeAddressObj(
553
+ initiatorAddressObj,
554
+ this.networkId
555
+ );
556
+ const recipientAddress = serializeAddressObj(
557
+ recipientAddressObj,
558
+ this.networkId
559
+ );
538
560
  const initiatorToReceive = MeshValue.fromValue(recipientAmount).toAssets();
539
561
  const recipientToReceive = MeshValue.fromValue(initiatorAmount).toAssets();
540
562
  await this.mesh.spendingPlutusScriptV2().txIn(
@@ -560,6 +582,7 @@ import {
560
582
  builtinByteString,
561
583
  mConStr0,
562
584
  mConStr1 as mConStr12,
585
+ outputReference,
563
586
  stringToHex,
564
587
  txOutRef
565
588
  } from "@meshsdk/common";
@@ -570,7 +593,7 @@ import {
570
593
  } from "@meshsdk/core";
571
594
  import { applyParamsToScript as applyParamsToScript2 } from "@meshsdk/core-csl";
572
595
 
573
- // src/giftcard/aiken-workspace/plutus.json
596
+ // src/giftcard/aiken-workspace-v1/plutus.json
574
597
  var plutus_default2 = {
575
598
  preamble: {
576
599
  title: "meshjs/giftcard",
@@ -710,22 +733,201 @@ var plutus_default2 = {
710
733
  }
711
734
  };
712
735
 
736
+ // src/giftcard/aiken-workspace-v2/plutus.json
737
+ var plutus_default3 = {
738
+ preamble: {
739
+ title: "meshjs/giftcard",
740
+ description: "Aiken contracts for project 'meshjs/giftcard'",
741
+ version: "0.0.0",
742
+ plutusVersion: "v3",
743
+ compiler: {
744
+ name: "Aiken",
745
+ version: "v1.1.0+unknown"
746
+ },
747
+ license: "Apache-2.0"
748
+ },
749
+ validators: [
750
+ {
751
+ title: "oneshot.gift_card.mint",
752
+ redeemer: {
753
+ title: "rdmr",
754
+ schema: {
755
+ $ref: "#/definitions/oneshot~1Action"
756
+ }
757
+ },
758
+ parameters: [
759
+ {
760
+ title: "token_name",
761
+ schema: {
762
+ $ref: "#/definitions/ByteArray"
763
+ }
764
+ },
765
+ {
766
+ title: "utxo_ref",
767
+ schema: {
768
+ $ref: "#/definitions/cardano~1transaction~1OutputReference"
769
+ }
770
+ }
771
+ ],
772
+ compiledCode: "5901ae01010032323232323232232225333005323232323253323300b3001300c3754004264646464a66601e600a0022a66602460226ea801c540085854ccc03cc00c00454ccc048c044dd50038a8010b0b18079baa006132323232533301430170021323253330133009301437540162a666026601260286ea8c8cc004004018894ccc0600045300103d87a80001323253330173375e603860326ea80080504cdd2a40006603600497ae0133004004001301c002301a00115333013300700113371e00402229405854ccc04ccdc3800a4002266e3c0080445281bad3014002375c60240022c602a00264a666020600860226ea800452f5bded8c026eacc054c048dd500099198008009bab3015301630163016301600322533301400114c103d87a80001323232325333015337220140042a66602a66e3c0280084cdd2a4000660326e980052f5c02980103d87a80001330060060033756602c0066eb8c050008c060008c058004dd6180980098079baa007370e90011bae3010300d37540046e1d200016300e300f002300d001300d002300b0013007375400229309b2b1bae0015734aae7555cf2ab9f5740ae855d11",
773
+ hash: "401c967008d42885400991f9225715e1c3a8e43757b1fd36a1328195"
774
+ },
775
+ {
776
+ title: "oneshot.gift_card.else",
777
+ parameters: [
778
+ {
779
+ title: "token_name",
780
+ schema: {
781
+ $ref: "#/definitions/ByteArray"
782
+ }
783
+ },
784
+ {
785
+ title: "utxo_ref",
786
+ schema: {
787
+ $ref: "#/definitions/cardano~1transaction~1OutputReference"
788
+ }
789
+ }
790
+ ],
791
+ compiledCode: "5901ae01010032323232323232232225333005323232323253323300b3001300c3754004264646464a66601e600a0022a66602460226ea801c540085854ccc03cc00c00454ccc048c044dd50038a8010b0b18079baa006132323232533301430170021323253330133009301437540162a666026601260286ea8c8cc004004018894ccc0600045300103d87a80001323253330173375e603860326ea80080504cdd2a40006603600497ae0133004004001301c002301a00115333013300700113371e00402229405854ccc04ccdc3800a4002266e3c0080445281bad3014002375c60240022c602a00264a666020600860226ea800452f5bded8c026eacc054c048dd500099198008009bab3015301630163016301600322533301400114c103d87a80001323232325333015337220140042a66602a66e3c0280084cdd2a4000660326e980052f5c02980103d87a80001330060060033756602c0066eb8c050008c060008c058004dd6180980098079baa007370e90011bae3010300d37540046e1d200016300e300f002300d001300d002300b0013007375400229309b2b1bae0015734aae7555cf2ab9f5740ae855d11",
792
+ hash: "401c967008d42885400991f9225715e1c3a8e43757b1fd36a1328195"
793
+ },
794
+ {
795
+ title: "oneshot.redeem.spend",
796
+ datum: {
797
+ title: "_d",
798
+ schema: {
799
+ $ref: "#/definitions/Data"
800
+ }
801
+ },
802
+ redeemer: {
803
+ title: "_r",
804
+ schema: {
805
+ $ref: "#/definitions/Data"
806
+ }
807
+ },
808
+ parameters: [
809
+ {
810
+ title: "token_name",
811
+ schema: {
812
+ $ref: "#/definitions/ByteArray"
813
+ }
814
+ },
815
+ {
816
+ title: "policy_id",
817
+ schema: {
818
+ $ref: "#/definitions/ByteArray"
819
+ }
820
+ }
821
+ ],
822
+ compiledCode: "59011501010032323232323232232232253330063232323232533300b3370e900118061baa001132323232325333013301600213253330113370e6eb4c04c009200113371e00201e2940dd718088008b180a00099299980799b8748008c040dd50008a5eb7bdb1804dd5980a18089baa001323300100137566028602a602a602a602a60226ea8020894ccc04c004530103d87a80001323232325333014337220200042a66602866e3c0400084cdd2a4000660306e980052f5c02980103d87a80001330060060033756602a0066eb8c04c008c05c008c054004c048c04c008c044004c034dd50008b1807980800118070009807001180600098041baa00114984d958dd70009bae0015734aae7555cf2ab9f5740ae855d101",
823
+ hash: "b2386630f1b210c58d0e46f132e931b362c3f373685118018e4d956f"
824
+ },
825
+ {
826
+ title: "oneshot.redeem.else",
827
+ parameters: [
828
+ {
829
+ title: "token_name",
830
+ schema: {
831
+ $ref: "#/definitions/ByteArray"
832
+ }
833
+ },
834
+ {
835
+ title: "policy_id",
836
+ schema: {
837
+ $ref: "#/definitions/ByteArray"
838
+ }
839
+ }
840
+ ],
841
+ compiledCode: "59011501010032323232323232232232253330063232323232533300b3370e900118061baa001132323232325333013301600213253330113370e6eb4c04c009200113371e00201e2940dd718088008b180a00099299980799b8748008c040dd50008a5eb7bdb1804dd5980a18089baa001323300100137566028602a602a602a602a60226ea8020894ccc04c004530103d87a80001323232325333014337220200042a66602866e3c0400084cdd2a4000660306e980052f5c02980103d87a80001330060060033756602a0066eb8c04c008c05c008c054004c048c04c008c044004c034dd50008b1807980800118070009807001180600098041baa00114984d958dd70009bae0015734aae7555cf2ab9f5740ae855d101",
842
+ hash: "b2386630f1b210c58d0e46f132e931b362c3f373685118018e4d956f"
843
+ }
844
+ ],
845
+ definitions: {
846
+ ByteArray: {
847
+ dataType: "bytes"
848
+ },
849
+ Data: {
850
+ title: "Data",
851
+ description: "Any Plutus data."
852
+ },
853
+ Int: {
854
+ dataType: "integer"
855
+ },
856
+ "cardano/transaction/OutputReference": {
857
+ title: "OutputReference",
858
+ 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",
859
+ anyOf: [
860
+ {
861
+ title: "OutputReference",
862
+ dataType: "constructor",
863
+ index: 0,
864
+ fields: [
865
+ {
866
+ title: "transaction_id",
867
+ $ref: "#/definitions/ByteArray"
868
+ },
869
+ {
870
+ title: "output_index",
871
+ $ref: "#/definitions/Int"
872
+ }
873
+ ]
874
+ }
875
+ ]
876
+ },
877
+ "oneshot/Action": {
878
+ title: "Action",
879
+ anyOf: [
880
+ {
881
+ title: "Mint",
882
+ dataType: "constructor",
883
+ index: 0,
884
+ fields: []
885
+ },
886
+ {
887
+ title: "Burn",
888
+ dataType: "constructor",
889
+ index: 1,
890
+ fields: []
891
+ }
892
+ ]
893
+ }
894
+ }
895
+ };
896
+
713
897
  // src/giftcard/offchain.ts
714
- var MeshGiftCardBlueprint = plutus_default2;
715
898
  var MeshGiftCardContract = class extends MeshTxInitiator {
716
899
  tokenNameHex = "";
717
900
  paramUtxo = { outputIndex: 0, txHash: "" };
718
901
  giftCardCbor = (tokenNameHex, utxoTxHash, utxoTxId) => {
902
+ let scriptCbor;
903
+ let utxo;
904
+ switch (this.version) {
905
+ case 2:
906
+ scriptCbor = plutus_default3.validators[0].compiledCode;
907
+ utxo = outputReference(utxoTxHash, utxoTxId);
908
+ break;
909
+ default:
910
+ scriptCbor = plutus_default2.validators[0].compiledCode;
911
+ utxo = txOutRef(utxoTxHash, utxoTxId);
912
+ break;
913
+ }
719
914
  return applyParamsToScript2(
720
- plutus_default2.validators[0].compiledCode,
721
- [builtinByteString(tokenNameHex), txOutRef(utxoTxHash, utxoTxId)],
915
+ scriptCbor,
916
+ [builtinByteString(tokenNameHex), utxo],
722
917
  "JSON"
723
918
  );
724
919
  };
725
- redeemCbor = (tokenNameHex, policyId) => applyParamsToScript2(plutus_default2.validators[1].compiledCode, [
726
- tokenNameHex,
727
- policyId
728
- ]);
920
+ redeemCbor = (tokenNameHex, policyId) => {
921
+ let scriptCbor;
922
+ switch (this.version) {
923
+ case 2:
924
+ scriptCbor = plutus_default3.validators[2].compiledCode;
925
+ break;
926
+ default:
927
+ scriptCbor = plutus_default2.validators[1].compiledCode;
928
+ }
929
+ return applyParamsToScript2(scriptCbor, [tokenNameHex, policyId]);
930
+ };
729
931
  constructor(inputs, tokenNameHex, paramUtxo) {
730
932
  super(inputs);
731
933
  if (tokenNameHex) {
@@ -734,7 +936,6 @@ var MeshGiftCardContract = class extends MeshTxInitiator {
734
936
  if (paramUtxo) {
735
937
  this.paramUtxo = paramUtxo;
736
938
  }
737
- this.mesh.setNetwork(inputs.networkId === 1 ? "mainnet" : "preprod");
738
939
  }
739
940
  createGiftCard = async (tokenName2, giftValue) => {
740
941
  const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
@@ -747,10 +948,13 @@ var MeshGiftCardContract = class extends MeshTxInitiator {
747
948
  firstUtxo.input.txHash,
748
949
  firstUtxo.input.outputIndex
749
950
  );
750
- const giftCardPolicy = resolveScriptHash(giftCardScript, "V2");
951
+ const giftCardPolicy = resolveScriptHash(
952
+ giftCardScript,
953
+ this.languageVersion
954
+ );
751
955
  const redeemScript = {
752
956
  code: this.redeemCbor(tokenNameHex, giftCardPolicy),
753
- version: "V2"
957
+ version: this.languageVersion
754
958
  };
755
959
  const redeemAddr = serializePlutusScript2(
756
960
  redeemScript,
@@ -762,7 +966,7 @@ var MeshGiftCardContract = class extends MeshTxInitiator {
762
966
  firstUtxo.input.outputIndex,
763
967
  firstUtxo.output.amount,
764
968
  firstUtxo.output.address
765
- ).mintPlutusScriptV2().mint("1", giftCardPolicy, tokenNameHex).mintingScript(giftCardScript).mintRedeemerValue(mConStr0([])).txOut(redeemAddr, [
969
+ ).mintPlutusScript(this.languageVersion).mint("1", giftCardPolicy, tokenNameHex).mintingScript(giftCardScript).mintRedeemerValue(mConStr0([])).txOut(redeemAddr, [
766
970
  ...giftValue,
767
971
  { unit: giftCardPolicy + tokenNameHex, quantity: "1" }
768
972
  ]).txOutInlineDatumValue([
@@ -792,14 +996,17 @@ var MeshGiftCardContract = class extends MeshTxInitiator {
792
996
  paramTxHash,
793
997
  paramTxId
794
998
  );
795
- const giftCardPolicy = resolveScriptHash(giftCardScript, "V2");
999
+ const giftCardPolicy = resolveScriptHash(
1000
+ giftCardScript,
1001
+ this.languageVersion
1002
+ );
796
1003
  const redeemScript = this.redeemCbor(tokenNameHex, giftCardPolicy);
797
- await this.mesh.spendingPlutusScriptV2().txIn(
1004
+ await this.mesh.spendingPlutusScript(this.languageVersion).txIn(
798
1005
  giftCardUtxo.input.txHash,
799
1006
  giftCardUtxo.input.outputIndex,
800
1007
  giftCardUtxo.output.amount,
801
1008
  giftCardUtxo.output.address
802
- ).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue("").txInScript(redeemScript).mintPlutusScriptV2().mint("-1", giftCardPolicy, tokenNameHex).mintingScript(giftCardScript).mintRedeemerValue(mConStr12([])).changeAddress(walletAddress).txInCollateral(
1009
+ ).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue("").txInScript(redeemScript).mintPlutusScript(this.languageVersion).mint("-1", giftCardPolicy, tokenNameHex).mintingScript(giftCardScript).mintRedeemerValue(mConStr12([])).changeAddress(walletAddress).txInCollateral(
803
1010
  collateral.input.txHash,
804
1011
  collateral.input.outputIndex,
805
1012
  collateral.output.amount,
@@ -822,7 +1029,7 @@ import {
822
1029
  import { applyParamsToScript as applyParamsToScript3 } from "@meshsdk/core-csl";
823
1030
 
824
1031
  // src/hello-world/aiken-workspace/plutus.json
825
- var plutus_default3 = {
1032
+ var plutus_default4 = {
826
1033
  preamble: {
827
1034
  title: "meshjs/aiken",
828
1035
  description: "Aiken on MeshJS",
@@ -893,12 +1100,11 @@ var plutus_default3 = {
893
1100
  };
894
1101
 
895
1102
  // src/hello-world/offchain.ts
896
- var MeshHelloWorldBlueprint = plutus_default3;
1103
+ var MeshHelloWorldBlueprint = plutus_default4;
897
1104
  var MeshHelloWorldContract = class extends MeshTxInitiator {
898
- scriptCbor = applyParamsToScript3(plutus_default3.validators[0].compiledCode, []);
1105
+ scriptCbor = applyParamsToScript3(plutus_default4.validators[0].compiledCode, []);
899
1106
  constructor(inputs) {
900
1107
  super(inputs);
901
- this.mesh.setNetwork(inputs.networkId === 1 ? "mainnet" : "preprod");
902
1108
  }
903
1109
  getScript = () => {
904
1110
  const { address } = serializePlutusScript3(
@@ -958,7 +1164,7 @@ import {
958
1164
  import { applyParamsToScript as applyParamsToScript4 } from "@meshsdk/core-csl";
959
1165
 
960
1166
  // src/marketplace/aiken-workspace/plutus.json
961
- var plutus_default4 = {
1167
+ var plutus_default5 = {
962
1168
  preamble: {
963
1169
  title: "meshjs/marketplace",
964
1170
  description: "Aiken contracts for project 'meshjs/marketplace'",
@@ -1164,7 +1370,7 @@ var plutus_default4 = {
1164
1370
  };
1165
1371
 
1166
1372
  // src/marketplace/offchain.ts
1167
- var MeshMarketplaceBlueprint = plutus_default4;
1373
+ var MeshMarketplaceBlueprint = plutus_default5;
1168
1374
  var marketplaceDatum = (sellerAddress, lovelaceFee, assetHex) => {
1169
1375
  const { pubKeyHash, stakeCredentialHash } = deserializeAddress3(sellerAddress);
1170
1376
  const { policyId, assetName } = parseAssetUnit(assetHex);
@@ -1185,14 +1391,13 @@ var MeshMarketplaceContract = class extends MeshTxInitiator {
1185
1391
  this.feePercentageBasisPoint = feePercentageBasisPoint;
1186
1392
  const { pubKeyHash, stakeCredentialHash } = deserializeAddress3(ownerAddress);
1187
1393
  this.scriptCbor = applyParamsToScript4(
1188
- plutus_default4.validators[0].compiledCode,
1394
+ plutus_default5.validators[0].compiledCode,
1189
1395
  [
1190
1396
  pubKeyAddress2(pubKeyHash, stakeCredentialHash),
1191
1397
  integer(feePercentageBasisPoint)
1192
1398
  ],
1193
1399
  "JSON"
1194
1400
  );
1195
- this.mesh.setNetwork(inputs.networkId === 1 ? "mainnet" : "preprod");
1196
1401
  }
1197
1402
  listAsset = async (asset, price) => {
1198
1403
  const { utxos, walletAddress } = await this.getWalletInfoForTx();
@@ -1258,7 +1463,10 @@ var MeshMarketplaceContract = class extends MeshTxInitiator {
1258
1463
  }
1259
1464
  const sellerToReceiveLovelace = inputDatum.fields[1].int + Number(inputLovelace);
1260
1465
  if (sellerToReceiveLovelace > 0) {
1261
- const sellerAddress = serializeAddressObj2(inputDatum.fields[0]);
1466
+ const sellerAddress = serializeAddressObj2(
1467
+ inputDatum.fields[0],
1468
+ this.networkId
1469
+ );
1262
1470
  const sellerToReceive = [
1263
1471
  {
1264
1472
  unit: "lovelace",
@@ -1312,7 +1520,7 @@ import {
1312
1520
  import { applyParamsToScript as applyParamsToScript5 } from "@meshsdk/core-csl";
1313
1521
 
1314
1522
  // src/payment-splitter/aiken-workspace/plutus.json
1315
- var plutus_default5 = {
1523
+ var plutus_default6 = {
1316
1524
  preamble: {
1317
1525
  title: "fabianbormann/payment-splitter",
1318
1526
  description: "Aiken contracts for project 'fabianbormann/payment-splitter'",
@@ -1397,7 +1605,7 @@ var plutus_default5 = {
1397
1605
  };
1398
1606
 
1399
1607
  // src/payment-splitter/offchain.ts
1400
- var MeshPaymentSplitterBlueprint = plutus_default5;
1608
+ var MeshPaymentSplitterBlueprint = plutus_default6;
1401
1609
  var MeshPaymentSplitterContract = class extends MeshTxInitiator {
1402
1610
  wrapPayees = (payees) => list(
1403
1611
  payees.map(
@@ -1405,7 +1613,7 @@ var MeshPaymentSplitterContract = class extends MeshTxInitiator {
1405
1613
  )
1406
1614
  );
1407
1615
  scriptCbor = () => applyParamsToScript5(
1408
- plutus_default5.validators[0].compiledCode,
1616
+ plutus_default6.validators[0].compiledCode,
1409
1617
  [this.wrapPayees(this.payees)],
1410
1618
  "JSON"
1411
1619
  );
@@ -1427,7 +1635,6 @@ var MeshPaymentSplitterContract = class extends MeshTxInitiator {
1427
1635
  "Wallet not provided. Therefore the payment address will not be added to the payees list which makes it impossible to trigger the payout."
1428
1636
  );
1429
1637
  }
1430
- this.mesh.setNetwork(inputs.networkId === 1 ? "mainnet" : "preprod");
1431
1638
  }
1432
1639
  sendLovelaceToSplitter = async (lovelaceAmount) => {
1433
1640
  if (this.wallet === null || this.wallet === void 0) {
@@ -1525,7 +1732,7 @@ import {
1525
1732
  import { applyParamsToScript as applyParamsToScript6 } from "@meshsdk/core-csl";
1526
1733
 
1527
1734
  // src/swap/aiken-workspace/plutus.json
1528
- var plutus_default6 = {
1735
+ var plutus_default7 = {
1529
1736
  preamble: {
1530
1737
  title: "meshjs/swap",
1531
1738
  description: "Aiken contracts for project 'meshjs/swap'",
@@ -1731,9 +1938,9 @@ var plutus_default6 = {
1731
1938
  };
1732
1939
 
1733
1940
  // src/swap/offchain.ts
1734
- var MeshSwapBlueprint = plutus_default6;
1941
+ var MeshSwapBlueprint = plutus_default7;
1735
1942
  var MeshSwapContract = class extends MeshTxInitiator {
1736
- scriptCbor = applyParamsToScript6(plutus_default6.validators[0].compiledCode, []);
1943
+ scriptCbor = applyParamsToScript6(plutus_default7.validators[0].compiledCode, []);
1737
1944
  scriptAddress;
1738
1945
  constructor(inputs) {
1739
1946
  super(inputs);
@@ -1742,7 +1949,6 @@ var MeshSwapContract = class extends MeshTxInitiator {
1742
1949
  void 0,
1743
1950
  inputs.networkId
1744
1951
  ).address;
1745
- this.mesh.setNetwork(inputs.networkId === 1 ? "mainnet" : "preprod");
1746
1952
  }
1747
1953
  initiateSwap = async (toProvide, toReceive) => {
1748
1954
  const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
@@ -1765,7 +1971,10 @@ var MeshSwapContract = class extends MeshTxInitiator {
1765
1971
  const inlineDatum = deserializeDatum4(
1766
1972
  swapUtxo.output.plutusData
1767
1973
  );
1768
- const initiatorAddress = serializeAddressObj3(inlineDatum.fields[0]);
1974
+ const initiatorAddress = serializeAddressObj3(
1975
+ inlineDatum.fields[0],
1976
+ this.networkId
1977
+ );
1769
1978
  const initiatorToReceive = inlineDatum.fields[2];
1770
1979
  await this.mesh.spendingPlutusScriptV2().txIn(
1771
1980
  swapUtxo.input.txHash,
@@ -1788,7 +1997,10 @@ var MeshSwapContract = class extends MeshTxInitiator {
1788
1997
  const inlineDatum = deserializeDatum4(
1789
1998
  swapUtxo.output.plutusData
1790
1999
  );
1791
- const initiatorAddress = serializeAddressObj3(inlineDatum.fields[0]);
2000
+ const initiatorAddress = serializeAddressObj3(
2001
+ inlineDatum.fields[0],
2002
+ this.networkId
2003
+ );
1792
2004
  await this.mesh.spendingPlutusScriptV2().txIn(
1793
2005
  swapUtxo.input.txHash,
1794
2006
  swapUtxo.input.outputIndex,
@@ -1820,8 +2032,8 @@ import {
1820
2032
  } from "@meshsdk/core";
1821
2033
  import { applyParamsToScript as applyParamsToScript7 } from "@meshsdk/core-csl";
1822
2034
 
1823
- // src/vesting/aiken-workspace/plutus.json
1824
- var plutus_default7 = {
2035
+ // src/vesting/aiken-workspace-v1/plutus.json
2036
+ var plutus_default8 = {
1825
2037
  preamble: {
1826
2038
  title: "meshjs/vesting",
1827
2039
  description: "Aiken contracts for project 'meshjs/vesting'",
@@ -1893,18 +2105,111 @@ var plutus_default7 = {
1893
2105
  }
1894
2106
  };
1895
2107
 
2108
+ // src/vesting/aiken-workspace-v2/plutus.json
2109
+ var plutus_default9 = {
2110
+ preamble: {
2111
+ title: "meshjs/vesting",
2112
+ description: "Aiken contracts for project 'meshjs/vesting'",
2113
+ version: "0.0.0",
2114
+ plutusVersion: "v3",
2115
+ compiler: {
2116
+ name: "Aiken",
2117
+ version: "v1.1.0+unknown"
2118
+ },
2119
+ license: "Apache-2.0"
2120
+ },
2121
+ validators: [
2122
+ {
2123
+ title: "vesting.vesting.spend",
2124
+ datum: {
2125
+ title: "datum_opt",
2126
+ schema: {
2127
+ $ref: "#/definitions/vesting~1VestingDatum"
2128
+ }
2129
+ },
2130
+ redeemer: {
2131
+ title: "_redeemer",
2132
+ schema: {
2133
+ $ref: "#/definitions/Data"
2134
+ }
2135
+ },
2136
+ compiledCode: "5901a7010100323232323232322533300232323232325332330083001300937540042646464a66601666e1d2000300c37540022646464a66601c660026eb0c008c040dd50059bae3013301430103754006294454ccc038cc004dd6180118081baa00b375c60266028602860206ea800c4c8cc88c8c8c8c8c94ccc058c03cc05cdd5001099299980b802099b88007001002375a603660306ea80080044c94ccc058c03cc05cdd5001099299980b802001099b89007001375a603660306ea8008004528180c8011806180a1baa3018301900133016301700133016333012300b30133754602e603000298103d87a80004c0103d87980004bd7018099baa3003301337540046028602a602a602a602a602a602a602a60226ea8030dd6980098089baa0042301400114a044646600200200644a66602800229404c94ccc048cdc79bae301700200414a2266006006002602e00246024602660266026602660266026602660260026020601a6ea800458c03cc040008c038004c028dd50011b874800858c02cc030008c028004c028008c020004c010dd50008a4c26cacae6955ceaab9e5573eae815d0aba21",
2137
+ hash: "d13324c13a48b69d67ccfc88e3e87f046f4417f57f5c740d515249fb"
2138
+ },
2139
+ {
2140
+ title: "vesting.vesting.else",
2141
+ compiledCode: "5901a7010100323232323232322533300232323232325332330083001300937540042646464a66601666e1d2000300c37540022646464a66601c660026eb0c008c040dd50059bae3013301430103754006294454ccc038cc004dd6180118081baa00b375c60266028602860206ea800c4c8cc88c8c8c8c8c94ccc058c03cc05cdd5001099299980b802099b88007001002375a603660306ea80080044c94ccc058c03cc05cdd5001099299980b802001099b89007001375a603660306ea8008004528180c8011806180a1baa3018301900133016301700133016333012300b30133754602e603000298103d87a80004c0103d87980004bd7018099baa3003301337540046028602a602a602a602a602a602a602a60226ea8030dd6980098089baa0042301400114a044646600200200644a66602800229404c94ccc048cdc79bae301700200414a2266006006002602e00246024602660266026602660266026602660260026020601a6ea800458c03cc040008c038004c028dd50011b874800858c02cc030008c028004c028008c020004c010dd50008a4c26cacae6955ceaab9e5573eae815d0aba21",
2142
+ hash: "d13324c13a48b69d67ccfc88e3e87f046f4417f57f5c740d515249fb"
2143
+ }
2144
+ ],
2145
+ definitions: {
2146
+ ByteArray: {
2147
+ dataType: "bytes"
2148
+ },
2149
+ Data: {
2150
+ title: "Data",
2151
+ description: "Any Plutus data."
2152
+ },
2153
+ Int: {
2154
+ dataType: "integer"
2155
+ },
2156
+ "vesting/VestingDatum": {
2157
+ title: "VestingDatum",
2158
+ anyOf: [
2159
+ {
2160
+ title: "VestingDatum",
2161
+ dataType: "constructor",
2162
+ index: 0,
2163
+ fields: [
2164
+ {
2165
+ title: "lock_until",
2166
+ description: "POSIX time in milliseconds, e.g. 1672843961000",
2167
+ $ref: "#/definitions/Int"
2168
+ },
2169
+ {
2170
+ title: "owner",
2171
+ description: "Owner's credentials",
2172
+ $ref: "#/definitions/ByteArray"
2173
+ },
2174
+ {
2175
+ title: "beneficiary",
2176
+ description: "Beneficiary's credentials",
2177
+ $ref: "#/definitions/ByteArray"
2178
+ }
2179
+ ]
2180
+ }
2181
+ ]
2182
+ }
2183
+ }
2184
+ };
2185
+
1896
2186
  // src/vesting/offchain.ts
1897
- var MeshVestingBlueprint = plutus_default7;
1898
2187
  var MeshVestingContract = class extends MeshTxInitiator {
1899
- scriptCbor = applyParamsToScript7(plutus_default7.validators[0].compiledCode, []);
1900
2188
  constructor(inputs) {
1901
2189
  super(inputs);
1902
- this.mesh.setNetwork(inputs.networkId === 1 ? "mainnet" : "preprod");
1903
2190
  }
2191
+ getScriptCbor = () => {
2192
+ let scriptCbor;
2193
+ switch (this.version) {
2194
+ case 2:
2195
+ scriptCbor = applyParamsToScript7(
2196
+ plutus_default9.validators[0].compiledCode,
2197
+ []
2198
+ );
2199
+ break;
2200
+ default:
2201
+ scriptCbor = applyParamsToScript7(
2202
+ plutus_default8.validators[0].compiledCode,
2203
+ []
2204
+ );
2205
+ break;
2206
+ }
2207
+ return scriptCbor;
2208
+ };
1904
2209
  depositFund = async (amount, lockUntilTimeStampMs, beneficiary) => {
1905
2210
  const { utxos, walletAddress } = await this.getWalletInfoForTx();
1906
2211
  const scriptAddr = serializePlutusScript7(
1907
- { code: this.scriptCbor, version: "V2" },
2212
+ { code: this.getScriptCbor(), version: this.languageVersion },
1908
2213
  void 0,
1909
2214
  this.networkId
1910
2215
  ).address;
@@ -1922,8 +2227,9 @@ var MeshVestingContract = class extends MeshTxInitiator {
1922
2227
  withdrawFund = async (vestingUtxo) => {
1923
2228
  const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
1924
2229
  const { input: collateralInput, output: collateralOutput } = collateral;
2230
+ const scriptCbor = this.getScriptCbor();
1925
2231
  const scriptAddr = serializePlutusScript7(
1926
- { code: this.scriptCbor, version: "V2" },
2232
+ { code: scriptCbor, version: this.languageVersion },
1927
2233
  void 0,
1928
2234
  this.networkId
1929
2235
  ).address;
@@ -1935,12 +2241,12 @@ var MeshVestingContract = class extends MeshTxInitiator {
1935
2241
  Math.min(datum.fields[0].int, Date.now() - 15e3),
1936
2242
  this.networkId === 0 ? SLOT_CONFIG_NETWORK.preprod : SLOT_CONFIG_NETWORK.mainnet
1937
2243
  ) + 1;
1938
- await this.mesh.spendingPlutusScriptV2().txIn(
2244
+ await this.mesh.spendingPlutusScript(this.languageVersion).txIn(
1939
2245
  vestingUtxo.input.txHash,
1940
2246
  vestingUtxo.input.outputIndex,
1941
2247
  vestingUtxo.output.amount,
1942
2248
  scriptAddr
1943
- ).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue("").txInScript(this.scriptCbor).txOut(walletAddress, []).txInCollateral(
2249
+ ).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue("").txInScript(scriptCbor).txOut(walletAddress, []).txInCollateral(
1944
2250
  collateralInput.txHash,
1945
2251
  collateralInput.outputIndex,
1946
2252
  collateralOutput.amount,
@@ -1949,13 +2255,12 @@ var MeshVestingContract = class extends MeshTxInitiator {
1949
2255
  return this.mesh.txHex;
1950
2256
  };
1951
2257
  getUtxoByTxHash = async (txHash) => {
1952
- return await this._getUtxoByTxHash(txHash, this.scriptCbor);
2258
+ return await this._getUtxoByTxHash(txHash, this.getScriptCbor());
1953
2259
  };
1954
2260
  };
1955
2261
  export {
1956
2262
  MeshEscrowBlueprint,
1957
2263
  MeshEscrowContract,
1958
- MeshGiftCardBlueprint,
1959
2264
  MeshGiftCardContract,
1960
2265
  MeshHelloWorldBlueprint,
1961
2266
  MeshHelloWorldContract,
@@ -1965,7 +2270,6 @@ export {
1965
2270
  MeshPaymentSplitterContract,
1966
2271
  MeshSwapBlueprint,
1967
2272
  MeshSwapContract,
1968
- MeshVestingBlueprint,
1969
2273
  MeshVestingContract,
1970
2274
  activeEscrowDatum,
1971
2275
  initiateEscrowDatum,