@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,58 +0,0 @@
1
- import { Effect, Encoding } from "effect"
2
- import * as Bytes from "./Bytes.js"
3
-
4
- /**
5
- * Decodes a list of uint8 bytes into a string using UTF-8 encoding.
6
- * @example
7
- * bytesToUtf8([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]) == "hello world"
8
- * @param bytes
9
- * @returns
10
- */
11
- export function decode(
12
- bytes: string | number[] | Uint8Array
13
- ): Effect.Effect<string, Encoding.DecodeException> {
14
- return Effect.sync(() =>
15
- new TextDecoder("utf-8", { fatal: true }).decode(
16
- Bytes.toUint8Array(bytes).buffer
17
- )
18
- ).pipe(
19
- Effect.catchAll(() =>
20
- Effect.fail(Bytes.DecodeException(bytes, "Invalid utf-8 encoding"))
21
- )
22
- )
23
- }
24
-
25
- /**
26
- * Encodes a string into a list of uint8 bytes using UTF-8 encoding.
27
- * @example
28
- * utf8ToBytes("hello world") == [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]
29
- * @param str
30
- * @returns
31
- */
32
- export function encode(str: string): Uint8Array {
33
- return new TextEncoder().encode(str)
34
- }
35
-
36
- /**
37
- * Tests if a uint8 array is valid utf8 encoding.
38
- * @param {number[]} bytes
39
- * @returns {boolean}
40
- */
41
- export function isValid(bytes: string | number[] | Uint8Array): boolean {
42
- /**
43
- * Bytes.toArray() doesn't fail if any of the bytes are out of range
44
- */
45
- const bs = Bytes.toArray(bytes)
46
-
47
- if (bs.some((b) => b < 0 || b > 255)) {
48
- return false
49
- }
50
-
51
- try {
52
- new TextDecoder("utf-8", { fatal: true }).decode(new Uint8Array(bs).buffer)
53
-
54
- return true
55
- } catch (_e) {
56
- return false
57
- }
58
- }