@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.
Files changed (84) hide show
  1. package/dist/index.cjs +1 -0
  2. package/dist/{index.d.mts → index.d.cts} +96 -8
  3. package/dist/index.d.ts +96 -8
  4. package/dist/index.js +1 -1316
  5. package/package.json +28 -9
  6. package/.turbo/turbo-build$colon$docs.log +0 -17
  7. package/.turbo/turbo-build$colon$mesh.log +0 -19
  8. package/.turbo/turbo-build.log +0 -19
  9. package/dist/index.mjs +0 -1189
  10. package/src/constants/cost-models.ts +0 -30
  11. package/src/constants/index.ts +0 -86
  12. package/src/constants/language-views.ts +0 -19
  13. package/src/constants/protocol-parameters.ts +0 -34
  14. package/src/constants/supported-wallets.ts +0 -12
  15. package/src/data/index.ts +0 -5
  16. package/src/data/json/aliases.ts +0 -218
  17. package/src/data/json/constructors.ts +0 -56
  18. package/src/data/json/credentials.ts +0 -77
  19. package/src/data/json/index.ts +0 -33
  20. package/src/data/json/primitives.ts +0 -154
  21. package/src/data/mesh/aliases.ts +0 -85
  22. package/src/data/mesh/constructors.ts +0 -68
  23. package/src/data/mesh/credentials.ts +0 -77
  24. package/src/data/mesh/index.ts +0 -4
  25. package/src/data/mesh/primitives.ts +0 -37
  26. package/src/data/parser.ts +0 -36
  27. package/src/data/time.ts +0 -92
  28. package/src/data/value.ts +0 -70
  29. package/src/index.ts +0 -7
  30. package/src/interfaces/evaluator.ts +0 -5
  31. package/src/interfaces/fetcher.ts +0 -31
  32. package/src/interfaces/index.ts +0 -7
  33. package/src/interfaces/initiator.ts +0 -9
  34. package/src/interfaces/listener.ts +0 -3
  35. package/src/interfaces/serializer.ts +0 -53
  36. package/src/interfaces/signer.ts +0 -12
  37. package/src/interfaces/submitter.ts +0 -3
  38. package/src/types/account-info.ts +0 -7
  39. package/src/types/action.ts +0 -15
  40. package/src/types/asset-extended.ts +0 -9
  41. package/src/types/asset-metadata.ts +0 -102
  42. package/src/types/asset.ts +0 -23
  43. package/src/types/block-info.ts +0 -17
  44. package/src/types/data-signature.ts +0 -4
  45. package/src/types/data.ts +0 -10
  46. package/src/types/deserialized/deserialized-address.ts +0 -6
  47. package/src/types/deserialized/deserialized-script.ts +0 -4
  48. package/src/types/deserialized/index.ts +0 -2
  49. package/src/types/era.ts +0 -1
  50. package/src/types/index.ts +0 -24
  51. package/src/types/message.ts +0 -4
  52. package/src/types/mint.ts +0 -12
  53. package/src/types/native-script.ts +0 -18
  54. package/src/types/network.ts +0 -7
  55. package/src/types/plutus-script.ts +0 -8
  56. package/src/types/pool-params.ts +0 -41
  57. package/src/types/protocol.ts +0 -22
  58. package/src/types/recipient.ts +0 -15
  59. package/src/types/relay.ts +0 -42
  60. package/src/types/token.ts +0 -3
  61. package/src/types/transaction-builder/data.ts +0 -31
  62. package/src/types/transaction-builder/index.ts +0 -73
  63. package/src/types/transaction-builder/mint.ts +0 -11
  64. package/src/types/transaction-builder/output.ts +0 -12
  65. package/src/types/transaction-builder/script.ts +0 -27
  66. package/src/types/transaction-builder/txin.ts +0 -46
  67. package/src/types/transaction-builder/withdrawal.ts +0 -207
  68. package/src/types/transaction-info.ts +0 -11
  69. package/src/types/utxo.ts +0 -16
  70. package/src/types/wallet.ts +0 -6
  71. package/src/utils/asset-fingerprint.ts +0 -11
  72. package/src/utils/bigNum.ts +0 -61
  73. package/src/utils/index.ts +0 -2
  74. package/test/data/json/aliases.test.ts +0 -135
  75. package/test/data/json/constructors.test.ts +0 -38
  76. package/test/data/json/credentials.test.ts +0 -84
  77. package/test/data/json/primitives.test.ts +0 -133
  78. package/test/data/mesh/aliases.test.ts +0 -45
  79. package/test/data/mesh/common.ts +0 -14
  80. package/test/data/mesh/constructors.test.ts +0 -53
  81. package/test/data/mesh/credentials.test.ts +0 -74
  82. package/test/data/mesh/primitives.test.ts +0 -41
  83. package/test/data/value.test.ts +0 -108
  84. package/tsconfig.json +0 -5
@@ -1,133 +0,0 @@
1
- import JSONBig from "json-bigint";
2
-
3
- import {
4
- assocMap,
5
- bool,
6
- ByteString,
7
- byteString,
8
- integer,
9
- List,
10
- list,
11
- plutusBSArrayToString,
12
- stringToPlutusBSArray,
13
- } from "../../../src";
14
-
15
- const testByteString = { bytes: "abcd" };
16
-
17
- describe("Plutus data type", () => {
18
- describe("bool", () => {
19
- test("bool - true", () => {
20
- const result = bool(true);
21
- expect(JSON.stringify(result)).toBe(
22
- JSON.stringify({ constructor: 1, fields: [] }),
23
- );
24
- });
25
- test("bool - false", () => {
26
- const result = bool(false);
27
- expect(JSON.stringify(result)).toBe(
28
- JSON.stringify({ constructor: 0, fields: [] }),
29
- );
30
- });
31
- });
32
-
33
- describe("byteString", () => {
34
- test("byteString - valid hex", () => {
35
- const hexString = "00112233445566aabbccddeeff";
36
- const result = byteString(hexString);
37
- expect(JSON.stringify(result)).toBe(JSON.stringify({ bytes: hexString }));
38
- });
39
- test("byteString - invalid hex - odd length", () => {
40
- const hexString = "00112233445566aabbccddeef";
41
- expect(() => byteString(hexString)).toThrow();
42
- });
43
- test("byteString - invalid hex - non hex string", () => {
44
- const hexString = "00112233445566aabbccddeeffgg";
45
- expect(() => byteString(hexString)).toThrow();
46
- });
47
- });
48
-
49
- describe("integer", () => {
50
- test("integer - number", () => {
51
- const testNumber = 1234567890;
52
- const result = integer(testNumber);
53
- expect(JSON.stringify(result)).toBe(JSON.stringify({ int: testNumber }));
54
- });
55
- test("integer - bigint", () => {
56
- const testBigInt = 1234567890123456789012345678901234567890n;
57
- const result = integer(testBigInt);
58
- expect(JSONBig.stringify(result)).toBe(
59
- JSONBig.stringify({ int: testBigInt }),
60
- );
61
- });
62
- });
63
-
64
- describe("list", () => {
65
- test("list - valid", () => {
66
- const result = list([testByteString, testByteString, testByteString]);
67
- expect(JSON.stringify(result)).toBe(
68
- JSON.stringify({
69
- list: [testByteString, testByteString, testByteString],
70
- }),
71
- );
72
- });
73
- test("list - invalid non-JSON items", () => {
74
- expect(() =>
75
- list([testByteString, testByteString, testByteString.bytes]),
76
- ).toThrow();
77
- });
78
- });
79
-
80
- describe("assocMap", () => {
81
- test("assocMap", () => {
82
- const result = assocMap([
83
- ["key1", "value1"],
84
- ["key2", "value2"],
85
- ]);
86
- expect(JSON.stringify(result)).toBe(
87
- JSON.stringify({
88
- map: [
89
- { k: "key1", v: "value1" },
90
- { k: "key2", v: "value2" },
91
- ],
92
- }),
93
- );
94
- });
95
- });
96
- });
97
-
98
- describe("String List of byte array conversion", () => {
99
- const testString =
100
- "baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc8170074657374696e676e657777616c2e616461baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc8170074657374696e676e657777616c2e616461baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc8170074657374696e676e657777616c2e616461";
101
- const testList: List<ByteString> = {
102
- list: [
103
- {
104
- bytes:
105
- "baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc8170074657374",
106
- },
107
- {
108
- bytes:
109
- "696e676e657777616c2e616461baefdc6c5b191be372a794cd8d40d839ec0dbd",
110
- },
111
- {
112
- bytes:
113
- "d3c28957267dc8170074657374696e676e657777616c2e616461baefdc6c5b19",
114
- },
115
- {
116
- bytes:
117
- "1be372a794cd8d40d839ec0dbdd3c28957267dc8170074657374696e676e6577",
118
- },
119
- {
120
- bytes: "77616c2e616461",
121
- },
122
- ],
123
- };
124
-
125
- test("stringToPlutusBSArray", () => {
126
- const result = stringToPlutusBSArray(testString);
127
- expect(JSON.stringify(testList)).toBe(JSON.stringify(result));
128
- });
129
- test("plutusBSArrayToString", () => {
130
- const result = plutusBSArrayToString(testList);
131
- expect(result).toBe(testString);
132
- });
133
- });
@@ -1,45 +0,0 @@
1
- import {
2
- assetClass,
3
- mAssetClass,
4
- mOutputReference,
5
- mTxOutRef,
6
- outputReference,
7
- txOutRef,
8
- } from "../../../src";
9
- import { serializeData } from "./common";
10
-
11
- const testHash = "baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc81700";
12
- const testTxHash =
13
- "a0bd47e8938e7c41d4c1d7c22033892319d28f86fdace791d45c51946553791b";
14
- describe("Plutus data type", () => {
15
- describe("assetClass", () => {
16
- test("assetClass", () => {
17
- const [meshCbor, jsonCbor] = serializeData(
18
- mAssetClass(testHash, "abcd"),
19
- assetClass(testHash, "abcd"),
20
- );
21
- expect(meshCbor).toBe(jsonCbor);
22
- });
23
- });
24
- describe("outputReference", () => {
25
- test("outputReference", () => {
26
- const [meshCbor, jsonCbor] = serializeData(
27
- mOutputReference(testTxHash, 1),
28
- outputReference(testTxHash, 1),
29
- );
30
- expect(meshCbor).toBe(jsonCbor);
31
- });
32
- test("outputReference - invalid length", () => {
33
- expect(() => mOutputReference(testHash, 1)).toThrow;
34
- });
35
- });
36
- describe("txOutRef", () => {
37
- test("txOutRef", () => {
38
- const [meshCbor, jsonCbor] = serializeData(
39
- mTxOutRef(testTxHash, 1),
40
- txOutRef(testTxHash, 1),
41
- );
42
- expect(meshCbor).toBe(jsonCbor);
43
- });
44
- });
45
- });
@@ -1,14 +0,0 @@
1
- import { castDataToPlutusData } from "../../../../mesh-core-csl";
2
- import { Data } from "../../../src";
3
-
4
- export const serializeData = (mesh: Data, json: any) => {
5
- const meshData = castDataToPlutusData({
6
- type: "Mesh",
7
- content: mesh,
8
- }).to_hex();
9
- const jsonData = castDataToPlutusData({
10
- type: "JSON",
11
- content: JSON.stringify(json),
12
- }).to_hex();
13
- return [meshData, jsonData];
14
- };
@@ -1,53 +0,0 @@
1
- import {
2
- byteString,
3
- conStr,
4
- conStr0,
5
- conStr1,
6
- conStr2,
7
- Data,
8
- mConStr,
9
- mConStr0,
10
- mConStr1,
11
- mConStr2,
12
- } from "../../../src";
13
- import { serializeData } from "./common";
14
-
15
- const testByteString = "abcd";
16
-
17
- describe("Plutus data type", () => {
18
- describe("constructor", () => {
19
- test("mConStr", () => {
20
- const mesh = mConStr(0, [testByteString]);
21
- const [meshCbor, jsonCbor] = serializeData(
22
- mesh,
23
- conStr(0, [byteString(testByteString)]),
24
- );
25
- expect(meshCbor).toBe(jsonCbor);
26
- });
27
-
28
- test("mConStr0", () => {
29
- const mesh = mConStr0([testByteString]);
30
- const [meshCbor, jsonCbor] = serializeData(
31
- mesh,
32
- conStr0([byteString(testByteString)]),
33
- );
34
- expect(meshCbor).toBe(jsonCbor);
35
- });
36
- test("mConStr1", () => {
37
- const mesh = mConStr1([testByteString]);
38
- const [meshCbor, jsonCbor] = serializeData(
39
- mesh,
40
- conStr1([byteString(testByteString)]),
41
- );
42
- expect(meshCbor).toBe(jsonCbor);
43
- });
44
- test("mConStr2", () => {
45
- const mesh = mConStr2([testByteString]);
46
- const [meshCbor, jsonCbor] = serializeData(
47
- mesh,
48
- conStr2([byteString(testByteString)]),
49
- );
50
- expect(meshCbor).toBe(jsonCbor);
51
- });
52
- });
53
- });
@@ -1,74 +0,0 @@
1
- import {
2
- conStr0,
3
- conStr1,
4
- maybeStakingHash,
5
- mMaybeStakingHash,
6
- mPubKeyAddress,
7
- mScriptAddress,
8
- pubKeyAddress,
9
- pubKeyHash,
10
- scriptAddress,
11
- scriptHash,
12
- } from "../../../src";
13
- import { serializeData } from "./common";
14
-
15
- const testKeyHash1 = "1e4eb194e3335a0dcc4f5c5d009318167c583bb3b0879d9f718cd9e0";
16
- const testKeyHash2 = "d63a93470bd4d8bb986c02ff8a6043796b91cc397ceb29058f5c9ac0";
17
-
18
- describe("Plutus data type", () => {
19
- describe("maybeStakingHash", () => {
20
- test("maybeStakingHash - no staking hash", () => {
21
- const [meshCbor, jsonCbor] = serializeData(
22
- mMaybeStakingHash(""),
23
- maybeStakingHash(""),
24
- );
25
- expect(meshCbor).toBe(jsonCbor);
26
- });
27
- test("maybeStakingHash - pub key staking hash", () => {
28
- const [meshCbor, jsonCbor] = serializeData(
29
- mMaybeStakingHash(testKeyHash1),
30
- maybeStakingHash(testKeyHash1),
31
- );
32
- expect(meshCbor).toBe(jsonCbor);
33
- });
34
- test("maybeStakingHash - script staking hash", () => {
35
- const [meshCbor, jsonCbor] = serializeData(
36
- mMaybeStakingHash(testKeyHash1, true),
37
- maybeStakingHash(testKeyHash1, true),
38
- );
39
- expect(meshCbor).toBe(jsonCbor);
40
- });
41
- });
42
- describe("pubKeyAddress", () => {
43
- test("pubKeyAddress", () => {
44
- const [meshCbor, jsonCbor] = serializeData(
45
- mPubKeyAddress(testKeyHash1),
46
- pubKeyAddress(testKeyHash1),
47
- );
48
- expect(meshCbor).toBe(jsonCbor);
49
- });
50
- test("pubKeyAddress - full base address", () => {
51
- const [meshCbor, jsonCbor] = serializeData(
52
- mPubKeyAddress(testKeyHash1, testKeyHash2),
53
- pubKeyAddress(testKeyHash1, testKeyHash2),
54
- );
55
- expect(meshCbor).toBe(jsonCbor);
56
- });
57
- });
58
- describe("scriptAddress", () => {
59
- test("scriptAddress", () => {
60
- const [meshCbor, jsonCbor] = serializeData(
61
- mScriptAddress(testKeyHash1),
62
- scriptAddress(testKeyHash1),
63
- );
64
- expect(meshCbor).toBe(jsonCbor);
65
- });
66
- test("scriptAddress - full base address", () => {
67
- const [meshCbor, jsonCbor] = serializeData(
68
- mScriptAddress(testKeyHash1, testKeyHash2),
69
- scriptAddress(testKeyHash1, testKeyHash2),
70
- );
71
- expect(meshCbor).toBe(jsonCbor);
72
- });
73
- });
74
- });
@@ -1,41 +0,0 @@
1
- import {
2
- bool,
3
- mBool,
4
- mPlutusBSArrayToString,
5
- mStringToPlutusBSArray,
6
- } from "../../../src";
7
- import { serializeData } from "./common";
8
-
9
- describe("Plutus data type", () => {
10
- describe("bool", () => {
11
- test("bool - true", () => {
12
- const [meshCbor, jsonCbor] = serializeData(mBool(true), bool(true));
13
- expect(meshCbor).toBe(jsonCbor);
14
- });
15
- test("bool - false", () => {
16
- const [meshCbor, jsonCbor] = serializeData(mBool(false), bool(false));
17
- expect(meshCbor).toBe(jsonCbor);
18
- });
19
- });
20
- });
21
-
22
- describe("String List of byte array conversion", () => {
23
- const testString =
24
- "baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc8170074657374696e676e657777616c2e616461baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc8170074657374696e676e657777616c2e616461baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc8170074657374696e676e657777616c2e616461";
25
- const testList: string[] = [
26
- "baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc8170074657374",
27
- "696e676e657777616c2e616461baefdc6c5b191be372a794cd8d40d839ec0dbd",
28
- "d3c28957267dc8170074657374696e676e657777616c2e616461baefdc6c5b19",
29
- "1be372a794cd8d40d839ec0dbdd3c28957267dc8170074657374696e676e6577",
30
- "77616c2e616461",
31
- ];
32
-
33
- test("stringToPlutusBSArray", () => {
34
- const result = mStringToPlutusBSArray(testString);
35
- expect(JSON.stringify(testList)).toBe(JSON.stringify(result));
36
- });
37
- test("plutusBSArrayToString", () => {
38
- const result = mPlutusBSArrayToString(testList);
39
- expect(result).toBe(testString);
40
- });
41
- });
@@ -1,108 +0,0 @@
1
- import {
2
- Asset,
3
- byteString,
4
- ByteString,
5
- dict,
6
- Dict,
7
- Integer,
8
- integer,
9
- parsePlutusValueToAssets,
10
- Value,
11
- value,
12
- } from "../../src";
13
-
14
- describe("value", () => {
15
- test("Simple ADA Value", () => {
16
- const val: Asset[] = [{ unit: "lovelace", quantity: "1000000" }];
17
- const datum: Value = value(val);
18
-
19
- const nameMap = dict<Integer>([[byteString(""), integer(1000000)]]);
20
- const valMap = dict<Dict<Integer>>([[byteString(""), nameMap]]);
21
- expect(JSON.stringify(datum)).toBe(JSON.stringify(valMap));
22
- });
23
- test("Simple token Value", () => {
24
- const val: Asset[] = [
25
- {
26
- unit: "baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc8170074657374696e676e657777616c2e616461",
27
- quantity: "345",
28
- },
29
- ];
30
- const datum: Value = value(val);
31
-
32
- const nameMap = dict<Integer>([
33
- [byteString("74657374696e676e657777616c2e616461"), integer(345)],
34
- ]);
35
- const valMap = dict<Dict<Integer>>([
36
- [
37
- byteString("baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc81700"),
38
- nameMap,
39
- ],
40
- ]);
41
- expect(JSON.stringify(datum)).toBe(JSON.stringify(valMap));
42
- });
43
- test("Complex Value", () => {
44
- const val: Asset[] = [
45
- { unit: "lovelace", quantity: "1000000" },
46
- {
47
- unit: "baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc8170074657374696e676e657777616c2e616461",
48
- quantity: "345",
49
- },
50
- {
51
- unit: "baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc817001234",
52
- quantity: "567",
53
- },
54
- ];
55
- const datum: Value = value(val);
56
-
57
- const nameMap = dict<Integer>([
58
- [byteString("1234"), integer(567)],
59
- [byteString("74657374696e676e657777616c2e616461"), integer(345)],
60
- ]);
61
- const valMap = dict<Dict<Integer>>([
62
- [byteString(""), dict([[byteString(""), integer(1000000)]])],
63
- [
64
- byteString("baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc81700"),
65
- nameMap,
66
- ],
67
- ]);
68
- expect(JSON.stringify(datum)).toBe(JSON.stringify(valMap));
69
- });
70
- });
71
-
72
- describe("Value", () => {
73
- test("Simple ADA Value", () => {
74
- const val: Asset[] = [{ unit: "lovelace", quantity: "1000000" }];
75
- const plutusValue: Value = value(val);
76
- const assets: Asset[] = parsePlutusValueToAssets(plutusValue);
77
-
78
- expect(JSON.stringify(val)).toBe(JSON.stringify(assets));
79
- });
80
- test("Simple token Value", () => {
81
- const val: Asset[] = [
82
- {
83
- unit: "baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc8170074657374696e676e657777616c2e616461",
84
- quantity: "345",
85
- },
86
- ];
87
- const plutusValue: Value = value(val);
88
- const assets: Asset[] = parsePlutusValueToAssets(plutusValue);
89
-
90
- expect(JSON.stringify(val)).toBe(JSON.stringify(assets));
91
- });
92
- test("Complex Value", () => {
93
- const val: Asset[] = [
94
- { unit: "lovelace", quantity: "1000000" },
95
- {
96
- unit: "baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc817001234",
97
- quantity: "567",
98
- },
99
- {
100
- unit: "baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc8170074657374696e676e657777616c2e616461",
101
- quantity: "345",
102
- },
103
- ];
104
- const plutusValue: Value = value(val);
105
- const assets: Asset[] = parsePlutusValueToAssets(plutusValue);
106
- expect(JSON.stringify(val)).toBe(JSON.stringify(assets));
107
- });
108
- });
package/tsconfig.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "extends": "@meshsdk/typescript-config/base.json",
3
- "include": ["src/**/*"],
4
- "exclude": ["dist", "node_modules"]
5
- }