@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.
- package/bun.lock +60 -0
- package/dist/Ledger/NetworkParams.js +40 -0
- package/dist/Ledger/NetworkParams.js.map +1 -0
- package/dist/Ledger/index.js +1 -0
- package/dist/Ledger/index.js.map +1 -1
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.check.tsbuildinfo +1 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/types/Address.d.ts +5 -0
- package/types/Address.d.ts.map +1 -0
- package/types/Bech32.d.ts +30 -0
- package/types/Bech32.d.ts.map +1 -0
- package/types/Cbor.d.ts +430 -0
- package/types/Cbor.d.ts.map +1 -0
- package/types/Ledger/Address.d.ts +109 -0
- package/types/Ledger/Address.d.ts.map +1 -0
- package/types/Ledger/AssetClass.d.ts +101 -0
- package/types/Ledger/AssetClass.d.ts.map +1 -0
- package/types/Ledger/Assets.d.ts +70 -0
- package/types/Ledger/Assets.d.ts.map +1 -0
- package/types/Ledger/Credential.d.ts +26 -0
- package/types/Ledger/Credential.d.ts.map +1 -0
- package/types/Ledger/DatumHash.d.ts +40 -0
- package/types/Ledger/DatumHash.d.ts.map +1 -0
- package/types/Ledger/IsMainnet.d.ts +6 -0
- package/types/Ledger/IsMainnet.d.ts.map +1 -0
- package/types/Ledger/MintingPolicy.d.ts +39 -0
- package/types/Ledger/MintingPolicy.d.ts.map +1 -0
- package/types/Ledger/NetworkParams.d.ts +40 -0
- package/types/Ledger/NetworkParams.d.ts.map +1 -0
- package/types/Ledger/PubKeyHash.d.ts +40 -0
- package/types/Ledger/PubKeyHash.d.ts.map +1 -0
- package/types/Ledger/TxId.d.ts +10 -0
- package/types/Ledger/TxId.d.ts.map +1 -0
- package/types/Ledger/TxInput.d.ts +55 -0
- package/types/Ledger/TxInput.d.ts.map +1 -0
- package/types/Ledger/TxOutput.d.ts +63 -0
- package/types/Ledger/TxOutput.d.ts.map +1 -0
- package/types/Ledger/TxOutputDatum.d.ts +41 -0
- package/types/Ledger/TxOutputDatum.d.ts.map +1 -0
- package/types/Ledger/TxOutputId.d.ts +14 -0
- package/types/Ledger/TxOutputId.d.ts.map +1 -0
- package/types/Ledger/ValidatorHash.d.ts +40 -0
- package/types/Ledger/ValidatorHash.d.ts.map +1 -0
- package/types/Ledger/index.d.ts +16 -0
- package/types/Ledger/index.d.ts.map +1 -0
- package/types/Uplc/Cek.d.ts +72 -0
- package/types/Uplc/Cek.d.ts.map +1 -0
- package/types/Uplc/Data.d.ts +530 -0
- package/types/Uplc/Data.d.ts.map +1 -0
- package/types/Uplc/DataSchema.d.ts +227 -0
- package/types/Uplc/DataSchema.d.ts.map +1 -0
- package/types/Uplc/Primitive.d.ts +26 -0
- package/types/Uplc/Primitive.d.ts.map +1 -0
- package/types/Uplc/index.d.ts +3 -0
- package/types/Uplc/index.d.ts.map +1 -0
- package/types/index.d.ts +5 -0
- package/types/index.d.ts.map +1 -0
- package/types/internal/Base32.d.ts +49 -0
- package/types/internal/Base32.d.ts.map +1 -0
- package/types/internal/BigEndian.d.ts +22 -0
- package/types/internal/BigEndian.d.ts.map +1 -0
- package/types/internal/Bits.d.ts +123 -0
- package/types/internal/Bits.d.ts.map +1 -0
- package/types/internal/Bytes.d.ts +88 -0
- package/types/internal/Bytes.d.ts.map +1 -0
- package/types/internal/Flat.d.ts +71 -0
- package/types/internal/Flat.d.ts.map +1 -0
- package/types/internal/Float.d.ts +38 -0
- package/types/internal/Float.d.ts.map +1 -0
- package/types/internal/Utf8.d.ts +24 -0
- package/types/internal/Utf8.d.ts.map +1 -0
- package/src/Bech32.test.ts +0 -117
- package/src/Bech32.ts +0 -198
- package/src/Cbor.test.ts +0 -1610
- package/src/Cbor.ts +0 -1704
- package/src/Ledger/Address.ts +0 -248
- package/src/Ledger/AssetClass.ts +0 -90
- package/src/Ledger/Assets.ts +0 -164
- package/src/Ledger/Credential.ts +0 -29
- package/src/Ledger/DatumHash.ts +0 -36
- package/src/Ledger/IsMainnet.ts +0 -6
- package/src/Ledger/MintingPolicy.ts +0 -57
- package/src/Ledger/PubKeyHash.ts +0 -36
- package/src/Ledger/TxId.ts +0 -31
- package/src/Ledger/TxInput.test.ts +0 -21
- package/src/Ledger/TxInput.ts +0 -66
- package/src/Ledger/TxOutput.ts +0 -166
- package/src/Ledger/TxOutputDatum.ts +0 -64
- package/src/Ledger/TxOutputId.ts +0 -63
- package/src/Ledger/ValidatorHash.ts +0 -36
- package/src/Ledger/index.ts +0 -14
- package/src/Uplc/Cek.ts +0 -92
- package/src/Uplc/Data.test.ts +0 -321
- package/src/Uplc/Data.ts +0 -657
- package/src/Uplc/Primitive.ts +0 -56
- package/src/Uplc/index.ts +0 -2
- package/src/index.ts +0 -4
- package/src/internal/Base32.test.ts +0 -219
- package/src/internal/Base32.ts +0 -341
- package/src/internal/BigEndian.test.ts +0 -79
- package/src/internal/BigEndian.ts +0 -67
- package/src/internal/Bits.test.ts +0 -300
- package/src/internal/Bits.ts +0 -398
- package/src/internal/Bytes.test.ts +0 -369
- package/src/internal/Bytes.ts +0 -343
- package/src/internal/Flat.test.ts +0 -29
- package/src/internal/Flat.ts +0 -387
- package/src/internal/Float.test.ts +0 -51
- package/src/internal/Float.ts +0 -190
- package/src/internal/Utf8.test.ts +0 -69
- package/src/internal/Utf8.ts +0 -58
package/src/internal/Utf8.ts
DELETED
|
@@ -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
|
-
}
|