@meshsdk/common 1.6.0-alpha.21 → 1.6.1
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 +1 -0
- package/dist/{index.d.mts → index.d.cts} +96 -8
- package/dist/index.d.ts +96 -8
- package/dist/index.js +1 -1316
- package/package.json +28 -9
- package/.turbo/turbo-build$colon$docs.log +0 -17
- package/.turbo/turbo-build$colon$mesh.log +0 -19
- package/.turbo/turbo-build.log +0 -19
- package/dist/index.mjs +0 -1189
- package/src/constants/cost-models.ts +0 -30
- package/src/constants/index.ts +0 -86
- package/src/constants/language-views.ts +0 -19
- package/src/constants/protocol-parameters.ts +0 -34
- package/src/constants/supported-wallets.ts +0 -12
- package/src/data/index.ts +0 -5
- package/src/data/json/aliases.ts +0 -218
- package/src/data/json/constructors.ts +0 -56
- package/src/data/json/credentials.ts +0 -77
- package/src/data/json/index.ts +0 -33
- package/src/data/json/primitives.ts +0 -154
- package/src/data/mesh/aliases.ts +0 -85
- package/src/data/mesh/constructors.ts +0 -68
- package/src/data/mesh/credentials.ts +0 -77
- package/src/data/mesh/index.ts +0 -4
- package/src/data/mesh/primitives.ts +0 -37
- package/src/data/parser.ts +0 -36
- package/src/data/time.ts +0 -92
- package/src/data/value.ts +0 -70
- package/src/index.ts +0 -7
- package/src/interfaces/evaluator.ts +0 -5
- package/src/interfaces/fetcher.ts +0 -31
- package/src/interfaces/index.ts +0 -7
- package/src/interfaces/initiator.ts +0 -9
- package/src/interfaces/listener.ts +0 -3
- package/src/interfaces/serializer.ts +0 -53
- package/src/interfaces/signer.ts +0 -12
- package/src/interfaces/submitter.ts +0 -3
- package/src/types/account-info.ts +0 -7
- package/src/types/action.ts +0 -15
- package/src/types/asset-extended.ts +0 -9
- package/src/types/asset-metadata.ts +0 -102
- package/src/types/asset.ts +0 -23
- package/src/types/block-info.ts +0 -17
- package/src/types/data-signature.ts +0 -4
- package/src/types/data.ts +0 -10
- package/src/types/deserialized/deserialized-address.ts +0 -6
- package/src/types/deserialized/deserialized-script.ts +0 -4
- package/src/types/deserialized/index.ts +0 -2
- package/src/types/era.ts +0 -1
- package/src/types/index.ts +0 -24
- package/src/types/message.ts +0 -4
- package/src/types/mint.ts +0 -12
- package/src/types/native-script.ts +0 -18
- package/src/types/network.ts +0 -7
- package/src/types/plutus-script.ts +0 -8
- package/src/types/pool-params.ts +0 -41
- package/src/types/protocol.ts +0 -22
- package/src/types/recipient.ts +0 -15
- package/src/types/relay.ts +0 -42
- package/src/types/token.ts +0 -3
- package/src/types/transaction-builder/data.ts +0 -31
- package/src/types/transaction-builder/index.ts +0 -73
- package/src/types/transaction-builder/mint.ts +0 -11
- package/src/types/transaction-builder/output.ts +0 -12
- package/src/types/transaction-builder/script.ts +0 -27
- package/src/types/transaction-builder/txin.ts +0 -46
- package/src/types/transaction-builder/withdrawal.ts +0 -207
- package/src/types/transaction-info.ts +0 -11
- package/src/types/utxo.ts +0 -16
- package/src/types/wallet.ts +0 -6
- package/src/utils/asset-fingerprint.ts +0 -11
- package/src/utils/bigNum.ts +0 -61
- package/src/utils/index.ts +0 -2
- package/test/data/json/aliases.test.ts +0 -135
- package/test/data/json/constructors.test.ts +0 -38
- package/test/data/json/credentials.test.ts +0 -84
- package/test/data/json/primitives.test.ts +0 -133
- package/test/data/mesh/aliases.test.ts +0 -45
- package/test/data/mesh/common.ts +0 -14
- package/test/data/mesh/constructors.test.ts +0 -53
- package/test/data/mesh/credentials.test.ts +0 -74
- package/test/data/mesh/primitives.test.ts +0 -41
- package/test/data/value.test.ts +0 -108
- package/tsconfig.json +0 -5
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_V1_COST_MODEL_LIST = [
|
|
2
|
-
205665, 812, 1, 1, 1000, 571, 0, 1, 1000, 24177, 4, 1, 1000, 32, 117366,
|
|
3
|
-
10475, 4, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000,
|
|
4
|
-
100, 100, 100, 23000, 100, 19537, 32, 175354, 32, 46417, 4, 221973, 511, 0, 1,
|
|
5
|
-
89141, 32, 497525, 14068, 4, 2, 196500, 453240, 220, 0, 1, 1, 1000, 28662, 4,
|
|
6
|
-
2, 245000, 216773, 62, 1, 1060367, 12586, 1, 208512, 421, 1, 187000, 1000,
|
|
7
|
-
52998, 1, 80436, 32, 43249, 32, 1000, 32, 80556, 1, 57667, 4, 1000, 10,
|
|
8
|
-
197145, 156, 1, 197145, 156, 1, 204924, 473, 1, 208896, 511, 1, 52467, 32,
|
|
9
|
-
64832, 32, 65493, 32, 22558, 32, 16563, 32, 76511, 32, 196500, 453240, 220, 0,
|
|
10
|
-
1, 1, 69522, 11687, 0, 1, 60091, 32, 196500, 453240, 220, 0, 1, 1, 196500,
|
|
11
|
-
453240, 220, 0, 1, 1, 806990, 30482, 4, 1927926, 82523, 4, 265318, 0, 4, 0,
|
|
12
|
-
85931, 32, 205665, 812, 1, 1, 41182, 32, 212342, 32, 31220, 32, 32696, 32,
|
|
13
|
-
43357, 32, 32247, 32, 38314, 32, 57996947, 18975, 10,
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
export const DEFAULT_V2_COST_MODEL_LIST = [
|
|
17
|
-
205665, 812, 1, 1, 1000, 571, 0, 1, 1000, 24177, 4, 1, 1000, 32, 117366,
|
|
18
|
-
10475, 4, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000,
|
|
19
|
-
100, 100, 100, 23000, 100, 19537, 32, 175354, 32, 46417, 4, 221973, 511, 0, 1,
|
|
20
|
-
89141, 32, 497525, 14068, 4, 2, 196500, 453240, 220, 0, 1, 1, 1000, 28662, 4,
|
|
21
|
-
2, 245000, 216773, 62, 1, 1060367, 12586, 1, 208512, 421, 1, 187000, 1000,
|
|
22
|
-
52998, 1, 80436, 32, 43249, 32, 1000, 32, 80556, 1, 57667, 4, 1000, 10,
|
|
23
|
-
197145, 156, 1, 197145, 156, 1, 204924, 473, 1, 208896, 511, 1, 52467, 32,
|
|
24
|
-
64832, 32, 65493, 32, 22558, 32, 16563, 32, 76511, 32, 196500, 453240, 220, 0,
|
|
25
|
-
1, 1, 69522, 11687, 0, 1, 60091, 32, 196500, 453240, 220, 0, 1, 1, 196500,
|
|
26
|
-
453240, 220, 0, 1, 1, 1159724, 392670, 0, 2, 806990, 30482, 4, 1927926, 82523,
|
|
27
|
-
4, 265318, 0, 4, 0, 85931, 32, 205665, 812, 1, 1, 41182, 32, 212342, 32,
|
|
28
|
-
31220, 32, 32696, 32, 43357, 32, 32247, 32, 38314, 32, 35892428, 10, 57996947,
|
|
29
|
-
18975, 10, 38887044, 32947, 10,
|
|
30
|
-
];
|
package/src/constants/index.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import type { Budget, Era, Network } from "../types";
|
|
2
|
-
|
|
3
|
-
export * from "./protocol-parameters";
|
|
4
|
-
export * from "./supported-wallets";
|
|
5
|
-
export * from "./cost-models";
|
|
6
|
-
export * from "./language-views";
|
|
7
|
-
|
|
8
|
-
export const DEFAULT_REDEEMER_BUDGET: Budget = {
|
|
9
|
-
mem: 7_000_000,
|
|
10
|
-
steps: 3_000_000_000,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const POLICY_ID_LENGTH = 56;
|
|
14
|
-
|
|
15
|
-
export const LANGUAGE_VERSIONS = {
|
|
16
|
-
V1: "V1",
|
|
17
|
-
V2: "V2",
|
|
18
|
-
V3: "V3",
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const HARDENED_KEY_START = 0x80000000;
|
|
22
|
-
|
|
23
|
-
export const SUPPORTED_CLOCKS: Record<
|
|
24
|
-
Network,
|
|
25
|
-
[epoch: string, slot: string, systemStart: string, epochLength: string]
|
|
26
|
-
> = {
|
|
27
|
-
testnet: ["74", "1598400", "1595967616", "432000"],
|
|
28
|
-
preview: ["183", "15811222", "1682467200", "86400"],
|
|
29
|
-
preprod: ["65", "26438400", "1682121600", "432000"],
|
|
30
|
-
mainnet: ["208", "4492800", "1596059091", "432000"],
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const SUPPORTED_HANDLES: Record<number, string> = {
|
|
34
|
-
0: "8d18d786e92776c824607fd8e193ec535c79dc61ea2405ddf3b09fe3",
|
|
35
|
-
1: "f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a",
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const SUPPORTED_OGMIOS_LINKS: Record<Network, string> = {
|
|
39
|
-
mainnet: "wss://ogmios-api.mainnet.dandelion.link",
|
|
40
|
-
preprod: "wss://ogmios-api.iohk-preprod.dandelion.link",
|
|
41
|
-
preview: "__TBD_SOON_TM__",
|
|
42
|
-
testnet: "wss://ogmios-api.testnet.dandelion.link",
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const SUPPORTED_TOKENS = {
|
|
46
|
-
LQ: "da8c30857834c6ae7203935b89278c532b3995245295456f993e1d244c51",
|
|
47
|
-
MIN: "29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c64d494e",
|
|
48
|
-
NTX: "edfd7a1d77bcb8b884c474bdc92a16002d1fb720e454fa6e993444794e5458",
|
|
49
|
-
iBTC: "f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069425443",
|
|
50
|
-
iETH: "f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069455448",
|
|
51
|
-
iUSD: "f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069555344",
|
|
52
|
-
MILK: "8a1cfae21368b8bebbbed9800fec304e95cce39a2a57dc35e2e3ebaa4d494c4b",
|
|
53
|
-
AGIX: "f43a62fdc3965df486de8a0d32fe800963589c41b38946602a0dc53541474958",
|
|
54
|
-
MELD: "6ac8ef33b510ec004fe11585f7c5a9f0c07f0c23428ab4f29c1d7d104d454c44",
|
|
55
|
-
INDY: "533bb94a8850ee3ccbe483106489399112b74c905342cb1792a797a0494e4459",
|
|
56
|
-
CLAY: "38ad9dc3aec6a2f38e220142b9aa6ade63ebe71f65e7cc2b7d8a8535434c4159",
|
|
57
|
-
MCOS: "6f46e1304b16d884c85c62fb0eef35028facdc41aaa0fd319a152ed64d434f53",
|
|
58
|
-
DING: "ce5b9e0f8a88255b65f2e4d065c6e716e9fa9a8a86dfb86423dd1ac044494e47",
|
|
59
|
-
GERO: "10a49b996e2402269af553a8a96fb8eb90d79e9eca79e2b4223057b64745524f",
|
|
60
|
-
NMKR: "5dac8536653edc12f6f5e1045d8164b9f59998d3bdc300fc928434894e4d4b52",
|
|
61
|
-
PAVIA: "884892bcdc360bcef87d6b3f806e7f9cd5ac30d999d49970e7a903ae5041564941",
|
|
62
|
-
HOSKY: "a0028f350aaabe0545fdcb56b039bfb08e4bb4d8c4d7c3c7d481c235484f534b59",
|
|
63
|
-
YUMMI: "078eafce5cd7edafdf63900edef2c1ea759e77f30ca81d6bbdeec92479756d6d69",
|
|
64
|
-
C3: "8e51398904a5d3fc129fbf4f1589701de23c7824d5c90fdb9490e15a434841524c4933",
|
|
65
|
-
GIMBAL:
|
|
66
|
-
"2b0a04a7b60132b1805b296c7fcb3b217ff14413991bf76f72663c3067696d62616c",
|
|
67
|
-
SUNDAE:
|
|
68
|
-
"9a9693a9a37912a5097918f97918d15240c92ab729a0b7c4aa144d7753554e444145",
|
|
69
|
-
GREENS:
|
|
70
|
-
"4623ab311b7d982d8d26fcbe1a9439ca56661aafcdcd8d8a0ef31fd6475245454e53",
|
|
71
|
-
GENS: "dda5fdb1002f7389b33e036b6afee82a8189becb6cba852e8b79b4fb0014df1047454e53",
|
|
72
|
-
SOCIETY:
|
|
73
|
-
"25f0fc240e91bd95dcdaebd2ba7713fc5168ac77234a3d79449fc20c534f4349455459",
|
|
74
|
-
DJED: "8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344",
|
|
75
|
-
SHEN: "8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd615368656e4d6963726f555344",
|
|
76
|
-
WMT: "1d7f33bd23d85e1a25d87d86fac4f199c3197a2f7afeb662a0f34e1e776f726c646d6f62696c65746f6b656e",
|
|
77
|
-
COPI: "b6a7467ea1deb012808ef4e87b5ff371e85f7142d7b356a40d9b42a0436f726e75636f70696173205b76696120436861696e506f72742e696f5d",
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export const CIP68_100 = (tokenNameHex: string) => {
|
|
81
|
-
return `000643b0${tokenNameHex}`;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export const CIP68_222 = (tokenNameHex: string) => {
|
|
85
|
-
return `000de140${tokenNameHex}`;
|
|
86
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { LANGUAGE_VERSIONS } from ".";
|
|
2
|
-
import { Era, LanguageVersion } from "../types";
|
|
3
|
-
|
|
4
|
-
export const SUPPORTED_LANGUAGE_VIEWS: Record<
|
|
5
|
-
Era,
|
|
6
|
-
Partial<Record<keyof typeof LANGUAGE_VERSIONS, string>>
|
|
7
|
-
> = {
|
|
8
|
-
ALONZO: {
|
|
9
|
-
V1: "a141005901d59f1a000302590001011a00060bc719026d00011a000249f01903e800011a000249f018201a0025cea81971f70419744d186419744d186419744d186419744d186419744d186419744d18641864186419744d18641a000249f018201a000249f018201a000249f018201a000249f01903e800011a000249f018201a000249f01903e800081a000242201a00067e2318760001011a000249f01903e800081a000249f01a0001b79818f7011a000249f0192710011a0002155e19052e011903e81a000249f01903e8011a000249f018201a000249f018201a000249f0182001011a000249f0011a000249f0041a000194af18f8011a000194af18f8011a0002377c190556011a0002bdea1901f1011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000242201a00067e23187600010119f04c192bd200011a000249f018201a000242201a00067e2318760001011a000242201a00067e2318760001011a0025cea81971f704001a000141bb041a000249f019138800011a000249f018201a000302590001011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a00330da70101ff",
|
|
10
|
-
},
|
|
11
|
-
BABBAGE: {
|
|
12
|
-
V1: "a141005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff",
|
|
13
|
-
V2: "a20198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201b00000004a817c8001b00000004a817c8001a009063b91903fd0a1b00000004a817c800001b00000004a817c80041005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff",
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const resolveLanguageView = (era: Era, version: LanguageVersion) => {
|
|
18
|
-
return SUPPORTED_LANGUAGE_VIEWS[era][version];
|
|
19
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Protocol } from "../types/protocol";
|
|
2
|
-
|
|
3
|
-
export const DEFAULT_PROTOCOL_PARAMETERS: Protocol = {
|
|
4
|
-
epoch: 0,
|
|
5
|
-
coinsPerUtxoSize: 4310,
|
|
6
|
-
priceMem: 0.0577,
|
|
7
|
-
priceStep: 0.0000721,
|
|
8
|
-
minFeeA: 44,
|
|
9
|
-
minFeeB: 155381,
|
|
10
|
-
keyDeposit: 2000000,
|
|
11
|
-
maxTxSize: 16384,
|
|
12
|
-
maxValSize: 5000,
|
|
13
|
-
poolDeposit: 500000000,
|
|
14
|
-
maxCollateralInputs: 3,
|
|
15
|
-
decentralisation: 0,
|
|
16
|
-
maxBlockSize: 98304,
|
|
17
|
-
collateralPercent: 150,
|
|
18
|
-
maxBlockHeaderSize: 1100,
|
|
19
|
-
minPoolCost: "340000000",
|
|
20
|
-
maxTxExMem: "16000000",
|
|
21
|
-
maxTxExSteps: "10000000000",
|
|
22
|
-
maxBlockExMem: "80000000",
|
|
23
|
-
maxBlockExSteps: "40000000000",
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const resolveTxFees = (
|
|
27
|
-
txSize: number,
|
|
28
|
-
minFeeA = DEFAULT_PROTOCOL_PARAMETERS.minFeeA,
|
|
29
|
-
minFeeB = DEFAULT_PROTOCOL_PARAMETERS.minFeeB,
|
|
30
|
-
) => {
|
|
31
|
-
const fees = BigInt(minFeeA) * BigInt(txSize) + BigInt(minFeeB);
|
|
32
|
-
|
|
33
|
-
return fees.toString();
|
|
34
|
-
};
|
package/src/data/index.ts
DELETED
package/src/data/json/aliases.ts
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* All the type aliases here represent the type name used in smart contracts from PlutusTx or Aiken.
|
|
3
|
-
* Please be aware that the types constructed here will be invalid when PlutusTx or Aiken team introduces breaking changes.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { PlutusData } from ".";
|
|
7
|
-
import { POLICY_ID_LENGTH } from "../../constants";
|
|
8
|
-
import { conStr0, ConStr0 } from "./constructors";
|
|
9
|
-
import { byteString, ByteString, integer, Integer, list } from "./primitives";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The Plutus Data script hash in JSON
|
|
13
|
-
*/
|
|
14
|
-
export type ScriptHash = ByteString;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The Plutus Data public key hash in JSON
|
|
18
|
-
*/
|
|
19
|
-
export type PubKeyHash = ByteString;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Aiken alias
|
|
23
|
-
* The Plutus Data policy id in JSON
|
|
24
|
-
*/
|
|
25
|
-
export type PolicyId = ByteString;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* PlutusTx alias
|
|
29
|
-
* The Plutus Data currency symbol in JSON
|
|
30
|
-
*/
|
|
31
|
-
export type CurrencySymbol = ByteString;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Aiken alias
|
|
35
|
-
* The Plutus Data asset name in JSON
|
|
36
|
-
*/
|
|
37
|
-
export type AssetName = ByteString;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* PlutusTx alias
|
|
41
|
-
* The Plutus Data token name in JSON
|
|
42
|
-
*/
|
|
43
|
-
export type TokenName = ByteString;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* PlutusTx alias
|
|
47
|
-
* The Plutus Data asset class in JSON
|
|
48
|
-
*/
|
|
49
|
-
export type AssetClass = ConStr0<[CurrencySymbol, TokenName]>;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Aiken alias
|
|
53
|
-
* The Plutus Data output reference in JSON
|
|
54
|
-
*/
|
|
55
|
-
export type OutputReference = ConStr0<[ConStr0<[ByteString]>, Integer]>;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* PlutusTx alias
|
|
59
|
-
* The Plutus Data TxOutRef in JSON
|
|
60
|
-
*/
|
|
61
|
-
export type TxOutRef = ConStr0<[ConStr0<[ByteString]>, Integer]>;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* PlutusTx alias
|
|
65
|
-
* The Plutus Data POSIX time in JSON
|
|
66
|
-
*/
|
|
67
|
-
export type POSIXTime = Integer;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Aiken alias
|
|
71
|
-
* The Plutus Data dictionary item in JSON
|
|
72
|
-
*/
|
|
73
|
-
export type DictItem<V> = { k: ByteString; v: V };
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Aiken alias
|
|
77
|
-
* The Plutus Data dictionary in JSON
|
|
78
|
-
*/
|
|
79
|
-
export type Dict<V> = { map: DictItem<V>[] };
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Aiken alias
|
|
83
|
-
* The Plutus Data tuple in JSON
|
|
84
|
-
*/
|
|
85
|
-
export type Tuple<K, V> = { list: [K, V] };
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Internal utility function to create a Plutus Data byte string in JSON, checking correct length
|
|
89
|
-
* @param bytes The byte string in hex
|
|
90
|
-
* @returns The Plutus Data byte string object
|
|
91
|
-
*/
|
|
92
|
-
export const hashByteString = (bytes: string): ByteString => {
|
|
93
|
-
if (bytes.length !== 56) {
|
|
94
|
-
throw new Error(`Invalid hash for [${bytes}] - should be 56 bytes long`);
|
|
95
|
-
}
|
|
96
|
-
return byteString(bytes);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* The utility function to create a Plutus Data script hash in JSON
|
|
101
|
-
* @param bytes The script hash in hex
|
|
102
|
-
* @returns The Plutus Data script hash object
|
|
103
|
-
*/
|
|
104
|
-
export const scriptHash = (bytes: string): ScriptHash => hashByteString(bytes);
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* The utility function to create a Plutus Data pub key hash in JSON
|
|
108
|
-
* @param bytes The script hash in hex
|
|
109
|
-
* @returns The Plutus Data script hash object
|
|
110
|
-
*/
|
|
111
|
-
export const pubKeyHash = (bytes: string): ScriptHash => hashByteString(bytes);
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* The utility function to create a Plutus Data policy id in JSON
|
|
115
|
-
* @param bytes The policy id in hex
|
|
116
|
-
* @returns The Plutus Data policy id object
|
|
117
|
-
*/
|
|
118
|
-
export const policyId = (bytes: string): PolicyId => {
|
|
119
|
-
if (bytes.length !== POLICY_ID_LENGTH && bytes !== "") {
|
|
120
|
-
throw new Error(
|
|
121
|
-
`Invalid policy id for [${bytes}] - should be ${POLICY_ID_LENGTH} bytes long or empty string for lovelace`,
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
return byteString(bytes);
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* The utility function to create a Plutus Data currency symbol in JSON
|
|
129
|
-
* @param bytes The policy id in hex
|
|
130
|
-
* @returns The Plutus Data policy id object
|
|
131
|
-
*/
|
|
132
|
-
export const currencySymbol = (bytes: string): CurrencySymbol =>
|
|
133
|
-
policyId(bytes);
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* The utility function to create a Plutus Data asset name in JSON
|
|
137
|
-
* @param bytes The asset name in hex
|
|
138
|
-
* @returns The Plutus Data asset name object
|
|
139
|
-
*/
|
|
140
|
-
export const assetName = (bytes: string): AssetName => {
|
|
141
|
-
if (bytes.length > 64) {
|
|
142
|
-
throw new Error(
|
|
143
|
-
`Invalid asset name for [${bytes}] - should be less than 32 bytes (64 hex length) long`,
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
return byteString(bytes);
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* The utility function to create a Plutus Data token name in JSON
|
|
151
|
-
* @param bytes The token name in hex
|
|
152
|
-
* @returns The Plutus Data token name object
|
|
153
|
-
*/
|
|
154
|
-
export const tokenName = (bytes: string): TokenName => assetName(bytes);
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* The utility function to create a Plutus Data asset class in JSON
|
|
158
|
-
* @param currencySymbolHex The currency symbol in hex
|
|
159
|
-
* @param tokenNameHex The token name in hex
|
|
160
|
-
* @returns The Plutus Data asset class object
|
|
161
|
-
*/
|
|
162
|
-
export const assetClass = (
|
|
163
|
-
currencySymbolHex: string,
|
|
164
|
-
tokenNameHex: string,
|
|
165
|
-
): AssetClass =>
|
|
166
|
-
conStr0([currencySymbol(currencySymbolHex), tokenName(tokenNameHex)]);
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* The utility function to create a Plutus Data output reference in JSON
|
|
170
|
-
* @param txHash The transaction hash
|
|
171
|
-
* @param index The index of the output
|
|
172
|
-
* @returns The Plutus Data output reference object
|
|
173
|
-
*/
|
|
174
|
-
export const outputReference = (
|
|
175
|
-
txHash: string,
|
|
176
|
-
index: number,
|
|
177
|
-
): OutputReference => {
|
|
178
|
-
if (txHash.length !== 64) {
|
|
179
|
-
throw new Error("Invalid transaction hash - should be 32 bytes long");
|
|
180
|
-
}
|
|
181
|
-
return conStr0([conStr0([byteString(txHash)]), integer(index)]);
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* The utility function to create a Plutus Data TxOutRef in JSON
|
|
186
|
-
* @param txHash The transaction hash
|
|
187
|
-
* @param index The index of the output
|
|
188
|
-
* @returns The Plutus Data TxOutRef object
|
|
189
|
-
*/
|
|
190
|
-
export const txOutRef = (txHash: string, index: number): TxOutRef =>
|
|
191
|
-
outputReference(txHash, index);
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* The utility function to create a Plutus Data POSIX time in JSON
|
|
195
|
-
* @param int The integer value of the POSIX time
|
|
196
|
-
* @returns The Plutus Data POSIX time object
|
|
197
|
-
*/
|
|
198
|
-
export const posixTime = (int: number): POSIXTime => ({ int });
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* The utility function to create a Plutus Data dictionary in JSON
|
|
202
|
-
* @param itemsMap The items map in array
|
|
203
|
-
* @returns The Plutus Data dictionary object
|
|
204
|
-
*/
|
|
205
|
-
export const dict = <V>(itemsMap: [ByteString, V][]): Dict<V> => ({
|
|
206
|
-
map: itemsMap.map(([k, v]) => ({ k, v })),
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* The utility function to create a Plutus Data tuple in JSON
|
|
211
|
-
* @param key The key of the tuple
|
|
212
|
-
* @param value The value of the tuple
|
|
213
|
-
* @returns The Plutus Data tuple object
|
|
214
|
-
*/
|
|
215
|
-
export const tuple = <K = PlutusData, V = PlutusData>(
|
|
216
|
-
key: K,
|
|
217
|
-
value: V,
|
|
218
|
-
): Tuple<K, V> => ({ list: [key, value] });
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Plutus Data constructor object, representing custom data type in JSON
|
|
3
|
-
*/
|
|
4
|
-
export type ConStr<T = any> = { constructor: number; fields: T };
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The Plutus Data index 0 constructor object, representing custom data type in JSON
|
|
8
|
-
*/
|
|
9
|
-
export type ConStr0<T = any> = ConStr<T>;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The Plutus Data index 1 constructor object, representing custom data type in JSON
|
|
13
|
-
*/
|
|
14
|
-
export type ConStr1<T = any> = ConStr<T>;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The Plutus Data index 2 constructor object, representing custom data type in JSON
|
|
18
|
-
*/
|
|
19
|
-
export type ConStr2<T = any> = ConStr<T>;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* The utility function to create a Plutus Data constructor object, representing custom data type in JSON
|
|
23
|
-
* @param constructor The constructor index number
|
|
24
|
-
* @param fields The items in array
|
|
25
|
-
* @returns The Plutus Data constructor object
|
|
26
|
-
*/
|
|
27
|
-
export const conStr = <T>(constructor: number, fields: T): ConStr<T> => {
|
|
28
|
-
if (!Array.isArray(fields)) {
|
|
29
|
-
throw new Error("fields of a constructor must be an array");
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
constructor,
|
|
33
|
-
fields,
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The utility function to create a Plutus Data index 0 constructor object, representing custom data type in JSON
|
|
39
|
-
* @param fields The items of in array
|
|
40
|
-
* @returns The Plutus Data constructor object
|
|
41
|
-
*/
|
|
42
|
-
export const conStr0 = <T>(fields: T): ConStr0<T> => conStr<T>(0, fields);
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* The utility function to create a Plutus Data index 1 constructor object, representing custom data type in JSON
|
|
46
|
-
* @param fields The items of in array
|
|
47
|
-
* @returns The Plutus Data constructor object
|
|
48
|
-
*/
|
|
49
|
-
export const conStr1 = <T>(fields: T): ConStr1<T> => conStr<T>(1, fields);
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* The utility function to create a Plutus Data index 2 constructor object, representing custom data type in JSON
|
|
53
|
-
* @param fields The items of in array
|
|
54
|
-
* @returns The Plutus Data constructor object
|
|
55
|
-
*/
|
|
56
|
-
export const conStr2 = <T>(fields: T): ConStr2<T> => conStr<T>(2, fields);
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { pubKeyHash, PubKeyHash, scriptHash, ScriptHash } from "./aliases";
|
|
2
|
-
import { conStr0, ConStr0, conStr1, ConStr1 } from "./constructors";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The Plutus Data staking credential in JSON
|
|
6
|
-
*/
|
|
7
|
-
export type MaybeStakingHash =
|
|
8
|
-
| ConStr1<[]>
|
|
9
|
-
| ConStr0<[ConStr0<[ConStr0<[PubKeyHash]>]>]>
|
|
10
|
-
| ConStr0<[ConStr0<[ConStr1<[ScriptHash]>]>]>;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The Plutus Data public key address in JSON
|
|
14
|
-
*/
|
|
15
|
-
export type PubKeyAddress = ConStr0<[ConStr0<[PubKeyHash]>, MaybeStakingHash]>;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The Plutus Data script address in JSON
|
|
19
|
-
*/
|
|
20
|
-
export type ScriptAddress = ConStr0<[ConStr1<[ScriptHash]>, MaybeStakingHash]>;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The utility function to create a Plutus Data staking hash in JSON
|
|
24
|
-
* @param stakeCredential The staking credential in hex
|
|
25
|
-
* @param isScriptCredential The flag to indicate if the credential is a script credential
|
|
26
|
-
* @returns The Plutus Data staking hash object
|
|
27
|
-
*/
|
|
28
|
-
export const maybeStakingHash = (
|
|
29
|
-
stakeCredential: string,
|
|
30
|
-
isScriptCredential = false,
|
|
31
|
-
): MaybeStakingHash => {
|
|
32
|
-
if (stakeCredential === "") {
|
|
33
|
-
return conStr1<[]>([]);
|
|
34
|
-
}
|
|
35
|
-
if (isScriptCredential) {
|
|
36
|
-
return conStr0([
|
|
37
|
-
conStr0([conStr1([scriptHash(stakeCredential)])]),
|
|
38
|
-
]) as ConStr0<[ConStr0<[ConStr1<[ScriptHash]>]>]>;
|
|
39
|
-
}
|
|
40
|
-
return conStr0([
|
|
41
|
-
conStr0([conStr0([pubKeyHash(stakeCredential)])]),
|
|
42
|
-
]) as ConStr0<[ConStr0<[ConStr1<[PubKeyHash]>]>]>;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* The utility function to create a Plutus Data public key address in JSON
|
|
47
|
-
* @param bytes The public key hash in hex
|
|
48
|
-
* @param stakeCredential The staking credential in hex
|
|
49
|
-
* @param isScriptCredential The flag to indicate if the credential is a script credential
|
|
50
|
-
* @returns The Plutus Data public key address object
|
|
51
|
-
*/
|
|
52
|
-
export const pubKeyAddress = (
|
|
53
|
-
bytes: string,
|
|
54
|
-
stakeCredential?: string,
|
|
55
|
-
isScriptCredential = false,
|
|
56
|
-
): PubKeyAddress =>
|
|
57
|
-
conStr0([
|
|
58
|
-
conStr0([pubKeyHash(bytes)]),
|
|
59
|
-
maybeStakingHash(stakeCredential || "", isScriptCredential),
|
|
60
|
-
]);
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* The utility function to create a Plutus Data script address in JSON
|
|
64
|
-
* @param bytes The validator hash in hex
|
|
65
|
-
* @param stakeCredential The staking credential in hex
|
|
66
|
-
* @param isScriptCredential The flag to indicate if the credential is a script credential
|
|
67
|
-
* @returns The Plutus Data script address object
|
|
68
|
-
*/
|
|
69
|
-
export const scriptAddress = (
|
|
70
|
-
bytes: string,
|
|
71
|
-
stakeCredential?: string,
|
|
72
|
-
isScriptCredential = false,
|
|
73
|
-
): ScriptAddress =>
|
|
74
|
-
conStr0([
|
|
75
|
-
conStr1([scriptHash(bytes)]),
|
|
76
|
-
maybeStakingHash(stakeCredential || "", isScriptCredential),
|
|
77
|
-
]);
|
package/src/data/json/index.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AssetClass,
|
|
3
|
-
Dict,
|
|
4
|
-
OutputReference,
|
|
5
|
-
POSIXTime,
|
|
6
|
-
PubKeyHash,
|
|
7
|
-
Tuple,
|
|
8
|
-
} from "./aliases";
|
|
9
|
-
import { ConStr } from "./constructors";
|
|
10
|
-
import { MaybeStakingHash, PubKeyAddress, ScriptAddress } from "./credentials";
|
|
11
|
-
import { AssocMap, Bool, ByteString, Integer, List } from "./primitives";
|
|
12
|
-
|
|
13
|
-
export type PlutusData =
|
|
14
|
-
| ConStr
|
|
15
|
-
| Bool
|
|
16
|
-
| ByteString
|
|
17
|
-
| Integer
|
|
18
|
-
| List
|
|
19
|
-
| AssocMap
|
|
20
|
-
| MaybeStakingHash
|
|
21
|
-
| PubKeyAddress
|
|
22
|
-
| ScriptAddress
|
|
23
|
-
| AssetClass
|
|
24
|
-
| OutputReference
|
|
25
|
-
| PubKeyHash
|
|
26
|
-
| POSIXTime
|
|
27
|
-
| Dict<any>
|
|
28
|
-
| Tuple<any, any>;
|
|
29
|
-
|
|
30
|
-
export * from "./aliases";
|
|
31
|
-
export * from "./constructors";
|
|
32
|
-
export * from "./credentials";
|
|
33
|
-
export * from "./primitives";
|