@meshsdk/core-cst 1.6.0-alpha.11

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.
@@ -0,0 +1,140 @@
1
+ import {
2
+ NativeScript,
3
+ PlutusScript,
4
+ resolveFingerprint,
5
+ } from "@meshsdk/common";
6
+ import {
7
+ resolveDataHash,
8
+ resolveNativeScriptAddress,
9
+ resolveNativeScriptHash,
10
+ resolvePaymentKeyHash,
11
+ resolvePlutusScriptAddress,
12
+ resolvePlutusScriptHash,
13
+ resolvePrivateKey,
14
+ resolveRewardAddress,
15
+ resolveStakeKeyHash,
16
+ } from "@meshsdk/core-cst";
17
+
18
+ describe("resolveDataHash", () => {
19
+ it("should return correct data", () => {
20
+ expect(resolveDataHash("supersecretdatum")).toEqual(
21
+ "d786b11f300b0a7b4e0fe7931eb7871fb7ed762c0a060cd1f922dfa631cafb8c",
22
+ );
23
+ });
24
+ });
25
+
26
+ describe("resolveFingerprint", () => {
27
+ it("should return correct data", () => {
28
+ expect(
29
+ resolveFingerprint(
30
+ "426117329844ccb3b0ba877220ff06a5bdf21eab3fb33e2f3a3f8e69",
31
+ "4d657368546f6b656e",
32
+ ),
33
+ ).toEqual("asset1w7z7f29z9pxy6epred5j2a0vsc69nllw8tcpf6");
34
+ });
35
+ });
36
+
37
+ describe("resolveNativeScriptAddress", () => {
38
+ it("should return correct data", () => {
39
+ const keyHash = resolvePaymentKeyHash(
40
+ "addr1v9vx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0c93pyfx",
41
+ );
42
+ const nativeScript: NativeScript = {
43
+ type: "all",
44
+ scripts: [
45
+ {
46
+ type: "sig",
47
+ keyHash: keyHash,
48
+ },
49
+ ],
50
+ };
51
+ expect(resolveNativeScriptAddress(nativeScript, 1)).toEqual(
52
+ "addr1w8m53kq6d06vrah40nux9qqhjqd8xcu686u60wm8x25vpjg6eys0w",
53
+ );
54
+ });
55
+ });
56
+
57
+ describe("resolveNativeScriptHash", () => {
58
+ it("should return correct data", () => {
59
+ const keyHash = resolvePaymentKeyHash(
60
+ "addr1v9vx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0c93pyfx",
61
+ );
62
+ const nativeScript: NativeScript = {
63
+ type: "all",
64
+ scripts: [
65
+ {
66
+ type: "sig",
67
+ keyHash: keyHash,
68
+ },
69
+ ],
70
+ };
71
+ expect(resolveNativeScriptHash(nativeScript)).toEqual(
72
+ "f748d81a6bf4c1f6f57cf8628017901a73639a3eb9a7bb6732a8c0c9",
73
+ );
74
+ });
75
+ });
76
+
77
+ describe("resolvePaymentKeyHash", () => {
78
+ it("should return correct data", () => {
79
+ expect(
80
+ resolvePaymentKeyHash(
81
+ "addr_test1vpvx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0c7e4cxr",
82
+ ),
83
+ ).toEqual("5867c3b8e27840f556ac268b781578b14c5661fc63ee720dbeab663f");
84
+ });
85
+ });
86
+
87
+ describe("resolvePlutusScriptAddress", () => {
88
+ it("should return correct data", () => {
89
+ const script: PlutusScript = {
90
+ code: "4e4d01000033222220051200120011",
91
+ version: "V1",
92
+ };
93
+
94
+ expect(resolvePlutusScriptAddress(script, 0)).toEqual(
95
+ "addr_test1wpnlxv2xv9a9ucvnvzqakwepzl9ltx7jzgm53av2e9ncv4sysemm8",
96
+ );
97
+ });
98
+ });
99
+
100
+ describe("resolvePlutusScriptHash", () => {
101
+ it("should return correct data", () => {
102
+ expect(
103
+ resolvePlutusScriptHash(
104
+ "addr_test1wpnlxv2xv9a9ucvnvzqakwepzl9ltx7jzgm53av2e9ncv4sysemm8",
105
+ ),
106
+ ).toEqual("67f33146617a5e61936081db3b2117cbf59bd2123748f58ac9678656");
107
+ });
108
+ });
109
+
110
+ describe("resolvePrivateKey", () => {
111
+ it("should return correct data", () => {
112
+ expect(
113
+ resolvePrivateKey("solution,".repeat(24).split(",").slice(0, 24)),
114
+ ).toEqual(
115
+ "xprv1cqa46gk29plgkg98upclnjv5t425fcpl4rgf9mq2txdxuga7jfq5shk7np6l55nj00sl3m4syzna3uwgrwppdm0azgy9d8zahyf32s62klfyhe0ayyxkc7x92nv4s77fa0v25tufk9tnv7x6dgexe9kdz5gpeqgu",
116
+ );
117
+ });
118
+ });
119
+
120
+ describe("resolveRewardAddress", () => {
121
+ it("should return correct data", () => {
122
+ expect(
123
+ resolveRewardAddress(
124
+ "addr_test1qzl2r3fpmav0fmh0vrry0e0tmzxxqwv32sylnlty2jj8dwg636sfudakhsh65qggs4ttjjsk8fuu3fkd65uaxcxv0tfqv3z0y3",
125
+ ),
126
+ ).toEqual(
127
+ "stake_test1uqdgagy7x7mtcta2qyyg244efgtr57wg5mxa2wwnvrx845s4sa2vp",
128
+ );
129
+ });
130
+ });
131
+
132
+ describe("resolveStakeKeyHash", () => {
133
+ it("should return correct data", () => {
134
+ expect(
135
+ resolveStakeKeyHash(
136
+ "stake1u93r8fsv43jyuw84yv4xwzfmka5sms5u5karqjysw2jszaq2kapyl",
137
+ ),
138
+ ).toEqual("6233a60cac644e38f5232a67093bb7690dc29ca5ba30489072a50174");
139
+ });
140
+ });
@@ -0,0 +1,18 @@
1
+ import { PlutusScript } from "@meshsdk/common";
2
+
3
+ import { fromScriptRef } from "../../src/utils/converter";
4
+
5
+ describe("fromScriptRef", () => {
6
+ // it("with native script cbor should return correct NativeScript", () => {});
7
+ // it("with V1 script cbor should return correct PlutusScript", () => {});
8
+ it("with V2 script cbor should return correct PlutusScript", () => {
9
+ const cbor =
10
+ "82025912b70100003333323232323232323232232232232232222323232323253330133232323232323232323232323232323232323232323232323232533302d3370e9000000899191919191919299981a19b8748000c0cc0044c8c8c8c8c8c8c8c94ccc0fcc1080084c94ccc0f4cdc3a400460780242646464a66608066e1d2000303f001132323232323232325333048002100114a0646600200200844a66609800229444c8c94ccc12cc8c8c8c8c8c8c8c8c8c94ccc154cdc3a400060a800426464a6660ae66e1d200030560051330303303d001375660b860aa00a0120066eacc16c004c14c0080044c94ccc154cdc3a400060a800426464a6660ae66e1d20023056005133030001009003375660b600260a6004002264a6660aa66e1d20023054002153330553370e9000182a0018998171bab305a305300300700100114a060a800460a800266ec0008004cc0cc02c00ccc0c8028010dd5982800118270009919bb03052001305230530013758609c00660980042660080080022940c140008c138004cc080dd6182598261826182618261826182618261826182200e806991980080080a1129998250008a5eb7bdb1804cc88c8c8c94ccc130cdc3a400400226666060008606e609400a6eacc0a4c1280140c44cccc0c0010c0dcc128014cc0c8dd5982898250011bab3029304a005031304a0013302d00200130343047002304c00133002002304d0013756608a002646600200202c44a666090002297bdb180101a000010100001332232533304800113253330493370e90001824000899191919191919191919299982b182c80109919191919299982c19b87480080044cdd81ba63333040375660b202401866ec0038dd30010209ba8337006eb4c1680480184c8c8cdd81ba63333042375660b602801c66ec0c16c004dd3198201bab305c001004043375066e00dd6982e00a0041919bb0305f001305f3060001375860bc00260ac00660ac004a6660ac010266607a6eb8c15c138dd7182c027002099981e9bae305704c375c60b009866e0ccdc10030022410112f464646600200200444a6660b60022980103d87a8000132323232533305c3375e020004266e95200033060374e660c060ba002660c060bc00297ae04bd700998030030019919bb0306100130613062001375860ba00660b600460be00460ba0026eacc15803cc114020c11002458dd6982b800982b8011bad305500130550023370e900118279baa3053001305300230510013051002304f0013047001163232533304a3370e900218248008982798240008b181a982380098129823001880119baf0053032304530243045002304a00133002002304b001302d3040301f30400013046001303e001163301a37586054607a02c002608600260760242c605a00a2c6eb8c100004c100008dd7181f000981f001181e000981e0011bae303a00130320011633300f00302f4881003758606e002606e0046eb0c0d4004c0d4008dd6181980098158020a99981699b87480080044c8c8c8c8c8c8c8c8c8c8c8c8c8c94ccc0eccdc3a400460740202646464a66607c66e1d2000303d0011323232323253330433370e9000000899191919299982399b87480000045288a50304500230340013049001304100214a0608200264a66608466e1d20003041001132323253330453370e9000182200089919299982399baf303230453024304500100713374a90001982580225eb805300103d87a8000304b0013043001163301f014016304800130400011632323300100100922533304700114c103d87a800013232323253330483375e00e004266e9520003304c0014bd70099803003001982480198238011825801182480099ba548008cc11404d2f5c06056607c603a607c002608800260780022c660306eb0c0a0c0ec050004c104004c0e404058dd5981f800981f800981f000981e800981e000981d800981d000981c800981c000981b8011bac3035001302d0063033001302b0211533302d3370e90020008a99981699b8748008c0b00084c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c94ccc100cdc3a4000607e002264646464a66608e609400426464a6660926098004264a66608e66e1d20003046001132323232323232325333052305500213232325333052002100114a06605602c00a66ebcc0b4c138c0b4c138034c0b4c13802cc10001458dd7182980098298011bae30510013051002304f001304f002375c609a002608a0022c6660440280849110016304a0013302501023375e6060608600200e2c60900026466048026466ebcc0bcc108c084c108004008c0b4c100c07cc100004c118004c0f800458cc068dd61815181e80b00898218009821800981d0189bac30400013040001303f001303e001303d001303c001303b0023758607200260720046eb0c0dc004c0dc008dd6181a8009816803181980098158010b099911929998198008a501325333034001132323232533303553330353371e00205e266e3c00801c528099b87003480045281bae3039003375c607060720046eb4c0dcc0e0c0e0004dd6181b0010a503036001300f323300100100322533303400114bd6f7b630099191919299981a99b8f489000021003133039337606ea4008dd3000998030030019bab3036003375c60680046070004606c0026eacc0c8c0ccc0ccc0ccc0ccc0ac010c8c94ccc0bccdc3a4004605c002264646464a66606666e1d2002001130110031323253330353370e9000181a0008991919299981c19b87480000044c058cc05c020dd7181e981b0010980b1980b8041bae303d30360023036001303b001303300116303900130310023031001300e302f004375c606a002605a0022c60326058002606460666056044605604060600026060004605c002604c0364464646600200200444a66605e00229444c8c94ccc0b8cdc49bad301a002333010007375c60320046eb8c02c0084cc01001000452818198011bac3031001300900122323300100100322533302d00114a026464a66605866e3c00801452889980200200098188011bae302f001223301100223375e6026604c00200444464a66605066e1d200030270011323232533302b3370e900218150008981818148008b180b181418039814000981700098130008b19808801919b8733300a3756600a604c600a604c002006004900111814981500091b9400122337140040024646600200200444a66604c002297ae0132333222323300100100322533302c00110031323302e374e6605c6ea4018cc0b8dd49bae302b0013302e37506eb4c0b00052f5c0660060066060004605c0026eb8c094004dd5981300099801801981500118140009119198008008019129998130008a5eb804c8c94ccc094c0140084cc0a4008cc0100100044cc010010004c0a8008c0a0004888c8c8c94ccc090cdc3a40040022900009bad3029302200230220013253330233370e90010008a6103d87a8000132323300100100222533302900114c103d87a8000132323232533302a3371e014004266e9520003302e375000297ae0133006006003375a60560066eb8c0a4008c0b4008c0ac004dd598141810801181080099198008008021129998130008a6103d87a800013232323253330273371e010004266e9520003302b374c00297ae0133006006003375660500066eb8c098008c0a8008c0a000488c8cc00400400c894ccc0900045300103d87a800013232323253330253375e00e004266e95200033029374c00297ae01330060060033756604c00660480046050004604c0024444646600200200a44a66604a00226604c66ec0014dd300225eb7bdb1804c8c8c8c94ccc098cdd79980380480126103d879800013302a337600126e9802001454ccc098cdd780480109981519bb0009374c01000626605466ec0008dd3000998030030019bab30270033025002302900230270012232323232323253330233370e9001181100109919299981299b8748008c0900144cc048004dd7181518118028019bae3029001302100200113253330233370e9000181100109919299981299b8748000c0900144cc048004dd7181518118028019bae3029001302100200114c103d87a8000302200230220013376000400260126038004601060360044464666002002006004444a6660440042002264666008008604c0066644646600200200a44a66604e00226605066ec0dd48021ba60034bd6f7b630099191919299981419baf330150080024c103d879800013302c337606ea4020dd30038028a99981419b8f00800213232533302a3370e900000089981719bb03752014605e605000400a200a605000264a666052a66605800229445280a60103d87a800013374a9000198169ba60014bd70191998008008040011112999817001080089919980200218190019991191980080080291299981980089981a19bb037520086ea000d2f5bded8c0264646464a66606866ebccc084020009300103d8798000133038337606ea4020dd40038028a99981a19b8f0080021323253330363370e900000089981d19bb037520146076606800400a200a606800264a66606a66e1c005200014c103d87a800013374a90001981c9ba80014bd7019b80007001133038337606ea4008dd4000998030030019bad3035003375c6066004606e004606a0026eb8c0b4004dd69817000981800109981619bb037520046e98004cc01801800cdd598148019bae3027002302b0023029001375c60420026eacc088004c0900088894ccc070cdc3800a4000297adef6c6013232330010014bd6f7b63011299981100089981199bb0375200c6e9800d2f5bded8c0264646464a66604666ebccc040028009300103d8798000133027337606ea4028dd30038028a99981199b8f00a002133027337606ea4028dd300380189981399bb037520046e98004cc01801800cdd598120019bae30220023026002302400132330010014bd6f7b63011299981080089981119bb037520086ea000d2f5bded8c0264646464a66604466ebccc03c02000930103d8798000133026337606ea4020dd40038028a99981119b8f008002133026337606ea4020dd400380189981319bb037520046ea0004cc01801800cdd698118019bae302100230250023023001222232330010010052253330210011330223376000a6e9ccc088c07c010cc088c0800112f5c097adef6c6013232323253330223375e6600e012004980103d8798000133026337600126e9ccc098c08c020cc098c0900212f5c000a2a66604466ebc0240084cc098cdd80049ba73302630230083302630240084bd7000189981319bb0002374e6604c60460026604c604800297ae0330060060033233760604e002604e60500026eb0c08c00cc084008c094008c08c00488c94ccc068cdc3a400460320022646464a66603a66e1d2002301c00113300a002375c604460360022c600e60340086eb8c080004c06000458c010c05c00888c8cc00400400c894ccc0740045300103d87a800013232533301c300500213374a90001981000125eb804cc010010004c084008c07c0048c06c0048c068c06cc06c004894ccc054cdc80010008a6103d8798000153330153371e0040022980103d87a800014c103d87b800014984d958c0040188c94ccc04ccdc3a40000022a66602c60220042930b0a99980999b87480080044c8c94ccc060c06c0084c9263253330163370e9000000899191919299980e981000109924c64a66603666e1d20000011323253330203023002149858dd71810800980c8020b180c8018b1bad301e001301e002301c00130140021630140011630190013011002153330133370e90020008a99980b18088010a4c2c2a66602666e1d200600115333016301100214985858c044004c94ccc044cdc3a4000002264646464646464646464a66603c60420042646493180680418060048b1bad301f001301f002375a603a002603a00466e1d2002301737546036002603600460320026032004602e002601e00c2c601e00a464a66602266e1d20000011323232325333018301b00213232498c94ccc05ccdc3a400000226464a666038603e0042649319299980d19b87480000044c8c94ccc07cc0880084c926300e00116302000130180021533301a3370e90010008991919191919299981198130010a4c2c6eb4c090004c090008dd6981100098110011bad3020001301800216301800116301d0013015003153330173370e90010008a99980d180a8018a4c2c2c602a004600e0062c60320026032004602e002601e0042c601e002464a66602066e1d20000011323253330153018002149858dd7180b00098070010a99980819b87480080044c8c94ccc054c06000852616375c602c002601c0042c601c0026466ec0c040004c040c044004dd60009919bb0300e001300e300f00137580026eb8004dd7000918029baa001230033754002ae6955ceaab9e5573eae815d0aba24c11e581ce6e5285a878161c101a59b4e36f1f99e5e464d30f510be3ee34f907f004c011e581c2291f67ee643db1a830734bd54d39022c5d1f990682e689c95d8fed0004c01049f4040ff004c01259f581c5066154a102ee037390c5236f78db23239b49c5748d3d349f3ccf04b4455534458ff0001";
11
+ const script = fromScriptRef(cbor) as PlutusScript;
12
+
13
+ expect(script.code).toEqual(cbor.slice(4));
14
+ expect(script.version).toEqual("V2");
15
+ });
16
+ // it("with V3 script cbor should return correct PlutusScript", () => {});
17
+ // it("with invalid script cbor should return undefined", () => {});
18
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "@meshsdk/typescript-config/base.json",
3
+ "include": ["src/**/*"],
4
+ "exclude": ["dist", "node_modules"]
5
+ }