@helios-lang/effect 0.1.4 → 0.1.6

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 (113) hide show
  1. package/bun.lock +60 -0
  2. package/dist/Ledger/NetworkParams.js +40 -0
  3. package/dist/Ledger/NetworkParams.js.map +1 -0
  4. package/dist/Ledger/index.js +1 -0
  5. package/dist/Ledger/index.js.map +1 -1
  6. package/package.json +1 -1
  7. package/tsconfig.build.tsbuildinfo +1 -0
  8. package/tsconfig.check.tsbuildinfo +1 -0
  9. package/tsconfig.tsbuildinfo +1 -0
  10. package/types/Address.d.ts +5 -0
  11. package/types/Address.d.ts.map +1 -0
  12. package/types/Bech32.d.ts +30 -0
  13. package/types/Bech32.d.ts.map +1 -0
  14. package/types/Cbor.d.ts +430 -0
  15. package/types/Cbor.d.ts.map +1 -0
  16. package/types/Ledger/Address.d.ts +109 -0
  17. package/types/Ledger/Address.d.ts.map +1 -0
  18. package/types/Ledger/AssetClass.d.ts +101 -0
  19. package/types/Ledger/AssetClass.d.ts.map +1 -0
  20. package/types/Ledger/Assets.d.ts +70 -0
  21. package/types/Ledger/Assets.d.ts.map +1 -0
  22. package/types/Ledger/Credential.d.ts +26 -0
  23. package/types/Ledger/Credential.d.ts.map +1 -0
  24. package/types/Ledger/DatumHash.d.ts +40 -0
  25. package/types/Ledger/DatumHash.d.ts.map +1 -0
  26. package/types/Ledger/IsMainnet.d.ts +6 -0
  27. package/types/Ledger/IsMainnet.d.ts.map +1 -0
  28. package/types/Ledger/MintingPolicy.d.ts +39 -0
  29. package/types/Ledger/MintingPolicy.d.ts.map +1 -0
  30. package/types/Ledger/NetworkParams.d.ts +40 -0
  31. package/types/Ledger/NetworkParams.d.ts.map +1 -0
  32. package/types/Ledger/PubKeyHash.d.ts +40 -0
  33. package/types/Ledger/PubKeyHash.d.ts.map +1 -0
  34. package/types/Ledger/TxId.d.ts +10 -0
  35. package/types/Ledger/TxId.d.ts.map +1 -0
  36. package/types/Ledger/TxInput.d.ts +55 -0
  37. package/types/Ledger/TxInput.d.ts.map +1 -0
  38. package/types/Ledger/TxOutput.d.ts +63 -0
  39. package/types/Ledger/TxOutput.d.ts.map +1 -0
  40. package/types/Ledger/TxOutputDatum.d.ts +41 -0
  41. package/types/Ledger/TxOutputDatum.d.ts.map +1 -0
  42. package/types/Ledger/TxOutputId.d.ts +14 -0
  43. package/types/Ledger/TxOutputId.d.ts.map +1 -0
  44. package/types/Ledger/ValidatorHash.d.ts +40 -0
  45. package/types/Ledger/ValidatorHash.d.ts.map +1 -0
  46. package/types/Ledger/index.d.ts +16 -0
  47. package/types/Ledger/index.d.ts.map +1 -0
  48. package/types/Uplc/Cek.d.ts +72 -0
  49. package/types/Uplc/Cek.d.ts.map +1 -0
  50. package/types/Uplc/Data.d.ts +530 -0
  51. package/types/Uplc/Data.d.ts.map +1 -0
  52. package/types/Uplc/DataSchema.d.ts +227 -0
  53. package/types/Uplc/DataSchema.d.ts.map +1 -0
  54. package/types/Uplc/Primitive.d.ts +26 -0
  55. package/types/Uplc/Primitive.d.ts.map +1 -0
  56. package/types/Uplc/index.d.ts +3 -0
  57. package/types/Uplc/index.d.ts.map +1 -0
  58. package/types/index.d.ts +5 -0
  59. package/types/index.d.ts.map +1 -0
  60. package/types/internal/Base32.d.ts +49 -0
  61. package/types/internal/Base32.d.ts.map +1 -0
  62. package/types/internal/BigEndian.d.ts +22 -0
  63. package/types/internal/BigEndian.d.ts.map +1 -0
  64. package/types/internal/Bits.d.ts +123 -0
  65. package/types/internal/Bits.d.ts.map +1 -0
  66. package/types/internal/Bytes.d.ts +88 -0
  67. package/types/internal/Bytes.d.ts.map +1 -0
  68. package/types/internal/Flat.d.ts +71 -0
  69. package/types/internal/Flat.d.ts.map +1 -0
  70. package/types/internal/Float.d.ts +38 -0
  71. package/types/internal/Float.d.ts.map +1 -0
  72. package/types/internal/Utf8.d.ts +24 -0
  73. package/types/internal/Utf8.d.ts.map +1 -0
  74. package/src/Bech32.test.ts +0 -117
  75. package/src/Bech32.ts +0 -198
  76. package/src/Cbor.test.ts +0 -1610
  77. package/src/Cbor.ts +0 -1704
  78. package/src/Ledger/Address.ts +0 -248
  79. package/src/Ledger/AssetClass.ts +0 -90
  80. package/src/Ledger/Assets.ts +0 -164
  81. package/src/Ledger/Credential.ts +0 -29
  82. package/src/Ledger/DatumHash.ts +0 -36
  83. package/src/Ledger/IsMainnet.ts +0 -6
  84. package/src/Ledger/MintingPolicy.ts +0 -57
  85. package/src/Ledger/PubKeyHash.ts +0 -36
  86. package/src/Ledger/TxId.ts +0 -31
  87. package/src/Ledger/TxInput.test.ts +0 -21
  88. package/src/Ledger/TxInput.ts +0 -66
  89. package/src/Ledger/TxOutput.ts +0 -166
  90. package/src/Ledger/TxOutputDatum.ts +0 -64
  91. package/src/Ledger/TxOutputId.ts +0 -63
  92. package/src/Ledger/ValidatorHash.ts +0 -36
  93. package/src/Ledger/index.ts +0 -14
  94. package/src/Uplc/Cek.ts +0 -92
  95. package/src/Uplc/Data.test.ts +0 -321
  96. package/src/Uplc/Data.ts +0 -657
  97. package/src/Uplc/Primitive.ts +0 -56
  98. package/src/Uplc/index.ts +0 -2
  99. package/src/index.ts +0 -4
  100. package/src/internal/Base32.test.ts +0 -219
  101. package/src/internal/Base32.ts +0 -341
  102. package/src/internal/BigEndian.test.ts +0 -79
  103. package/src/internal/BigEndian.ts +0 -67
  104. package/src/internal/Bits.test.ts +0 -300
  105. package/src/internal/Bits.ts +0 -398
  106. package/src/internal/Bytes.test.ts +0 -369
  107. package/src/internal/Bytes.ts +0 -343
  108. package/src/internal/Flat.test.ts +0 -29
  109. package/src/internal/Flat.ts +0 -387
  110. package/src/internal/Float.test.ts +0 -51
  111. package/src/internal/Float.ts +0 -190
  112. package/src/internal/Utf8.test.ts +0 -69
  113. package/src/internal/Utf8.ts +0 -58
@@ -1,321 +0,0 @@
1
- import { describe, expect, it } from "bun:test"
2
- import { Schema } from "effect"
3
- import * as Data from "./Data.js"
4
-
5
- describe("Uplc.DataSchema.BigInt", () => {
6
- it("succeeds for {int: 0n}", () => {
7
- expect(Schema.decodeSync(Data.BigInt)({ int: 0n })).toBe(0n)
8
- })
9
-
10
- it("fails for {int: '0'}", () => {
11
- expect(() => Schema.decodeUnknownSync(Data.BigInt)({ int: "0" })).toThrow()
12
- })
13
- })
14
-
15
- describe("Uplc.DataSchema.Int", () => {
16
- it("succeeds for {int: 0n}", () => {
17
- expect(Schema.decodeSync(Data.Int)({ int: 0n })).toBe(0)
18
- })
19
-
20
- it("fails for {int: '0'}", () => {
21
- expect(() => Schema.decodeUnknownSync(Data.Int)({ int: "0" })).toThrow()
22
- })
23
- })
24
-
25
- describe("Uplc.DataSchema.String", () => {
26
- it("succeeds for {bytes: ''}", () => {
27
- expect(Schema.decodeSync(Data.String)(Data.makeByteArrayData(""))).toBe("")
28
- })
29
-
30
- it("fails for {bytes: 'ff'}", () => {
31
- expect(() =>
32
- Schema.decodeSync(Data.String)(Data.makeByteArrayData("ff"))
33
- ).toThrow()
34
- })
35
-
36
- it("succeeds for {bytes: '48656C6C6F20576F726C64'}", () => {
37
- expect(
38
- Schema.decodeSync(Data.String)(
39
- Data.makeByteArrayData("48656C6C6F20576F726C64")
40
- )
41
- ).toBe("Hello World")
42
- })
43
- })
44
-
45
- describe("Uplc.DataSchema.Array", () => {
46
- it("succeeds for empty ListData", () => {
47
- expect(Schema.decodeSync(Data.Array(Data.String))({ list: [] })).toEqual([])
48
- })
49
-
50
- it("succeeds for ListData containg single 'Hello World' string", () => {
51
- expect(
52
- Schema.decodeSync(Data.Array(Data.String))({
53
- list: [Data.makeByteArrayData("48656C6C6F20576F726C64")]
54
- })
55
- ).toEqual(["Hello World"])
56
- })
57
-
58
- it("fails if ListData items are heterogenous", () => {
59
- expect(() =>
60
- Schema.decodeSync(Data.Array(Data.String))({
61
- list: [
62
- Data.makeByteArrayData("48656C6C6F20576F726C64"),
63
- Data.makeIntData(0)
64
- ]
65
- })
66
- ).toThrow()
67
- })
68
- })
69
-
70
- describe("Uplc.DataSchema.Struct", () => {
71
- it("succeeds for empty ListData for empty Struct", () => {
72
- expect(Schema.decodeSync(Data.Struct({}))({ list: [] })).toEqual({})
73
- })
74
-
75
- it("fails for empty ListData if one field is defined", () => {
76
- expect(() =>
77
- Schema.decodeSync(Data.Struct({ foo: Data.String }))({
78
- list: []
79
- })
80
- ).toThrow()
81
- })
82
-
83
- it("succeeds for ListData with single entry if one field is defined", () => {
84
- expect(
85
- Schema.decodeSync(Data.Struct({ foo: Data.String }))({
86
- list: [Data.makeByteArrayData("48656C6C6F20576F726C64")]
87
- })
88
- ).toEqual({ foo: "Hello World" })
89
- })
90
-
91
- it("fails for ListData with wrong entry in first place with one field is defined", () => {
92
- expect(() =>
93
- Schema.decodeSync(Data.Struct({ foo: Data.String }))({
94
- list: [{ int: 0n }]
95
- })
96
- ).toThrow()
97
- })
98
-
99
- it("succeeds for ListData with spurious entries at end with one field is defined", () => {
100
- expect(
101
- Schema.decodeSync(Data.Struct({ foo: Data.String }))({
102
- list: [
103
- Data.makeByteArrayData("48656C6C6F20576F726C64"),
104
- Data.makeIntData(0)
105
- ]
106
- })
107
- ).toEqual({ foo: "Hello World" })
108
- })
109
-
110
- it("succeeds for ListData with two entries with two fields", () => {
111
- expect(
112
- Schema.decodeSync(Data.Struct({ foo: Data.String, bar: Data.Int }))({
113
- list: [
114
- Data.makeByteArrayData("48656C6C6F20576F726C64"),
115
- Data.makeIntData(0n)
116
- ]
117
- })
118
- ).toEqual({ foo: "Hello World", bar: 0 })
119
- })
120
-
121
- it("fails for ListData with two entries in wrong order with two fields", () => {
122
- expect(() =>
123
- Schema.decodeSync(Data.Struct({ bar: Data.Int, foo: Data.String }))({
124
- list: [
125
- Data.makeByteArrayData("48656C6C6F20576F726C64"),
126
- Data.makeIntData(0n)
127
- ]
128
- })
129
- ).toThrow()
130
- })
131
- })
132
-
133
- describe("Uplc.DataSchema.EnumVariant", () => {
134
- it("succeeds for empty ConstrData for empty EnumVariant", () => {
135
- expect(
136
- Schema.decodeSync(Data.EnumVariant(0, {}))({
137
- constructor: 0,
138
- fields: []
139
- })
140
- ).toEqual({})
141
- })
142
-
143
- it("fields for ConstrData with wrong tag", () => {
144
- expect(() =>
145
- Schema.decodeSync(Data.EnumVariant(0, {}))({
146
- constructor: 1,
147
- fields: []
148
- })
149
- ).toThrow()
150
- })
151
-
152
- it("fails for empty ConstrData if one field is defined", () => {
153
- expect(() =>
154
- Schema.decodeSync(Data.EnumVariant(0, { foo: Data.String }))({
155
- constructor: 0,
156
- fields: []
157
- })
158
- ).toThrow()
159
- })
160
-
161
- it("succeeds for ConstrData with single entry if one field is defined", () => {
162
- expect(
163
- Schema.decodeSync(Data.EnumVariant(0, { foo: Data.String }))({
164
- constructor: 0,
165
- fields: [Data.makeByteArrayData("48656C6C6F20576F726C64")]
166
- })
167
- ).toEqual({ foo: "Hello World" })
168
- })
169
-
170
- it("fails for ConstrData with wrong entry in first place with one field is defined", () => {
171
- expect(() =>
172
- Schema.decodeSync(Data.EnumVariant(0, { foo: Data.String }))({
173
- constructor: 0,
174
- fields: [{ int: 0n }]
175
- })
176
- ).toThrow()
177
- })
178
-
179
- it("succeeds for EnumVariant with spurious entries at end with one field is defined", () => {
180
- expect(
181
- Schema.decodeSync(Data.EnumVariant(0, { foo: Data.String }))({
182
- constructor: 0,
183
- fields: [
184
- Data.makeByteArrayData("48656C6C6F20576F726C64"),
185
- Data.makeIntData(0n)
186
- ]
187
- })
188
- ).toEqual({ foo: "Hello World" })
189
- })
190
-
191
- it("succeeds for EnumVariant with two entries with two fields", () => {
192
- expect(
193
- Schema.decodeSync(
194
- Data.EnumVariant(0, {
195
- foo: Data.String,
196
- bar: Data.Int
197
- })
198
- )({
199
- constructor: 0,
200
- fields: [
201
- Data.makeByteArrayData("48656C6C6F20576F726C64"),
202
- Data.makeIntData(0n)
203
- ]
204
- })
205
- ).toEqual({ foo: "Hello World", bar: 0 })
206
- })
207
-
208
- it("fails for EnumVariant with two entries in wrong order with two fields", () => {
209
- expect(() =>
210
- Schema.decodeSync(
211
- Data.EnumVariant(0, {
212
- bar: Data.Int,
213
- foo: Data.String
214
- })
215
- )({
216
- constructor: 0,
217
- fields: [
218
- Data.makeByteArrayData("48656C6C6F20576F726C64"),
219
- Data.makeIntData(0n)
220
- ]
221
- })
222
- ).toThrow()
223
- })
224
- })
225
-
226
- describe("Uplc.DataSchema.Enum", () => {
227
- it("succeeds for empty ConstrData for empty EnumVariant", () => {
228
- expect(
229
- Schema.decodeSync(Data.Enum({ foo: {} }))({
230
- constructor: 0,
231
- fields: []
232
- })
233
- ).toEqual({ _tag: "foo" })
234
- })
235
-
236
- it("fields for ConstrData with wrong tag", () => {
237
- expect(() =>
238
- Schema.decodeSync(Data.Enum({ foo: {} }))({
239
- constructor: 1,
240
- fields: []
241
- })
242
- ).toThrow()
243
- })
244
-
245
- it("fails for empty ConstrData if one field is defined", () => {
246
- expect(() =>
247
- Schema.decodeSync(Data.Enum({ foo: { bar: Data.String } }))({
248
- constructor: 0,
249
- fields: []
250
- })
251
- ).toThrow()
252
- })
253
-
254
- it("succeeds for ConstrData with single entry if one field is defined", () => {
255
- expect(
256
- Schema.decodeSync(Data.Enum({ foo: { bar: Data.String } }))({
257
- constructor: 0,
258
- fields: [Data.makeByteArrayData("48656C6C6F20576F726C64")]
259
- })
260
- ).toEqual({ _tag: "foo", bar: "Hello World" })
261
- })
262
-
263
- it("fails for ConstrData with wrong entry in first place with one field is defined", () => {
264
- expect(() =>
265
- Schema.decodeSync(Data.Enum({ foo: { bar: Data.String } }))({
266
- constructor: 0,
267
- fields: [{ int: 0n }]
268
- })
269
- ).toThrow()
270
- })
271
-
272
- it("succeeds for Enum with spurious entries at end with one field is defined", () => {
273
- expect(
274
- Schema.decodeSync(Data.Enum({ foo: { bar: Data.String } }))({
275
- constructor: 0,
276
- fields: [
277
- Data.makeByteArrayData("48656C6C6F20576F726C64"),
278
- Data.makeIntData(0n)
279
- ]
280
- })
281
- ).toEqual({ _tag: "foo", bar: "Hello World" })
282
- })
283
-
284
- it("succeeds for Enum with two entries with two fields", () => {
285
- expect(
286
- Schema.decodeSync(
287
- Data.Enum({
288
- foo: {
289
- a: Data.String,
290
- b: Data.Int
291
- }
292
- })
293
- )({
294
- constructor: 0,
295
- fields: [
296
- Data.makeByteArrayData("48656C6C6F20576F726C64"),
297
- Data.makeIntData(0n)
298
- ]
299
- })
300
- ).toEqual({ _tag: "foo", a: "Hello World", b: 0 })
301
- })
302
-
303
- it("fails for Enum with two entries in wrong order with two fields", () => {
304
- expect(() =>
305
- Schema.decodeSync(
306
- Data.Enum({
307
- foo: {
308
- a: Data.Int,
309
- b: Data.String
310
- }
311
- })
312
- )({
313
- constructor: 0,
314
- fields: [
315
- Data.makeByteArrayData("48656C6C6F20576F726C64"),
316
- Data.makeIntData(0n)
317
- ]
318
- })
319
- ).toThrow()
320
- })
321
- })