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
@@ -6,7 +6,7 @@ import * as S from "effect/Schema";
6
6
  * Type representing an EVM opcode value (0x00-0xFF).
7
7
  * @since 0.0.1
8
8
  */
9
- type OpcodeType = ReturnType<typeof Opcode>;
9
+ export type OpcodeType = ReturnType<typeof Opcode>;
10
10
 
11
11
  const OpcodeTypeSchema = S.declare<OpcodeType>(
12
12
  (u): u is OpcodeType => typeof u === "number" && u >= 0x00 && u <= 0xff,
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module disassemble
3
+ * @description Disassemble bytecode to opcode instructions (pure)
4
+ * @since 0.1.0
5
+ */
6
+ import { Opcode } from "@tevm/voltaire/Opcode";
7
+
8
+ /**
9
+ * Disassemble bytecode into instructions
10
+ *
11
+ * @param bytecode - Bytecode to disassemble
12
+ * @returns Array of disassembled instructions
13
+ */
14
+ export const disassemble = Opcode.disassemble;
15
+ export const _disassemble = disassemble;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module dupPosition
3
+ * @description Get DUP instruction position (pure)
4
+ * @since 0.1.0
5
+ */
6
+ import { Opcode } from "@tevm/voltaire/Opcode";
7
+
8
+ /**
9
+ * Get the stack position for a DUP instruction
10
+ *
11
+ * @param opcode - DUP opcode (0x80-0x8f)
12
+ * @returns Stack position (1-16), or 0 if not a DUP
13
+ */
14
+ export const dupPosition = Opcode.dupPosition;
15
+ export const _dupPosition = dupPosition;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module format
3
+ * @description Format opcode to string (pure)
4
+ * @since 0.1.0
5
+ */
6
+ import { Opcode } from "@tevm/voltaire/Opcode";
7
+
8
+ /**
9
+ * Format an opcode to human-readable string
10
+ *
11
+ * @param opcode - Opcode to format
12
+ * @returns Formatted string (e.g., "PUSH1", "ADD")
13
+ */
14
+ export const format = Opcode.format;
15
+ export const _format = format;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @module getters
3
+ * @description Opcode metadata getters (pure)
4
+ * @since 0.1.0
5
+ */
6
+ import { Opcode } from "@tevm/voltaire/Opcode";
7
+
8
+ /**
9
+ * Get the category of an opcode
10
+ */
11
+ export const getCategory = Opcode.getCategory;
12
+ export const _getCategory = getCategory;
13
+
14
+ /**
15
+ * Get the description of an opcode
16
+ */
17
+ export const getDescription = Opcode.getDescription;
18
+ export const _getDescription = getDescription;
19
+
20
+ /**
21
+ * Get the base gas cost of an opcode
22
+ */
23
+ export const getGasCost = Opcode.getGasCost;
24
+ export const _getGasCost = getGasCost;
25
+
26
+ /**
27
+ * Get the name of an opcode
28
+ */
29
+ export const getName = Opcode.getName;
30
+ export const _getName = getName;
31
+
32
+ /**
33
+ * Get the push size for PUSH opcodes
34
+ */
35
+ export const getPushSize = Opcode.getPushSize;
36
+ export const _getPushSize = getPushSize;
37
+
38
+ /**
39
+ * Get the stack effect (inputs - outputs) of an opcode
40
+ */
41
+ export const getStackEffect = Opcode.getStackEffect;
42
+ export const _getStackEffect = getStackEffect;
43
+
44
+ /**
45
+ * Get the number of stack inputs for an opcode
46
+ */
47
+ export const getStackInput = Opcode.getStackInput;
48
+ export const _getStackInput = getStackInput;
49
+
50
+ /**
51
+ * Get the number of stack outputs for an opcode
52
+ */
53
+ export const getStackOutput = Opcode.getStackOutput;
54
+ export const _getStackOutput = getStackOutput;
@@ -1,24 +1,314 @@
1
1
  /**
2
- * Opcode module for Effect-based EVM opcode handling.
2
+ * @module Opcode
3
+ * @description Effect-wrapped operations for EVM opcodes.
3
4
  *
4
- * Provides Effect-wrapped operations for working with EVM opcodes (0x00-0xFF).
5
+ * Provides functions for working with EVM opcodes (0x00-0xFF).
6
+ *
7
+ * ## Type Declarations
8
+ *
9
+ * ```typescript
10
+ * import * as Opcode from 'voltaire-effect/primitives/Opcode'
11
+ *
12
+ * function executeOpcode(op: Opcode.OpcodeType) {
13
+ * // ...
14
+ * }
15
+ * ```
16
+ *
17
+ * ## Constants
18
+ *
19
+ * All EVM opcodes are exported as constants:
20
+ * ```typescript
21
+ * Opcode.STOP, Opcode.ADD, Opcode.MUL, Opcode.SUB, ...
22
+ * Opcode.PUSH1, Opcode.PUSH2, ..., Opcode.PUSH32
23
+ * Opcode.DUP1, Opcode.DUP2, ..., Opcode.DUP16
24
+ * Opcode.SWAP1, Opcode.SWAP2, ..., Opcode.SWAP16
25
+ * Opcode.LOG0, Opcode.LOG1, ..., Opcode.LOG4
26
+ * Opcode.CREATE, Opcode.CALL, Opcode.RETURN, Opcode.REVERT, ...
27
+ * ```
28
+ *
29
+ * ## Pure Functions
30
+ *
31
+ * ```typescript
32
+ * // Disassembly
33
+ * Opcode.disassemble(bytecode) // Instruction[]
34
+ * Opcode.format(opcode) // string
35
+ * Opcode.parse(value) // OpcodeType
36
+ *
37
+ * // Metadata
38
+ * Opcode.info(opcode) // Info
39
+ * Opcode.name(opcode) // string
40
+ * Opcode.getCategory(opcode) // string
41
+ * Opcode.getDescription(opcode) // string
42
+ * Opcode.getGasCost(opcode) // number
43
+ * Opcode.getPushSize(opcode) // number
44
+ * Opcode.getStackEffect(opcode) // number
45
+ * Opcode.getStackInput(opcode) // number
46
+ * Opcode.getStackOutput(opcode) // number
47
+ *
48
+ * // Position helpers
49
+ * Opcode.dupPosition(opcode) // number
50
+ * Opcode.swapPosition(opcode) // number
51
+ * Opcode.pushBytes(opcode) // number
52
+ * Opcode.pushOpcode(n) // OpcodeType
53
+ * Opcode.logTopics(opcode) // number
54
+ *
55
+ * // Predicates
56
+ * Opcode.isDup(opcode) // boolean
57
+ * Opcode.isJump(opcode) // boolean
58
+ * Opcode.isJumpDestination(opcode) // boolean
59
+ * Opcode.isLog(opcode) // boolean
60
+ * Opcode.isPush(opcode) // boolean
61
+ * Opcode.isSwap(opcode) // boolean
62
+ * Opcode.isTerminating(opcode) // boolean
63
+ * Opcode.isTerminator(opcode) // boolean
64
+ * Opcode.isValid(opcode) // boolean
65
+ * Opcode.isValidJumpDest(opcode) // boolean
66
+ * Opcode.isValidOpcode(opcode) // boolean
67
+ *
68
+ * // Analysis
69
+ * Opcode.jumpDests(bytecode) // Set<number>
70
+ * ```
5
71
  *
6
72
  * @example
7
73
  * ```typescript
8
74
  * import * as Opcode from 'voltaire-effect/primitives/Opcode'
9
- * import * as Effect from 'effect/Effect'
10
75
  *
11
- * // Create opcode from number
12
- * const add = Opcode.from(0x01) // ADD
13
- * const stop = Opcode.from(0x00) // STOP
76
+ * const addInfo = Opcode.info(Opcode.ADD)
77
+ * console.log(addInfo?.name) // "ADD"
78
+ * console.log(addInfo?.gasCost) // 3
14
79
  *
15
- * // Use with schema validation
16
- * import * as S from 'effect/Schema'
17
- * const validated = S.decodeSync(Opcode.OpcodeSchema)(0x60) // PUSH1
80
+ * Opcode.isPush(0x60) // true (PUSH1)
81
+ * Opcode.getPushSize(0x60) // 1
18
82
  * ```
19
83
  *
20
- * @module
21
- * @since 0.0.1
84
+ * @since 0.1.0
22
85
  */
23
86
 
87
+ // Re-export types
88
+ export type { Instruction, Info } from "@tevm/voltaire/Opcode";
89
+
90
+ // OpcodeType is number & { [brand]: "Opcode" } - re-export from OpcodeSchema
91
+ export type { OpcodeType } from "./OpcodeSchema.js";
92
+
93
+ // Schema
24
94
  export { OpcodeSchema } from "./OpcodeSchema.js";
95
+
96
+ // Disassembly
97
+ export { disassemble, _disassemble } from "./disassemble.js";
98
+ export { format, _format } from "./format.js";
99
+ export { parse, _parse } from "./parse.js";
100
+
101
+ // Metadata getters
102
+ export {
103
+ getCategory,
104
+ _getCategory,
105
+ getDescription,
106
+ _getDescription,
107
+ getGasCost,
108
+ _getGasCost,
109
+ getName,
110
+ _getName,
111
+ getPushSize,
112
+ _getPushSize,
113
+ getStackEffect,
114
+ _getStackEffect,
115
+ getStackInput,
116
+ _getStackInput,
117
+ getStackOutput,
118
+ _getStackOutput,
119
+ } from "./getters.js";
120
+
121
+ // Info
122
+ export { info, _info } from "./info.js";
123
+
124
+ // Position helpers
125
+ export { dupPosition, _dupPosition } from "./dupPosition.js";
126
+ export { swapPosition, _swapPosition } from "./swapPosition.js";
127
+ export { pushBytes, _pushBytes } from "./pushBytes.js";
128
+ export { pushOpcode, _pushOpcode } from "./pushOpcode.js";
129
+ export { logTopics, _logTopics } from "./logTopics.js";
130
+ export { name, _name } from "./name.js";
131
+
132
+ // Predicates
133
+ export {
134
+ isDup,
135
+ _isDup,
136
+ isJump,
137
+ _isJump,
138
+ isJumpDestination,
139
+ _isJumpDestination,
140
+ isLog,
141
+ _isLog,
142
+ isPush,
143
+ _isPush,
144
+ isSwap,
145
+ _isSwap,
146
+ isTerminating,
147
+ _isTerminating,
148
+ isTerminator,
149
+ _isTerminator,
150
+ isValid,
151
+ _isValid,
152
+ isValidJumpDest,
153
+ _isValidJumpDest,
154
+ isValidOpcode,
155
+ _isValidOpcode,
156
+ } from "./predicates.js";
157
+
158
+ // Analysis
159
+ export { jumpDests, _jumpDests } from "./jumpDests.js";
160
+
161
+ // Constants - re-export all opcode constants
162
+ export {
163
+ STOP,
164
+ ADD,
165
+ MUL,
166
+ SUB,
167
+ DIV,
168
+ SDIV,
169
+ MOD,
170
+ SMOD,
171
+ ADDMOD,
172
+ MULMOD,
173
+ EXP,
174
+ SIGNEXTEND,
175
+ LT,
176
+ GT,
177
+ SLT,
178
+ SGT,
179
+ EQ,
180
+ ISZERO,
181
+ AND,
182
+ OR,
183
+ XOR,
184
+ NOT,
185
+ BYTE,
186
+ SHL,
187
+ SHR,
188
+ SAR,
189
+ KECCAK256,
190
+ ADDRESS,
191
+ BALANCE,
192
+ ORIGIN,
193
+ CALLER,
194
+ CALLVALUE,
195
+ CALLDATALOAD,
196
+ CALLDATASIZE,
197
+ CALLDATACOPY,
198
+ CODESIZE,
199
+ CODECOPY,
200
+ GASPRICE,
201
+ EXTCODESIZE,
202
+ EXTCODECOPY,
203
+ RETURNDATASIZE,
204
+ RETURNDATACOPY,
205
+ EXTCODEHASH,
206
+ BLOCKHASH,
207
+ COINBASE,
208
+ TIMESTAMP,
209
+ NUMBER,
210
+ DIFFICULTY,
211
+ GASLIMIT,
212
+ CHAINID,
213
+ SELFBALANCE,
214
+ BASEFEE,
215
+ BLOBHASH,
216
+ BLOBBASEFEE,
217
+ POP,
218
+ MLOAD,
219
+ MSTORE,
220
+ MSTORE8,
221
+ SLOAD,
222
+ SSTORE,
223
+ JUMP,
224
+ JUMPI,
225
+ PC,
226
+ MSIZE,
227
+ GAS,
228
+ JUMPDEST,
229
+ TLOAD,
230
+ TSTORE,
231
+ MCOPY,
232
+ PUSH0,
233
+ PUSH1,
234
+ PUSH2,
235
+ PUSH3,
236
+ PUSH4,
237
+ PUSH5,
238
+ PUSH6,
239
+ PUSH7,
240
+ PUSH8,
241
+ PUSH9,
242
+ PUSH10,
243
+ PUSH11,
244
+ PUSH12,
245
+ PUSH13,
246
+ PUSH14,
247
+ PUSH15,
248
+ PUSH16,
249
+ PUSH17,
250
+ PUSH18,
251
+ PUSH19,
252
+ PUSH20,
253
+ PUSH21,
254
+ PUSH22,
255
+ PUSH23,
256
+ PUSH24,
257
+ PUSH25,
258
+ PUSH26,
259
+ PUSH27,
260
+ PUSH28,
261
+ PUSH29,
262
+ PUSH30,
263
+ PUSH31,
264
+ PUSH32,
265
+ DUP1,
266
+ DUP2,
267
+ DUP3,
268
+ DUP4,
269
+ DUP5,
270
+ DUP6,
271
+ DUP7,
272
+ DUP8,
273
+ DUP9,
274
+ DUP10,
275
+ DUP11,
276
+ DUP12,
277
+ DUP13,
278
+ DUP14,
279
+ DUP15,
280
+ DUP16,
281
+ SWAP1,
282
+ SWAP2,
283
+ SWAP3,
284
+ SWAP4,
285
+ SWAP5,
286
+ SWAP6,
287
+ SWAP7,
288
+ SWAP8,
289
+ SWAP9,
290
+ SWAP10,
291
+ SWAP11,
292
+ SWAP12,
293
+ SWAP13,
294
+ SWAP14,
295
+ SWAP15,
296
+ SWAP16,
297
+ LOG0,
298
+ LOG1,
299
+ LOG2,
300
+ LOG3,
301
+ LOG4,
302
+ CREATE,
303
+ CALL,
304
+ CALLCODE,
305
+ RETURN,
306
+ DELEGATECALL,
307
+ CREATE2,
308
+ AUTH,
309
+ AUTHCALL,
310
+ STATICCALL,
311
+ REVERT,
312
+ INVALID,
313
+ SELFDESTRUCT,
314
+ } from "@tevm/voltaire/Opcode";
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @module info
3
+ * @description Get full opcode metadata (pure)
4
+ * @since 0.1.0
5
+ */
6
+ import { Opcode } from "@tevm/voltaire/Opcode";
7
+ import type { Info } from "@tevm/voltaire/Opcode";
8
+
9
+ /**
10
+ * Get full metadata info for an opcode
11
+ *
12
+ * @param opcode - Opcode to look up
13
+ * @returns Info object with gas, stack effects, name
14
+ */
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ export const info = (opcode: number): Info | undefined =>
17
+ Opcode.info(opcode as any);
18
+ export const _info = info;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module jumpDests
3
+ * @description Find jump destinations in bytecode (pure)
4
+ * @since 0.1.0
5
+ */
6
+ import { Opcode } from "@tevm/voltaire/Opcode";
7
+
8
+ /**
9
+ * Find all valid JUMPDEST positions in bytecode
10
+ *
11
+ * @param bytecode - Bytecode to analyze
12
+ * @returns Set of valid jump destination positions
13
+ */
14
+ export const jumpDests = Opcode.jumpDests;
15
+ export const _jumpDests = jumpDests;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module logTopics
3
+ * @description Get number of topics for LOG opcode (pure)
4
+ * @since 0.1.0
5
+ */
6
+ import { Opcode } from "@tevm/voltaire/Opcode";
7
+
8
+ /**
9
+ * Get the number of topics for a LOG opcode
10
+ *
11
+ * @param opcode - LOG opcode (0xa0-0xa4)
12
+ * @returns Number of topics (0-4), or -1 if not a LOG
13
+ */
14
+ export const logTopics = Opcode.logTopics;
15
+ export const _logTopics = logTopics;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module name
3
+ * @description Get opcode name (pure)
4
+ * @since 0.1.0
5
+ */
6
+ import { Opcode } from "@tevm/voltaire/Opcode";
7
+
8
+ /**
9
+ * Get the mnemonic name for an opcode
10
+ *
11
+ * @param opcode - Opcode to look up
12
+ * @returns Opcode name (e.g., "ADD", "PUSH1")
13
+ */
14
+ export const name = Opcode.name;
15
+ export const _name = name;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module parse
3
+ * @description Parse opcode from number or string (pure)
4
+ * @since 0.1.0
5
+ */
6
+ import { Opcode } from "@tevm/voltaire/Opcode";
7
+
8
+ /**
9
+ * Parse an opcode from number or name string
10
+ *
11
+ * @param value - Opcode number or name
12
+ * @returns Opcode value
13
+ */
14
+ export const parse = Opcode.parse;
15
+ export const _parse = parse;
@@ -0,0 +1,72 @@
1
+ /**
2
+ * @module predicates
3
+ * @description Opcode type predicates (pure)
4
+ * @since 0.1.0
5
+ */
6
+ import { Opcode } from "@tevm/voltaire/Opcode";
7
+
8
+ /**
9
+ * Check if opcode is a DUP instruction
10
+ */
11
+ export const isDup = Opcode.isDup;
12
+ export const _isDup = isDup;
13
+
14
+ /**
15
+ * Check if opcode is a JUMP instruction
16
+ */
17
+ export const isJump = Opcode.isJump;
18
+ export const _isJump = isJump;
19
+
20
+ /**
21
+ * Check if opcode is JUMPDEST
22
+ */
23
+ export const isJumpDestination = Opcode.isJumpDestination;
24
+ export const _isJumpDestination = isJumpDestination;
25
+
26
+ /**
27
+ * Check if opcode is a LOG instruction
28
+ */
29
+ export const isLog = Opcode.isLog;
30
+ export const _isLog = isLog;
31
+
32
+ /**
33
+ * Check if opcode is a PUSH instruction
34
+ */
35
+ export const isPush = Opcode.isPush;
36
+ export const _isPush = isPush;
37
+
38
+ /**
39
+ * Check if opcode is a SWAP instruction
40
+ */
41
+ export const isSwap = Opcode.isSwap;
42
+ export const _isSwap = isSwap;
43
+
44
+ /**
45
+ * Check if opcode terminates execution
46
+ */
47
+ export const isTerminating = Opcode.isTerminating;
48
+ export const _isTerminating = isTerminating;
49
+
50
+ /**
51
+ * Check if opcode is a block terminator
52
+ */
53
+ export const isTerminator = Opcode.isTerminator;
54
+ export const _isTerminator = isTerminator;
55
+
56
+ /**
57
+ * Check if opcode is valid (known)
58
+ */
59
+ export const isValid = Opcode.isValid;
60
+ export const _isValid = isValid;
61
+
62
+ /**
63
+ * Check if opcode is a valid jump destination
64
+ */
65
+ export const isValidJumpDest = Opcode.isValidJumpDest;
66
+ export const _isValidJumpDest = isValidJumpDest;
67
+
68
+ /**
69
+ * Check if opcode value is a valid opcode
70
+ */
71
+ export const isValidOpcode = Opcode.isValidOpcode;
72
+ export const _isValidOpcode = isValidOpcode;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module pushBytes
3
+ * @description Get bytes pushed by PUSH opcode (pure)
4
+ * @since 0.1.0
5
+ */
6
+ import { Opcode } from "@tevm/voltaire/Opcode";
7
+
8
+ /**
9
+ * Get the number of bytes pushed by a PUSH opcode
10
+ *
11
+ * @param opcode - PUSH opcode (0x5f-0x7f)
12
+ * @returns Number of bytes (0-32)
13
+ */
14
+ export const pushBytes = Opcode.pushBytes;
15
+ export const _pushBytes = pushBytes;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module pushOpcode
3
+ * @description Get PUSH opcode for given byte count (pure)
4
+ * @since 0.1.0
5
+ */
6
+ import { Opcode } from "@tevm/voltaire/Opcode";
7
+
8
+ /**
9
+ * Get the PUSH opcode for a given number of bytes
10
+ *
11
+ * @param n - Number of bytes (0-32)
12
+ * @returns PUSH opcode (PUSH0-PUSH32)
13
+ */
14
+ export const pushOpcode = Opcode.pushOpcode;
15
+ export const _pushOpcode = pushOpcode;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module swapPosition
3
+ * @description Get SWAP instruction position (pure)
4
+ * @since 0.1.0
5
+ */
6
+ import { Opcode } from "@tevm/voltaire/Opcode";
7
+
8
+ /**
9
+ * Get the stack position for a SWAP instruction
10
+ *
11
+ * @param opcode - SWAP opcode (0x90-0x9f)
12
+ * @returns Stack position (1-16), or 0 if not a SWAP
13
+ */
14
+ export const swapPosition = Opcode.swapPosition;
15
+ export const _swapPosition = swapPosition;
@@ -0,0 +1,46 @@
1
+ import {
2
+ type RlpDecodingError,
3
+ RlpDecodingError as RlpDecodingErrorClass,
4
+ Rlp as VoltaireRlp,
5
+ } from "@tevm/voltaire/Rlp";
6
+ import * as Effect from "effect/Effect";
7
+
8
+ const isRlpDecodingError = (e: unknown): e is RlpDecodingError =>
9
+ e instanceof RlpDecodingErrorClass ||
10
+ (e !== null &&
11
+ typeof e === "object" &&
12
+ "name" in e &&
13
+ e.name === "RlpDecodingError");
14
+
15
+ /**
16
+ * Decodes multiple RLP-encoded items.
17
+ *
18
+ * @param data - Array of RLP-encoded data
19
+ * @returns Effect that succeeds with array of decoded results or fails with RlpDecodingError
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * import * as Effect from 'effect/Effect'
24
+ * import { decodeBatch, encode } from 'voltaire-effect/primitives/Rlp'
25
+ *
26
+ * const items = [
27
+ * Effect.runSync(encode([new Uint8Array([1, 2])])),
28
+ * Effect.runSync(encode([new Uint8Array([3, 4])]))
29
+ * ]
30
+ * const decoded = Effect.runSync(decodeBatch(items))
31
+ * ```
32
+ *
33
+ * @since 0.0.1
34
+ */
35
+ export const decodeBatch = (
36
+ data: Uint8Array[],
37
+ ): Effect.Effect<unknown[][], RlpDecodingError> =>
38
+ Effect.try({
39
+ try: () => VoltaireRlp.decodeBatch(data),
40
+ catch: (e) =>
41
+ isRlpDecodingError(e)
42
+ ? e
43
+ : new RlpDecodingErrorClass("RLP batch decoding failed", {
44
+ cause: e instanceof Error ? e : undefined,
45
+ }),
46
+ });