@helios-lang/effect 0.2.0 → 0.3.0

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 (45) hide show
  1. package/dist/Cardano/Ledger/Address.js +1 -1
  2. package/dist/Cardano/Ledger/Address.js.map +1 -1
  3. package/dist/Cardano/Ledger/PubKey.js +16 -14
  4. package/dist/Cardano/Ledger/PubKey.js.map +1 -1
  5. package/dist/Cardano/Ledger/index.js +1 -0
  6. package/dist/Cardano/Ledger/index.js.map +1 -1
  7. package/dist/Cardano/TxBuilder.js +26 -9
  8. package/dist/Cardano/TxBuilder.js.map +1 -1
  9. package/dist/Cardano/Uplc/Data.js.map +1 -1
  10. package/dist/Cardano/Wallet.js +48 -0
  11. package/dist/Cardano/Wallet.js.map +1 -0
  12. package/dist/Cardano/index.js +1 -0
  13. package/dist/Cardano/index.js.map +1 -1
  14. package/dist/Codecs/LittleEndian.js +4 -0
  15. package/dist/Codecs/LittleEndian.js.map +1 -1
  16. package/dist/Crypto/Bip32.js +131 -0
  17. package/dist/Crypto/Bip32.js.map +1 -0
  18. package/dist/Crypto/Bip39.js +2176 -0
  19. package/dist/Crypto/Bip39.js.map +1 -0
  20. package/package.json +1 -1
  21. package/types/Cardano/Ledger/Address.d.ts +2 -2
  22. package/types/Cardano/Ledger/Address.d.ts.map +1 -1
  23. package/types/Cardano/Ledger/PubKey.d.ts +11 -7
  24. package/types/Cardano/Ledger/PubKey.d.ts.map +1 -1
  25. package/types/Cardano/Ledger/Signature.d.ts +1 -1
  26. package/types/Cardano/Ledger/Tx.d.ts +8 -8
  27. package/types/Cardano/Ledger/TxOutput.d.ts +4 -4
  28. package/types/Cardano/Ledger/UTxO.d.ts +23 -23
  29. package/types/Cardano/Ledger/index.d.ts +1 -0
  30. package/types/Cardano/Ledger/index.d.ts.map +1 -1
  31. package/types/Cardano/TxBuilder.d.ts +6 -35
  32. package/types/Cardano/TxBuilder.d.ts.map +1 -1
  33. package/types/Cardano/Uplc/Data.d.ts.map +1 -1
  34. package/types/Cardano/Wallet.d.ts +73 -0
  35. package/types/Cardano/Wallet.d.ts.map +1 -0
  36. package/types/Cardano/index.d.ts +1 -0
  37. package/types/Cardano/index.d.ts.map +1 -1
  38. package/types/Codecs/LittleEndian.d.ts +1 -0
  39. package/types/Codecs/LittleEndian.d.ts.map +1 -1
  40. package/types/Crypto/Bip32.d.ts +29 -0
  41. package/types/Crypto/Bip32.d.ts.map +1 -0
  42. package/types/Crypto/Bip39.d.ts +43 -0
  43. package/types/Crypto/Bip39.d.ts.map +1 -0
  44. package/tsconfig.build.tsbuildinfo +0 -1
  45. package/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,73 @@
1
+ import { Context, Effect } from "effect";
2
+ import * as Bip39 from "../Crypto/Bip39.js";
3
+ import * as Address from "./Ledger/Address.js";
4
+ import * as Signature from "./Ledger/Signature.js";
5
+ import * as Tx from "./Ledger/Tx.js";
6
+ import * as UTxO from "./Ledger/UTxO.js";
7
+ import * as Network from "./Network";
8
+ declare const Balancing_base: Context.TagClass<Balancing, "Cardano.Wallet.Balancing", {
9
+ changeAddress: Effect.Effect<Address.Address>;
10
+ utxos: Effect.Effect<UTxO.UTxO[], Error>;
11
+ signTx(tx: Tx.Tx): Effect.Effect<Signature.Signature[], Error>;
12
+ }>;
13
+ export declare class Balancing extends Balancing_base {
14
+ }
15
+ /**
16
+ * @param phrase
17
+ * Space separated
18
+ * @returns
19
+ */
20
+ export declare const Phrase: (phrase: string | string[], account?: number, subAccount?: number) => Effect.Effect<{
21
+ changeAddress: Effect.Effect<string & import("effect/Brand").Brand<"Cardano.Ledger.Address">, never, never>;
22
+ utxos: Effect.Effect<{
23
+ readonly output: {
24
+ readonly address: string & import("effect/Brand").Brand<"Cardano.Ledger.Address">;
25
+ readonly assets: {
26
+ readonly [x: string]: bigint;
27
+ };
28
+ readonly datum?: {
29
+ readonly _tag: "Inline";
30
+ readonly data: {
31
+ readonly bytes: Uint8Array<ArrayBufferLike>;
32
+ } | {
33
+ readonly int: bigint;
34
+ } | {
35
+ readonly list: readonly import("./Uplc/Data.js").Data[];
36
+ } | {
37
+ readonly map: readonly {
38
+ readonly k: import("./Uplc/Data.js").Data;
39
+ readonly v: import("./Uplc/Data.js").Data;
40
+ }[];
41
+ } | {
42
+ readonly fields: readonly import("./Uplc/Data.js").Data[];
43
+ readonly constructor: number;
44
+ };
45
+ } | {
46
+ readonly _tag: "Hash";
47
+ readonly hash: string & import("effect/Brand").Brand<"DatumHash">;
48
+ } | undefined;
49
+ readonly refScript?: ({
50
+ readonly root: Uint8Array<ArrayBufferLike>;
51
+ readonly verbose?: Uint8Array<ArrayBufferLike> | undefined;
52
+ } & {
53
+ readonly version: 2;
54
+ }) | ({
55
+ readonly root: Uint8Array<ArrayBufferLike>;
56
+ readonly verbose?: Uint8Array<ArrayBufferLike> | undefined;
57
+ } & {
58
+ readonly version: 3;
59
+ }) | undefined;
60
+ readonly encodingConfig?: {
61
+ readonly strictBabbage?: boolean | undefined;
62
+ } | undefined;
63
+ };
64
+ readonly ref: string & import("effect/Brand").Brand<"UTxORef">;
65
+ }[], Error, never>;
66
+ signTx: (tx: Tx.Tx) => Effect.Effect<{
67
+ pubKey: string & import("effect/Brand").Brand<"Crypto.Bip32.VerificationKey">;
68
+ signature: Uint8Array<ArrayBufferLike>;
69
+ }[], never, never>;
70
+ }, Bip39.InvalidPhraseLength | Bip39.InvalidWord | Bip39.InvalidChecksum, Network.IsMainnet | Network.UTxOsAt>;
71
+ export declare const Browser: (_handle: unknown) => never;
72
+ export {};
73
+ //# sourceMappingURL=Wallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Wallet.d.ts","sourceRoot":"","sources":["../../src/Cardano/Wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAExC,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAC3C,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAA;AAE9C,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAA;AAClD,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACpC,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAA;AACxC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAA;;mBAKjB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;WACtC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC;eAC7B,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,KAAK,CAAC;;AALlE,qBAAa,SAAU,SAAQ,cAO5B;CAAG;AAEN;;;;GAIG;AACH,eAAO,MAAM,MAAM,GACjB,QAAQ,MAAM,GAAG,MAAM,EAAE,EACzB,UAAS,MAAU,EACnB,aAAY,MAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkCL,EAAE,CAAC,EAAE;;;;8GAGpB,CAAA;AAEJ,eAAO,MAAM,OAAO,GAAI,SAAS,OAAO,UAEvC,CAAA"}
@@ -3,4 +3,5 @@ export * as Ledger from "./Ledger";
3
3
  export * as Network from "./Network";
4
4
  export * as TxBuilder from "./TxBuilder.js";
5
5
  export * as Uplc from "./Uplc";
6
+ export * as Wallet from "./Wallet.js";
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Cardano/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,MAAM,MAAM,UAAU,CAAA;AAClC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAA;AACpC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Cardano/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,MAAM,MAAM,UAAU,CAAA;AAClC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAA;AACpC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAA;AAC9B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA"}
@@ -9,6 +9,7 @@ import * as Bytes from "./Bytes.js";
9
9
  * @returns
10
10
  */
11
11
  export declare function decode(bytes: Bytes.BytesLike): Either.Either<bigint, Encoding.DecodeException>;
12
+ export declare function decodeOrThrow(bytes: Bytes.BytesLike): bigint;
12
13
  /**
13
14
  * Little Endian 32 bytes
14
15
  * @param {IntLike} x
@@ -1 +1 @@
1
- {"version":3,"file":"LittleEndian.d.ts","sourceRoot":"","sources":["../../src/Codecs/LittleEndian.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEzC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAEnC;;GAEG;AAEH;;;;GAIG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,KAAK,CAAC,SAAS,GACrB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAMrD"}
1
+ {"version":3,"file":"LittleEndian.d.ts","sourceRoot":"","sources":["../../src/Codecs/LittleEndian.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEzC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAEnC;;GAEG;AAEH;;;;GAIG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,KAAK,CAAC,SAAS,GACrB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,CAEjD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,GAAG,MAAM,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAMrD"}
@@ -0,0 +1,29 @@
1
+ import { Either, ParseResult, Schema } from "effect";
2
+ import * as Bytes from "../Codecs/Bytes.js";
3
+ /**
4
+ * Used during `PrivateKey` derivation, to create a new `PrivateKey` instance with a non-publicly deriveable `PubKey`.
5
+ */
6
+ export declare const HARDEN = 2147483648;
7
+ export declare function isValidSigningKey(sk: string): boolean;
8
+ export declare const SigningKey: Schema.brand<Schema.filter<typeof Schema.String>, "Crypto.Bip32.SigningKey">;
9
+ export type SigningKey = Schema.Schema.Type<typeof SigningKey>;
10
+ export declare function isValidVerificationKey(pk: string): boolean;
11
+ export declare const VerificationKey: Schema.brand<Schema.filter<typeof Schema.String>, "Crypto.Bip32.VerificationKey">;
12
+ export type VerificationKey = Schema.Schema.Type<typeof VerificationKey>;
13
+ export declare const makeVerificationKeyUnsafe: (bytes: Bytes.BytesLike) => string;
14
+ export declare const makeVerificationKey: (bytes: Bytes.BytesLike) => Either.Either<VerificationKey, ParseResult.Unexpected>;
15
+ /**
16
+ * @param {number[]} entropy
17
+ * @param {boolean} force
18
+ * @returns {Bip32PrivateKey}
19
+ */
20
+ export declare function skFromEntropy(entropy: Bytes.BytesLike, force?: boolean): SigningKey;
21
+ export declare const skBytes: (sk: SigningKey) => Uint8Array;
22
+ export declare const vkBytes: (vk: VerificationKey) => Uint8Array;
23
+ export declare const deriveVerificationKey: (sk: SigningKey) => VerificationKey;
24
+ export declare const derivePath: (sk: SigningKey, path: number[]) => SigningKey;
25
+ export declare const sign: (sk: SigningKey) => (message: Bytes.BytesLike) => {
26
+ pubKey: string & import("effect/Brand").Brand<"Crypto.Bip32.VerificationKey">;
27
+ signature: Uint8Array<ArrayBufferLike>;
28
+ };
29
+ //# sourceMappingURL=Bip32.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Bip32.d.ts","sourceRoot":"","sources":["../../src/Crypto/Bip32.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAGpD,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAM3C;;GAEG;AACH,eAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAsBrD;AAED,eAAO,MAAM,UAAU,8EAKtB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC,CAAA;AAM9D,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAsB1D;AAED,eAAO,MAAM,eAAe,mFAK3B,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,eAAe,CAAC,CAAA;AAExE,eAAO,MAAM,yBAAyB,GAAI,OAAO,KAAK,CAAC,SAAS,KAAG,MACd,CAAA;AACrD,eAAO,MAAM,mBAAmB,GAC9B,OAAO,KAAK,CAAC,SAAS,KACrB,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,WAAW,CAAC,UAAU,CAUvD,CAAA;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,KAAK,CAAC,SAAS,EACxB,KAAK,GAAE,OAAc,GACpB,UAAU,CAyBZ;AAED,eAAO,MAAM,OAAO,GAAI,IAAI,UAAU,KAAG,UACuB,CAAA;AAChE,eAAO,MAAM,OAAO,GAAI,IAAI,eAAe,KAAG,UACkB,CAAA;AAEhE,eAAO,MAAM,qBAAqB,GAAI,IAAI,UAAU,KAAG,eAIjC,CAAA;AAkDtB,eAAO,MAAM,UAAU,GAAI,IAAI,UAAU,EAAE,MAAM,MAAM,EAAE,KAAG,UAM3D,CAAA;AAED,eAAO,MAAM,IAAI,GAAI,IAAI,UAAU,MAAM,SAAS,KAAK,CAAC,SAAS;;;CAOhE,CAAA"}
@@ -0,0 +1,43 @@
1
+ import { Either } from "effect";
2
+ declare const InvalidPhraseLength_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
3
+ readonly _tag: "Crypto.Bip39.InvalidPhraseLength";
4
+ } & Readonly<A>;
5
+ export declare class InvalidPhraseLength extends InvalidPhraseLength_base<{
6
+ message: string;
7
+ }> {
8
+ constructor(n: number);
9
+ }
10
+ declare const InvalidWord_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
11
+ readonly _tag: "Crypto.Bip39.InvalidWord";
12
+ } & Readonly<A>;
13
+ export declare class InvalidWord extends InvalidWord_base<{
14
+ message: string;
15
+ }> {
16
+ constructor(w: string);
17
+ }
18
+ declare const InvalidChecksum_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
19
+ readonly _tag: "Crypto.Bip39.InvalidChecksum";
20
+ } & Readonly<A>;
21
+ export declare class InvalidChecksum extends InvalidChecksum_base<{
22
+ message: string;
23
+ }> {
24
+ constructor(message?: string);
25
+ }
26
+ declare const InvalidEntropyLength_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
27
+ readonly _tag: "Crypto.Bip39.InvalidEntropyLength";
28
+ } & Readonly<A>;
29
+ export declare class InvalidEntropyLength extends InvalidEntropyLength_base<{
30
+ message: string;
31
+ }> {
32
+ constructor(n: number);
33
+ }
34
+ export declare function clean(phrase: string | string[]): string[];
35
+ export declare const phraseToEntropy: (phrase: string | string[], dict?: string[]) => Either.Either<Uint8Array, InvalidPhraseLength | InvalidWord | InvalidChecksum>;
36
+ export declare function isValidPhrase(phrase: string | string[], dict?: string[]): boolean;
37
+ export declare const entropyToPhrase: (entropy: Uint8Array, dict?: string[]) => Either.Either<string[], InvalidEntropyLength>;
38
+ /**
39
+ * Standard English Bip39 dictionary consisting of 2048 words allowing wallet root keys to be formed by a phrase of 12, 15, 18, 21 or 24 of these words.
40
+ */
41
+ export declare const English: string[];
42
+ export {};
43
+ //# sourceMappingURL=Bip39.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Bip39.d.ts","sourceRoot":"","sources":["../../src/Crypto/Bip39.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAAE,MAAM,QAAQ,CAAA;;;;AAKrC,qBAAa,mBAAoB,SAAQ,yBAEvC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;gBACR,CAAC,EAAE,MAAM;CAKtB;;;;AAED,qBAAa,WAAY,SAAQ,iBAA6C;IAC5E,OAAO,EAAE,MAAM,CAAA;CAChB,CAAC;gBACY,CAAC,EAAE,MAAM;CAGtB;;;;AAED,qBAAa,eAAgB,SAAQ,qBAEnC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;gBACR,OAAO,GAAE,MAA2B;CAGjD;;;;AAED,qBAAa,oBAAqB,SAAQ,0BAExC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;gBACR,CAAC,EAAE,MAAM;CAKtB;AAED,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,CAUzD;AAED,eAAO,MAAM,eAAe,GAC1B,QAAQ,MAAM,GAAG,MAAM,EAAE,EACzB,OAAM,MAAM,EAAY,KACvB,MAAM,CAAC,MAAM,CACd,UAAU,EACV,mBAAmB,GAAG,WAAW,GAAG,eAAe,CAwDpD,CAAA;AAED,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EACzB,IAAI,GAAE,MAAM,EAAY,GACvB,OAAO,CAET;AAED,eAAO,MAAM,eAAe,GAC1B,SAAS,UAAU,EACnB,OAAM,MAAM,EAAY,KACvB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,oBAAoB,CAkE9C,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,OAAO,UAigEnB,CAAA"}