voltaire-effect 0.3.0 → 1.0.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 (88) hide show
  1. package/dist/{X25519Test-D5Q-5fL9.d.ts → X25519Test-avt1DUgp.d.ts} +231 -6
  2. package/dist/crypto/index.d.ts +2 -2
  3. package/dist/crypto/index.js +72 -2
  4. package/dist/{index-3UKSP3cd.d.ts → index-DxwZo3xo.d.ts} +7781 -5513
  5. package/dist/index.d.ts +990 -3096
  6. package/dist/index.js +2374 -1652
  7. package/dist/native/index.d.ts +6 -6
  8. package/dist/native/index.js +2399 -1677
  9. package/dist/primitives/index.d.ts +7 -6
  10. package/dist/primitives/index.js +2966 -2361
  11. package/dist/services/index.d.ts +1631 -1255
  12. package/dist/services/index.js +4493 -3977
  13. package/package.json +7 -3
  14. package/src/crypto/Signers/SignersService.ts +1 -1
  15. package/src/crypto/Signers/errors.ts +29 -0
  16. package/src/crypto/Signers/index.ts +1 -0
  17. package/src/crypto/Signers/operations.ts +26 -8
  18. package/src/crypto/index.ts +10 -11
  19. package/src/index.ts +1 -2
  20. package/src/jsonrpc/Anvil.ts +13 -8
  21. package/src/jsonrpc/Eth.ts +13 -8
  22. package/src/jsonrpc/Hardhat.ts +13 -8
  23. package/src/jsonrpc/IdCounter.ts +21 -5
  24. package/src/jsonrpc/JsonRpc.test.ts +126 -61
  25. package/src/jsonrpc/Net.ts +13 -8
  26. package/src/jsonrpc/Request.ts +16 -8
  27. package/src/jsonrpc/Txpool.ts +13 -8
  28. package/src/jsonrpc/Wallet.ts +13 -8
  29. package/src/jsonrpc/Web3.ts +13 -8
  30. package/src/jsonrpc/index.ts +1 -1
  31. package/src/primitives/Abi/AbiSchema.ts +3 -4
  32. package/src/primitives/Abi/fromBytecode.test.ts +47 -0
  33. package/src/primitives/Abi/fromBytecode.ts +81 -0
  34. package/src/primitives/Abi/index.ts +3 -0
  35. package/src/primitives/AccessList/from.ts +12 -9
  36. package/src/primitives/Address/Checksummed.ts +21 -27
  37. package/src/primitives/Address/from.ts +12 -15
  38. package/src/primitives/Address/toHex.ts +2 -1
  39. package/src/primitives/Base64/from.ts +21 -4
  40. package/src/primitives/Blob/from.ts +12 -4
  41. package/src/primitives/BlockHash/index.ts +2 -2
  42. package/src/primitives/BlockNumber/index.ts +3 -3
  43. package/src/primitives/Bytecode/from.ts +11 -2
  44. package/src/primitives/ContractSignature/verifySignature.ts +3 -5
  45. package/src/primitives/Ens/from.ts +12 -11
  46. package/src/primitives/Hex/from.ts +12 -4
  47. package/src/primitives/Signature/from.ts +11 -2
  48. package/src/primitives/Transaction/EIP2930/index.ts +12 -12
  49. package/src/primitives/Transaction/EIP4844/index.ts +14 -14
  50. package/src/primitives/Transaction/EIP7702/index.ts +13 -13
  51. package/src/primitives/Transaction/Legacy/index.ts +13 -13
  52. package/src/primitives/TransactionHash/index.ts +3 -2
  53. package/src/primitives/TransactionIndex/index.ts +2 -2
  54. package/src/primitives/Trie/Trie.test.ts +70 -0
  55. package/src/primitives/Trie/TrieSchema.ts +26 -0
  56. package/src/primitives/Trie/clear.ts +16 -0
  57. package/src/primitives/Trie/del.ts +18 -0
  58. package/src/primitives/Trie/get.ts +18 -0
  59. package/src/primitives/Trie/index.ts +30 -0
  60. package/src/primitives/Trie/init.ts +13 -0
  61. package/src/primitives/Trie/prove.ts +19 -0
  62. package/src/primitives/Trie/put.ts +20 -0
  63. package/src/primitives/Trie/rootHash.ts +14 -0
  64. package/src/primitives/Trie/verify.ts +18 -0
  65. package/src/primitives/Uint/from.ts +11 -2
  66. package/src/primitives/Uint16/index.ts +5 -4
  67. package/src/primitives/Uint64/index.ts +5 -4
  68. package/src/primitives/Uint8/index.ts +5 -4
  69. package/src/primitives/index.ts +3 -2
  70. package/src/services/BlockExplorerApi/BlockExplorerApi.test.ts +789 -0
  71. package/src/services/BlockExplorerApi/BlockExplorerApi.ts +797 -0
  72. package/src/services/BlockExplorerApi/BlockExplorerApiErrors.ts +176 -0
  73. package/src/services/BlockExplorerApi/BlockExplorerApiService.ts +60 -0
  74. package/src/services/BlockExplorerApi/BlockExplorerApiTypes.ts +225 -0
  75. package/src/services/BlockExplorerApi/index.ts +42 -0
  76. package/src/services/Contract/Contract.test.ts +2 -6
  77. package/src/services/Contract/ContractTypes.ts +26 -8
  78. package/src/services/Contract/estimateGas.test.ts +4 -7
  79. package/src/services/Provider/actions/multicall.ts +28 -9
  80. package/src/services/Provider/actions/readContract.test.ts +8 -11
  81. package/src/services/Provider/actions/readContract.ts +28 -9
  82. package/src/services/Provider/functions/getBlock.ts +2 -1
  83. package/src/services/Provider/functions/getBlockReceipts.ts +2 -1
  84. package/src/services/Provider/functions/getBlockTransactionCount.ts +2 -1
  85. package/src/services/Provider/functions/getUncle.ts +2 -1
  86. package/src/services/Provider/functions/getUncleCount.ts +2 -1
  87. package/src/services/Signer/actions/deployContract.ts +1 -1
  88. package/src/services/index.ts +25 -0
@@ -8,15 +8,15 @@
8
8
  import {
9
9
  type HexType,
10
10
  Hex as VoltaireHex,
11
- InvalidFormatError,
12
11
  } from "@tevm/voltaire/Hex";
12
+ import { ValidationError } from "@tevm/voltaire/errors";
13
13
  import { Effect } from "effect";
14
14
 
15
15
  /**
16
16
  * Parse any input (string or Uint8Array) to Hex.
17
17
  *
18
18
  * @param value - String or bytes to convert
19
- * @returns Effect with HexType or InvalidFormatError
19
+ * @returns Effect with HexType or ValidationError
20
20
  *
21
21
  * @example
22
22
  * ```ts
@@ -31,8 +31,16 @@ import { Effect } from "effect";
31
31
  */
32
32
  export const from = (
33
33
  value: string | Uint8Array,
34
- ): Effect.Effect<HexType, InvalidFormatError> =>
34
+ ): Effect.Effect<HexType, ValidationError> =>
35
35
  Effect.try({
36
36
  try: () => VoltaireHex.from(value),
37
- catch: (e) => e as InvalidFormatError,
37
+ catch: (error) =>
38
+ new ValidationError(
39
+ error instanceof Error ? error.message : "Invalid hex input",
40
+ {
41
+ value,
42
+ expected: "hex string (0x-prefixed) or Uint8Array",
43
+ cause: error instanceof Error ? error : undefined,
44
+ },
45
+ ),
38
46
  });
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { Signature, type SignatureType } from "@tevm/voltaire/Signature";
7
7
  import * as Effect from "effect/Effect";
8
+ import { ValidationError } from "@tevm/voltaire/errors";
8
9
 
9
10
  /**
10
11
  * Creates a Signature from various input formats.
@@ -31,8 +32,16 @@ export const from = (
31
32
  v?: number;
32
33
  algorithm?: "secp256k1" | "p256" | "ed25519";
33
34
  },
34
- ): Effect.Effect<SignatureType, Error> =>
35
+ ): Effect.Effect<SignatureType, ValidationError> =>
35
36
  Effect.try({
36
37
  try: () => Signature.from(value),
37
- catch: (e) => e as Error,
38
+ catch: (error) =>
39
+ new ValidationError(
40
+ error instanceof Error ? error.message : "Invalid signature input",
41
+ {
42
+ value,
43
+ expected: "signature bytes or {r, s, v} object",
44
+ cause: error instanceof Error ? error : undefined,
45
+ },
46
+ ),
38
47
  });
@@ -1,16 +1,16 @@
1
1
  import { EIP2930 } from "@tevm/voltaire/Transaction";
2
2
 
3
- export const {
4
- TransactionEIP2930,
5
- deserialize,
6
- serialize,
7
- hash,
8
- getSigningHash,
9
- getSender,
10
- verifySignature,
11
- Hash,
12
- GetSigningHash,
13
- VerifySignature,
14
- } = EIP2930;
3
+ export type TransactionEIP2930Type = ReturnType<typeof EIP2930.TransactionEIP2930>;
4
+
5
+ export const TransactionEIP2930 = EIP2930.TransactionEIP2930;
6
+ export const deserialize = EIP2930.deserialize;
7
+ export const serialize = EIP2930.serialize;
8
+ export const hash: (tx: TransactionEIP2930Type) => Uint8Array = EIP2930.hash;
9
+ export const getSigningHash: (tx: TransactionEIP2930Type) => Uint8Array = EIP2930.getSigningHash;
10
+ export const getSender = EIP2930.getSender;
11
+ export const verifySignature: (tx: TransactionEIP2930Type) => boolean = EIP2930.verifySignature;
12
+ export const Hash = EIP2930.Hash;
13
+ export const GetSigningHash = EIP2930.GetSigningHash;
14
+ export const VerifySignature = EIP2930.VerifySignature;
15
15
 
16
16
  export { EIP2930 };
@@ -1,18 +1,18 @@
1
1
  import { EIP4844 } from "@tevm/voltaire/Transaction";
2
2
 
3
- export const {
4
- TransactionEIP4844,
5
- deserialize,
6
- serialize,
7
- hash,
8
- getSigningHash,
9
- getSender,
10
- verifySignature,
11
- getEffectiveGasPrice,
12
- getBlobGasCost,
13
- Hash,
14
- GetSigningHash,
15
- VerifySignature,
16
- } = EIP4844;
3
+ export type TransactionEIP4844Type = ReturnType<typeof EIP4844.TransactionEIP4844>;
4
+
5
+ export const TransactionEIP4844 = EIP4844.TransactionEIP4844;
6
+ export const deserialize = EIP4844.deserialize;
7
+ export const serialize = EIP4844.serialize;
8
+ export const hash: (tx: TransactionEIP4844Type) => Uint8Array = EIP4844.hash;
9
+ export const getSigningHash: (tx: TransactionEIP4844Type) => Uint8Array = EIP4844.getSigningHash;
10
+ export const getSender = EIP4844.getSender;
11
+ export const verifySignature: (tx: TransactionEIP4844Type) => boolean = EIP4844.verifySignature;
12
+ export const getEffectiveGasPrice = EIP4844.getEffectiveGasPrice;
13
+ export const getBlobGasCost = EIP4844.getBlobGasCost;
14
+ export const Hash = EIP4844.Hash;
15
+ export const GetSigningHash = EIP4844.GetSigningHash;
16
+ export const VerifySignature = EIP4844.VerifySignature;
17
17
 
18
18
  export { EIP4844 };
@@ -1,17 +1,17 @@
1
1
  import { EIP7702 } from "@tevm/voltaire/Transaction";
2
2
 
3
- export const {
4
- TransactionEIP7702,
5
- deserialize,
6
- serialize,
7
- hash,
8
- getSigningHash,
9
- getSender,
10
- verifySignature,
11
- getEffectiveGasPrice,
12
- Hash,
13
- GetSigningHash,
14
- VerifySignature,
15
- } = EIP7702;
3
+ export type TransactionEIP7702Type = ReturnType<typeof EIP7702.TransactionEIP7702>;
4
+
5
+ export const TransactionEIP7702 = EIP7702.TransactionEIP7702;
6
+ export const deserialize = EIP7702.deserialize;
7
+ export const serialize = EIP7702.serialize;
8
+ export const hash: (tx: TransactionEIP7702Type) => Uint8Array = EIP7702.hash;
9
+ export const getSigningHash: (tx: TransactionEIP7702Type) => Uint8Array = EIP7702.getSigningHash;
10
+ export const getSender = EIP7702.getSender;
11
+ export const verifySignature: (tx: TransactionEIP7702Type) => boolean = EIP7702.verifySignature;
12
+ export const getEffectiveGasPrice = EIP7702.getEffectiveGasPrice;
13
+ export const Hash = EIP7702.Hash;
14
+ export const GetSigningHash = EIP7702.GetSigningHash;
15
+ export const VerifySignature = EIP7702.VerifySignature;
16
16
 
17
17
  export { EIP7702 };
@@ -1,17 +1,17 @@
1
1
  import { Legacy } from "@tevm/voltaire/Transaction";
2
2
 
3
- export const {
4
- TransactionLegacy,
5
- deserialize,
6
- serialize,
7
- hash,
8
- getChainId,
9
- getSigningHash,
10
- getSender,
11
- verifySignature,
12
- Hash,
13
- GetSigningHash,
14
- VerifySignature,
15
- } = Legacy;
3
+ export type TransactionLegacyType = ReturnType<typeof Legacy.TransactionLegacy>;
4
+
5
+ export const TransactionLegacy = Legacy.TransactionLegacy;
6
+ export const deserialize = Legacy.deserialize;
7
+ export const serialize = Legacy.serialize;
8
+ export const hash: (this: TransactionLegacyType) => Uint8Array = Legacy.hash;
9
+ export const getChainId = Legacy.getChainId;
10
+ export const getSigningHash: (this: TransactionLegacyType) => Uint8Array = Legacy.getSigningHash;
11
+ export const getSender = Legacy.getSender;
12
+ export const verifySignature: (this: TransactionLegacyType) => boolean = Legacy.verifySignature;
13
+ export const Hash = Legacy.Hash;
14
+ export const GetSigningHash = Legacy.GetSigningHash;
15
+ export const VerifySignature = Legacy.VerifySignature;
16
16
 
17
17
  export { Legacy };
@@ -47,10 +47,11 @@ export { Hex } from "./Hex.js";
47
47
  // Re-export pure functions from voltaire
48
48
  import { TransactionHash } from "@tevm/voltaire";
49
49
 
50
- export const equals = TransactionHash.equals;
50
+ export const equals = (a: TransactionHashType, b: TransactionHashType): boolean =>
51
+ TransactionHash.equals(a as unknown as Parameters<typeof TransactionHash.equals>[0], b as unknown as Parameters<typeof TransactionHash.equals>[1]);
51
52
  export const toHex = (
52
53
  hash: Uint8Array & { readonly __tag: "TransactionHash" },
53
- ): string => TransactionHash.toHex(hash as any);
54
+ ): string => TransactionHash.toHex(hash as unknown as Parameters<typeof TransactionHash.toHex>[0]);
54
55
 
55
56
  // Type export
56
57
  export type TransactionHashType = Uint8Array & {
@@ -45,8 +45,8 @@ export { Number } from "./Number.js";
45
45
  // Re-export pure functions from voltaire
46
46
  import { TransactionIndex } from "@tevm/voltaire";
47
47
 
48
- export const equals = TransactionIndex.equals;
49
- export const toNumber = TransactionIndex.toNumber;
48
+ export const equals: (a: TransactionIndexType, b: TransactionIndexType) => boolean = TransactionIndex.equals;
49
+ export const toNumber: (index: TransactionIndexType) => number = TransactionIndex.toNumber;
50
50
 
51
51
  // Type export
52
52
  import type { TransactionIndex as _TransactionIndex } from "@tevm/voltaire";
@@ -0,0 +1,70 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Trie from "./index.js";
4
+
5
+ describe("Trie Effect wrappers", () => {
6
+ it("init returns empty trie", async () => {
7
+ const trie = await Effect.runPromise(Trie.init());
8
+ expect(trie.root).toBe(null);
9
+ expect(trie.nodes.size).toBe(0);
10
+ });
11
+
12
+ it("put-get round trip", async () => {
13
+ const program = Effect.gen(function* () {
14
+ const trie = yield* Trie.init();
15
+ const key = new Uint8Array([0x01, 0x02]);
16
+ const value = new Uint8Array([0xaa, 0xbb]);
17
+ const updated = yield* Trie.put(trie, key, value);
18
+ return yield* Trie.get(updated, key);
19
+ });
20
+ const result = await Effect.runPromise(program);
21
+ expect(result).toEqual(new Uint8Array([0xaa, 0xbb]));
22
+ });
23
+
24
+ it("del removes key", async () => {
25
+ const program = Effect.gen(function* () {
26
+ let trie = yield* Trie.init();
27
+ const key = new Uint8Array([0x01]);
28
+ trie = yield* Trie.put(trie, key, new Uint8Array([0xaa]));
29
+ trie = yield* Trie.del(trie, key);
30
+ return yield* Trie.get(trie, key);
31
+ });
32
+ const result = await Effect.runPromise(program);
33
+ expect(result).toBe(null);
34
+ });
35
+
36
+ it("rootHash returns 32 bytes", async () => {
37
+ const program = Effect.gen(function* () {
38
+ let trie = yield* Trie.init();
39
+ trie = yield* Trie.put(trie, new Uint8Array([1]), new Uint8Array([2]));
40
+ return Trie.rootHash(trie);
41
+ });
42
+ const hash = await Effect.runPromise(program);
43
+ expect(hash.length).toBe(32);
44
+ });
45
+
46
+ it("clear resets trie", async () => {
47
+ const program = Effect.gen(function* () {
48
+ let trie = yield* Trie.init();
49
+ trie = yield* Trie.put(trie, new Uint8Array([1]), new Uint8Array([2]));
50
+ trie = yield* Trie.clear(trie);
51
+ return yield* Trie.get(trie, new Uint8Array([1]));
52
+ });
53
+ const result = await Effect.runPromise(program);
54
+ expect(result).toBe(null);
55
+ });
56
+
57
+ it("prove-verify round trip", async () => {
58
+ const program = Effect.gen(function* () {
59
+ let trie = yield* Trie.init();
60
+ trie = yield* Trie.put(trie, new Uint8Array([0x10]), new Uint8Array([1]));
61
+ trie = yield* Trie.put(trie, new Uint8Array([0x20]), new Uint8Array([2]));
62
+ const root = Trie.rootHash(trie);
63
+ const proof = yield* Trie.prove(trie, new Uint8Array([0x10]));
64
+ return yield* Trie.verify(root, new Uint8Array([0x10]), proof.proof);
65
+ });
66
+ const result = await Effect.runPromise(program);
67
+ expect(result.valid).toBe(true);
68
+ expect(result.value).toEqual(new Uint8Array([1]));
69
+ });
70
+ });
@@ -0,0 +1,26 @@
1
+ import type { Trie } from "@tevm/voltaire";
2
+ import * as ParseResult from "effect/ParseResult";
3
+ import * as Schema from "effect/Schema";
4
+
5
+ type TrieType = Trie.TrieType;
6
+
7
+ const TrieTypeSchema = Schema.declare<TrieType>(
8
+ (u): u is TrieType => {
9
+ if (typeof u !== "object" || u === null) return false;
10
+ return "nodes" in u && "root" in u;
11
+ },
12
+ { identifier: "Trie" },
13
+ );
14
+
15
+ /**
16
+ * Effect Schema for validating Trie structures.
17
+ * Identity transform - validates the trie structure.
18
+ *
19
+ * @since 0.0.1
20
+ */
21
+ export const TrieSchema: Schema.Schema<TrieType, TrieType> =
22
+ Schema.transformOrFail(TrieTypeSchema, TrieTypeSchema, {
23
+ strict: true,
24
+ decode: (t, _options, _ast) => ParseResult.succeed(t),
25
+ encode: (t) => ParseResult.succeed(t),
26
+ }).annotations({ identifier: "TrieSchema" });
@@ -0,0 +1,16 @@
1
+ import { Trie } from "@tevm/voltaire";
2
+ import * as Effect from "effect/Effect";
3
+
4
+ type TrieType = Trie.TrieType;
5
+
6
+ /**
7
+ * Reset trie to empty state.
8
+ *
9
+ * @param trie - The trie to clear
10
+ * @returns Effect yielding an empty trie
11
+ * @since 0.0.1
12
+ */
13
+ export const clear = (
14
+ trie: TrieType,
15
+ ): Effect.Effect<TrieType, never> =>
16
+ Effect.succeed(Trie.clear(trie));
@@ -0,0 +1,18 @@
1
+ import { Trie } from "@tevm/voltaire";
2
+ import * as Effect from "effect/Effect";
3
+
4
+ type TrieType = Trie.TrieType;
5
+
6
+ /**
7
+ * Delete a key from the trie. Returns new trie (immutable).
8
+ *
9
+ * @param trie - The trie to delete from
10
+ * @param key - Key to delete
11
+ * @returns Effect yielding the updated trie
12
+ * @since 0.0.1
13
+ */
14
+ export const del = (
15
+ trie: TrieType,
16
+ key: Uint8Array,
17
+ ): Effect.Effect<TrieType, never> =>
18
+ Effect.succeed(Trie.del(trie, key));
@@ -0,0 +1,18 @@
1
+ import { Trie } from "@tevm/voltaire";
2
+ import * as Effect from "effect/Effect";
3
+
4
+ type TrieType = Trie.TrieType;
5
+
6
+ /**
7
+ * Look up a value in the trie by key. Returns null if not found.
8
+ *
9
+ * @param trie - The trie to search
10
+ * @param key - Key to look up
11
+ * @returns Effect yielding the value or null
12
+ * @since 0.0.1
13
+ */
14
+ export const get = (
15
+ trie: TrieType,
16
+ key: Uint8Array,
17
+ ): Effect.Effect<Uint8Array | null, never> =>
18
+ Effect.succeed(Trie.get(trie, key));
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Trie module for Merkle Patricia Trie operations.
3
+ * Provides Effect-based functions for trie initialization, insertion, lookup,
4
+ * deletion, and Merkle proof generation/verification.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import * as Trie from 'voltaire-effect/primitives/Trie'
9
+ * import * as Effect from 'effect/Effect'
10
+ *
11
+ * const program = Effect.gen(function* () {
12
+ * const trie = yield* Trie.init()
13
+ * const updated = yield* Trie.put(trie, key, value)
14
+ * return Trie.rootHash(updated)
15
+ * })
16
+ * ```
17
+ *
18
+ * @since 0.0.1
19
+ * @module
20
+ */
21
+
22
+ export { TrieSchema, TrieSchema as Schema } from "./TrieSchema.js";
23
+ export { clear } from "./clear.js";
24
+ export { del } from "./del.js";
25
+ export { get } from "./get.js";
26
+ export { init } from "./init.js";
27
+ export { prove } from "./prove.js";
28
+ export { put } from "./put.js";
29
+ export { rootHash } from "./rootHash.js";
30
+ export { verify } from "./verify.js";
@@ -0,0 +1,13 @@
1
+ import { Trie } from "@tevm/voltaire";
2
+ import * as Effect from "effect/Effect";
3
+
4
+ type TrieType = Trie.TrieType;
5
+
6
+ /**
7
+ * Initializes a new empty Merkle Patricia Trie.
8
+ *
9
+ * @returns Effect yielding an empty TrieType
10
+ * @since 0.0.1
11
+ */
12
+ export const init = (): Effect.Effect<TrieType, never> =>
13
+ Effect.succeed(Trie.init());
@@ -0,0 +1,19 @@
1
+ import { Trie } from "@tevm/voltaire";
2
+ import type { TrieProof } from "@tevm/voltaire/Trie";
3
+ import * as Effect from "effect/Effect";
4
+
5
+ type TrieType = Trie.TrieType;
6
+
7
+ /**
8
+ * Generate a Merkle proof for a key.
9
+ *
10
+ * @param trie - The trie to generate proof from
11
+ * @param key - Key to prove
12
+ * @returns Effect yielding the proof
13
+ * @since 0.0.1
14
+ */
15
+ export const prove = (
16
+ trie: TrieType,
17
+ key: Uint8Array,
18
+ ): Effect.Effect<TrieProof, never> =>
19
+ Effect.succeed(Trie.prove(trie, key));
@@ -0,0 +1,20 @@
1
+ import { Trie } from "@tevm/voltaire";
2
+ import * as Effect from "effect/Effect";
3
+
4
+ type TrieType = Trie.TrieType;
5
+
6
+ /**
7
+ * Insert a key-value pair into the trie. Returns new trie (immutable).
8
+ *
9
+ * @param trie - The trie to insert into
10
+ * @param key - Key bytes
11
+ * @param value - Value bytes
12
+ * @returns Effect yielding the updated trie
13
+ * @since 0.0.1
14
+ */
15
+ export const put = (
16
+ trie: TrieType,
17
+ key: Uint8Array,
18
+ value: Uint8Array,
19
+ ): Effect.Effect<TrieType, never> =>
20
+ Effect.succeed(Trie.put(trie, key, value));
@@ -0,0 +1,14 @@
1
+ import { Trie } from "@tevm/voltaire";
2
+
3
+ type TrieType = Trie.TrieType;
4
+
5
+ /**
6
+ * Compute the 32-byte root hash of the trie.
7
+ * Pure function - never throws.
8
+ *
9
+ * @param trie - The trie to hash
10
+ * @returns 32-byte root hash as Uint8Array
11
+ * @since 0.0.1
12
+ */
13
+ export const rootHash = (trie: TrieType): Uint8Array =>
14
+ Trie.rootHash(trie);
@@ -0,0 +1,18 @@
1
+ import { Trie } from "@tevm/voltaire";
2
+ import * as Effect from "effect/Effect";
3
+
4
+ /**
5
+ * Verify a Merkle proof against a root hash.
6
+ *
7
+ * @param root - Expected 32-byte root hash
8
+ * @param key - Key to verify
9
+ * @param proof - Array of RLP-encoded proof nodes
10
+ * @returns Effect yielding { value, valid }
11
+ * @since 0.0.1
12
+ */
13
+ export const verify = (
14
+ root: Uint8Array,
15
+ key: Uint8Array,
16
+ proof: ReadonlyArray<Uint8Array>,
17
+ ): Effect.Effect<{ value: Uint8Array | null; valid: boolean }, never> =>
18
+ Effect.succeed(Trie.verify(root, key, proof));
@@ -6,6 +6,7 @@
6
6
 
7
7
  import { Uint256, type Type as Uint256Type } from "@tevm/voltaire/Uint";
8
8
  import * as Effect from "effect/Effect";
9
+ import { ValidationError } from "@tevm/voltaire/errors";
9
10
 
10
11
  /**
11
12
  * Create Uint256 from bigint, number, or string.
@@ -28,8 +29,16 @@ import * as Effect from "effect/Effect";
28
29
  */
29
30
  export const from = (
30
31
  value: bigint | number | string,
31
- ): Effect.Effect<Uint256Type, Error> =>
32
+ ): Effect.Effect<Uint256Type, ValidationError> =>
32
33
  Effect.try({
33
34
  try: () => Uint256.from(value),
34
- catch: (e) => (e instanceof Error ? e : new Error(String(e))),
35
+ catch: (error) =>
36
+ new ValidationError(
37
+ error instanceof Error ? error.message : "Invalid Uint256 input",
38
+ {
39
+ value,
40
+ expected: "bigint, number, or string (decimal or hex)",
41
+ cause: error instanceof Error ? error : undefined,
42
+ },
43
+ ),
35
44
  });
@@ -54,6 +54,7 @@ export { String } from "./String.js";
54
54
 
55
55
  // Re-export pure functions from voltaire
56
56
  import { BrandedUint16 } from "@tevm/voltaire";
57
+ import type { Uint16Type } from "./Uint16Schema.js";
57
58
 
58
59
  export const equals = BrandedUint16.equals;
59
60
  export const plus = BrandedUint16.plus;
@@ -61,10 +62,10 @@ export const minus = BrandedUint16.minus;
61
62
  export const times = BrandedUint16.times;
62
63
  export const toNumber = BrandedUint16.toNumber;
63
64
  export const toHex = BrandedUint16.toHex;
64
- export const MAX = BrandedUint16.MAX;
65
- export const MIN = BrandedUint16.MIN;
66
- export const ZERO = BrandedUint16.ZERO;
67
- export const ONE = BrandedUint16.ONE;
65
+ export const MAX: Uint16Type = BrandedUint16.MAX;
66
+ export const MIN: Uint16Type = BrandedUint16.MIN;
67
+ export const ZERO: Uint16Type = BrandedUint16.ZERO;
68
+ export const ONE: Uint16Type = BrandedUint16.ONE;
68
69
 
69
70
  // Type export
70
71
  export type { Uint16Type } from "./Uint16Schema.js";
@@ -54,6 +54,7 @@ export { String } from "./String.js";
54
54
 
55
55
  // Re-export pure functions from voltaire
56
56
  import { Uint64 } from "@tevm/voltaire";
57
+ import type { Uint64Type } from "./Uint64Schema.js";
57
58
 
58
59
  export const equals = Uint64.equals;
59
60
  export const plus = Uint64.plus;
@@ -62,10 +63,10 @@ export const times = Uint64.times;
62
63
  export const toBigInt = Uint64.toBigInt;
63
64
  export const toNumber = Uint64.toNumber;
64
65
  export const toHex = Uint64.toHex;
65
- export const MAX = Uint64.MAX;
66
- export const MIN = Uint64.MIN;
67
- export const ZERO = Uint64.ZERO;
68
- export const ONE = Uint64.ONE;
66
+ export const MAX: Uint64Type = Uint64.MAX;
67
+ export const MIN: Uint64Type = Uint64.MIN;
68
+ export const ZERO: Uint64Type = Uint64.ZERO;
69
+ export const ONE: Uint64Type = Uint64.ONE;
69
70
 
70
71
  // Type export
71
72
  export type { Uint64Type } from "./Uint64Schema.js";
@@ -54,6 +54,7 @@ export { String } from "./String.js";
54
54
 
55
55
  // Re-export pure functions from voltaire
56
56
  import { BrandedUint8 } from "@tevm/voltaire";
57
+ import type { Uint8Type } from "./Uint8Schema.js";
57
58
 
58
59
  export const equals = BrandedUint8.equals;
59
60
  export const plus = BrandedUint8.plus;
@@ -61,10 +62,10 @@ export const minus = BrandedUint8.minus;
61
62
  export const times = BrandedUint8.times;
62
63
  export const toNumber = BrandedUint8.toNumber;
63
64
  export const toHex = BrandedUint8.toHex;
64
- export const MAX = BrandedUint8.MAX;
65
- export const MIN = BrandedUint8.MIN;
66
- export const ZERO = BrandedUint8.ZERO;
67
- export const ONE = BrandedUint8.ONE;
65
+ export const MAX: Uint8Type = BrandedUint8.MAX;
66
+ export const MIN: Uint8Type = BrandedUint8.MIN;
67
+ export const ZERO: Uint8Type = BrandedUint8.ZERO;
68
+ export const ONE: Uint8Type = BrandedUint8.ONE;
68
69
 
69
70
  // Type export
70
71
  export type { Uint8Type } from "./Uint8Schema.js";
@@ -1,5 +1,4 @@
1
- // Abi module temporarily disabled - requires @tevm/voltaire subpath exports
2
- // export * as Abi from "./Abi/index.js";
1
+ export * as Abi from "./Abi/index.js";
3
2
  export * as AccessList from "./AccessList/index.js";
4
3
  export * as AccountState from "./AccountState/index.js";
5
4
  export * as Address from "./Address/index.js";
@@ -121,6 +120,8 @@ export * as SyncStatus from "./SyncStatus/index.js";
121
120
  export * as TokenBalance from "./TokenBalance/index.js";
122
121
  export * as TokenId from "./TokenId/index.js";
123
122
  export * as TopicFilter from "./TopicFilter/index.js";
123
+ // TODO: Re-enable when @tevm/voltaire exports Trie
124
+ // export * as Trie from "./Trie/index.js";
124
125
  export * as TraceConfig from "./TraceConfig/index.js";
125
126
  export * as TraceResult from "./TraceResult/index.js";
126
127
  export * as Transaction from "./Transaction/index.js";