voltaire-effect 0.2.23 → 0.2.24

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 (264) hide show
  1. package/dist/KZGService-B7PJerOb.d.ts +146 -0
  2. package/dist/{X25519Test-DGsk1V9o.d.ts → X25519Test-C8Cicdd_.d.ts} +2 -139
  3. package/dist/crypto/index.d.ts +3 -2
  4. package/dist/{index-IgkEHjBe.d.ts → index-DsFjN_a3.d.ts} +17633 -11961
  5. package/dist/index.d.ts +3104 -938
  6. package/dist/index.js +4467 -2446
  7. package/dist/native/index.d.ts +14 -5
  8. package/dist/native/index.js +4489 -2468
  9. package/dist/primitives/index.d.ts +12 -4
  10. package/dist/primitives/index.js +3980 -2411
  11. package/package.json +2 -2
  12. package/src/crypto/Keccak256/index.ts +1 -0
  13. package/src/index.ts +2 -2
  14. package/src/primitives/Abi/decode.test.ts +38 -0
  15. package/src/primitives/Abi/decode.ts +67 -0
  16. package/src/primitives/Abi/decodeData.test.ts +37 -0
  17. package/src/primitives/Abi/decodeData.ts +77 -0
  18. package/src/primitives/Abi/decodeLog.test.ts +32 -0
  19. package/src/primitives/Abi/decodeLog.ts +81 -0
  20. package/src/primitives/Abi/decodeWrappedError.test.ts +41 -0
  21. package/src/primitives/Abi/decodeWrappedError.ts +68 -0
  22. package/src/primitives/Abi/encode.test.ts +43 -0
  23. package/src/primitives/Abi/encode.ts +67 -0
  24. package/src/primitives/Abi/encodePacked.test.ts +35 -0
  25. package/src/primitives/Abi/encodePacked.ts +62 -0
  26. package/src/primitives/Abi/encodeWrappedError.test.ts +21 -0
  27. package/src/primitives/Abi/encodeWrappedError.ts +64 -0
  28. package/src/primitives/Abi/findSelectorCollisions.test.ts +50 -0
  29. package/src/primitives/Abi/findSelectorCollisions.ts +83 -0
  30. package/src/primitives/Abi/index.ts +33 -7
  31. package/src/primitives/Abi/parseLogs.test.ts +37 -0
  32. package/src/primitives/Abi/parseLogs.ts +62 -0
  33. package/src/primitives/AccessList/AccessList.test.ts +229 -0
  34. package/src/primitives/AccessList/AccessListTypeSchema.ts +16 -0
  35. package/src/primitives/AccessList/addressCount.ts +21 -0
  36. package/src/primitives/AccessList/assertValid.ts +37 -0
  37. package/src/primitives/AccessList/create.ts +19 -0
  38. package/src/primitives/AccessList/deduplicate.ts +23 -0
  39. package/src/primitives/AccessList/from.ts +39 -0
  40. package/src/primitives/AccessList/fromBytes.ts +36 -0
  41. package/src/primitives/AccessList/gasCost.ts +22 -0
  42. package/src/primitives/AccessList/gasSavings.ts +26 -0
  43. package/src/primitives/AccessList/hasSavings.ts +23 -0
  44. package/src/primitives/AccessList/includesAddress.ts +25 -0
  45. package/src/primitives/AccessList/includesStorageKey.ts +28 -0
  46. package/src/primitives/AccessList/index.ts +99 -19
  47. package/src/primitives/AccessList/is.ts +23 -0
  48. package/src/primitives/AccessList/isEmpty.ts +23 -0
  49. package/src/primitives/AccessList/isItem.ts +22 -0
  50. package/src/primitives/AccessList/keysFor.ts +29 -0
  51. package/src/primitives/AccessList/merge.ts +24 -0
  52. package/src/primitives/AccessList/storageKeyCount.ts +21 -0
  53. package/src/primitives/AccessList/toBytes.ts +23 -0
  54. package/src/primitives/AccessList/withAddress.ts +27 -0
  55. package/src/primitives/AccessList/withStorageKey.ts +30 -0
  56. package/src/primitives/Address/Address.test.ts +146 -0
  57. package/src/primitives/Address/assert.ts +51 -0
  58. package/src/primitives/Address/calculateCreate2Address.ts +33 -0
  59. package/src/primitives/Address/calculateCreateAddress.ts +30 -0
  60. package/src/primitives/Address/deduplicateAddresses.ts +20 -0
  61. package/src/primitives/Address/from.ts +41 -0
  62. package/src/primitives/Address/fromAbiEncoded.ts +35 -0
  63. package/src/primitives/Address/fromBase64.ts +25 -0
  64. package/src/primitives/Address/fromBytes.ts +25 -0
  65. package/src/primitives/Address/fromHex.ts +31 -0
  66. package/src/primitives/Address/fromNumber.ts +25 -0
  67. package/src/primitives/Address/fromPrivateKey.ts +25 -0
  68. package/src/primitives/Address/fromPublicKey.ts +56 -0
  69. package/src/primitives/Address/index.ts +99 -35
  70. package/src/primitives/Address/is.ts +20 -0
  71. package/src/primitives/Address/isAddress.ts +22 -0
  72. package/src/primitives/Address/sortAddresses.ts +19 -0
  73. package/src/primitives/Address/toChecksummed.ts +32 -0
  74. package/src/primitives/Address/toHex.ts +18 -0
  75. package/src/primitives/Address/zero.ts +18 -0
  76. package/src/primitives/Base64/Base64.test.ts +75 -0
  77. package/src/primitives/Base64/convert.ts +37 -0
  78. package/src/primitives/Base64/decode.ts +59 -0
  79. package/src/primitives/Base64/encode.ts +42 -0
  80. package/src/primitives/Base64/from.ts +39 -0
  81. package/src/primitives/Base64/index.ts +81 -1
  82. package/src/primitives/Base64/size.ts +16 -0
  83. package/src/primitives/Base64/validation.ts +16 -0
  84. package/src/primitives/Blob/Blob.test.ts +292 -0
  85. package/src/primitives/Blob/calculateGas.ts +30 -0
  86. package/src/primitives/Blob/estimateBlobCount.ts +30 -0
  87. package/src/primitives/Blob/from.ts +38 -0
  88. package/src/primitives/Blob/fromData.ts +36 -0
  89. package/src/primitives/Blob/index.ts +99 -12
  90. package/src/primitives/Blob/isValidVersion.ts +27 -0
  91. package/src/primitives/Blob/joinData.ts +43 -0
  92. package/src/primitives/Blob/splitData.ts +36 -0
  93. package/src/primitives/Blob/toCommitment.ts +43 -0
  94. package/src/primitives/Blob/toProof.ts +50 -0
  95. package/src/primitives/Blob/toVersionedHash.ts +35 -0
  96. package/src/primitives/Blob/verify.ts +49 -0
  97. package/src/primitives/Blob/verifyBatch.ts +119 -0
  98. package/src/primitives/BloomFilter/BloomFilter.test.ts +138 -0
  99. package/src/primitives/BloomFilter/add.ts +23 -0
  100. package/src/primitives/BloomFilter/combine.ts +21 -0
  101. package/src/primitives/BloomFilter/contains.ts +26 -0
  102. package/src/primitives/BloomFilter/create.ts +35 -0
  103. package/src/primitives/BloomFilter/density.ts +22 -0
  104. package/src/primitives/BloomFilter/expectedFalsePositiveRate.ts +25 -0
  105. package/src/primitives/BloomFilter/fromHex.ts +37 -0
  106. package/src/primitives/BloomFilter/hash.ts +43 -0
  107. package/src/primitives/BloomFilter/index.ts +59 -37
  108. package/src/primitives/BloomFilter/isEmpty.ts +22 -0
  109. package/src/primitives/BloomFilter/merge.ts +24 -0
  110. package/src/primitives/BloomFilter/toHex.ts +22 -0
  111. package/src/primitives/Bytecode/analyze.ts +58 -0
  112. package/src/primitives/Bytecode/detectFusions.ts +10 -0
  113. package/src/primitives/Bytecode/equals.ts +10 -0
  114. package/src/primitives/Bytecode/extractRuntime.ts +12 -0
  115. package/src/primitives/Bytecode/format.ts +16 -0
  116. package/src/primitives/Bytecode/from.ts +16 -0
  117. package/src/primitives/Bytecode/fromHex.ts +14 -0
  118. package/src/primitives/Bytecode/getBlock.ts +12 -0
  119. package/src/primitives/Bytecode/getNextPc.ts +12 -0
  120. package/src/primitives/Bytecode/getPushSize.ts +8 -0
  121. package/src/primitives/Bytecode/hasMetadata.ts +10 -0
  122. package/src/primitives/Bytecode/hash.ts +9 -0
  123. package/src/primitives/Bytecode/index.ts +103 -13
  124. package/src/primitives/Bytecode/isPush.ts +8 -0
  125. package/src/primitives/Bytecode/isTerminator.ts +8 -0
  126. package/src/primitives/Bytecode/isValidJumpDest.ts +12 -0
  127. package/src/primitives/Bytecode/parseInstructions.ts +10 -0
  128. package/src/primitives/Bytecode/prettyPrint.ts +12 -0
  129. package/src/primitives/Bytecode/scan.ts +20 -0
  130. package/src/primitives/Bytecode/size.ts +9 -0
  131. package/src/primitives/Bytecode/stripMetadata.ts +10 -0
  132. package/src/primitives/Bytecode/toAbi.ts +10 -0
  133. package/src/primitives/Bytecode/toHex.ts +10 -0
  134. package/src/primitives/Bytecode/types.ts +23 -0
  135. package/src/primitives/Bytecode/validate.ts +9 -0
  136. package/src/primitives/Ens/Ens.test.ts +71 -0
  137. package/src/primitives/Ens/convert.ts +13 -0
  138. package/src/primitives/Ens/from.ts +32 -0
  139. package/src/primitives/Ens/hash.ts +46 -0
  140. package/src/primitives/Ens/index.ts +86 -4
  141. package/src/primitives/Ens/normalize.ts +45 -0
  142. package/src/primitives/Ens/validation.ts +38 -0
  143. package/src/primitives/EventLog/accessors.ts +32 -0
  144. package/src/primitives/EventLog/clone.ts +17 -0
  145. package/src/primitives/EventLog/create.ts +46 -0
  146. package/src/primitives/EventLog/filtering.ts +48 -0
  147. package/src/primitives/EventLog/index.ts +96 -6
  148. package/src/primitives/EventLog/status.ts +17 -0
  149. package/src/primitives/EventLog/toRpc.ts +49 -0
  150. package/src/primitives/Hardfork/HardforkSchema.ts +3 -3
  151. package/src/primitives/Hardfork/allIds.ts +13 -0
  152. package/src/primitives/Hardfork/allNames.ts +13 -0
  153. package/src/primitives/Hardfork/compare.ts +17 -0
  154. package/src/primitives/Hardfork/comparisons.ts +45 -0
  155. package/src/primitives/Hardfork/equals.ts +17 -0
  156. package/src/primitives/Hardfork/features.ts +61 -0
  157. package/src/primitives/Hardfork/fromString.ts +16 -0
  158. package/src/primitives/Hardfork/index.ts +128 -18
  159. package/src/primitives/Hardfork/isValidName.ts +14 -0
  160. package/src/primitives/Hardfork/minMax.ts +23 -0
  161. package/src/primitives/Hardfork/range.ts +19 -0
  162. package/src/primitives/Hardfork/toString.ts +16 -0
  163. package/src/primitives/Hash/Hash.test.ts +104 -0
  164. package/src/primitives/Hash/from.ts +47 -0
  165. package/src/primitives/Hash/fromBytes.ts +46 -0
  166. package/src/primitives/Hash/fromHex.ts +44 -0
  167. package/src/primitives/Hash/index.ts +45 -8
  168. package/src/primitives/Hash/isHash.ts +31 -0
  169. package/src/primitives/Hash/toHex.ts +29 -0
  170. package/src/primitives/Hex/Hex.test.ts +266 -155
  171. package/src/primitives/Hex/assertSize.ts +41 -0
  172. package/src/primitives/Hex/concat.ts +37 -0
  173. package/src/primitives/Hex/from.ts +38 -0
  174. package/src/primitives/Hex/fromBigInt.ts +40 -0
  175. package/src/primitives/Hex/fromBoolean.ts +29 -0
  176. package/src/primitives/Hex/fromNumber.ts +41 -0
  177. package/src/primitives/Hex/fromString.ts +28 -0
  178. package/src/primitives/Hex/index.ts +68 -37
  179. package/src/primitives/Hex/pad.ts +40 -0
  180. package/src/primitives/Hex/padRight.ts +39 -0
  181. package/src/primitives/Hex/size.ts +29 -0
  182. package/src/primitives/Hex/slice.ts +42 -0
  183. package/src/primitives/Hex/toBigInt.ts +27 -0
  184. package/src/primitives/Hex/toBoolean.ts +38 -0
  185. package/src/primitives/Hex/toNumber.ts +37 -0
  186. package/src/primitives/Hex/toStringHex.ts +39 -0
  187. package/src/primitives/Hex/trim.ts +27 -0
  188. package/src/primitives/Hex/validate.ts +37 -0
  189. package/src/primitives/Hex/xor.ts +39 -0
  190. package/src/primitives/Opcode/OpcodeSchema.ts +1 -1
  191. package/src/primitives/Opcode/disassemble.ts +15 -0
  192. package/src/primitives/Opcode/dupPosition.ts +15 -0
  193. package/src/primitives/Opcode/format.ts +15 -0
  194. package/src/primitives/Opcode/getters.ts +54 -0
  195. package/src/primitives/Opcode/index.ts +301 -11
  196. package/src/primitives/Opcode/info.ts +18 -0
  197. package/src/primitives/Opcode/jumpDests.ts +15 -0
  198. package/src/primitives/Opcode/logTopics.ts +15 -0
  199. package/src/primitives/Opcode/name.ts +15 -0
  200. package/src/primitives/Opcode/parse.ts +15 -0
  201. package/src/primitives/Opcode/predicates.ts +72 -0
  202. package/src/primitives/Opcode/pushBytes.ts +15 -0
  203. package/src/primitives/Opcode/pushOpcode.ts +15 -0
  204. package/src/primitives/Opcode/swapPosition.ts +15 -0
  205. package/src/primitives/Rlp/decodeBatch.ts +46 -0
  206. package/src/primitives/Rlp/decodeObject.ts +46 -0
  207. package/src/primitives/Rlp/decodeValue.ts +51 -0
  208. package/src/primitives/Rlp/encodeBatch.ts +50 -0
  209. package/src/primitives/Rlp/encodeObject.ts +48 -0
  210. package/src/primitives/Rlp/encodeVariadic.ts +49 -0
  211. package/src/primitives/Rlp/equals.ts +22 -0
  212. package/src/primitives/Rlp/from.ts +44 -0
  213. package/src/primitives/Rlp/fromJSON.ts +45 -0
  214. package/src/primitives/Rlp/getEncodedLength.ts +47 -0
  215. package/src/primitives/Rlp/getLength.ts +44 -0
  216. package/src/primitives/Rlp/index.ts +67 -14
  217. package/src/primitives/Rlp/isBytesData.ts +21 -0
  218. package/src/primitives/Rlp/isCanonical.ts +32 -0
  219. package/src/primitives/Rlp/isData.ts +21 -0
  220. package/src/primitives/Rlp/isList.ts +46 -0
  221. package/src/primitives/Rlp/isListData.ts +21 -0
  222. package/src/primitives/Rlp/isString.ts +46 -0
  223. package/src/primitives/Rlp/toJSON.ts +20 -0
  224. package/src/primitives/Rlp/toRaw.ts +31 -0
  225. package/src/primitives/Signature/Signature.test.ts +217 -0
  226. package/src/primitives/Signature/from.ts +38 -0
  227. package/src/primitives/Signature/fromBytes.ts +31 -0
  228. package/src/primitives/Signature/fromCompact.ts +33 -0
  229. package/src/primitives/Signature/fromDER.ts +35 -0
  230. package/src/primitives/Signature/fromEd25519.ts +24 -0
  231. package/src/primitives/Signature/fromHex.ts +29 -0
  232. package/src/primitives/Signature/fromP256.ts +25 -0
  233. package/src/primitives/Signature/fromRpc.ts +38 -0
  234. package/src/primitives/Signature/fromSecp256k1.ts +29 -0
  235. package/src/primitives/Signature/fromTuple.ts +33 -0
  236. package/src/primitives/Signature/getR.ts +24 -0
  237. package/src/primitives/Signature/getS.ts +24 -0
  238. package/src/primitives/Signature/getV.ts +24 -0
  239. package/src/primitives/Signature/index.ts +61 -11
  240. package/src/primitives/Signature/toDER.ts +24 -0
  241. package/src/primitives/Signature/toHex.ts +24 -0
  242. package/src/primitives/Signature/toRpc.ts +35 -0
  243. package/src/primitives/Signature/toTuple.ts +29 -0
  244. package/src/primitives/Signature/verify.ts +31 -0
  245. package/src/primitives/Siwe/create.ts +56 -0
  246. package/src/primitives/Siwe/hash.ts +27 -0
  247. package/src/primitives/Siwe/index.ts +57 -21
  248. package/src/primitives/Siwe/parse.ts +24 -0
  249. package/src/primitives/Siwe/verify.ts +47 -0
  250. package/src/primitives/Transaction/index.ts +467 -2
  251. package/src/primitives/Uint/Uint.test.ts +200 -0
  252. package/src/primitives/Uint/dividedBy.ts +34 -0
  253. package/src/primitives/Uint/from.ts +35 -0
  254. package/src/primitives/Uint/fromAbiEncoded.ts +29 -0
  255. package/src/primitives/Uint/fromBigInt.ts +30 -0
  256. package/src/primitives/Uint/fromBytes.ts +32 -0
  257. package/src/primitives/Uint/fromHex.ts +32 -0
  258. package/src/primitives/Uint/fromNumber.ts +30 -0
  259. package/src/primitives/Uint/index.ts +90 -45
  260. package/src/primitives/Uint/isUint256.ts +25 -0
  261. package/src/primitives/Uint/isValid.ts +25 -0
  262. package/src/primitives/Uint/modulo.ts +34 -0
  263. package/src/primitives/Uint/toHex.ts +31 -0
  264. package/src/primitives/Uint/tryFrom.ts +30 -0
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @module Address
3
- * @description Effect Schemas for Ethereum addresses with EIP-55 checksum support.
3
+ * @description Effect Schemas and functions for Ethereum addresses with EIP-55 checksum support.
4
4
  *
5
5
  * ## Type Declarations
6
6
  *
@@ -20,70 +20,134 @@
20
20
  * | `Address.Checksummed` | checksummed string | AddressType | Validates checksum on decode, requires KeccakService for encode |
21
21
  * | `Address.Bytes` | Uint8Array | AddressType | 20-byte array conversion |
22
22
  *
23
- * ## Usage
23
+ * ## Constructors (Effect-wrapped)
24
24
  *
25
25
  * ```typescript
26
- * import * as Address from 'voltaire-effect/primitives/Address'
27
- * import * as S from 'effect/Schema'
28
- *
29
- * // Decode (parse input)
30
- * const addr = S.decodeSync(Address.Hex)('0x742d35Cc6634C0532925a3b844Bc9e7595f251e3')
31
- *
32
- * // Encode (format output)
33
- * const hex = S.encodeSync(Address.Hex)(addr)
34
- * // "0x742d35cc6634c0532925a3b844bc9e7595f251e3"
26
+ * Address.from(value) // Effect<AddressType, AddressError>
27
+ * Address.fromHex(hex) // Effect<AddressType, HexError>
28
+ * Address.fromBytes(bytes) // Effect<AddressType, LengthError>
29
+ * Address.fromNumber(n) // Effect<AddressType, ValueError>
30
+ * Address.fromBase64(str) // Effect<AddressType, LengthError>
31
+ * Address.fromAbiEncoded(bytes) // Effect<AddressType, AbiError>
32
+ * Address.fromPublicKey(pk) // Effect<AddressType, ValueError>
33
+ * Address.fromPrivateKey(sk) // Effect<AddressType, ValueError>
34
+ * Address.zero() // AddressType (pure)
35
+ * ```
35
36
  *
36
- * // Checksummed encoding (requires KeccakService)
37
- * import * as Effect from 'effect/Effect'
38
- * import { KeccakLive } from 'voltaire-effect/crypto/Keccak256'
37
+ * ## Pure Functions
39
38
  *
40
- * const program = S.encode(Address.Checksummed)(addr)
41
- * const checksummed = await Effect.runPromise(program.pipe(Effect.provide(KeccakLive)))
42
- * // "0x742d35Cc6634C0532925a3b844Bc9e7595f251e3"
39
+ * ```typescript
40
+ * Address.equals(a, b) // boolean
41
+ * Address.compare(a, b) // -1 | 0 | 1
42
+ * Address.isZero(addr) // boolean
43
+ * Address.lessThan(a, b) // boolean
44
+ * Address.greaterThan(a, b) // boolean
45
+ * Address.isValid(value) // boolean
46
+ * Address.isValidChecksum(str) // boolean
47
+ * Address.isAddress(value) // boolean
48
+ * Address.is(value) // type guard
49
+ * Address.clone(addr) // AddressType
50
+ * Address.toBytes(addr) // Uint8Array
51
+ * Address.toHex(addr) // string
52
+ * Address.toU256(addr) // Uint256Type
53
+ * Address.toShortHex(addr) // string
54
+ * Address.toLowercase(addr) // string
55
+ * Address.toUppercase(addr) // string
56
+ * Address.toAbiEncoded(addr) // Uint8Array
57
+ * Address.sortAddresses(arr) // AddressType[]
58
+ * Address.deduplicateAddresses(arr) // AddressType[]
43
59
  * ```
44
60
  *
45
- * ## Pure Functions
61
+ * ## Effectful Functions
46
62
  *
47
63
  * ```typescript
48
- * Address.equals(a, b) // boolean
49
- * Address.compare(a, b) // -1 | 0 | 1
50
- * Address.isZero(addr) // boolean
51
- * Address.lessThan(a, b) // boolean
52
- * Address.greaterThan(a, b) // boolean
53
- * Address.isValid(value) // boolean
54
- * Address.isValidChecksum(str) // boolean
55
- * Address.clone(addr) // AddressType
56
- * Address.toBytes(addr) // Uint8Array
57
- * Address.toU256(addr) // Uint256Type (U256)
58
- * Address.toShortHex(addr) // string (e.g., "0x742d...51e3")
59
- * Address.toLowercase(addr) // Lowercase address hex
60
- * Address.toUppercase(addr) // Uppercase address hex
61
- * Address.toAbiEncoded(addr) // Uint8Array (32 bytes)
64
+ * Address.toChecksummed(addr) // Effect<string, never, KeccakService>
65
+ * Address.assert(value, opts) // Effect<void, AssertError, KeccakService>
66
+ * Address.assertBasic(value) // Effect<void, InvalidAddressError>
67
+ * Address.calculateCreateAddress(addr, nonce) // Effect<AddressType, ValueError>
68
+ * Address.calculateCreate2Address(addr, salt, initCode) // Effect<AddressType, Error>
62
69
  * ```
63
70
  *
64
71
  * @since 0.1.0
65
72
  */
66
73
 
67
- // Re-export AddressType from voltaire
68
- export type { AddressType } from "@tevm/voltaire/Address";
74
+ // Re-export types from voltaire
75
+ export type { AddressType, BrandedAddress } from "@tevm/voltaire/Address";
69
76
  export { AddressTypeSchema } from "./AddressSchema.js";
77
+
78
+ // Re-export constants from voltaire
79
+ export {
80
+ SIZE,
81
+ HEX_SIZE,
82
+ ZERO_ADDRESS,
83
+ NATIVE_ASSET_ADDRESS,
84
+ } from "@tevm/voltaire/Address";
85
+
86
+ // Re-export errors from voltaire
87
+ export {
88
+ InvalidAddressError,
89
+ InvalidAddressLengthError,
90
+ InvalidAbiEncodedPaddingError,
91
+ InvalidChecksumError,
92
+ InvalidHexFormatError,
93
+ InvalidHexStringError,
94
+ InvalidValueError,
95
+ NotImplementedError,
96
+ } from "@tevm/voltaire/Address";
97
+
98
+ // Re-export DI factory functions for advanced use cases
99
+ // These accept crypto services as parameters for dependency injection
100
+ import { Address as AddressNamespace } from "@tevm/voltaire/functional";
101
+ export const Assert = AddressNamespace.Assert;
102
+ export const CalculateCreate2Address = AddressNamespace.CalculateCreate2Address;
103
+ export const CalculateCreateAddress = AddressNamespace.CalculateCreateAddress;
104
+ export const From = AddressNamespace.From;
105
+ export const FromPrivateKey = AddressNamespace.FromPrivateKey;
106
+ export const FromPublicKey = AddressNamespace.FromPublicKey;
107
+ export const IsContract = AddressNamespace.IsContract;
108
+ export const IsValid = AddressNamespace.IsValid;
109
+ export const IsValidChecksum = AddressNamespace.IsValidChecksum;
110
+ export const ToChecksummed = AddressNamespace.ToChecksummed;
111
+
70
112
  // Schemas
71
113
  export { Bytes } from "./Bytes.js";
72
114
  export { Checksummed } from "./Checksummed.js";
115
+ export { Hex } from "./Hex.js";
116
+
117
+ // Constructors (Effect-wrapped)
118
+ export { from } from "./from.js";
119
+ export { fromAbiEncoded } from "./fromAbiEncoded.js";
120
+ export { fromBase64 } from "./fromBase64.js";
121
+ export { fromBytes } from "./fromBytes.js";
122
+ export { fromHex } from "./fromHex.js";
123
+ export { fromNumber } from "./fromNumber.js";
124
+ export { fromPrivateKey } from "./fromPrivateKey.js";
125
+ export { fromPublicKey } from "./fromPublicKey.js";
126
+ export { zero } from "./zero.js";
73
127
 
74
128
  // Pure functions
75
129
  export { clone } from "./clone.js";
76
130
  export { compare } from "./compare.js";
131
+ export { deduplicateAddresses } from "./deduplicateAddresses.js";
77
132
  export { equals } from "./equals.js";
78
133
  export { greaterThan } from "./greaterThan.js";
79
- export { Hex } from "./Hex.js";
134
+ export { is } from "./is.js";
135
+ export { isAddress } from "./isAddress.js";
80
136
  export { isValid } from "./isValid.js";
81
137
  export { isValidChecksum } from "./isValidChecksum.js";
82
138
  export { isZero } from "./isZero.js";
83
139
  export { lessThan } from "./lessThan.js";
140
+ export { sortAddresses } from "./sortAddresses.js";
84
141
  export { toAbiEncoded } from "./toAbiEncoded.js";
85
142
  export { toBytes } from "./toBytes.js";
143
+ export { toHex } from "./toHex.js";
86
144
  export { toLowercase } from "./toLowercase.js";
87
145
  export { toShortHex } from "./toShortHex.js";
88
146
  export { toU256 } from "./toU256.js";
89
147
  export { toUppercase } from "./toUppercase.js";
148
+
149
+ // Effectful functions
150
+ export { assert, assertBasic } from "./assert.js";
151
+ export { calculateCreate2Address } from "./calculateCreate2Address.js";
152
+ export { calculateCreateAddress } from "./calculateCreateAddress.js";
153
+ export { toChecksummed } from "./toChecksummed.js";
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @module is
3
+ * @description Type guard to check if value is an AddressType
4
+ * @since 0.1.0
5
+ */
6
+ import { Address, type AddressType } from "@tevm/voltaire/Address";
7
+
8
+ /**
9
+ * Type guard: check if value is an AddressType
10
+ *
11
+ * @param value - Value to check
12
+ * @returns True if value is AddressType
13
+ * @example
14
+ * ```typescript
15
+ * if (Address.is(value)) {
16
+ * // value is AddressType
17
+ * }
18
+ * ```
19
+ */
20
+ export const is = (value: unknown): value is AddressType => Address.is(value);
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @module isAddress
3
+ * @description Check if value is a valid address (string or bytes)
4
+ * @since 0.1.0
5
+ */
6
+ import { Address } from "@tevm/voltaire/Address";
7
+
8
+ /**
9
+ * Check if value is a valid Ethereum address
10
+ *
11
+ * Alias for isValid - checks if string or bytes is valid address format.
12
+ *
13
+ * @param value - Value to check
14
+ * @returns True if valid address format
15
+ * @example
16
+ * ```typescript
17
+ * Address.isAddress('0x742d35cc6634c0532925a3b844bc9e7595f251e3') // true
18
+ * Address.isAddress('invalid') // false
19
+ * ```
20
+ */
21
+ export const isAddress = (value: string | Uint8Array): boolean =>
22
+ Address.isValid(value);
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @module sortAddresses
3
+ * @description Sort array of addresses lexicographically
4
+ * @since 0.1.0
5
+ */
6
+ import { sortAddresses as voltaireSortAddresses, type AddressType } from "@tevm/voltaire/Address";
7
+
8
+ /**
9
+ * Sort array of addresses lexicographically
10
+ *
11
+ * @param addresses - Array of addresses to sort
12
+ * @returns New sorted array
13
+ * @example
14
+ * ```typescript
15
+ * const sorted = Address.sortAddresses([addr1, addr2, addr3])
16
+ * ```
17
+ */
18
+ export const sortAddresses = (addresses: AddressType[]): AddressType[] =>
19
+ voltaireSortAddresses(addresses);
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @module toChecksummed
3
+ * @description Convert Address to EIP-55 checksummed hex string (requires KeccakService)
4
+ * @since 0.1.0
5
+ */
6
+ import { Effect } from "effect";
7
+ import { Address, type AddressType } from "@tevm/voltaire/Address";
8
+ import { KeccakService } from "../../crypto/Keccak256/index.js";
9
+
10
+ /**
11
+ * Convert Address to EIP-55 checksummed hex string
12
+ *
13
+ * Requires KeccakService to be provided.
14
+ *
15
+ * @param addr - Address to convert
16
+ * @returns Effect yielding checksummed hex string
17
+ * @example
18
+ * ```typescript
19
+ * import { KeccakLive } from 'voltaire-effect/crypto/Keccak256'
20
+ *
21
+ * const program = Address.toChecksummed(addr)
22
+ * const checksummed = await Effect.runPromise(program.pipe(Effect.provide(KeccakLive)))
23
+ * // "0x742d35Cc6634C0532925a3b844Bc9e7595f251e3"
24
+ * ```
25
+ */
26
+ export const toChecksummed = (
27
+ addr: AddressType,
28
+ ): Effect.Effect<string, never, KeccakService> =>
29
+ Effect.gen(function* () {
30
+ yield* KeccakService;
31
+ return Address.toChecksummed(addr);
32
+ });
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @module toHex
3
+ * @description Convert Address to lowercase hex string
4
+ * @since 0.1.0
5
+ */
6
+ import { Address, type AddressType } from "@tevm/voltaire/Address";
7
+
8
+ /**
9
+ * Convert Address to lowercase hex string
10
+ *
11
+ * @param addr - Address to convert
12
+ * @returns Lowercase hex string with 0x prefix
13
+ * @example
14
+ * ```typescript
15
+ * Address.toHex(addr) // "0x742d35cc6634c0532925a3b844bc9e7595f251e3"
16
+ * ```
17
+ */
18
+ export const toHex = (addr: AddressType): string => Address.toHex(addr);
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @module zero
3
+ * @description Create the zero address (0x0000...0000)
4
+ * @since 0.1.0
5
+ */
6
+ import { Address, type AddressType } from "@tevm/voltaire/Address";
7
+
8
+ /**
9
+ * Create zero address (0x0000...0000)
10
+ *
11
+ * @returns AddressType with all bytes set to 0
12
+ * @example
13
+ * ```typescript
14
+ * const zeroAddr = Address.zero()
15
+ * Address.isZero(zeroAddr) // true
16
+ * ```
17
+ */
18
+ export const zero = (): AddressType => Address.zero();
@@ -0,0 +1,75 @@
1
+ import { describe, expect, it } from "@effect/vitest";
2
+ import { Effect } from "effect";
3
+ import * as Schema from "effect/Schema";
4
+ import * as Base64 from "./index.js";
5
+
6
+ describe("Base64.Schema", () => {
7
+ it("validates standard Base64", () => {
8
+ const result = Schema.decodeSync(Base64.Schema)("SGVsbG8gV29ybGQ=");
9
+ expect(typeof result).toBe("string");
10
+ });
11
+
12
+ it("validates URL-safe Base64", () => {
13
+ const result = Schema.decodeSync(Base64.UrlSchema)("SGVsbG8tV29ybGQ_");
14
+ expect(typeof result).toBe("string");
15
+ });
16
+ });
17
+
18
+ describe("Base64.from", () => {
19
+ it("creates BrandedBase64 from string", async () => {
20
+ const result = await Effect.runPromise(Base64.from("SGVsbG8="));
21
+ expect(typeof result).toBe("string");
22
+ });
23
+
24
+ it("creates BrandedBase64Url from string", async () => {
25
+ // URL-safe Base64 doesn't use padding (=) and uses - and _ instead of + and /
26
+ const result = await Effect.runPromise(Base64.fromUrlSafe("SGVsbG8"));
27
+ expect(typeof result).toBe("string");
28
+ });
29
+ });
30
+
31
+ describe("Base64 encoding", () => {
32
+ it("encodes bytes to Base64", () => {
33
+ const bytes = new Uint8Array([72, 101, 108, 108, 111]); // "Hello"
34
+ const encoded = Base64.encode(bytes);
35
+ expect(encoded).toBe("SGVsbG8=");
36
+ });
37
+
38
+ it("encodes string to Base64", () => {
39
+ const encoded = Base64.encodeString("Hello");
40
+ expect(encoded).toBe("SGVsbG8=");
41
+ });
42
+ });
43
+
44
+ describe("Base64 decoding", () => {
45
+ it("decodes Base64 to bytes", async () => {
46
+ const bytes = await Effect.runPromise(Base64.decode("SGVsbG8="));
47
+ expect(bytes).toEqual(new Uint8Array([72, 101, 108, 108, 111]));
48
+ });
49
+
50
+ it("decodes Base64 to string", async () => {
51
+ const str = await Effect.runPromise(Base64.decodeToString("SGVsbG8="));
52
+ expect(str).toBe("Hello");
53
+ });
54
+ });
55
+
56
+ describe("Base64 validation", () => {
57
+ it("validates correct Base64", () => {
58
+ expect(Base64.isValid("SGVsbG8=")).toBe(true);
59
+ });
60
+
61
+ it("rejects invalid Base64", () => {
62
+ expect(Base64.isValid("!!!invalid!!!")).toBe(false);
63
+ });
64
+ });
65
+
66
+ describe("Base64 size calculation", () => {
67
+ it("calculates encoded size", () => {
68
+ expect(Base64.calcEncodedSize(5)).toBe(8);
69
+ });
70
+
71
+ it("calculates decoded size from length", () => {
72
+ // calcDecodedSize takes the length of the encoded string, not the string itself
73
+ expect(Base64.calcDecodedSize(8)).toBe(4); // 8 chars -> 4 bytes (accounting for padding)
74
+ });
75
+ });
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @module convert
3
+ * @description Pure Base64 conversion functions
4
+ * @since 0.1.0
5
+ */
6
+ import { Base64, type BrandedBase64, type BrandedBase64Url } from "@tevm/voltaire/Base64";
7
+
8
+ /**
9
+ * Convert Base64 to bytes
10
+ */
11
+ export const toBytes = (b64: BrandedBase64): Uint8Array => Base64.toBytes(b64);
12
+
13
+ /**
14
+ * Convert URL-safe Base64 to bytes
15
+ */
16
+ export const toBytesUrlSafe = (b64: BrandedBase64Url): Uint8Array => Base64.toBytesUrlSafe(b64);
17
+
18
+ /**
19
+ * Convert Base64 to UTF-8 string
20
+ */
21
+ // biome-ignore lint/suspicious/noShadowRestrictedNames: intentional API name
22
+ export const toString = (b64: BrandedBase64): string => Base64.toString(b64);
23
+
24
+ /**
25
+ * Convert URL-safe Base64 to UTF-8 string
26
+ */
27
+ export const toStringUrlSafe = (b64: BrandedBase64Url): string => Base64.toStringUrlSafe(b64);
28
+
29
+ /**
30
+ * Convert standard Base64 to URL-safe Base64
31
+ */
32
+ export const toBase64Url = (value: BrandedBase64): BrandedBase64Url => Base64.toBase64Url(value);
33
+
34
+ /**
35
+ * Convert URL-safe Base64 to standard Base64
36
+ */
37
+ export const toBase64 = (value: BrandedBase64Url): BrandedBase64 => Base64.toBase64(value);
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @module decode
3
+ * @description Effect-wrapped Base64 decode operations
4
+ * @since 0.1.0
5
+ */
6
+ import { Effect } from "effect";
7
+ import { Base64 } from "@tevm/voltaire/Base64";
8
+
9
+ /**
10
+ * Decode standard Base64 string to bytes
11
+ *
12
+ * @param encoded - Base64 encoded string
13
+ * @returns Effect yielding decoded Uint8Array
14
+ * @example
15
+ * ```typescript
16
+ * const bytes = await Effect.runPromise(Base64.decode('SGVsbG8='))
17
+ * ```
18
+ */
19
+ export const decode = (encoded: string): Effect.Effect<Uint8Array, Error> =>
20
+ Effect.try({
21
+ try: () => Base64.decode(encoded),
22
+ catch: (e) => e as Error,
23
+ });
24
+
25
+ /**
26
+ * Decode standard Base64 string to UTF-8 string
27
+ *
28
+ * @param encoded - Base64 encoded string
29
+ * @returns Effect yielding decoded string
30
+ */
31
+ export const decodeToString = (encoded: string): Effect.Effect<string, Error> =>
32
+ Effect.try({
33
+ try: () => Base64.decodeToString(encoded),
34
+ catch: (e) => e as Error,
35
+ });
36
+
37
+ /**
38
+ * Decode URL-safe Base64 string to bytes
39
+ *
40
+ * @param encoded - URL-safe Base64 encoded string
41
+ * @returns Effect yielding decoded Uint8Array
42
+ */
43
+ export const decodeUrlSafe = (encoded: string): Effect.Effect<Uint8Array, Error> =>
44
+ Effect.try({
45
+ try: () => Base64.decodeUrlSafe(encoded),
46
+ catch: (e) => e as Error,
47
+ });
48
+
49
+ /**
50
+ * Decode URL-safe Base64 string to UTF-8 string
51
+ *
52
+ * @param encoded - URL-safe Base64 encoded string
53
+ * @returns Effect yielding decoded string
54
+ */
55
+ export const decodeUrlSafeToString = (encoded: string): Effect.Effect<string, Error> =>
56
+ Effect.try({
57
+ try: () => Base64.decodeUrlSafeToString(encoded),
58
+ catch: (e) => e as Error,
59
+ });
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @module encode
3
+ * @description Pure Base64 encode operations
4
+ * @since 0.1.0
5
+ */
6
+ import { Base64, type BrandedBase64, type BrandedBase64Url } from "@tevm/voltaire/Base64";
7
+
8
+ /**
9
+ * Encode bytes to standard Base64 string
10
+ *
11
+ * @param data - Bytes to encode
12
+ * @returns Base64 encoded string
13
+ * @example
14
+ * ```typescript
15
+ * const b64 = Base64.encode(new Uint8Array([72, 101, 108, 108, 111]))
16
+ * ```
17
+ */
18
+ export const encode = (data: Uint8Array): BrandedBase64 => Base64.encode(data);
19
+
20
+ /**
21
+ * Encode UTF-8 string to standard Base64
22
+ *
23
+ * @param str - String to encode
24
+ * @returns Base64 encoded string
25
+ */
26
+ export const encodeString = (str: string): string => Base64.encodeString(str);
27
+
28
+ /**
29
+ * Encode bytes to URL-safe Base64 string
30
+ *
31
+ * @param data - Bytes to encode
32
+ * @returns URL-safe Base64 encoded string
33
+ */
34
+ export const encodeUrlSafe = (data: Uint8Array): BrandedBase64Url => Base64.encodeUrlSafe(data);
35
+
36
+ /**
37
+ * Encode UTF-8 string to URL-safe Base64
38
+ *
39
+ * @param str - String to encode
40
+ * @returns URL-safe Base64 encoded string
41
+ */
42
+ export const encodeStringUrlSafe = (str: string): BrandedBase64Url => Base64.encodeStringUrlSafe(str);
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @module from
3
+ * @description Effect-wrapped Base64 constructors
4
+ * @since 0.1.0
5
+ */
6
+ import { Effect } from "effect";
7
+ import { Base64, type BrandedBase64, type BrandedBase64Url } from "@tevm/voltaire/Base64";
8
+
9
+ /**
10
+ * Create validated standard Base64 string from input
11
+ *
12
+ * @param value - String or Uint8Array to convert
13
+ * @returns Effect yielding BrandedBase64
14
+ * @example
15
+ * ```typescript
16
+ * const b64 = await Effect.runPromise(Base64.from('SGVsbG8='))
17
+ * ```
18
+ */
19
+ export const from = (
20
+ value: string | Uint8Array,
21
+ ): Effect.Effect<BrandedBase64, Error> =>
22
+ Effect.try({
23
+ try: () => Base64.from(value),
24
+ catch: (e) => e as Error,
25
+ });
26
+
27
+ /**
28
+ * Create validated URL-safe Base64 string from input
29
+ *
30
+ * @param value - String or Uint8Array to convert
31
+ * @returns Effect yielding BrandedBase64Url
32
+ */
33
+ export const fromUrlSafe = (
34
+ value: string | Uint8Array,
35
+ ): Effect.Effect<BrandedBase64Url, Error> =>
36
+ Effect.try({
37
+ try: () => Base64.fromUrlSafe(value),
38
+ catch: (e) => e as Error,
39
+ });
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @module Base64
3
- * @description Effect-based schemas for standard and URL-safe base64 encoding.
3
+ * @description Effect-based schemas and functions for standard and URL-safe base64 encoding.
4
4
  *
5
5
  * ## Type Declarations
6
6
  *
@@ -12,17 +12,97 @@
12
12
  * }
13
13
  * ```
14
14
  *
15
+ * ## Schemas
16
+ *
17
+ * | Schema | Input | Output |
18
+ * |--------|-------|--------|
19
+ * | `Base64.Schema` | string \| Uint8Array | BrandedBase64 |
20
+ * | `Base64.UrlSchema` | string \| Uint8Array | BrandedBase64Url |
21
+ *
22
+ * ## Constructors (Effect-wrapped)
23
+ *
24
+ * ```typescript
25
+ * Base64.from(value) // Effect<BrandedBase64, Error>
26
+ * Base64.fromUrlSafe(value) // Effect<BrandedBase64Url, Error>
27
+ * ```
28
+ *
29
+ * ## Encoding (Pure)
30
+ *
31
+ * ```typescript
32
+ * Base64.encode(bytes) // BrandedBase64
33
+ * Base64.encodeString(str) // BrandedBase64
34
+ * Base64.encodeUrlSafe(bytes) // BrandedBase64Url
35
+ * Base64.encodeStringUrlSafe(str) // BrandedBase64Url
36
+ * ```
37
+ *
38
+ * ## Decoding (Effect-wrapped)
39
+ *
40
+ * ```typescript
41
+ * Base64.decode(encoded) // Effect<Uint8Array, Error>
42
+ * Base64.decodeToString(encoded) // Effect<string, Error>
43
+ * Base64.decodeUrlSafe(encoded) // Effect<Uint8Array, Error>
44
+ * Base64.decodeUrlSafeToString(encoded) // Effect<string, Error>
45
+ * ```
46
+ *
47
+ * ## Conversion (Pure)
48
+ *
49
+ * ```typescript
50
+ * Base64.toBytes(b64) // Uint8Array
51
+ * Base64.toBytesUrlSafe(b64) // Uint8Array
52
+ * Base64.toString(b64) // string
53
+ * Base64.toStringUrlSafe(b64) // string
54
+ * Base64.toBase64(bytes) // BrandedBase64
55
+ * Base64.toBase64Url(bytes) // BrandedBase64Url
56
+ * ```
57
+ *
58
+ * ## Validation (Pure)
59
+ *
60
+ * ```typescript
61
+ * Base64.isValid(str) // boolean
62
+ * Base64.isValidUrlSafe(str) // boolean
63
+ * ```
64
+ *
65
+ * ## Size Calculation (Pure)
66
+ *
67
+ * ```typescript
68
+ * Base64.calcEncodedSize(byteCount) // number
69
+ * Base64.calcDecodedSize(encoded) // number
70
+ * ```
71
+ *
15
72
  * @example
16
73
  * ```typescript
17
74
  * import * as Base64 from 'voltaire-effect/primitives/Base64'
18
75
  * import * as Schema from 'effect/Schema'
76
+ * import { Effect } from 'effect'
19
77
  *
20
78
  * const encoded = Schema.decodeSync(Base64.Schema)('SGVsbG8gV29ybGQ=')
79
+ * const decoded = await Effect.runPromise(Base64.decode('SGVsbG8='))
21
80
  * ```
22
81
  *
23
82
  * @since 0.0.1
24
83
  * @module
25
84
  */
26
85
 
86
+ // Types
27
87
  export type { BrandedBase64, BrandedBase64Url } from "@tevm/voltaire/Base64";
88
+
89
+ // Schemas
28
90
  export { Schema, UrlSchema } from "./Base64Schema.js";
91
+
92
+ // Constructors (Effect-wrapped)
93
+ export { from, fromUrlSafe } from "./from.js";
94
+
95
+ // Encoding (Pure)
96
+ export { encode, encodeString, encodeUrlSafe, encodeStringUrlSafe } from "./encode.js";
97
+
98
+ // Decoding (Effect-wrapped)
99
+ export { decode, decodeToString, decodeUrlSafe, decodeUrlSafeToString } from "./decode.js";
100
+
101
+ // Conversion (Pure)
102
+ export { toBytes, toBytesUrlSafe, toString, toStringUrlSafe, toBase64, toBase64Url } from "./convert.js";
103
+
104
+ // Validation (Pure)
105
+ export { isValid, isValidUrlSafe } from "./validation.js";
106
+
107
+ // Size Calculation (Pure)
108
+ export { calcEncodedSize, calcDecodedSize } from "./size.js";