@meshsdk/contract 1.7.1 → 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
@@ -4,9 +4,9 @@ import {
4
4
  conStr1,
5
5
  mConStr1,
6
6
  mConStr2,
7
+ MeshValue,
7
8
  pubKeyAddress,
8
- value,
9
- MeshValue
9
+ value
10
10
  } from "@meshsdk/common";
11
11
  import {
12
12
  deserializeAddress,
@@ -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();
@@ -458,10 +469,18 @@ var MeshEscrowContract = class extends MeshTxInitiator {
458
469
  recipientAddressObj,
459
470
  recipientAmount
460
471
  ] = inputDatum.fields;
461
- const initiatorAddress = serializeAddressObj(initiatorAddressObj);
462
- const recipientAddress = serializeAddressObj(recipientAddressObj);
472
+ const initiatorAddress = serializeAddressObj(
473
+ initiatorAddressObj,
474
+ this.networkId
475
+ );
476
+ const recipientAddress = serializeAddressObj(
477
+ recipientAddressObj,
478
+ this.networkId
479
+ );
463
480
  const initiatorToReceive = MeshValue.fromValue(initiatorAmount).toAssets();
464
- const recipientToReceive = MeshValue.fromValue(recipientAmount).toAssets();
481
+ const recipientToReceive = MeshValue.fromValue(
482
+ recipientAmount
483
+ ).toAssets();
465
484
  this.mesh.txOut(initiatorAddress, initiatorToReceive).txOut(recipientAddress, recipientToReceive);
466
485
  }
467
486
  await this.mesh.spendingPlutusScriptV2().txIn(
@@ -530,8 +549,14 @@ var MeshEscrowContract = class extends MeshTxInitiator {
530
549
  recipientAddressObj,
531
550
  recipientAmount
532
551
  ] = inputDatum.fields;
533
- const initiatorAddress = serializeAddressObj(initiatorAddressObj);
534
- const recipientAddress = serializeAddressObj(recipientAddressObj);
552
+ const initiatorAddress = serializeAddressObj(
553
+ initiatorAddressObj,
554
+ this.networkId
555
+ );
556
+ const recipientAddress = serializeAddressObj(
557
+ recipientAddressObj,
558
+ this.networkId
559
+ );
535
560
  const initiatorToReceive = MeshValue.fromValue(recipientAmount).toAssets();
536
561
  const recipientToReceive = MeshValue.fromValue(initiatorAmount).toAssets();
537
562
  await this.mesh.spendingPlutusScriptV2().txIn(
@@ -557,6 +582,7 @@ import {
557
582
  builtinByteString,
558
583
  mConStr0,
559
584
  mConStr1 as mConStr12,
585
+ outputReference,
560
586
  stringToHex,
561
587
  txOutRef
562
588
  } from "@meshsdk/common";
@@ -567,7 +593,7 @@ import {
567
593
  } from "@meshsdk/core";
568
594
  import { applyParamsToScript as applyParamsToScript2 } from "@meshsdk/core-csl";
569
595
 
570
- // src/giftcard/aiken-workspace/plutus.json
596
+ // src/giftcard/aiken-workspace-v1/plutus.json
571
597
  var plutus_default2 = {
572
598
  preamble: {
573
599
  title: "meshjs/giftcard",
@@ -707,22 +733,201 @@ var plutus_default2 = {
707
733
  }
708
734
  };
709
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
+
710
897
  // src/giftcard/offchain.ts
711
- var MeshGiftCardBlueprint = plutus_default2;
712
898
  var MeshGiftCardContract = class extends MeshTxInitiator {
713
899
  tokenNameHex = "";
714
900
  paramUtxo = { outputIndex: 0, txHash: "" };
715
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
+ }
716
914
  return applyParamsToScript2(
717
- plutus_default2.validators[0].compiledCode,
718
- [builtinByteString(tokenNameHex), txOutRef(utxoTxHash, utxoTxId)],
915
+ scriptCbor,
916
+ [builtinByteString(tokenNameHex), utxo],
719
917
  "JSON"
720
918
  );
721
919
  };
722
- redeemCbor = (tokenNameHex, policyId) => applyParamsToScript2(plutus_default2.validators[1].compiledCode, [
723
- tokenNameHex,
724
- policyId
725
- ]);
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
+ };
726
931
  constructor(inputs, tokenNameHex, paramUtxo) {
727
932
  super(inputs);
728
933
  if (tokenNameHex) {
@@ -743,10 +948,13 @@ var MeshGiftCardContract = class extends MeshTxInitiator {
743
948
  firstUtxo.input.txHash,
744
949
  firstUtxo.input.outputIndex
745
950
  );
746
- const giftCardPolicy = resolveScriptHash(giftCardScript, "V2");
951
+ const giftCardPolicy = resolveScriptHash(
952
+ giftCardScript,
953
+ this.languageVersion
954
+ );
747
955
  const redeemScript = {
748
956
  code: this.redeemCbor(tokenNameHex, giftCardPolicy),
749
- version: "V2"
957
+ version: this.languageVersion
750
958
  };
751
959
  const redeemAddr = serializePlutusScript2(
752
960
  redeemScript,
@@ -758,7 +966,7 @@ var MeshGiftCardContract = class extends MeshTxInitiator {
758
966
  firstUtxo.input.outputIndex,
759
967
  firstUtxo.output.amount,
760
968
  firstUtxo.output.address
761
- ).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, [
762
970
  ...giftValue,
763
971
  { unit: giftCardPolicy + tokenNameHex, quantity: "1" }
764
972
  ]).txOutInlineDatumValue([
@@ -788,14 +996,17 @@ var MeshGiftCardContract = class extends MeshTxInitiator {
788
996
  paramTxHash,
789
997
  paramTxId
790
998
  );
791
- const giftCardPolicy = resolveScriptHash(giftCardScript, "V2");
999
+ const giftCardPolicy = resolveScriptHash(
1000
+ giftCardScript,
1001
+ this.languageVersion
1002
+ );
792
1003
  const redeemScript = this.redeemCbor(tokenNameHex, giftCardPolicy);
793
- await this.mesh.spendingPlutusScriptV2().txIn(
1004
+ await this.mesh.spendingPlutusScript(this.languageVersion).txIn(
794
1005
  giftCardUtxo.input.txHash,
795
1006
  giftCardUtxo.input.outputIndex,
796
1007
  giftCardUtxo.output.amount,
797
1008
  giftCardUtxo.output.address
798
- ).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(
799
1010
  collateral.input.txHash,
800
1011
  collateral.input.outputIndex,
801
1012
  collateral.output.amount,
@@ -818,7 +1029,7 @@ import {
818
1029
  import { applyParamsToScript as applyParamsToScript3 } from "@meshsdk/core-csl";
819
1030
 
820
1031
  // src/hello-world/aiken-workspace/plutus.json
821
- var plutus_default3 = {
1032
+ var plutus_default4 = {
822
1033
  preamble: {
823
1034
  title: "meshjs/aiken",
824
1035
  description: "Aiken on MeshJS",
@@ -889,9 +1100,9 @@ var plutus_default3 = {
889
1100
  };
890
1101
 
891
1102
  // src/hello-world/offchain.ts
892
- var MeshHelloWorldBlueprint = plutus_default3;
1103
+ var MeshHelloWorldBlueprint = plutus_default4;
893
1104
  var MeshHelloWorldContract = class extends MeshTxInitiator {
894
- scriptCbor = applyParamsToScript3(plutus_default3.validators[0].compiledCode, []);
1105
+ scriptCbor = applyParamsToScript3(plutus_default4.validators[0].compiledCode, []);
895
1106
  constructor(inputs) {
896
1107
  super(inputs);
897
1108
  }
@@ -953,7 +1164,7 @@ import {
953
1164
  import { applyParamsToScript as applyParamsToScript4 } from "@meshsdk/core-csl";
954
1165
 
955
1166
  // src/marketplace/aiken-workspace/plutus.json
956
- var plutus_default4 = {
1167
+ var plutus_default5 = {
957
1168
  preamble: {
958
1169
  title: "meshjs/marketplace",
959
1170
  description: "Aiken contracts for project 'meshjs/marketplace'",
@@ -1159,7 +1370,7 @@ var plutus_default4 = {
1159
1370
  };
1160
1371
 
1161
1372
  // src/marketplace/offchain.ts
1162
- var MeshMarketplaceBlueprint = plutus_default4;
1373
+ var MeshMarketplaceBlueprint = plutus_default5;
1163
1374
  var marketplaceDatum = (sellerAddress, lovelaceFee, assetHex) => {
1164
1375
  const { pubKeyHash, stakeCredentialHash } = deserializeAddress3(sellerAddress);
1165
1376
  const { policyId, assetName } = parseAssetUnit(assetHex);
@@ -1180,7 +1391,7 @@ var MeshMarketplaceContract = class extends MeshTxInitiator {
1180
1391
  this.feePercentageBasisPoint = feePercentageBasisPoint;
1181
1392
  const { pubKeyHash, stakeCredentialHash } = deserializeAddress3(ownerAddress);
1182
1393
  this.scriptCbor = applyParamsToScript4(
1183
- plutus_default4.validators[0].compiledCode,
1394
+ plutus_default5.validators[0].compiledCode,
1184
1395
  [
1185
1396
  pubKeyAddress2(pubKeyHash, stakeCredentialHash),
1186
1397
  integer(feePercentageBasisPoint)
@@ -1252,7 +1463,10 @@ var MeshMarketplaceContract = class extends MeshTxInitiator {
1252
1463
  }
1253
1464
  const sellerToReceiveLovelace = inputDatum.fields[1].int + Number(inputLovelace);
1254
1465
  if (sellerToReceiveLovelace > 0) {
1255
- const sellerAddress = serializeAddressObj2(inputDatum.fields[0]);
1466
+ const sellerAddress = serializeAddressObj2(
1467
+ inputDatum.fields[0],
1468
+ this.networkId
1469
+ );
1256
1470
  const sellerToReceive = [
1257
1471
  {
1258
1472
  unit: "lovelace",
@@ -1306,7 +1520,7 @@ import {
1306
1520
  import { applyParamsToScript as applyParamsToScript5 } from "@meshsdk/core-csl";
1307
1521
 
1308
1522
  // src/payment-splitter/aiken-workspace/plutus.json
1309
- var plutus_default5 = {
1523
+ var plutus_default6 = {
1310
1524
  preamble: {
1311
1525
  title: "fabianbormann/payment-splitter",
1312
1526
  description: "Aiken contracts for project 'fabianbormann/payment-splitter'",
@@ -1391,7 +1605,7 @@ var plutus_default5 = {
1391
1605
  };
1392
1606
 
1393
1607
  // src/payment-splitter/offchain.ts
1394
- var MeshPaymentSplitterBlueprint = plutus_default5;
1608
+ var MeshPaymentSplitterBlueprint = plutus_default6;
1395
1609
  var MeshPaymentSplitterContract = class extends MeshTxInitiator {
1396
1610
  wrapPayees = (payees) => list(
1397
1611
  payees.map(
@@ -1399,7 +1613,7 @@ var MeshPaymentSplitterContract = class extends MeshTxInitiator {
1399
1613
  )
1400
1614
  );
1401
1615
  scriptCbor = () => applyParamsToScript5(
1402
- plutus_default5.validators[0].compiledCode,
1616
+ plutus_default6.validators[0].compiledCode,
1403
1617
  [this.wrapPayees(this.payees)],
1404
1618
  "JSON"
1405
1619
  );
@@ -1434,7 +1648,7 @@ var MeshPaymentSplitterContract = class extends MeshTxInitiator {
1434
1648
  const { address: scriptAddress } = serializePlutusScript5(
1435
1649
  script,
1436
1650
  void 0,
1437
- 0
1651
+ this.networkId
1438
1652
  );
1439
1653
  const { pubKeyHash } = deserializeAddress4(walletAddress);
1440
1654
  const datum = {
@@ -1463,7 +1677,7 @@ var MeshPaymentSplitterContract = class extends MeshTxInitiator {
1463
1677
  const { address: scriptAddress } = serializePlutusScript5(
1464
1678
  script,
1465
1679
  void 0,
1466
- 0
1680
+ this.networkId
1467
1681
  );
1468
1682
  const utxos = await this.fetcher?.fetchAddressUTxOs(scriptAddress) || [];
1469
1683
  const { pubKeyHash } = deserializeAddress4(walletAddress);
@@ -1518,7 +1732,7 @@ import {
1518
1732
  import { applyParamsToScript as applyParamsToScript6 } from "@meshsdk/core-csl";
1519
1733
 
1520
1734
  // src/swap/aiken-workspace/plutus.json
1521
- var plutus_default6 = {
1735
+ var plutus_default7 = {
1522
1736
  preamble: {
1523
1737
  title: "meshjs/swap",
1524
1738
  description: "Aiken contracts for project 'meshjs/swap'",
@@ -1724,16 +1938,16 @@ var plutus_default6 = {
1724
1938
  };
1725
1939
 
1726
1940
  // src/swap/offchain.ts
1727
- var MeshSwapBlueprint = plutus_default6;
1941
+ var MeshSwapBlueprint = plutus_default7;
1728
1942
  var MeshSwapContract = class extends MeshTxInitiator {
1729
- scriptCbor = applyParamsToScript6(plutus_default6.validators[0].compiledCode, []);
1943
+ scriptCbor = applyParamsToScript6(plutus_default7.validators[0].compiledCode, []);
1730
1944
  scriptAddress;
1731
1945
  constructor(inputs) {
1732
1946
  super(inputs);
1733
1947
  this.scriptAddress = serializePlutusScript6(
1734
1948
  { code: this.scriptCbor, version: "V2" },
1735
1949
  void 0,
1736
- 0
1950
+ inputs.networkId
1737
1951
  ).address;
1738
1952
  }
1739
1953
  initiateSwap = async (toProvide, toReceive) => {
@@ -1757,7 +1971,10 @@ var MeshSwapContract = class extends MeshTxInitiator {
1757
1971
  const inlineDatum = deserializeDatum4(
1758
1972
  swapUtxo.output.plutusData
1759
1973
  );
1760
- const initiatorAddress = serializeAddressObj3(inlineDatum.fields[0]);
1974
+ const initiatorAddress = serializeAddressObj3(
1975
+ inlineDatum.fields[0],
1976
+ this.networkId
1977
+ );
1761
1978
  const initiatorToReceive = inlineDatum.fields[2];
1762
1979
  await this.mesh.spendingPlutusScriptV2().txIn(
1763
1980
  swapUtxo.input.txHash,
@@ -1780,7 +1997,10 @@ var MeshSwapContract = class extends MeshTxInitiator {
1780
1997
  const inlineDatum = deserializeDatum4(
1781
1998
  swapUtxo.output.plutusData
1782
1999
  );
1783
- const initiatorAddress = serializeAddressObj3(inlineDatum.fields[0]);
2000
+ const initiatorAddress = serializeAddressObj3(
2001
+ inlineDatum.fields[0],
2002
+ this.networkId
2003
+ );
1784
2004
  await this.mesh.spendingPlutusScriptV2().txIn(
1785
2005
  swapUtxo.input.txHash,
1786
2006
  swapUtxo.input.outputIndex,
@@ -1812,8 +2032,8 @@ import {
1812
2032
  } from "@meshsdk/core";
1813
2033
  import { applyParamsToScript as applyParamsToScript7 } from "@meshsdk/core-csl";
1814
2034
 
1815
- // src/vesting/aiken-workspace/plutus.json
1816
- var plutus_default7 = {
2035
+ // src/vesting/aiken-workspace-v1/plutus.json
2036
+ var plutus_default8 = {
1817
2037
  preamble: {
1818
2038
  title: "meshjs/vesting",
1819
2039
  description: "Aiken contracts for project 'meshjs/vesting'",
@@ -1885,19 +2105,113 @@ var plutus_default7 = {
1885
2105
  }
1886
2106
  };
1887
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
+
1888
2186
  // src/vesting/offchain.ts
1889
- var MeshVestingBlueprint = plutus_default7;
1890
2187
  var MeshVestingContract = class extends MeshTxInitiator {
1891
- scriptCbor = applyParamsToScript7(plutus_default7.validators[0].compiledCode, []);
1892
2188
  constructor(inputs) {
1893
2189
  super(inputs);
1894
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
+ };
1895
2209
  depositFund = async (amount, lockUntilTimeStampMs, beneficiary) => {
1896
2210
  const { utxos, walletAddress } = await this.getWalletInfoForTx();
1897
2211
  const scriptAddr = serializePlutusScript7(
1898
- { code: this.scriptCbor, version: "V2" },
2212
+ { code: this.getScriptCbor(), version: this.languageVersion },
1899
2213
  void 0,
1900
- 0
2214
+ this.networkId
1901
2215
  ).address;
1902
2216
  const { pubKeyHash: ownerPubKeyHash } = deserializeAddress6(walletAddress);
1903
2217
  const { pubKeyHash: beneficiaryPubKeyHash } = deserializeAddress6(beneficiary);
@@ -1913,10 +2227,11 @@ var MeshVestingContract = class extends MeshTxInitiator {
1913
2227
  withdrawFund = async (vestingUtxo) => {
1914
2228
  const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
1915
2229
  const { input: collateralInput, output: collateralOutput } = collateral;
2230
+ const scriptCbor = this.getScriptCbor();
1916
2231
  const scriptAddr = serializePlutusScript7(
1917
- { code: this.scriptCbor, version: "V2" },
2232
+ { code: scriptCbor, version: this.languageVersion },
1918
2233
  void 0,
1919
- 0
2234
+ this.networkId
1920
2235
  ).address;
1921
2236
  const { pubKeyHash } = deserializeAddress6(walletAddress);
1922
2237
  const datum = deserializeDatum5(
@@ -1926,12 +2241,12 @@ var MeshVestingContract = class extends MeshTxInitiator {
1926
2241
  Math.min(datum.fields[0].int, Date.now() - 15e3),
1927
2242
  this.networkId === 0 ? SLOT_CONFIG_NETWORK.preprod : SLOT_CONFIG_NETWORK.mainnet
1928
2243
  ) + 1;
1929
- await this.mesh.spendingPlutusScriptV2().txIn(
2244
+ await this.mesh.spendingPlutusScript(this.languageVersion).txIn(
1930
2245
  vestingUtxo.input.txHash,
1931
2246
  vestingUtxo.input.outputIndex,
1932
2247
  vestingUtxo.output.amount,
1933
2248
  scriptAddr
1934
- ).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue("").txInScript(this.scriptCbor).txOut(walletAddress, []).txInCollateral(
2249
+ ).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue("").txInScript(scriptCbor).txOut(walletAddress, []).txInCollateral(
1935
2250
  collateralInput.txHash,
1936
2251
  collateralInput.outputIndex,
1937
2252
  collateralOutput.amount,
@@ -1940,13 +2255,12 @@ var MeshVestingContract = class extends MeshTxInitiator {
1940
2255
  return this.mesh.txHex;
1941
2256
  };
1942
2257
  getUtxoByTxHash = async (txHash) => {
1943
- return await this._getUtxoByTxHash(txHash, this.scriptCbor);
2258
+ return await this._getUtxoByTxHash(txHash, this.getScriptCbor());
1944
2259
  };
1945
2260
  };
1946
2261
  export {
1947
2262
  MeshEscrowBlueprint,
1948
2263
  MeshEscrowContract,
1949
- MeshGiftCardBlueprint,
1950
2264
  MeshGiftCardContract,
1951
2265
  MeshHelloWorldBlueprint,
1952
2266
  MeshHelloWorldContract,
@@ -1956,7 +2270,6 @@ export {
1956
2270
  MeshPaymentSplitterContract,
1957
2271
  MeshSwapBlueprint,
1958
2272
  MeshSwapContract,
1959
- MeshVestingBlueprint,
1960
2273
  MeshVestingContract,
1961
2274
  activeEscrowDatum,
1962
2275
  initiateEscrowDatum,