@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.cjs +363 -53
- package/dist/index.d.cts +7 -159
- package/dist/index.d.ts +7 -159
- package/dist/index.js +366 -53
- package/package.json +6 -6
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();
|
|
@@ -487,10 +496,18 @@ var MeshEscrowContract = class extends MeshTxInitiator {
|
|
|
487
496
|
recipientAddressObj,
|
|
488
497
|
recipientAmount
|
|
489
498
|
] = inputDatum.fields;
|
|
490
|
-
const initiatorAddress = (0, import_core.serializeAddressObj)(
|
|
491
|
-
|
|
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
|
+
);
|
|
492
507
|
const initiatorToReceive = import_common.MeshValue.fromValue(initiatorAmount).toAssets();
|
|
493
|
-
const recipientToReceive = import_common.MeshValue.fromValue(
|
|
508
|
+
const recipientToReceive = import_common.MeshValue.fromValue(
|
|
509
|
+
recipientAmount
|
|
510
|
+
).toAssets();
|
|
494
511
|
this.mesh.txOut(initiatorAddress, initiatorToReceive).txOut(recipientAddress, recipientToReceive);
|
|
495
512
|
}
|
|
496
513
|
await this.mesh.spendingPlutusScriptV2().txIn(
|
|
@@ -559,8 +576,14 @@ var MeshEscrowContract = class extends MeshTxInitiator {
|
|
|
559
576
|
recipientAddressObj,
|
|
560
577
|
recipientAmount
|
|
561
578
|
] = inputDatum.fields;
|
|
562
|
-
const initiatorAddress = (0, import_core.serializeAddressObj)(
|
|
563
|
-
|
|
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
|
+
);
|
|
564
587
|
const initiatorToReceive = import_common.MeshValue.fromValue(recipientAmount).toAssets();
|
|
565
588
|
const recipientToReceive = import_common.MeshValue.fromValue(initiatorAmount).toAssets();
|
|
566
589
|
await this.mesh.spendingPlutusScriptV2().txIn(
|
|
@@ -586,7 +609,7 @@ var import_common3 = require("@meshsdk/common");
|
|
|
586
609
|
var import_core2 = require("@meshsdk/core");
|
|
587
610
|
var import_core_csl3 = require("@meshsdk/core-csl");
|
|
588
611
|
|
|
589
|
-
// src/giftcard/aiken-workspace/plutus.json
|
|
612
|
+
// src/giftcard/aiken-workspace-v1/plutus.json
|
|
590
613
|
var plutus_default2 = {
|
|
591
614
|
preamble: {
|
|
592
615
|
title: "meshjs/giftcard",
|
|
@@ -726,22 +749,201 @@ var plutus_default2 = {
|
|
|
726
749
|
}
|
|
727
750
|
};
|
|
728
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
|
+
|
|
729
913
|
// src/giftcard/offchain.ts
|
|
730
|
-
var MeshGiftCardBlueprint = plutus_default2;
|
|
731
914
|
var MeshGiftCardContract = class extends MeshTxInitiator {
|
|
732
915
|
tokenNameHex = "";
|
|
733
916
|
paramUtxo = { outputIndex: 0, txHash: "" };
|
|
734
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
|
+
}
|
|
735
930
|
return (0, import_core_csl3.applyParamsToScript)(
|
|
736
|
-
|
|
737
|
-
[(0, import_common3.builtinByteString)(tokenNameHex),
|
|
931
|
+
scriptCbor,
|
|
932
|
+
[(0, import_common3.builtinByteString)(tokenNameHex), utxo],
|
|
738
933
|
"JSON"
|
|
739
934
|
);
|
|
740
935
|
};
|
|
741
|
-
redeemCbor = (tokenNameHex, policyId) =>
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
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
|
+
};
|
|
745
947
|
constructor(inputs, tokenNameHex, paramUtxo) {
|
|
746
948
|
super(inputs);
|
|
747
949
|
if (tokenNameHex) {
|
|
@@ -762,10 +964,13 @@ var MeshGiftCardContract = class extends MeshTxInitiator {
|
|
|
762
964
|
firstUtxo.input.txHash,
|
|
763
965
|
firstUtxo.input.outputIndex
|
|
764
966
|
);
|
|
765
|
-
const giftCardPolicy = (0, import_core2.resolveScriptHash)(
|
|
967
|
+
const giftCardPolicy = (0, import_core2.resolveScriptHash)(
|
|
968
|
+
giftCardScript,
|
|
969
|
+
this.languageVersion
|
|
970
|
+
);
|
|
766
971
|
const redeemScript = {
|
|
767
972
|
code: this.redeemCbor(tokenNameHex, giftCardPolicy),
|
|
768
|
-
version:
|
|
973
|
+
version: this.languageVersion
|
|
769
974
|
};
|
|
770
975
|
const redeemAddr = (0, import_core2.serializePlutusScript)(
|
|
771
976
|
redeemScript,
|
|
@@ -777,7 +982,7 @@ var MeshGiftCardContract = class extends MeshTxInitiator {
|
|
|
777
982
|
firstUtxo.input.outputIndex,
|
|
778
983
|
firstUtxo.output.amount,
|
|
779
984
|
firstUtxo.output.address
|
|
780
|
-
).
|
|
985
|
+
).mintPlutusScript(this.languageVersion).mint("1", giftCardPolicy, tokenNameHex).mintingScript(giftCardScript).mintRedeemerValue((0, import_common3.mConStr0)([])).txOut(redeemAddr, [
|
|
781
986
|
...giftValue,
|
|
782
987
|
{ unit: giftCardPolicy + tokenNameHex, quantity: "1" }
|
|
783
988
|
]).txOutInlineDatumValue([
|
|
@@ -807,14 +1012,17 @@ var MeshGiftCardContract = class extends MeshTxInitiator {
|
|
|
807
1012
|
paramTxHash,
|
|
808
1013
|
paramTxId
|
|
809
1014
|
);
|
|
810
|
-
const giftCardPolicy = (0, import_core2.resolveScriptHash)(
|
|
1015
|
+
const giftCardPolicy = (0, import_core2.resolveScriptHash)(
|
|
1016
|
+
giftCardScript,
|
|
1017
|
+
this.languageVersion
|
|
1018
|
+
);
|
|
811
1019
|
const redeemScript = this.redeemCbor(tokenNameHex, giftCardPolicy);
|
|
812
|
-
await this.mesh.
|
|
1020
|
+
await this.mesh.spendingPlutusScript(this.languageVersion).txIn(
|
|
813
1021
|
giftCardUtxo.input.txHash,
|
|
814
1022
|
giftCardUtxo.input.outputIndex,
|
|
815
1023
|
giftCardUtxo.output.amount,
|
|
816
1024
|
giftCardUtxo.output.address
|
|
817
|
-
).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue("").txInScript(redeemScript).
|
|
1025
|
+
).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue("").txInScript(redeemScript).mintPlutusScript(this.languageVersion).mint("-1", giftCardPolicy, tokenNameHex).mintingScript(giftCardScript).mintRedeemerValue((0, import_common3.mConStr1)([])).changeAddress(walletAddress).txInCollateral(
|
|
818
1026
|
collateral.input.txHash,
|
|
819
1027
|
collateral.input.outputIndex,
|
|
820
1028
|
collateral.output.amount,
|
|
@@ -832,7 +1040,7 @@ var import_core3 = require("@meshsdk/core");
|
|
|
832
1040
|
var import_core_csl4 = require("@meshsdk/core-csl");
|
|
833
1041
|
|
|
834
1042
|
// src/hello-world/aiken-workspace/plutus.json
|
|
835
|
-
var
|
|
1043
|
+
var plutus_default4 = {
|
|
836
1044
|
preamble: {
|
|
837
1045
|
title: "meshjs/aiken",
|
|
838
1046
|
description: "Aiken on MeshJS",
|
|
@@ -903,9 +1111,9 @@ var plutus_default3 = {
|
|
|
903
1111
|
};
|
|
904
1112
|
|
|
905
1113
|
// src/hello-world/offchain.ts
|
|
906
|
-
var MeshHelloWorldBlueprint =
|
|
1114
|
+
var MeshHelloWorldBlueprint = plutus_default4;
|
|
907
1115
|
var MeshHelloWorldContract = class extends MeshTxInitiator {
|
|
908
|
-
scriptCbor = (0, import_core_csl4.applyParamsToScript)(
|
|
1116
|
+
scriptCbor = (0, import_core_csl4.applyParamsToScript)(plutus_default4.validators[0].compiledCode, []);
|
|
909
1117
|
constructor(inputs) {
|
|
910
1118
|
super(inputs);
|
|
911
1119
|
}
|
|
@@ -953,7 +1161,7 @@ var import_core4 = require("@meshsdk/core");
|
|
|
953
1161
|
var import_core_csl5 = require("@meshsdk/core-csl");
|
|
954
1162
|
|
|
955
1163
|
// src/marketplace/aiken-workspace/plutus.json
|
|
956
|
-
var
|
|
1164
|
+
var plutus_default5 = {
|
|
957
1165
|
preamble: {
|
|
958
1166
|
title: "meshjs/marketplace",
|
|
959
1167
|
description: "Aiken contracts for project 'meshjs/marketplace'",
|
|
@@ -1159,7 +1367,7 @@ var plutus_default4 = {
|
|
|
1159
1367
|
};
|
|
1160
1368
|
|
|
1161
1369
|
// src/marketplace/offchain.ts
|
|
1162
|
-
var MeshMarketplaceBlueprint =
|
|
1370
|
+
var MeshMarketplaceBlueprint = plutus_default5;
|
|
1163
1371
|
var marketplaceDatum = (sellerAddress, lovelaceFee, assetHex) => {
|
|
1164
1372
|
const { pubKeyHash, stakeCredentialHash } = (0, import_core4.deserializeAddress)(sellerAddress);
|
|
1165
1373
|
const { policyId, assetName } = (0, import_common6.parseAssetUnit)(assetHex);
|
|
@@ -1180,7 +1388,7 @@ var MeshMarketplaceContract = class extends MeshTxInitiator {
|
|
|
1180
1388
|
this.feePercentageBasisPoint = feePercentageBasisPoint;
|
|
1181
1389
|
const { pubKeyHash, stakeCredentialHash } = (0, import_core4.deserializeAddress)(ownerAddress);
|
|
1182
1390
|
this.scriptCbor = (0, import_core_csl5.applyParamsToScript)(
|
|
1183
|
-
|
|
1391
|
+
plutus_default5.validators[0].compiledCode,
|
|
1184
1392
|
[
|
|
1185
1393
|
(0, import_common6.pubKeyAddress)(pubKeyHash, stakeCredentialHash),
|
|
1186
1394
|
(0, import_common6.integer)(feePercentageBasisPoint)
|
|
@@ -1252,7 +1460,10 @@ var MeshMarketplaceContract = class extends MeshTxInitiator {
|
|
|
1252
1460
|
}
|
|
1253
1461
|
const sellerToReceiveLovelace = inputDatum.fields[1].int + Number(inputLovelace);
|
|
1254
1462
|
if (sellerToReceiveLovelace > 0) {
|
|
1255
|
-
const sellerAddress = (0, import_core4.serializeAddressObj)(
|
|
1463
|
+
const sellerAddress = (0, import_core4.serializeAddressObj)(
|
|
1464
|
+
inputDatum.fields[0],
|
|
1465
|
+
this.networkId
|
|
1466
|
+
);
|
|
1256
1467
|
const sellerToReceive = [
|
|
1257
1468
|
{
|
|
1258
1469
|
unit: "lovelace",
|
|
@@ -1300,7 +1511,7 @@ var import_core5 = require("@meshsdk/core");
|
|
|
1300
1511
|
var import_core_csl6 = require("@meshsdk/core-csl");
|
|
1301
1512
|
|
|
1302
1513
|
// src/payment-splitter/aiken-workspace/plutus.json
|
|
1303
|
-
var
|
|
1514
|
+
var plutus_default6 = {
|
|
1304
1515
|
preamble: {
|
|
1305
1516
|
title: "fabianbormann/payment-splitter",
|
|
1306
1517
|
description: "Aiken contracts for project 'fabianbormann/payment-splitter'",
|
|
@@ -1385,7 +1596,7 @@ var plutus_default5 = {
|
|
|
1385
1596
|
};
|
|
1386
1597
|
|
|
1387
1598
|
// src/payment-splitter/offchain.ts
|
|
1388
|
-
var MeshPaymentSplitterBlueprint =
|
|
1599
|
+
var MeshPaymentSplitterBlueprint = plutus_default6;
|
|
1389
1600
|
var MeshPaymentSplitterContract = class extends MeshTxInitiator {
|
|
1390
1601
|
wrapPayees = (payees) => (0, import_common8.list)(
|
|
1391
1602
|
payees.map(
|
|
@@ -1393,7 +1604,7 @@ var MeshPaymentSplitterContract = class extends MeshTxInitiator {
|
|
|
1393
1604
|
)
|
|
1394
1605
|
);
|
|
1395
1606
|
scriptCbor = () => (0, import_core_csl6.applyParamsToScript)(
|
|
1396
|
-
|
|
1607
|
+
plutus_default6.validators[0].compiledCode,
|
|
1397
1608
|
[this.wrapPayees(this.payees)],
|
|
1398
1609
|
"JSON"
|
|
1399
1610
|
);
|
|
@@ -1428,7 +1639,7 @@ var MeshPaymentSplitterContract = class extends MeshTxInitiator {
|
|
|
1428
1639
|
const { address: scriptAddress } = (0, import_core5.serializePlutusScript)(
|
|
1429
1640
|
script,
|
|
1430
1641
|
void 0,
|
|
1431
|
-
|
|
1642
|
+
this.networkId
|
|
1432
1643
|
);
|
|
1433
1644
|
const { pubKeyHash } = (0, import_core5.deserializeAddress)(walletAddress);
|
|
1434
1645
|
const datum = {
|
|
@@ -1457,7 +1668,7 @@ var MeshPaymentSplitterContract = class extends MeshTxInitiator {
|
|
|
1457
1668
|
const { address: scriptAddress } = (0, import_core5.serializePlutusScript)(
|
|
1458
1669
|
script,
|
|
1459
1670
|
void 0,
|
|
1460
|
-
|
|
1671
|
+
this.networkId
|
|
1461
1672
|
);
|
|
1462
1673
|
const utxos = await this.fetcher?.fetchAddressUTxOs(scriptAddress) || [];
|
|
1463
1674
|
const { pubKeyHash } = (0, import_core5.deserializeAddress)(walletAddress);
|
|
@@ -1500,7 +1711,7 @@ var import_core6 = require("@meshsdk/core");
|
|
|
1500
1711
|
var import_core_csl7 = require("@meshsdk/core-csl");
|
|
1501
1712
|
|
|
1502
1713
|
// src/swap/aiken-workspace/plutus.json
|
|
1503
|
-
var
|
|
1714
|
+
var plutus_default7 = {
|
|
1504
1715
|
preamble: {
|
|
1505
1716
|
title: "meshjs/swap",
|
|
1506
1717
|
description: "Aiken contracts for project 'meshjs/swap'",
|
|
@@ -1706,16 +1917,16 @@ var plutus_default6 = {
|
|
|
1706
1917
|
};
|
|
1707
1918
|
|
|
1708
1919
|
// src/swap/offchain.ts
|
|
1709
|
-
var MeshSwapBlueprint =
|
|
1920
|
+
var MeshSwapBlueprint = plutus_default7;
|
|
1710
1921
|
var MeshSwapContract = class extends MeshTxInitiator {
|
|
1711
|
-
scriptCbor = (0, import_core_csl7.applyParamsToScript)(
|
|
1922
|
+
scriptCbor = (0, import_core_csl7.applyParamsToScript)(plutus_default7.validators[0].compiledCode, []);
|
|
1712
1923
|
scriptAddress;
|
|
1713
1924
|
constructor(inputs) {
|
|
1714
1925
|
super(inputs);
|
|
1715
1926
|
this.scriptAddress = (0, import_core6.serializePlutusScript)(
|
|
1716
1927
|
{ code: this.scriptCbor, version: "V2" },
|
|
1717
1928
|
void 0,
|
|
1718
|
-
|
|
1929
|
+
inputs.networkId
|
|
1719
1930
|
).address;
|
|
1720
1931
|
}
|
|
1721
1932
|
initiateSwap = async (toProvide, toReceive) => {
|
|
@@ -1739,7 +1950,10 @@ var MeshSwapContract = class extends MeshTxInitiator {
|
|
|
1739
1950
|
const inlineDatum = (0, import_core6.deserializeDatum)(
|
|
1740
1951
|
swapUtxo.output.plutusData
|
|
1741
1952
|
);
|
|
1742
|
-
const initiatorAddress = (0, import_core6.serializeAddressObj)(
|
|
1953
|
+
const initiatorAddress = (0, import_core6.serializeAddressObj)(
|
|
1954
|
+
inlineDatum.fields[0],
|
|
1955
|
+
this.networkId
|
|
1956
|
+
);
|
|
1743
1957
|
const initiatorToReceive = inlineDatum.fields[2];
|
|
1744
1958
|
await this.mesh.spendingPlutusScriptV2().txIn(
|
|
1745
1959
|
swapUtxo.input.txHash,
|
|
@@ -1762,7 +1976,10 @@ var MeshSwapContract = class extends MeshTxInitiator {
|
|
|
1762
1976
|
const inlineDatum = (0, import_core6.deserializeDatum)(
|
|
1763
1977
|
swapUtxo.output.plutusData
|
|
1764
1978
|
);
|
|
1765
|
-
const initiatorAddress = (0, import_core6.serializeAddressObj)(
|
|
1979
|
+
const initiatorAddress = (0, import_core6.serializeAddressObj)(
|
|
1980
|
+
inlineDatum.fields[0],
|
|
1981
|
+
this.networkId
|
|
1982
|
+
);
|
|
1766
1983
|
await this.mesh.spendingPlutusScriptV2().txIn(
|
|
1767
1984
|
swapUtxo.input.txHash,
|
|
1768
1985
|
swapUtxo.input.outputIndex,
|
|
@@ -1786,8 +2003,8 @@ var import_common12 = require("@meshsdk/common");
|
|
|
1786
2003
|
var import_core7 = require("@meshsdk/core");
|
|
1787
2004
|
var import_core_csl8 = require("@meshsdk/core-csl");
|
|
1788
2005
|
|
|
1789
|
-
// src/vesting/aiken-workspace/plutus.json
|
|
1790
|
-
var
|
|
2006
|
+
// src/vesting/aiken-workspace-v1/plutus.json
|
|
2007
|
+
var plutus_default8 = {
|
|
1791
2008
|
preamble: {
|
|
1792
2009
|
title: "meshjs/vesting",
|
|
1793
2010
|
description: "Aiken contracts for project 'meshjs/vesting'",
|
|
@@ -1859,19 +2076,113 @@ var plutus_default7 = {
|
|
|
1859
2076
|
}
|
|
1860
2077
|
};
|
|
1861
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
|
+
|
|
1862
2157
|
// src/vesting/offchain.ts
|
|
1863
|
-
var MeshVestingBlueprint = plutus_default7;
|
|
1864
2158
|
var MeshVestingContract = class extends MeshTxInitiator {
|
|
1865
|
-
scriptCbor = (0, import_core_csl8.applyParamsToScript)(plutus_default7.validators[0].compiledCode, []);
|
|
1866
2159
|
constructor(inputs) {
|
|
1867
2160
|
super(inputs);
|
|
1868
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
|
+
};
|
|
1869
2180
|
depositFund = async (amount, lockUntilTimeStampMs, beneficiary) => {
|
|
1870
2181
|
const { utxos, walletAddress } = await this.getWalletInfoForTx();
|
|
1871
2182
|
const scriptAddr = (0, import_core7.serializePlutusScript)(
|
|
1872
|
-
{ code: this.
|
|
2183
|
+
{ code: this.getScriptCbor(), version: this.languageVersion },
|
|
1873
2184
|
void 0,
|
|
1874
|
-
|
|
2185
|
+
this.networkId
|
|
1875
2186
|
).address;
|
|
1876
2187
|
const { pubKeyHash: ownerPubKeyHash } = (0, import_core7.deserializeAddress)(walletAddress);
|
|
1877
2188
|
const { pubKeyHash: beneficiaryPubKeyHash } = (0, import_core7.deserializeAddress)(beneficiary);
|
|
@@ -1887,10 +2198,11 @@ var MeshVestingContract = class extends MeshTxInitiator {
|
|
|
1887
2198
|
withdrawFund = async (vestingUtxo) => {
|
|
1888
2199
|
const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
|
|
1889
2200
|
const { input: collateralInput, output: collateralOutput } = collateral;
|
|
2201
|
+
const scriptCbor = this.getScriptCbor();
|
|
1890
2202
|
const scriptAddr = (0, import_core7.serializePlutusScript)(
|
|
1891
|
-
{ code:
|
|
2203
|
+
{ code: scriptCbor, version: this.languageVersion },
|
|
1892
2204
|
void 0,
|
|
1893
|
-
|
|
2205
|
+
this.networkId
|
|
1894
2206
|
).address;
|
|
1895
2207
|
const { pubKeyHash } = (0, import_core7.deserializeAddress)(walletAddress);
|
|
1896
2208
|
const datum = (0, import_core7.deserializeDatum)(
|
|
@@ -1900,12 +2212,12 @@ var MeshVestingContract = class extends MeshTxInitiator {
|
|
|
1900
2212
|
Math.min(datum.fields[0].int, Date.now() - 15e3),
|
|
1901
2213
|
this.networkId === 0 ? import_common12.SLOT_CONFIG_NETWORK.preprod : import_common12.SLOT_CONFIG_NETWORK.mainnet
|
|
1902
2214
|
) + 1;
|
|
1903
|
-
await this.mesh.
|
|
2215
|
+
await this.mesh.spendingPlutusScript(this.languageVersion).txIn(
|
|
1904
2216
|
vestingUtxo.input.txHash,
|
|
1905
2217
|
vestingUtxo.input.outputIndex,
|
|
1906
2218
|
vestingUtxo.output.amount,
|
|
1907
2219
|
scriptAddr
|
|
1908
|
-
).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue("").txInScript(
|
|
2220
|
+
).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue("").txInScript(scriptCbor).txOut(walletAddress, []).txInCollateral(
|
|
1909
2221
|
collateralInput.txHash,
|
|
1910
2222
|
collateralInput.outputIndex,
|
|
1911
2223
|
collateralOutput.amount,
|
|
@@ -1914,14 +2226,13 @@ var MeshVestingContract = class extends MeshTxInitiator {
|
|
|
1914
2226
|
return this.mesh.txHex;
|
|
1915
2227
|
};
|
|
1916
2228
|
getUtxoByTxHash = async (txHash) => {
|
|
1917
|
-
return await this._getUtxoByTxHash(txHash, this.
|
|
2229
|
+
return await this._getUtxoByTxHash(txHash, this.getScriptCbor());
|
|
1918
2230
|
};
|
|
1919
2231
|
};
|
|
1920
2232
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1921
2233
|
0 && (module.exports = {
|
|
1922
2234
|
MeshEscrowBlueprint,
|
|
1923
2235
|
MeshEscrowContract,
|
|
1924
|
-
MeshGiftCardBlueprint,
|
|
1925
2236
|
MeshGiftCardContract,
|
|
1926
2237
|
MeshHelloWorldBlueprint,
|
|
1927
2238
|
MeshHelloWorldContract,
|
|
@@ -1931,7 +2242,6 @@ var MeshVestingContract = class extends MeshTxInitiator {
|
|
|
1931
2242
|
MeshPaymentSplitterContract,
|
|
1932
2243
|
MeshSwapBlueprint,
|
|
1933
2244
|
MeshSwapContract,
|
|
1934
|
-
MeshVestingBlueprint,
|
|
1935
2245
|
MeshVestingContract,
|
|
1936
2246
|
activeEscrowDatum,
|
|
1937
2247
|
initiateEscrowDatum,
|