voltaire-effect 0.2.23

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 (1262) hide show
  1. package/README.md +42 -0
  2. package/dist/AccountService-BetXokad.d.ts +1717 -0
  3. package/dist/RpcResolver-BpvqybjD.d.ts +6439 -0
  4. package/dist/Secp256k1Service-OxQ6hJFp.d.ts +250 -0
  5. package/dist/X25519Test-DGsk1V9o.d.ts +5352 -0
  6. package/dist/crypto/index.d.ts +289 -0
  7. package/dist/crypto/index.js +1254 -0
  8. package/dist/index-IgkEHjBe.d.ts +20058 -0
  9. package/dist/index.d.ts +11961 -0
  10. package/dist/index.js +20715 -0
  11. package/dist/native/index.d.ts +193 -0
  12. package/dist/native/index.js +20931 -0
  13. package/dist/primitives/index.d.ts +273 -0
  14. package/dist/primitives/index.js +8688 -0
  15. package/dist/services/index.d.ts +42 -0
  16. package/dist/services/index.js +6176 -0
  17. package/package.json +108 -0
  18. package/src/auth/index.ts +20 -0
  19. package/src/auth/siwe.test.ts +156 -0
  20. package/src/auth/siwe.ts +319 -0
  21. package/src/block/BlockError.test.ts +120 -0
  22. package/src/block/BlockError.ts +52 -0
  23. package/src/block/block.test.ts +579 -0
  24. package/src/block/fetchBlock.ts +100 -0
  25. package/src/block/fetchBlockByHash.ts +97 -0
  26. package/src/block/fetchBlockReceipts.ts +129 -0
  27. package/src/block/index.ts +52 -0
  28. package/src/block/toLightBlock.ts +43 -0
  29. package/src/blockchain/Blockchain.test.ts +468 -0
  30. package/src/blockchain/Blockchain.ts +441 -0
  31. package/src/blockchain/BlockchainService.ts +203 -0
  32. package/src/blockchain/index.ts +46 -0
  33. package/src/contract/EventStream.test.ts +802 -0
  34. package/src/contract/EventStream.ts +138 -0
  35. package/src/contract/EventStreamError.test.ts +92 -0
  36. package/src/contract/EventStreamError.ts +33 -0
  37. package/src/contract/EventStreamService.ts +124 -0
  38. package/src/contract/index.ts +39 -0
  39. package/src/crypto/AesGcm/AesGcm.test.ts +185 -0
  40. package/src/crypto/AesGcm/AesGcmService.ts +86 -0
  41. package/src/crypto/AesGcm/errors.ts +38 -0
  42. package/src/crypto/AesGcm/index.ts +101 -0
  43. package/src/crypto/AesGcm/operations.ts +191 -0
  44. package/src/crypto/Bip39/Bip39.test.ts +183 -0
  45. package/src/crypto/Bip39/Bip39Service.ts +160 -0
  46. package/src/crypto/Bip39/index.ts +52 -0
  47. package/src/crypto/Bip39/operations.ts +168 -0
  48. package/src/crypto/Bip39/types.ts +16 -0
  49. package/src/crypto/Bip39/utils.ts +42 -0
  50. package/src/crypto/Blake2/Blake2.test.ts +317 -0
  51. package/src/crypto/Blake2/Blake2Service.ts +121 -0
  52. package/src/crypto/Blake2/hash.ts +59 -0
  53. package/src/crypto/Blake2/index.ts +30 -0
  54. package/src/crypto/Bls12381/Bls12381.test.ts +464 -0
  55. package/src/crypto/Bls12381/Bls12381Live.ts +43 -0
  56. package/src/crypto/Bls12381/Bls12381Service.ts +131 -0
  57. package/src/crypto/Bls12381/aggregate.ts +66 -0
  58. package/src/crypto/Bls12381/index.ts +43 -0
  59. package/src/crypto/Bls12381/sign.ts +65 -0
  60. package/src/crypto/Bls12381/verify.ts +71 -0
  61. package/src/crypto/Bn254/Bn254.test.ts +131 -0
  62. package/src/crypto/Bn254/Bn254Service.ts +369 -0
  63. package/src/crypto/Bn254/index.ts +56 -0
  64. package/src/crypto/Bn254/operations.ts +259 -0
  65. package/src/crypto/Bn254/types.ts +15 -0
  66. package/src/crypto/ChaCha20Poly1305/ChaCha20Poly1305.test.ts +199 -0
  67. package/src/crypto/ChaCha20Poly1305/ChaCha20Poly1305Service.ts +177 -0
  68. package/src/crypto/ChaCha20Poly1305/errors.ts +38 -0
  69. package/src/crypto/ChaCha20Poly1305/index.ts +46 -0
  70. package/src/crypto/ChaCha20Poly1305/operations.ts +161 -0
  71. package/src/crypto/CryptoLive.test.ts +42 -0
  72. package/src/crypto/CryptoLive.ts +52 -0
  73. package/src/crypto/CryptoTest.ts +49 -0
  74. package/src/crypto/EIP712/EIP712.test.ts +197 -0
  75. package/src/crypto/EIP712/EIP712Service.ts +184 -0
  76. package/src/crypto/EIP712/index.ts +50 -0
  77. package/src/crypto/EIP712/operations.ts +220 -0
  78. package/src/crypto/ERC6492/ERC6492.test.ts +115 -0
  79. package/src/crypto/ERC6492/index.ts +9 -0
  80. package/src/crypto/ERC6492/unwrapSignature.ts +72 -0
  81. package/src/crypto/ERC6492/verifySignature.ts +139 -0
  82. package/src/crypto/ERC6492/wrapSignature.ts +55 -0
  83. package/src/crypto/Ed25519/Ed25519.test.ts +472 -0
  84. package/src/crypto/Ed25519/Ed25519Live.ts +44 -0
  85. package/src/crypto/Ed25519/Ed25519Service.ts +134 -0
  86. package/src/crypto/Ed25519/Ed25519Test.ts +59 -0
  87. package/src/crypto/Ed25519/getPublicKey.ts +60 -0
  88. package/src/crypto/Ed25519/index.ts +42 -0
  89. package/src/crypto/Ed25519/sign.ts +66 -0
  90. package/src/crypto/Ed25519/verify.ts +75 -0
  91. package/src/crypto/HDWallet/HDWallet.cleanup.test.ts +128 -0
  92. package/src/crypto/HDWallet/HDWallet.test.ts +383 -0
  93. package/src/crypto/HDWallet/HDWalletLive.ts +201 -0
  94. package/src/crypto/HDWallet/HDWalletService.ts +186 -0
  95. package/src/crypto/HDWallet/derive.ts +348 -0
  96. package/src/crypto/HDWallet/errors.ts +121 -0
  97. package/src/crypto/HDWallet/index.ts +65 -0
  98. package/src/crypto/HMAC/HMAC.test.ts +380 -0
  99. package/src/crypto/HMAC/HMACService.ts +174 -0
  100. package/src/crypto/HMAC/index.ts +39 -0
  101. package/src/crypto/HMAC/operations.ts +112 -0
  102. package/src/crypto/Hash/index.ts +51 -0
  103. package/src/crypto/KZG/KZG.test.ts +94 -0
  104. package/src/crypto/KZG/KZGService.ts +241 -0
  105. package/src/crypto/KZG/commit.ts +76 -0
  106. package/src/crypto/KZG/index.ts +42 -0
  107. package/src/crypto/KZG/verify.ts +52 -0
  108. package/src/crypto/Keccak256/Keccak256.test.ts +265 -0
  109. package/src/crypto/Keccak256/KeccakService.ts +177 -0
  110. package/src/crypto/Keccak256/hash.ts +76 -0
  111. package/src/crypto/Keccak256/index.ts +49 -0
  112. package/src/crypto/Keystore/Keystore.cleanup.test.ts +93 -0
  113. package/src/crypto/Keystore/Keystore.test.ts +511 -0
  114. package/src/crypto/Keystore/KeystoreLive.ts +35 -0
  115. package/src/crypto/Keystore/KeystoreService.ts +115 -0
  116. package/src/crypto/Keystore/KeystoreTest.ts +65 -0
  117. package/src/crypto/Keystore/decrypt.ts +105 -0
  118. package/src/crypto/Keystore/encrypt.ts +71 -0
  119. package/src/crypto/Keystore/index.ts +41 -0
  120. package/src/crypto/ModExp/ModExp.test.ts +177 -0
  121. package/src/crypto/ModExp/ModExpService.ts +139 -0
  122. package/src/crypto/ModExp/index.ts +39 -0
  123. package/src/crypto/ModExp/operations.ts +122 -0
  124. package/src/crypto/P256/P256.test.ts +414 -0
  125. package/src/crypto/P256/P256Live.ts +41 -0
  126. package/src/crypto/P256/P256Service.ts +115 -0
  127. package/src/crypto/P256/index.ts +37 -0
  128. package/src/crypto/P256/sign.ts +66 -0
  129. package/src/crypto/P256/verify.ts +75 -0
  130. package/src/crypto/Ripemd160/Ripemd160.test.ts +61 -0
  131. package/src/crypto/Ripemd160/Ripemd160Service.ts +119 -0
  132. package/src/crypto/Ripemd160/hash.ts +58 -0
  133. package/src/crypto/Ripemd160/index.ts +35 -0
  134. package/src/crypto/SHA256/SHA256.test.ts +284 -0
  135. package/src/crypto/SHA256/SHA256Service.ts +179 -0
  136. package/src/crypto/SHA256/hash.ts +93 -0
  137. package/src/crypto/SHA256/index.ts +48 -0
  138. package/src/crypto/Secp256k1/Secp256k1.test.ts +469 -0
  139. package/src/crypto/Secp256k1/Secp256k1Live.ts +83 -0
  140. package/src/crypto/Secp256k1/Secp256k1Service.ts +194 -0
  141. package/src/crypto/Secp256k1/Secp256k1Test.ts +101 -0
  142. package/src/crypto/Secp256k1/errors.ts +224 -0
  143. package/src/crypto/Secp256k1/index.ts +65 -0
  144. package/src/crypto/Secp256k1/recover.ts +106 -0
  145. package/src/crypto/Secp256k1/sign.ts +96 -0
  146. package/src/crypto/Secp256k1/verify.ts +111 -0
  147. package/src/crypto/Signature/Signature.test.ts +323 -0
  148. package/src/crypto/Signature/constantTimeEqual.ts +54 -0
  149. package/src/crypto/Signature/errors.ts +93 -0
  150. package/src/crypto/Signature/hashMessage.ts +83 -0
  151. package/src/crypto/Signature/index.ts +69 -0
  152. package/src/crypto/Signature/recoverAddress.ts +163 -0
  153. package/src/crypto/Signature/recoverMessageAddress.ts +70 -0
  154. package/src/crypto/Signature/verifyHash.ts +72 -0
  155. package/src/crypto/Signature/verifyMessage.ts +71 -0
  156. package/src/crypto/Signature/verifyTypedData.ts +88 -0
  157. package/src/crypto/Signers/Signers.test.ts +149 -0
  158. package/src/crypto/Signers/SignersLive.ts +40 -0
  159. package/src/crypto/Signers/SignersService.ts +73 -0
  160. package/src/crypto/Signers/SignersTest.ts +49 -0
  161. package/src/crypto/Signers/index.ts +44 -0
  162. package/src/crypto/Signers/operations.ts +123 -0
  163. package/src/crypto/Verify/errors.ts +97 -0
  164. package/src/crypto/Verify/hashMessage.ts +68 -0
  165. package/src/crypto/Verify/recoverAddress.ts +163 -0
  166. package/src/crypto/X25519/X25519.test.ts +168 -0
  167. package/src/crypto/X25519/X25519Live.ts +37 -0
  168. package/src/crypto/X25519/X25519Service.ts +81 -0
  169. package/src/crypto/X25519/X25519Test.ts +38 -0
  170. package/src/crypto/X25519/computeSecret.ts +61 -0
  171. package/src/crypto/X25519/generateKeyPair.ts +37 -0
  172. package/src/crypto/X25519/getPublicKey.ts +40 -0
  173. package/src/crypto/X25519/index.ts +41 -0
  174. package/src/crypto/index.ts +239 -0
  175. package/src/crypto/utils/constantTimeEqual.test.ts +40 -0
  176. package/src/crypto/utils/constantTimeEqual.ts +36 -0
  177. package/src/crypto/utils/index.ts +7 -0
  178. package/src/index.ts +224 -0
  179. package/src/jsonrpc/Anvil.ts +87 -0
  180. package/src/jsonrpc/BatchRequest.ts +23 -0
  181. package/src/jsonrpc/BatchResponse.ts +55 -0
  182. package/src/jsonrpc/Error.ts +107 -0
  183. package/src/jsonrpc/Eth.ts +224 -0
  184. package/src/jsonrpc/Hardhat.ts +69 -0
  185. package/src/jsonrpc/IdCounter.ts +7 -0
  186. package/src/jsonrpc/JsonRpc.test.ts +751 -0
  187. package/src/jsonrpc/Net.ts +24 -0
  188. package/src/jsonrpc/Request.ts +44 -0
  189. package/src/jsonrpc/Response.ts +98 -0
  190. package/src/jsonrpc/Txpool.ts +24 -0
  191. package/src/jsonrpc/Wallet.ts +52 -0
  192. package/src/jsonrpc/Web3.ts +22 -0
  193. package/src/jsonrpc/errors.test.ts +355 -0
  194. package/src/jsonrpc/errors.ts +680 -0
  195. package/src/jsonrpc/index.ts +112 -0
  196. package/src/jsonrpc/schemas/anvil/dropTransaction.ts +53 -0
  197. package/src/jsonrpc/schemas/anvil/impersonateAccount.ts +53 -0
  198. package/src/jsonrpc/schemas/anvil/index.ts +73 -0
  199. package/src/jsonrpc/schemas/anvil/mine.ts +52 -0
  200. package/src/jsonrpc/schemas/anvil/reset.ts +57 -0
  201. package/src/jsonrpc/schemas/anvil/revert.ts +49 -0
  202. package/src/jsonrpc/schemas/anvil/setAutomine.ts +45 -0
  203. package/src/jsonrpc/schemas/anvil/setBalance.ts +50 -0
  204. package/src/jsonrpc/schemas/anvil/setBlockTimestampInterval.ts +49 -0
  205. package/src/jsonrpc/schemas/anvil/setCode.ts +50 -0
  206. package/src/jsonrpc/schemas/anvil/setNextBlockTimestamp.ts +53 -0
  207. package/src/jsonrpc/schemas/anvil/setNonce.ts +50 -0
  208. package/src/jsonrpc/schemas/anvil/setStorageAt.ts +56 -0
  209. package/src/jsonrpc/schemas/anvil/snapshot.ts +49 -0
  210. package/src/jsonrpc/schemas/anvil/stopImpersonatingAccount.ts +53 -0
  211. package/src/jsonrpc/schemas/common.ts +450 -0
  212. package/src/jsonrpc/schemas/eth/accounts.ts +49 -0
  213. package/src/jsonrpc/schemas/eth/blobBaseFee.ts +49 -0
  214. package/src/jsonrpc/schemas/eth/blockNumber.ts +49 -0
  215. package/src/jsonrpc/schemas/eth/call.ts +69 -0
  216. package/src/jsonrpc/schemas/eth/chainId.ts +49 -0
  217. package/src/jsonrpc/schemas/eth/coinbase.ts +49 -0
  218. package/src/jsonrpc/schemas/eth/createAccessList.ts +57 -0
  219. package/src/jsonrpc/schemas/eth/estimateGas.ts +59 -0
  220. package/src/jsonrpc/schemas/eth/feeHistory.ts +54 -0
  221. package/src/jsonrpc/schemas/eth/gasPrice.ts +49 -0
  222. package/src/jsonrpc/schemas/eth/getBalance.ts +51 -0
  223. package/src/jsonrpc/schemas/eth/getBlockByHash.ts +54 -0
  224. package/src/jsonrpc/schemas/eth/getBlockByNumber.ts +54 -0
  225. package/src/jsonrpc/schemas/eth/getBlockReceipts.ts +54 -0
  226. package/src/jsonrpc/schemas/eth/getBlockTransactionCountByHash.ts +54 -0
  227. package/src/jsonrpc/schemas/eth/getBlockTransactionCountByNumber.ts +55 -0
  228. package/src/jsonrpc/schemas/eth/getCode.ts +51 -0
  229. package/src/jsonrpc/schemas/eth/getFilterChanges.ts +58 -0
  230. package/src/jsonrpc/schemas/eth/getFilterLogs.ts +54 -0
  231. package/src/jsonrpc/schemas/eth/getLogs.ts +50 -0
  232. package/src/jsonrpc/schemas/eth/getProof.ts +56 -0
  233. package/src/jsonrpc/schemas/eth/getStorageAt.ts +57 -0
  234. package/src/jsonrpc/schemas/eth/getTransactionByBlockHashAndIndex.ts +59 -0
  235. package/src/jsonrpc/schemas/eth/getTransactionByBlockNumberAndIndex.ts +59 -0
  236. package/src/jsonrpc/schemas/eth/getTransactionByHash.ts +54 -0
  237. package/src/jsonrpc/schemas/eth/getTransactionCount.ts +58 -0
  238. package/src/jsonrpc/schemas/eth/getTransactionReceipt.ts +54 -0
  239. package/src/jsonrpc/schemas/eth/getUncleByBlockHashAndIndex.ts +58 -0
  240. package/src/jsonrpc/schemas/eth/getUncleByBlockNumberAndIndex.ts +58 -0
  241. package/src/jsonrpc/schemas/eth/getUncleCountByBlockHash.ts +54 -0
  242. package/src/jsonrpc/schemas/eth/getUncleCountByBlockNumber.ts +54 -0
  243. package/src/jsonrpc/schemas/eth/getWork.ts +53 -0
  244. package/src/jsonrpc/schemas/eth/hashrate.ts +49 -0
  245. package/src/jsonrpc/schemas/eth/index.ts +178 -0
  246. package/src/jsonrpc/schemas/eth/maxPriorityFeePerGas.ts +53 -0
  247. package/src/jsonrpc/schemas/eth/mining.ts +45 -0
  248. package/src/jsonrpc/schemas/eth/newBlockFilter.ts +53 -0
  249. package/src/jsonrpc/schemas/eth/newFilter.ts +50 -0
  250. package/src/jsonrpc/schemas/eth/newPendingTransactionFilter.ts +53 -0
  251. package/src/jsonrpc/schemas/eth/protocolVersion.ts +49 -0
  252. package/src/jsonrpc/schemas/eth/sendRawTransaction.ts +54 -0
  253. package/src/jsonrpc/schemas/eth/sendTransaction.ts +54 -0
  254. package/src/jsonrpc/schemas/eth/sign.ts +50 -0
  255. package/src/jsonrpc/schemas/eth/signTransaction.ts +54 -0
  256. package/src/jsonrpc/schemas/eth/submitHashrate.ts +57 -0
  257. package/src/jsonrpc/schemas/eth/submitWork.ts +54 -0
  258. package/src/jsonrpc/schemas/eth/subscribe.ts +86 -0
  259. package/src/jsonrpc/schemas/eth/syncing.ts +49 -0
  260. package/src/jsonrpc/schemas/eth/uninstallFilter.ts +53 -0
  261. package/src/jsonrpc/schemas/eth/unsubscribe.ts +49 -0
  262. package/src/jsonrpc/schemas/hardhat/dropTransaction.ts +53 -0
  263. package/src/jsonrpc/schemas/hardhat/impersonateAccount.ts +53 -0
  264. package/src/jsonrpc/schemas/hardhat/index.ts +60 -0
  265. package/src/jsonrpc/schemas/hardhat/mine.ts +52 -0
  266. package/src/jsonrpc/schemas/hardhat/reset.ts +53 -0
  267. package/src/jsonrpc/schemas/hardhat/setBalance.ts +50 -0
  268. package/src/jsonrpc/schemas/hardhat/setCode.ts +50 -0
  269. package/src/jsonrpc/schemas/hardhat/setNonce.ts +50 -0
  270. package/src/jsonrpc/schemas/hardhat/setStorageAt.ts +56 -0
  271. package/src/jsonrpc/schemas/hardhat/stopImpersonatingAccount.ts +53 -0
  272. package/src/jsonrpc/schemas/index.ts +271 -0
  273. package/src/jsonrpc/schemas/net/index.ts +40 -0
  274. package/src/jsonrpc/schemas/net/listening.ts +45 -0
  275. package/src/jsonrpc/schemas/net/peerCount.ts +49 -0
  276. package/src/jsonrpc/schemas/net/version.ts +45 -0
  277. package/src/jsonrpc/schemas/schemas.test.ts +563 -0
  278. package/src/jsonrpc/schemas/txpool/content.ts +70 -0
  279. package/src/jsonrpc/schemas/txpool/index.ts +40 -0
  280. package/src/jsonrpc/schemas/txpool/inspect.ts +67 -0
  281. package/src/jsonrpc/schemas/txpool/status.ts +52 -0
  282. package/src/jsonrpc/schemas/wallet/addEthereumChain.ts +81 -0
  283. package/src/jsonrpc/schemas/wallet/getCallsStatus.ts +87 -0
  284. package/src/jsonrpc/schemas/wallet/getCapabilities.ts +87 -0
  285. package/src/jsonrpc/schemas/wallet/getPermissions.ts +51 -0
  286. package/src/jsonrpc/schemas/wallet/index.ts +64 -0
  287. package/src/jsonrpc/schemas/wallet/registerOnboarding.ts +50 -0
  288. package/src/jsonrpc/schemas/wallet/requestPermissions.ts +88 -0
  289. package/src/jsonrpc/schemas/wallet/revokePermissions.ts +62 -0
  290. package/src/jsonrpc/schemas/wallet/sendCalls.ts +79 -0
  291. package/src/jsonrpc/schemas/wallet/showCallsStatus.ts +50 -0
  292. package/src/jsonrpc/schemas/wallet/switchEthereumChain.ts +66 -0
  293. package/src/jsonrpc/schemas/wallet/watchAsset.ts +75 -0
  294. package/src/jsonrpc/schemas/web3/clientVersion.ts +49 -0
  295. package/src/jsonrpc/schemas/web3/index.ts +34 -0
  296. package/src/jsonrpc/schemas/web3/sha3.ts +50 -0
  297. package/src/native/CryptoLiveNative.ts +8 -0
  298. package/src/native/index.ts +14 -0
  299. package/src/primitives/Abi/Abi.test.ts +967 -0
  300. package/src/primitives/Abi/AbiSchema.test.ts +382 -0
  301. package/src/primitives/Abi/AbiSchema.ts +489 -0
  302. package/src/primitives/Abi/Item/index.ts +17 -0
  303. package/src/primitives/Abi/constructor/index.ts +5 -0
  304. package/src/primitives/Abi/decodeError.test.ts +117 -0
  305. package/src/primitives/Abi/decodeError.ts +103 -0
  306. package/src/primitives/Abi/decodeEventLog.test.ts +128 -0
  307. package/src/primitives/Abi/decodeEventLog.ts +164 -0
  308. package/src/primitives/Abi/decodeFunction.test.ts +91 -0
  309. package/src/primitives/Abi/decodeFunction.ts +87 -0
  310. package/src/primitives/Abi/decodeFunctionData.test.ts +158 -0
  311. package/src/primitives/Abi/decodeFunctionData.ts +116 -0
  312. package/src/primitives/Abi/decodeFunctionResult.test.ts +197 -0
  313. package/src/primitives/Abi/decodeFunctionResult.ts +160 -0
  314. package/src/primitives/Abi/encodeError.test.ts +106 -0
  315. package/src/primitives/Abi/encodeError.ts +96 -0
  316. package/src/primitives/Abi/encodeEventLog.test.ts +91 -0
  317. package/src/primitives/Abi/encodeEventLog.ts +86 -0
  318. package/src/primitives/Abi/encodeFunction.test.ts +65 -0
  319. package/src/primitives/Abi/encodeFunction.ts +65 -0
  320. package/src/primitives/Abi/encodeFunctionData.test.ts +149 -0
  321. package/src/primitives/Abi/encodeFunctionData.ts +124 -0
  322. package/src/primitives/Abi/encodeFunctionResult.test.ts +114 -0
  323. package/src/primitives/Abi/encodeFunctionResult.ts +96 -0
  324. package/src/primitives/Abi/error/index.ts +11 -0
  325. package/src/primitives/Abi/error/standards/index.ts +23 -0
  326. package/src/primitives/Abi/error/wrapped/index.ts +7 -0
  327. package/src/primitives/Abi/event/index.ts +15 -0
  328. package/src/primitives/Abi/findError.test.ts +97 -0
  329. package/src/primitives/Abi/findError.ts +55 -0
  330. package/src/primitives/Abi/findEvent.test.ts +100 -0
  331. package/src/primitives/Abi/findEvent.ts +51 -0
  332. package/src/primitives/Abi/findFunction.test.ts +86 -0
  333. package/src/primitives/Abi/findFunction.ts +58 -0
  334. package/src/primitives/Abi/format.test.ts +112 -0
  335. package/src/primitives/Abi/format.ts +39 -0
  336. package/src/primitives/Abi/formatWithArgs.test.ts +105 -0
  337. package/src/primitives/Abi/formatWithArgs.ts +43 -0
  338. package/src/primitives/Abi/function/errors.ts +69 -0
  339. package/src/primitives/Abi/function/index.ts +24 -0
  340. package/src/primitives/Abi/getErrorSignature.test.ts +78 -0
  341. package/src/primitives/Abi/getErrorSignature.ts +40 -0
  342. package/src/primitives/Abi/getEvent.test.ts +98 -0
  343. package/src/primitives/Abi/getEvent.ts +131 -0
  344. package/src/primitives/Abi/getEventSignature.test.ts +79 -0
  345. package/src/primitives/Abi/getEventSignature.ts +40 -0
  346. package/src/primitives/Abi/getFunction.test.ts +116 -0
  347. package/src/primitives/Abi/getFunction.ts +121 -0
  348. package/src/primitives/Abi/getFunctionSignature.test.ts +88 -0
  349. package/src/primitives/Abi/getFunctionSignature.ts +40 -0
  350. package/src/primitives/Abi/getSelector.test.ts +149 -0
  351. package/src/primitives/Abi/getSelector.ts +59 -0
  352. package/src/primitives/Abi/index.ts +53 -0
  353. package/src/primitives/Abi/interface/index.ts +11 -0
  354. package/src/primitives/Abi/parameter/index.ts +5 -0
  355. package/src/primitives/Abi/parse.test.ts +97 -0
  356. package/src/primitives/Abi/parse.ts +61 -0
  357. package/src/primitives/Abi/parseItem.test.ts +144 -0
  358. package/src/primitives/Abi/parseItem.ts +76 -0
  359. package/src/primitives/Abi/wasm/index.ts +67 -0
  360. package/src/primitives/AccessList/Rpc.ts +128 -0
  361. package/src/primitives/AccessList/index.ts +32 -0
  362. package/src/primitives/AccountState/Struct.ts +214 -0
  363. package/src/primitives/AccountState/index.ts +60 -0
  364. package/src/primitives/Address/Address.test.ts +366 -0
  365. package/src/primitives/Address/AddressSchema.ts +21 -0
  366. package/src/primitives/Address/Bytes.ts +55 -0
  367. package/src/primitives/Address/Checksummed.ts +93 -0
  368. package/src/primitives/Address/Hex.ts +56 -0
  369. package/src/primitives/Address/clone.ts +26 -0
  370. package/src/primitives/Address/compare.ts +29 -0
  371. package/src/primitives/Address/equals.ts +29 -0
  372. package/src/primitives/Address/greaterThan.ts +29 -0
  373. package/src/primitives/Address/index.ts +89 -0
  374. package/src/primitives/Address/isValid.ts +26 -0
  375. package/src/primitives/Address/isValidChecksum.ts +26 -0
  376. package/src/primitives/Address/isZero.ts +26 -0
  377. package/src/primitives/Address/lessThan.ts +29 -0
  378. package/src/primitives/Address/toAbiEncoded.ts +28 -0
  379. package/src/primitives/Address/toBytes.ts +26 -0
  380. package/src/primitives/Address/toLowercase.ts +28 -0
  381. package/src/primitives/Address/toShortHex.ts +27 -0
  382. package/src/primitives/Address/toU256.ts +28 -0
  383. package/src/primitives/Address/toUppercase.ts +28 -0
  384. package/src/primitives/Authorization/Rpc.ts +148 -0
  385. package/src/primitives/Authorization/index.ts +38 -0
  386. package/src/primitives/Balance/BigInt.ts +48 -0
  387. package/src/primitives/Balance/Number.ts +46 -0
  388. package/src/primitives/Balance/String.ts +47 -0
  389. package/src/primitives/Balance/index.ts +44 -0
  390. package/src/primitives/Base64/Base64Schema.ts +90 -0
  391. package/src/primitives/Base64/extensions/index.ts +10 -0
  392. package/src/primitives/Base64/index.ts +28 -0
  393. package/src/primitives/BaseFeePerGas/BigInt.ts +49 -0
  394. package/src/primitives/BaseFeePerGas/Gwei.ts +63 -0
  395. package/src/primitives/BaseFeePerGas/index.ts +47 -0
  396. package/src/primitives/BaseFeePerGas/toGwei.ts +28 -0
  397. package/src/primitives/BeaconBlockRoot/Hex.ts +76 -0
  398. package/src/primitives/BeaconBlockRoot/index.ts +47 -0
  399. package/src/primitives/BinaryTree/BinaryTreeSchema.ts +34 -0
  400. package/src/primitives/BinaryTree/get.ts +28 -0
  401. package/src/primitives/BinaryTree/index.ts +27 -0
  402. package/src/primitives/BinaryTree/init.ts +23 -0
  403. package/src/primitives/BinaryTree/rootHash.ts +22 -0
  404. package/src/primitives/Blob/BlobSchema.ts +87 -0
  405. package/src/primitives/Blob/index.ts +54 -0
  406. package/src/primitives/Blob/isValid.ts +22 -0
  407. package/src/primitives/Blob/toData.ts +23 -0
  408. package/src/primitives/Block/Block.test.ts +377 -0
  409. package/src/primitives/Block/BlockSchema.ts +201 -0
  410. package/src/primitives/Block/Rpc.ts +189 -0
  411. package/src/primitives/Block/index.ts +55 -0
  412. package/src/primitives/BlockBody/BlockBody.test.ts +228 -0
  413. package/src/primitives/BlockBody/BlockBodySchema.ts +85 -0
  414. package/src/primitives/BlockBody/Rpc.ts +100 -0
  415. package/src/primitives/BlockBody/index.ts +52 -0
  416. package/src/primitives/BlockFilter/BlockFilterSchema.ts +39 -0
  417. package/src/primitives/BlockFilter/index.ts +20 -0
  418. package/src/primitives/BlockHash/BlockHashTypeSchema.ts +21 -0
  419. package/src/primitives/BlockHash/Bytes.ts +53 -0
  420. package/src/primitives/BlockHash/Hex.ts +56 -0
  421. package/src/primitives/BlockHash/index.ts +55 -0
  422. package/src/primitives/BlockHeader/BlockHeaderSchema.ts +84 -0
  423. package/src/primitives/BlockHeader/Rpc.ts +95 -0
  424. package/src/primitives/BlockHeader/calculateHash.ts +24 -0
  425. package/src/primitives/BlockHeader/index.ts +61 -0
  426. package/src/primitives/BlockNumber/BigInt.ts +51 -0
  427. package/src/primitives/BlockNumber/BlockNumber.test.ts +122 -0
  428. package/src/primitives/BlockNumber/BlockNumberTypeSchema.ts +21 -0
  429. package/src/primitives/BlockNumber/Hex.ts +56 -0
  430. package/src/primitives/BlockNumber/Number.ts +66 -0
  431. package/src/primitives/BlockNumber/index.ts +60 -0
  432. package/src/primitives/BloomFilter/BloomFilterSchema.ts +96 -0
  433. package/src/primitives/BloomFilter/extensions/index.ts +12 -0
  434. package/src/primitives/BloomFilter/index.ts +64 -0
  435. package/src/primitives/Brand/Brand.test.ts +192 -0
  436. package/src/primitives/Brand/index.ts +292 -0
  437. package/src/primitives/BuilderBid/BuilderBidSchema.ts +116 -0
  438. package/src/primitives/BuilderBid/index.ts +38 -0
  439. package/src/primitives/Bundle/BundleSchema.ts +176 -0
  440. package/src/primitives/Bundle/index.ts +43 -0
  441. package/src/primitives/BundleHash/Hex.ts +68 -0
  442. package/src/primitives/BundleHash/index.ts +30 -0
  443. package/src/primitives/Bundler/BundlerSchema.ts +77 -0
  444. package/src/primitives/Bundler/index.ts +35 -0
  445. package/src/primitives/Bytecode/Bytecode.test.ts +49 -0
  446. package/src/primitives/Bytecode/BytecodeSchema.ts +48 -0
  447. package/src/primitives/Bytecode/Bytes.ts +60 -0
  448. package/src/primitives/Bytecode/Hex.ts +61 -0
  449. package/src/primitives/Bytecode/index.ts +45 -0
  450. package/src/primitives/Bytes/Bytes.test.ts +402 -0
  451. package/src/primitives/Bytes/Bytes1/index.ts +18 -0
  452. package/src/primitives/Bytes/Bytes16/index.ts +23 -0
  453. package/src/primitives/Bytes/Bytes2/index.ts +17 -0
  454. package/src/primitives/Bytes/Bytes3/index.ts +17 -0
  455. package/src/primitives/Bytes/Bytes32/index.ts +28 -0
  456. package/src/primitives/Bytes/Bytes4/index.ts +17 -0
  457. package/src/primitives/Bytes/Bytes5/index.ts +17 -0
  458. package/src/primitives/Bytes/Bytes6/index.ts +17 -0
  459. package/src/primitives/Bytes/Bytes64/index.ts +23 -0
  460. package/src/primitives/Bytes/Bytes7/index.ts +17 -0
  461. package/src/primitives/Bytes/Bytes8/index.ts +17 -0
  462. package/src/primitives/Bytes/Hex.ts +59 -0
  463. package/src/primitives/Bytes/concat.ts +23 -0
  464. package/src/primitives/Bytes/equals.ts +26 -0
  465. package/src/primitives/Bytes/extensions/index.ts +6 -0
  466. package/src/primitives/Bytes/index.ts +79 -0
  467. package/src/primitives/Bytes/isBytes.ts +23 -0
  468. package/src/primitives/Bytes/random.ts +22 -0
  469. package/src/primitives/Bytes/size.ts +22 -0
  470. package/src/primitives/Bytes/toString.ts +24 -0
  471. package/src/primitives/Bytes32/Bytes.ts +57 -0
  472. package/src/primitives/Bytes32/Bytes32.test.ts +62 -0
  473. package/src/primitives/Bytes32/Hex.ts +57 -0
  474. package/src/primitives/Bytes32/index.ts +80 -0
  475. package/src/primitives/CallData/CallData.test.ts +35 -0
  476. package/src/primitives/CallData/Hex.ts +74 -0
  477. package/src/primitives/CallData/empty.ts +24 -0
  478. package/src/primitives/CallData/index.ts +50 -0
  479. package/src/primitives/CallTrace/CallTraceSchema.ts +38 -0
  480. package/src/primitives/CallTrace/flatten.ts +21 -0
  481. package/src/primitives/CallTrace/getCalls.ts +20 -0
  482. package/src/primitives/CallTrace/hasError.ts +22 -0
  483. package/src/primitives/CallTrace/index.ts +13 -0
  484. package/src/primitives/Chain/ChainSchema.ts +231 -0
  485. package/src/primitives/Chain/index.ts +57 -0
  486. package/src/primitives/ChainHead/ChainHeadSchema.ts +130 -0
  487. package/src/primitives/ChainHead/index.ts +53 -0
  488. package/src/primitives/ChainId/BigInt.ts +79 -0
  489. package/src/primitives/ChainId/Hex.ts +83 -0
  490. package/src/primitives/ChainId/Number.ts +78 -0
  491. package/src/primitives/ChainId/index.ts +56 -0
  492. package/src/primitives/CompilerVersion/CompilerVersionSchema.ts +42 -0
  493. package/src/primitives/CompilerVersion/index.ts +10 -0
  494. package/src/primitives/ContractCode/Bytes.ts +63 -0
  495. package/src/primitives/ContractCode/ContractCode.test.ts +45 -0
  496. package/src/primitives/ContractCode/Hex.ts +65 -0
  497. package/src/primitives/ContractCode/index.ts +51 -0
  498. package/src/primitives/ContractResult/ContractResultSchema.ts +98 -0
  499. package/src/primitives/ContractResult/index.ts +13 -0
  500. package/src/primitives/ContractSignature/ContractSignature.test.ts +111 -0
  501. package/src/primitives/ContractSignature/Struct.ts +67 -0
  502. package/src/primitives/ContractSignature/index.ts +68 -0
  503. package/src/primitives/ContractSignature/verifySignature.ts +254 -0
  504. package/src/primitives/DecodedData/DecodedDataSchema.ts +72 -0
  505. package/src/primitives/DecodedData/index.ts +11 -0
  506. package/src/primitives/Denomination/EtherSchema.ts +87 -0
  507. package/src/primitives/Denomination/GweiSchema.ts +86 -0
  508. package/src/primitives/Denomination/WeiSchema.ts +87 -0
  509. package/src/primitives/Denomination/index.ts +49 -0
  510. package/src/primitives/Domain/Domain.test.ts +80 -0
  511. package/src/primitives/Domain/Struct.ts +165 -0
  512. package/src/primitives/Domain/index.ts +62 -0
  513. package/src/primitives/DomainSeparator/DomainSeparator.test.ts +67 -0
  514. package/src/primitives/DomainSeparator/Hex.ts +105 -0
  515. package/src/primitives/DomainSeparator/index.ts +50 -0
  516. package/src/primitives/EffectiveGasPrice/BigInt.ts +47 -0
  517. package/src/primitives/EffectiveGasPrice/Gwei.ts +54 -0
  518. package/src/primitives/EffectiveGasPrice/calculate.ts +39 -0
  519. package/src/primitives/EffectiveGasPrice/compare.ts +31 -0
  520. package/src/primitives/EffectiveGasPrice/equals.ts +31 -0
  521. package/src/primitives/EffectiveGasPrice/index.ts +59 -0
  522. package/src/primitives/EffectiveGasPrice/toGwei.ts +28 -0
  523. package/src/primitives/EncodedData/EncodedDataSchema.ts +66 -0
  524. package/src/primitives/EncodedData/index.ts +11 -0
  525. package/src/primitives/Ens/String.ts +45 -0
  526. package/src/primitives/Ens/index.ts +18 -0
  527. package/src/primitives/EntryPoint/EntryPointSchema.ts +113 -0
  528. package/src/primitives/EntryPoint/index.ts +47 -0
  529. package/src/primitives/Epoch/BigInt.ts +46 -0
  530. package/src/primitives/Epoch/index.ts +18 -0
  531. package/src/primitives/ErrorSignature/ErrorSignature.test.ts +43 -0
  532. package/src/primitives/ErrorSignature/String.ts +102 -0
  533. package/src/primitives/ErrorSignature/index.ts +55 -0
  534. package/src/primitives/EventLog/EventLog.test.ts +77 -0
  535. package/src/primitives/EventLog/Rpc.ts +159 -0
  536. package/src/primitives/EventLog/extensions/index.ts +17 -0
  537. package/src/primitives/EventLog/extensions/utils.ts +18 -0
  538. package/src/primitives/EventLog/index.ts +23 -0
  539. package/src/primitives/EventSignature/EventSignature.test.ts +54 -0
  540. package/src/primitives/EventSignature/String.ts +102 -0
  541. package/src/primitives/EventSignature/index.ts +53 -0
  542. package/src/primitives/FeeMarket/FeeMarketSchema.ts +160 -0
  543. package/src/primitives/FeeMarket/index.ts +36 -0
  544. package/src/primitives/FeeOracle/Struct.ts +152 -0
  545. package/src/primitives/FeeOracle/index.ts +29 -0
  546. package/src/primitives/FilterId/Hex.ts +97 -0
  547. package/src/primitives/FilterId/index.ts +57 -0
  548. package/src/primitives/ForkId/ForkIdSchema.ts +66 -0
  549. package/src/primitives/ForkId/index.ts +34 -0
  550. package/src/primitives/ForwardRequest/ForwardRequestSchema.ts +109 -0
  551. package/src/primitives/ForwardRequest/index.ts +26 -0
  552. package/src/primitives/FunctionSignature/FunctionSignature.test.ts +34 -0
  553. package/src/primitives/FunctionSignature/String.ts +77 -0
  554. package/src/primitives/FunctionSignature/index.ts +41 -0
  555. package/src/primitives/Gas/BigInt.ts +66 -0
  556. package/src/primitives/Gas/Hex.ts +66 -0
  557. package/src/primitives/Gas/Number.ts +74 -0
  558. package/src/primitives/Gas/index.ts +51 -0
  559. package/src/primitives/GasConstants/GasConstantsSchema.ts +139 -0
  560. package/src/primitives/GasConstants/index.ts +33 -0
  561. package/src/primitives/GasCosts/GasCostsSchema.ts +113 -0
  562. package/src/primitives/GasCosts/index.ts +24 -0
  563. package/src/primitives/GasEstimate/BigInt.ts +47 -0
  564. package/src/primitives/GasEstimate/Number.ts +47 -0
  565. package/src/primitives/GasEstimate/index.ts +50 -0
  566. package/src/primitives/GasEstimate/toGasLimit.ts +34 -0
  567. package/src/primitives/GasEstimate/withBuffer.ts +38 -0
  568. package/src/primitives/GasPrice/BigInt.ts +67 -0
  569. package/src/primitives/GasPrice/Gwei.ts +70 -0
  570. package/src/primitives/GasPrice/Hex.ts +67 -0
  571. package/src/primitives/GasPrice/Number.ts +71 -0
  572. package/src/primitives/GasPrice/index.ts +57 -0
  573. package/src/primitives/GasRefund/BigInt.ts +47 -0
  574. package/src/primitives/GasRefund/Number.ts +46 -0
  575. package/src/primitives/GasRefund/cappedRefund.ts +38 -0
  576. package/src/primitives/GasRefund/index.ts +49 -0
  577. package/src/primitives/GasUsed/BigInt.ts +47 -0
  578. package/src/primitives/GasUsed/Number.ts +46 -0
  579. package/src/primitives/GasUsed/calculateCost.ts +33 -0
  580. package/src/primitives/GasUsed/index.ts +48 -0
  581. package/src/primitives/Hardfork/HardforkSchema.ts +47 -0
  582. package/src/primitives/Hardfork/index.ts +39 -0
  583. package/src/primitives/Hash/Bytes.ts +71 -0
  584. package/src/primitives/Hash/Hash.test.ts +630 -0
  585. package/src/primitives/Hash/Hex.ts +72 -0
  586. package/src/primitives/Hash/assert.ts +46 -0
  587. package/src/primitives/Hash/clone.ts +32 -0
  588. package/src/primitives/Hash/concat.ts +32 -0
  589. package/src/primitives/Hash/equals.ts +35 -0
  590. package/src/primitives/Hash/extensions/index.ts +21 -0
  591. package/src/primitives/Hash/format.ts +38 -0
  592. package/src/primitives/Hash/index.ts +65 -0
  593. package/src/primitives/Hash/isValidHex.ts +30 -0
  594. package/src/primitives/Hash/isZero.ts +32 -0
  595. package/src/primitives/Hash/keccak256.ts +54 -0
  596. package/src/primitives/Hash/merkleRoot.ts +32 -0
  597. package/src/primitives/Hash/random.ts +36 -0
  598. package/src/primitives/Hash/slice.ts +38 -0
  599. package/src/primitives/Hash/toBytes.ts +43 -0
  600. package/src/primitives/Hash/toString.ts +32 -0
  601. package/src/primitives/Hex/Bytes.ts +67 -0
  602. package/src/primitives/Hex/Hex.test.ts +478 -0
  603. package/src/primitives/Hex/String.ts +64 -0
  604. package/src/primitives/Hex/clone.ts +31 -0
  605. package/src/primitives/Hex/equals.ts +32 -0
  606. package/src/primitives/Hex/index.ts +82 -0
  607. package/src/primitives/Hex/isHex.ts +32 -0
  608. package/src/primitives/Hex/isSized.ts +34 -0
  609. package/src/primitives/Hex/random.ts +31 -0
  610. package/src/primitives/Hex/zero.ts +30 -0
  611. package/src/primitives/InitCode/Bytes.ts +62 -0
  612. package/src/primitives/InitCode/Hex.ts +64 -0
  613. package/src/primitives/InitCode/InitCode.test.ts +46 -0
  614. package/src/primitives/InitCode/index.ts +50 -0
  615. package/src/primitives/Int128/BigInt.ts +52 -0
  616. package/src/primitives/Int128/Int128.test.ts +374 -0
  617. package/src/primitives/Int128/Int128Schema.ts +13 -0
  618. package/src/primitives/Int128/Number.ts +53 -0
  619. package/src/primitives/Int128/String.ts +52 -0
  620. package/src/primitives/Int128/abs.ts +10 -0
  621. package/src/primitives/Int128/add.ts +11 -0
  622. package/src/primitives/Int128/compare.ts +13 -0
  623. package/src/primitives/Int128/constants.ts +13 -0
  624. package/src/primitives/Int128/div.ts +11 -0
  625. package/src/primitives/Int128/equals.ts +11 -0
  626. package/src/primitives/Int128/index.ts +83 -0
  627. package/src/primitives/Int128/isNegative.ts +11 -0
  628. package/src/primitives/Int128/isZero.ts +11 -0
  629. package/src/primitives/Int128/mul.ts +11 -0
  630. package/src/primitives/Int128/negate.ts +11 -0
  631. package/src/primitives/Int128/sub.ts +11 -0
  632. package/src/primitives/Int16/BigInt.ts +54 -0
  633. package/src/primitives/Int16/Int16.test.ts +285 -0
  634. package/src/primitives/Int16/Int16Schema.ts +13 -0
  635. package/src/primitives/Int16/Number.ts +52 -0
  636. package/src/primitives/Int16/String.ts +52 -0
  637. package/src/primitives/Int16/abs.ts +10 -0
  638. package/src/primitives/Int16/add.ts +11 -0
  639. package/src/primitives/Int16/compare.ts +13 -0
  640. package/src/primitives/Int16/constants.ts +10 -0
  641. package/src/primitives/Int16/div.ts +11 -0
  642. package/src/primitives/Int16/equals.ts +11 -0
  643. package/src/primitives/Int16/index.ts +80 -0
  644. package/src/primitives/Int16/isNegative.ts +11 -0
  645. package/src/primitives/Int16/isZero.ts +10 -0
  646. package/src/primitives/Int16/mul.ts +11 -0
  647. package/src/primitives/Int16/negate.ts +11 -0
  648. package/src/primitives/Int16/sub.ts +11 -0
  649. package/src/primitives/Int256/BigInt.ts +53 -0
  650. package/src/primitives/Int256/Int256.test.ts +499 -0
  651. package/src/primitives/Int256/Int256Schema.ts +14 -0
  652. package/src/primitives/Int256/Number.ts +53 -0
  653. package/src/primitives/Int256/String.ts +53 -0
  654. package/src/primitives/Int256/abs.ts +10 -0
  655. package/src/primitives/Int256/add.ts +11 -0
  656. package/src/primitives/Int256/compare.ts +13 -0
  657. package/src/primitives/Int256/constants.ts +13 -0
  658. package/src/primitives/Int256/div.ts +11 -0
  659. package/src/primitives/Int256/equals.ts +11 -0
  660. package/src/primitives/Int256/index.ts +87 -0
  661. package/src/primitives/Int256/isNegative.ts +11 -0
  662. package/src/primitives/Int256/isZero.ts +11 -0
  663. package/src/primitives/Int256/mul.ts +11 -0
  664. package/src/primitives/Int256/negate.ts +11 -0
  665. package/src/primitives/Int256/sub.ts +11 -0
  666. package/src/primitives/Int32/BigInt.ts +52 -0
  667. package/src/primitives/Int32/Int32.test.ts +267 -0
  668. package/src/primitives/Int32/Int32Schema.ts +13 -0
  669. package/src/primitives/Int32/Number.ts +52 -0
  670. package/src/primitives/Int32/String.ts +52 -0
  671. package/src/primitives/Int32/abs.ts +10 -0
  672. package/src/primitives/Int32/add.ts +11 -0
  673. package/src/primitives/Int32/compare.ts +13 -0
  674. package/src/primitives/Int32/constants.ts +10 -0
  675. package/src/primitives/Int32/div.ts +11 -0
  676. package/src/primitives/Int32/equals.ts +11 -0
  677. package/src/primitives/Int32/index.ts +80 -0
  678. package/src/primitives/Int32/isNegative.ts +11 -0
  679. package/src/primitives/Int32/isZero.ts +10 -0
  680. package/src/primitives/Int32/mul.ts +11 -0
  681. package/src/primitives/Int32/negate.ts +11 -0
  682. package/src/primitives/Int32/sub.ts +11 -0
  683. package/src/primitives/Int64/BigInt.ts +52 -0
  684. package/src/primitives/Int64/Int64.test.ts +306 -0
  685. package/src/primitives/Int64/Int64Schema.ts +13 -0
  686. package/src/primitives/Int64/Number.ts +53 -0
  687. package/src/primitives/Int64/String.ts +52 -0
  688. package/src/primitives/Int64/abs.ts +10 -0
  689. package/src/primitives/Int64/add.ts +11 -0
  690. package/src/primitives/Int64/compare.ts +13 -0
  691. package/src/primitives/Int64/constants.ts +10 -0
  692. package/src/primitives/Int64/div.ts +11 -0
  693. package/src/primitives/Int64/equals.ts +11 -0
  694. package/src/primitives/Int64/index.ts +80 -0
  695. package/src/primitives/Int64/isNegative.ts +11 -0
  696. package/src/primitives/Int64/isZero.ts +10 -0
  697. package/src/primitives/Int64/mul.ts +11 -0
  698. package/src/primitives/Int64/negate.ts +11 -0
  699. package/src/primitives/Int64/sub.ts +11 -0
  700. package/src/primitives/Int8/BigInt.ts +60 -0
  701. package/src/primitives/Int8/Int8.test.ts +477 -0
  702. package/src/primitives/Int8/Int8Schema.ts +13 -0
  703. package/src/primitives/Int8/Number.ts +58 -0
  704. package/src/primitives/Int8/String.ts +58 -0
  705. package/src/primitives/Int8/abs.ts +10 -0
  706. package/src/primitives/Int8/add.ts +11 -0
  707. package/src/primitives/Int8/compare.ts +13 -0
  708. package/src/primitives/Int8/constants.ts +10 -0
  709. package/src/primitives/Int8/div.ts +11 -0
  710. package/src/primitives/Int8/equals.ts +11 -0
  711. package/src/primitives/Int8/index.ts +80 -0
  712. package/src/primitives/Int8/isNegative.ts +11 -0
  713. package/src/primitives/Int8/isZero.ts +10 -0
  714. package/src/primitives/Int8/mul.ts +11 -0
  715. package/src/primitives/Int8/negate.ts +10 -0
  716. package/src/primitives/Int8/sub.ts +11 -0
  717. package/src/primitives/License/String.ts +57 -0
  718. package/src/primitives/License/index.ts +22 -0
  719. package/src/primitives/LogFilter/LogFilter.test.ts +81 -0
  720. package/src/primitives/LogFilter/Rpc.ts +209 -0
  721. package/src/primitives/LogFilter/index.ts +36 -0
  722. package/src/primitives/LogIndex/Number.ts +93 -0
  723. package/src/primitives/LogIndex/index.ts +38 -0
  724. package/src/primitives/MaxFeePerGas/BigInt.ts +49 -0
  725. package/src/primitives/MaxFeePerGas/Gwei.ts +63 -0
  726. package/src/primitives/MaxFeePerGas/index.ts +47 -0
  727. package/src/primitives/MaxFeePerGas/toGwei.ts +28 -0
  728. package/src/primitives/MaxPriorityFeePerGas/BigInt.ts +48 -0
  729. package/src/primitives/MaxPriorityFeePerGas/Gwei.ts +63 -0
  730. package/src/primitives/MaxPriorityFeePerGas/index.ts +51 -0
  731. package/src/primitives/MaxPriorityFeePerGas/toGwei.ts +28 -0
  732. package/src/primitives/MemoryDump/MemoryDumpSchema.ts +70 -0
  733. package/src/primitives/MemoryDump/index.ts +22 -0
  734. package/src/primitives/MerkleTree/MerkleTreeSchema.ts +52 -0
  735. package/src/primitives/MerkleTree/index.ts +39 -0
  736. package/src/primitives/Metadata/MetadataSchema.ts +57 -0
  737. package/src/primitives/Metadata/index.ts +24 -0
  738. package/src/primitives/MultiTokenId/MultiTokenIdSchema.ts +48 -0
  739. package/src/primitives/MultiTokenId/index.ts +23 -0
  740. package/src/primitives/NetworkId/BigInt.ts +79 -0
  741. package/src/primitives/NetworkId/Hex.ts +86 -0
  742. package/src/primitives/NetworkId/Number.ts +104 -0
  743. package/src/primitives/NetworkId/index.ts +60 -0
  744. package/src/primitives/NodeInfo/NodeInfoSchema.ts +70 -0
  745. package/src/primitives/NodeInfo/index.ts +39 -0
  746. package/src/primitives/Nonce/BigInt.ts +66 -0
  747. package/src/primitives/Nonce/Hex.ts +66 -0
  748. package/src/primitives/Nonce/Number.ts +74 -0
  749. package/src/primitives/Nonce/index.ts +56 -0
  750. package/src/primitives/OpStep/OpStepSchema.ts +118 -0
  751. package/src/primitives/OpStep/index.ts +29 -0
  752. package/src/primitives/Opcode/OpcodeSchema.ts +55 -0
  753. package/src/primitives/Opcode/index.ts +24 -0
  754. package/src/primitives/PackedUserOperation/PackedUserOperationSchema.ts +203 -0
  755. package/src/primitives/PackedUserOperation/hash.test.ts +103 -0
  756. package/src/primitives/PackedUserOperation/hash.ts +128 -0
  757. package/src/primitives/PackedUserOperation/index.ts +80 -0
  758. package/src/primitives/PackedUserOperation/unpack.ts +101 -0
  759. package/src/primitives/Paymaster/PaymasterSchema.ts +194 -0
  760. package/src/primitives/Paymaster/index.ts +21 -0
  761. package/src/primitives/PeerId/PeerIdSchema.ts +47 -0
  762. package/src/primitives/PeerId/index.ts +31 -0
  763. package/src/primitives/PeerInfo/PeerInfoSchema.ts +61 -0
  764. package/src/primitives/PeerInfo/index.ts +39 -0
  765. package/src/primitives/PendingTransactionFilter/Struct.ts +56 -0
  766. package/src/primitives/PendingTransactionFilter/index.ts +25 -0
  767. package/src/primitives/Permit/Permit.test.ts +32 -0
  768. package/src/primitives/Permit/Struct.ts +77 -0
  769. package/src/primitives/Permit/index.ts +58 -0
  770. package/src/primitives/PrivateKey/Bytes.ts +59 -0
  771. package/src/primitives/PrivateKey/Hex.ts +64 -0
  772. package/src/primitives/PrivateKey/PrivateKey.test.ts +410 -0
  773. package/src/primitives/PrivateKey/index.ts +62 -0
  774. package/src/primitives/PrivateKey/isValid.ts +35 -0
  775. package/src/primitives/PrivateKey/random.ts +27 -0
  776. package/src/primitives/Proof/Struct.ts +32 -0
  777. package/src/primitives/Proof/equals.ts +10 -0
  778. package/src/primitives/Proof/index.ts +37 -0
  779. package/src/primitives/Proof/verify.ts +11 -0
  780. package/src/primitives/ProtocolVersion/ProtocolVersionSchema.ts +55 -0
  781. package/src/primitives/ProtocolVersion/index.ts +32 -0
  782. package/src/primitives/Proxy/Struct.ts +49 -0
  783. package/src/primitives/Proxy/index.ts +11 -0
  784. package/src/primitives/PublicKey/Bytes.ts +68 -0
  785. package/src/primitives/PublicKey/Compressed.ts +71 -0
  786. package/src/primitives/PublicKey/Hex.ts +57 -0
  787. package/src/primitives/PublicKey/PublicKey.test.ts +443 -0
  788. package/src/primitives/PublicKey/equals.ts +30 -0
  789. package/src/primitives/PublicKey/index.ts +70 -0
  790. package/src/primitives/PublicKey/isCompressed.ts +27 -0
  791. package/src/primitives/PublicKey/isValid.ts +31 -0
  792. package/src/primitives/PublicKey/toAddress.ts +29 -0
  793. package/src/primitives/PublicKey/toBytes.ts +27 -0
  794. package/src/primitives/PublicKey/verify.ts +36 -0
  795. package/src/primitives/Receipt/ReceiptSchema.test.ts +94 -0
  796. package/src/primitives/Receipt/ReceiptSchema.ts +492 -0
  797. package/src/primitives/Receipt/index.ts +65 -0
  798. package/src/primitives/RelayData/RelayDataSchema.ts +106 -0
  799. package/src/primitives/RelayData/index.ts +10 -0
  800. package/src/primitives/ReturnData/Bytes.ts +60 -0
  801. package/src/primitives/ReturnData/Hex.ts +61 -0
  802. package/src/primitives/ReturnData/ReturnData.test.ts +43 -0
  803. package/src/primitives/ReturnData/ReturnDataSchema.ts +50 -0
  804. package/src/primitives/ReturnData/index.ts +45 -0
  805. package/src/primitives/RevertReason/Bytes.ts +81 -0
  806. package/src/primitives/RevertReason/Hex.ts +85 -0
  807. package/src/primitives/RevertReason/RevertReason.test.ts +42 -0
  808. package/src/primitives/RevertReason/RevertReasonSchema.ts +108 -0
  809. package/src/primitives/RevertReason/index.ts +67 -0
  810. package/src/primitives/RevertReason/toString.ts +28 -0
  811. package/src/primitives/Rlp/Rlp.test.ts +991 -0
  812. package/src/primitives/Rlp/RlpSchema.ts +50 -0
  813. package/src/primitives/Rlp/decode.ts +57 -0
  814. package/src/primitives/Rlp/decodeArray.ts +48 -0
  815. package/src/primitives/Rlp/encode.ts +58 -0
  816. package/src/primitives/Rlp/encodeArray.ts +32 -0
  817. package/src/primitives/Rlp/encodeBytes.ts +27 -0
  818. package/src/primitives/Rlp/encodeList.ts +32 -0
  819. package/src/primitives/Rlp/flatten.ts +38 -0
  820. package/src/primitives/Rlp/index.ts +74 -0
  821. package/src/primitives/Rlp/validate.ts +25 -0
  822. package/src/primitives/RuntimeCode/Bytes.ts +60 -0
  823. package/src/primitives/RuntimeCode/Hex.ts +61 -0
  824. package/src/primitives/RuntimeCode/RuntimeCode.test.ts +43 -0
  825. package/src/primitives/RuntimeCode/RuntimeCodeSchema.ts +49 -0
  826. package/src/primitives/RuntimeCode/index.ts +46 -0
  827. package/src/primitives/Selector/Bytes.ts +64 -0
  828. package/src/primitives/Selector/Hex.ts +69 -0
  829. package/src/primitives/Selector/Selector.test.ts +258 -0
  830. package/src/primitives/Selector/SelectorSchema.ts +95 -0
  831. package/src/primitives/Selector/Signature.ts +65 -0
  832. package/src/primitives/Selector/equals.ts +33 -0
  833. package/src/primitives/Selector/index.ts +55 -0
  834. package/src/primitives/Signature/Bytes.ts +57 -0
  835. package/src/primitives/Signature/Compact.ts +59 -0
  836. package/src/primitives/Signature/DER.ts +65 -0
  837. package/src/primitives/Signature/Hex.ts +56 -0
  838. package/src/primitives/Signature/Rpc.ts +77 -0
  839. package/src/primitives/Signature/Signature.test.ts +496 -0
  840. package/src/primitives/Signature/SignatureSchema.ts +30 -0
  841. package/src/primitives/Signature/Tuple.ts +75 -0
  842. package/src/primitives/Signature/equals.ts +25 -0
  843. package/src/primitives/Signature/getAlgorithm.ts +29 -0
  844. package/src/primitives/Signature/index.ts +93 -0
  845. package/src/primitives/Signature/is.ts +26 -0
  846. package/src/primitives/Signature/isCanonical.ts +28 -0
  847. package/src/primitives/Signature/isSignature.ts +26 -0
  848. package/src/primitives/Signature/normalize.ts +24 -0
  849. package/src/primitives/Signature/toBytes.ts +24 -0
  850. package/src/primitives/Signature/toCompact.ts +26 -0
  851. package/src/primitives/SignedData/SignedDataSchema.ts +61 -0
  852. package/src/primitives/SignedData/index.ts +26 -0
  853. package/src/primitives/Siwe/Siwe.test.ts +42 -0
  854. package/src/primitives/Siwe/String.ts +136 -0
  855. package/src/primitives/Siwe/index.ts +55 -0
  856. package/src/primitives/Slot/SlotSchema.ts +51 -0
  857. package/src/primitives/Slot/index.ts +20 -0
  858. package/src/primitives/SourceMap/Struct.ts +94 -0
  859. package/src/primitives/SourceMap/index.ts +12 -0
  860. package/src/primitives/Ssz/SszSchema.ts +49 -0
  861. package/src/primitives/Ssz/index.ts +29 -0
  862. package/src/primitives/State/StateSchema.ts +112 -0
  863. package/src/primitives/State/index.ts +22 -0
  864. package/src/primitives/StateDiff/StateDiffSchema.ts +251 -0
  865. package/src/primitives/StateDiff/index.ts +28 -0
  866. package/src/primitives/StateProof/StateProofSchema.ts +109 -0
  867. package/src/primitives/StateProof/index.ts +66 -0
  868. package/src/primitives/StateRoot/StateRootSchema.ts +109 -0
  869. package/src/primitives/StateRoot/index.ts +78 -0
  870. package/src/primitives/StealthAddress/Struct.ts +48 -0
  871. package/src/primitives/StealthAddress/index.ts +6 -0
  872. package/src/primitives/Storage/StorageSchema.ts +100 -0
  873. package/src/primitives/Storage/index.ts +53 -0
  874. package/src/primitives/StorageDiff/StorageDiffSchema.ts +111 -0
  875. package/src/primitives/StorageDiff/index.ts +59 -0
  876. package/src/primitives/StorageProof/Struct.ts +93 -0
  877. package/src/primitives/StorageProof/equals.ts +72 -0
  878. package/src/primitives/StorageProof/index.ts +67 -0
  879. package/src/primitives/StorageValue/Hex.ts +109 -0
  880. package/src/primitives/StorageValue/index.ts +92 -0
  881. package/src/primitives/StructLog/Struct.ts +101 -0
  882. package/src/primitives/StructLog/index.ts +28 -0
  883. package/src/primitives/SyncStatus/SyncStatusSchema.ts +87 -0
  884. package/src/primitives/SyncStatus/index.ts +36 -0
  885. package/src/primitives/TokenBalance/Struct.ts +48 -0
  886. package/src/primitives/TokenBalance/index.ts +23 -0
  887. package/src/primitives/TokenId/BigInt.ts +50 -0
  888. package/src/primitives/TokenId/index.ts +36 -0
  889. package/src/primitives/TopicFilter/Rpc.ts +142 -0
  890. package/src/primitives/TopicFilter/TopicFilter.test.ts +22 -0
  891. package/src/primitives/TopicFilter/index.ts +29 -0
  892. package/src/primitives/TraceConfig/TraceConfigSchema.ts +104 -0
  893. package/src/primitives/TraceConfig/index.ts +22 -0
  894. package/src/primitives/TraceResult/TraceResultSchema.ts +96 -0
  895. package/src/primitives/TraceResult/index.ts +23 -0
  896. package/src/primitives/Transaction/Authorization/index.ts +5 -0
  897. package/src/primitives/Transaction/EIP1559/index.ts +17 -0
  898. package/src/primitives/Transaction/EIP2930/index.ts +16 -0
  899. package/src/primitives/Transaction/EIP4844/index.ts +18 -0
  900. package/src/primitives/Transaction/EIP7702/index.ts +17 -0
  901. package/src/primitives/Transaction/Legacy/index.ts +17 -0
  902. package/src/primitives/Transaction/Rpc.ts +176 -0
  903. package/src/primitives/Transaction/Serialized.ts +98 -0
  904. package/src/primitives/Transaction/Transaction.test.ts +1562 -0
  905. package/src/primitives/Transaction/TransactionSchema.ts +515 -0
  906. package/src/primitives/Transaction/index.ts +289 -0
  907. package/src/primitives/TransactionHash/Bytes.ts +56 -0
  908. package/src/primitives/TransactionHash/Hex.ts +62 -0
  909. package/src/primitives/TransactionHash/index.ts +58 -0
  910. package/src/primitives/TransactionIndex/Number.ts +59 -0
  911. package/src/primitives/TransactionIndex/index.ts +53 -0
  912. package/src/primitives/TransactionStatus/TransactionStatusSchema.ts +57 -0
  913. package/src/primitives/TransactionStatus/index.ts +9 -0
  914. package/src/primitives/TransactionUrl/TransactionUrlSchema.ts +54 -0
  915. package/src/primitives/TransactionUrl/index.ts +21 -0
  916. package/src/primitives/TypedData/Struct.ts +194 -0
  917. package/src/primitives/TypedData/TypedData.test.ts +63 -0
  918. package/src/primitives/TypedData/index.ts +54 -0
  919. package/src/primitives/U256/index.ts +71 -0
  920. package/src/primitives/Uint/BigInt.ts +60 -0
  921. package/src/primitives/Uint/Bytes.ts +62 -0
  922. package/src/primitives/Uint/Hex.ts +61 -0
  923. package/src/primitives/Uint/Number.ts +61 -0
  924. package/src/primitives/Uint/String.ts +57 -0
  925. package/src/primitives/Uint/Uint.test.ts +838 -0
  926. package/src/primitives/Uint/bitLength.ts +22 -0
  927. package/src/primitives/Uint/bitwiseAnd.ts +24 -0
  928. package/src/primitives/Uint/bitwiseNot.ts +23 -0
  929. package/src/primitives/Uint/bitwiseOr.ts +24 -0
  930. package/src/primitives/Uint/bitwiseXor.ts +24 -0
  931. package/src/primitives/Uint/clone.ts +22 -0
  932. package/src/primitives/Uint/equals.ts +24 -0
  933. package/src/primitives/Uint/gcd.ts +24 -0
  934. package/src/primitives/Uint/greaterThan.ts +24 -0
  935. package/src/primitives/Uint/greaterThanOrEqual.ts +24 -0
  936. package/src/primitives/Uint/index.ts +85 -0
  937. package/src/primitives/Uint/isPowerOf2.ts +23 -0
  938. package/src/primitives/Uint/isZero.ts +22 -0
  939. package/src/primitives/Uint/lcm.ts +24 -0
  940. package/src/primitives/Uint/leadingZeros.ts +24 -0
  941. package/src/primitives/Uint/lessThan.ts +24 -0
  942. package/src/primitives/Uint/lessThanOrEqual.ts +24 -0
  943. package/src/primitives/Uint/max.ts +24 -0
  944. package/src/primitives/Uint/maximum.ts +27 -0
  945. package/src/primitives/Uint/min.ts +24 -0
  946. package/src/primitives/Uint/minimum.ts +27 -0
  947. package/src/primitives/Uint/minus.ts +27 -0
  948. package/src/primitives/Uint/notEquals.ts +24 -0
  949. package/src/primitives/Uint/plus.ts +27 -0
  950. package/src/primitives/Uint/popCount.ts +24 -0
  951. package/src/primitives/Uint/product.ts +24 -0
  952. package/src/primitives/Uint/shiftLeft.ts +24 -0
  953. package/src/primitives/Uint/shiftRight.ts +24 -0
  954. package/src/primitives/Uint/sum.ts +24 -0
  955. package/src/primitives/Uint/times.ts +27 -0
  956. package/src/primitives/Uint/toAbiEncoded.ts +24 -0
  957. package/src/primitives/Uint/toBigInt.ts +25 -0
  958. package/src/primitives/Uint/toBytes.ts +25 -0
  959. package/src/primitives/Uint/toNumber.ts +28 -0
  960. package/src/primitives/Uint/toPower.ts +29 -0
  961. package/src/primitives/Uint/toString.ts +31 -0
  962. package/src/primitives/Uint128/BigInt.ts +54 -0
  963. package/src/primitives/Uint128/Bytes.ts +56 -0
  964. package/src/primitives/Uint128/Hex.ts +55 -0
  965. package/src/primitives/Uint128/Number.ts +59 -0
  966. package/src/primitives/Uint128/String.ts +55 -0
  967. package/src/primitives/Uint128/Uint128Schema.ts +119 -0
  968. package/src/primitives/Uint128/index.ts +71 -0
  969. package/src/primitives/Uint16/BigInt.ts +57 -0
  970. package/src/primitives/Uint16/Bytes.ts +55 -0
  971. package/src/primitives/Uint16/Hex.ts +55 -0
  972. package/src/primitives/Uint16/Number.ts +55 -0
  973. package/src/primitives/Uint16/String.ts +55 -0
  974. package/src/primitives/Uint16/Uint16.test.ts +313 -0
  975. package/src/primitives/Uint16/Uint16Schema.ts +117 -0
  976. package/src/primitives/Uint16/index.ts +70 -0
  977. package/src/primitives/Uint32/BigInt.ts +55 -0
  978. package/src/primitives/Uint32/Bytes.ts +55 -0
  979. package/src/primitives/Uint32/Hex.ts +55 -0
  980. package/src/primitives/Uint32/Number.ts +55 -0
  981. package/src/primitives/Uint32/String.ts +55 -0
  982. package/src/primitives/Uint32/Uint32Schema.ts +122 -0
  983. package/src/primitives/Uint32/index.ts +70 -0
  984. package/src/primitives/Uint64/BigInt.ts +55 -0
  985. package/src/primitives/Uint64/Bytes.ts +56 -0
  986. package/src/primitives/Uint64/Hex.ts +55 -0
  987. package/src/primitives/Uint64/Number.ts +59 -0
  988. package/src/primitives/Uint64/String.ts +55 -0
  989. package/src/primitives/Uint64/Uint64Schema.ts +122 -0
  990. package/src/primitives/Uint64/index.ts +71 -0
  991. package/src/primitives/Uint8/BigInt.ts +57 -0
  992. package/src/primitives/Uint8/Bytes.ts +55 -0
  993. package/src/primitives/Uint8/Hex.ts +55 -0
  994. package/src/primitives/Uint8/Number.ts +55 -0
  995. package/src/primitives/Uint8/String.ts +55 -0
  996. package/src/primitives/Uint8/Uint8.test.ts +324 -0
  997. package/src/primitives/Uint8/Uint8Schema.ts +117 -0
  998. package/src/primitives/Uint8/index.ts +70 -0
  999. package/src/primitives/Uncle/Rpc.ts +49 -0
  1000. package/src/primitives/Uncle/index.ts +11 -0
  1001. package/src/primitives/UserOperation/UserOperationSchema.ts +213 -0
  1002. package/src/primitives/UserOperation/index.ts +81 -0
  1003. package/src/primitives/ValidatorIndex/ValidatorIndexSchema.ts +44 -0
  1004. package/src/primitives/ValidatorIndex/index.ts +20 -0
  1005. package/src/primitives/Withdrawal/WithdrawalSchema.ts +47 -0
  1006. package/src/primitives/Withdrawal/index.ts +20 -0
  1007. package/src/primitives/WithdrawalIndex/WithdrawalIndexSchema.ts +47 -0
  1008. package/src/primitives/WithdrawalIndex/index.ts +20 -0
  1009. package/src/primitives/errors/index.ts +1 -0
  1010. package/src/primitives/index.ts +143 -0
  1011. package/src/primitives/validation/assertCommon.ts +40 -0
  1012. package/src/primitives/validation/assertInRange.ts +60 -0
  1013. package/src/primitives/validation/assertInt.ts +121 -0
  1014. package/src/primitives/validation/assertSize.ts +68 -0
  1015. package/src/primitives/validation/assertUint.ts +114 -0
  1016. package/src/primitives/validation/index.ts +23 -0
  1017. package/src/services/AbiEncoder/AbiEncoder.test.ts +190 -0
  1018. package/src/services/AbiEncoder/AbiEncoderService.ts +141 -0
  1019. package/src/services/AbiEncoder/DefaultAbiEncoder.ts +186 -0
  1020. package/src/services/AbiEncoder/index.ts +14 -0
  1021. package/src/services/Account/Account.test.ts +756 -0
  1022. package/src/services/Account/AccountService.ts +453 -0
  1023. package/src/services/Account/JsonRpcAccount.ts +347 -0
  1024. package/src/services/Account/LocalAccount.ts +967 -0
  1025. package/src/services/Account/fromMnemonic.test.ts +67 -0
  1026. package/src/services/Account/fromMnemonic.ts +221 -0
  1027. package/src/services/Account/index.ts +65 -0
  1028. package/src/services/Account/toAccount.test.ts +139 -0
  1029. package/src/services/Account/toAccount.ts +185 -0
  1030. package/src/services/BlockStream/BlockStream.test.ts +1246 -0
  1031. package/src/services/BlockStream/BlockStream.ts +125 -0
  1032. package/src/services/BlockStream/BlockStreamError.ts +33 -0
  1033. package/src/services/BlockStream/BlockStreamService.ts +105 -0
  1034. package/src/services/BlockStream/index.ts +32 -0
  1035. package/src/services/Cache/CacheService.ts +102 -0
  1036. package/src/services/Cache/LookupCacheService.test.ts +305 -0
  1037. package/src/services/Cache/LookupCacheService.ts +209 -0
  1038. package/src/services/Cache/MemoryCache.test.ts +154 -0
  1039. package/src/services/Cache/MemoryCache.ts +175 -0
  1040. package/src/services/Cache/NoopCache.test.ts +159 -0
  1041. package/src/services/Cache/NoopCache.ts +81 -0
  1042. package/src/services/Cache/index.ts +176 -0
  1043. package/src/services/Ccip/Ccip.test.ts +569 -0
  1044. package/src/services/Ccip/CcipService.ts +106 -0
  1045. package/src/services/Ccip/DefaultCcip.ts +189 -0
  1046. package/src/services/Ccip/NoopCcip.ts +52 -0
  1047. package/src/services/Ccip/index.ts +20 -0
  1048. package/src/services/Chain/BlockExplorerService.ts +39 -0
  1049. package/src/services/Chain/Chain.test.ts +296 -0
  1050. package/src/services/Chain/ChainService.ts +97 -0
  1051. package/src/services/Chain/ContractsService.ts +46 -0
  1052. package/src/services/Chain/chains/arbitrum.ts +73 -0
  1053. package/src/services/Chain/chains/base.ts +73 -0
  1054. package/src/services/Chain/chains/index.ts +48 -0
  1055. package/src/services/Chain/chains/mainnet.ts +77 -0
  1056. package/src/services/Chain/chains/optimism.ts +73 -0
  1057. package/src/services/Chain/chains/polygon.ts +73 -0
  1058. package/src/services/Chain/chains/sepolia.ts +78 -0
  1059. package/src/services/Chain/index.ts +77 -0
  1060. package/src/services/Chain/rpcUrls.ts +31 -0
  1061. package/src/services/Contract/Contract.test.ts +988 -0
  1062. package/src/services/Contract/Contract.ts +432 -0
  1063. package/src/services/Contract/ContractTypes.ts +412 -0
  1064. package/src/services/Contract/estimateGas.test.ts +124 -0
  1065. package/src/services/Contract/estimateGas.ts +163 -0
  1066. package/src/services/Contract/index.ts +67 -0
  1067. package/src/services/Debug/Debug.ts +121 -0
  1068. package/src/services/Debug/DebugService.ts +89 -0
  1069. package/src/services/Debug/index.ts +13 -0
  1070. package/src/services/EngineApi/EngineApi.ts +95 -0
  1071. package/src/services/EngineApi/EngineApiService.ts +99 -0
  1072. package/src/services/EngineApi/index.ts +9 -0
  1073. package/src/services/Ens/DefaultEns.ts +60 -0
  1074. package/src/services/Ens/EnsService.ts +66 -0
  1075. package/src/services/Ens/index.ts +61 -0
  1076. package/src/services/FeeEstimator/DefaultFeeEstimator.ts +277 -0
  1077. package/src/services/FeeEstimator/FeeEstimator.test.ts +810 -0
  1078. package/src/services/FeeEstimator/FeeEstimatorService.ts +168 -0
  1079. package/src/services/FeeEstimator/index.ts +57 -0
  1080. package/src/services/Formatter/DefaultFormatter.ts +74 -0
  1081. package/src/services/Formatter/Formatter.test.ts +92 -0
  1082. package/src/services/Formatter/FormatterService.ts +137 -0
  1083. package/src/services/Formatter/chains/arbitrum.ts +35 -0
  1084. package/src/services/Formatter/chains/chains.test.ts +102 -0
  1085. package/src/services/Formatter/chains/index.ts +13 -0
  1086. package/src/services/Formatter/chains/optimism.ts +36 -0
  1087. package/src/services/Formatter/chains/zksync.ts +35 -0
  1088. package/src/services/Formatter/index.ts +22 -0
  1089. package/src/services/Kzg/DefaultKzg.ts +111 -0
  1090. package/src/services/Kzg/Kzg.test.ts +320 -0
  1091. package/src/services/Kzg/KzgService.ts +123 -0
  1092. package/src/services/Kzg/NoopKzg.ts +75 -0
  1093. package/src/services/Kzg/index.ts +15 -0
  1094. package/src/services/Multicall/BalanceResolver.ts +182 -0
  1095. package/src/services/Multicall/GetBalance.ts +27 -0
  1096. package/src/services/Multicall/Multicall.test.ts +384 -0
  1097. package/src/services/Multicall/Multicall.ts +241 -0
  1098. package/src/services/Multicall/index.ts +20 -0
  1099. package/src/services/NonceManager/DefaultNonceManager.ts +154 -0
  1100. package/src/services/NonceManager/NonceManager.test.ts +468 -0
  1101. package/src/services/NonceManager/NonceManagerService.ts +191 -0
  1102. package/src/services/NonceManager/index.ts +46 -0
  1103. package/src/services/Provider/Account.ts +33 -0
  1104. package/src/services/Provider/AccountService.ts +84 -0
  1105. package/src/services/Provider/Blocks.ts +32 -0
  1106. package/src/services/Provider/BlocksService.ts +73 -0
  1107. package/src/services/Provider/Events.ts +33 -0
  1108. package/src/services/Provider/EventsService.ts +71 -0
  1109. package/src/services/Provider/Network.ts +41 -0
  1110. package/src/services/Provider/NetworkService.ts +114 -0
  1111. package/src/services/Provider/Provider.test.ts +1723 -0
  1112. package/src/services/Provider/Provider.ts +1193 -0
  1113. package/src/services/Provider/ProviderService.ts +1218 -0
  1114. package/src/services/Provider/REFACTOR_PLAN.md +203 -0
  1115. package/src/services/Provider/Simulation.ts +34 -0
  1116. package/src/services/Provider/SimulationService.ts +161 -0
  1117. package/src/services/Provider/Streaming.ts +30 -0
  1118. package/src/services/Provider/StreamingService.ts +58 -0
  1119. package/src/services/Provider/Transaction.ts +39 -0
  1120. package/src/services/Provider/TransactionService.ts +83 -0
  1121. package/src/services/Provider/actions/index.ts +26 -0
  1122. package/src/services/Provider/actions/multicall.test.ts +716 -0
  1123. package/src/services/Provider/actions/multicall.ts +304 -0
  1124. package/src/services/Provider/actions/readContract.test.ts +808 -0
  1125. package/src/services/Provider/actions/readContract.ts +311 -0
  1126. package/src/services/Provider/actions/simulateContract.test.ts +454 -0
  1127. package/src/services/Provider/actions/simulateContract.ts +189 -0
  1128. package/src/services/Provider/ens/EnsError.ts +38 -0
  1129. package/src/services/Provider/ens/constants.ts +81 -0
  1130. package/src/services/Provider/ens/ens.test.ts +322 -0
  1131. package/src/services/Provider/ens/getEnsAddress.ts +126 -0
  1132. package/src/services/Provider/ens/getEnsAvatar.ts +51 -0
  1133. package/src/services/Provider/ens/getEnsName.ts +124 -0
  1134. package/src/services/Provider/ens/getEnsResolver.ts +82 -0
  1135. package/src/services/Provider/ens/getEnsText.ts +158 -0
  1136. package/src/services/Provider/ens/index.ts +49 -0
  1137. package/src/services/Provider/ens/utils.ts +165 -0
  1138. package/src/services/Provider/filters.ts +91 -0
  1139. package/src/services/Provider/getBlobBaseFee.ts +170 -0
  1140. package/src/services/Provider/index.ts +213 -0
  1141. package/src/services/Provider/simulateCalls.test.ts +127 -0
  1142. package/src/services/Provider/simulateCalls.ts +281 -0
  1143. package/src/services/RateLimiter/DefaultRateLimiter.ts +226 -0
  1144. package/src/services/RateLimiter/RateLimiter.test.ts +181 -0
  1145. package/src/services/RateLimiter/RateLimiterService.ts +208 -0
  1146. package/src/services/RateLimiter/index.ts +54 -0
  1147. package/src/services/RawProvider/ForkProviderTransport.ts +100 -0
  1148. package/src/services/RawProvider/HttpProviderTransport.test.ts +310 -0
  1149. package/src/services/RawProvider/HttpProviderTransport.ts +76 -0
  1150. package/src/services/RawProvider/InMemoryProviderTransport.test.ts +246 -0
  1151. package/src/services/RawProvider/InMemoryProviderTransport.ts +81 -0
  1152. package/src/services/RawProvider/RawProvider.test.ts +454 -0
  1153. package/src/services/RawProvider/RawProviderService.ts +61 -0
  1154. package/src/services/RawProvider/RawProviderTransport.ts +64 -0
  1155. package/src/services/RawProvider/WebSocketProviderTransport.ts +106 -0
  1156. package/src/services/RawProvider/index.ts +31 -0
  1157. package/src/services/RpcBatch/RpcBatch.test.ts +628 -0
  1158. package/src/services/RpcBatch/RpcRequest.ts +227 -0
  1159. package/src/services/RpcBatch/RpcResolver.test.ts +315 -0
  1160. package/src/services/RpcBatch/RpcResolver.ts +362 -0
  1161. package/src/services/RpcBatch/index.ts +88 -0
  1162. package/src/services/Signer/Signer.test.ts +1629 -0
  1163. package/src/services/Signer/Signer.ts +812 -0
  1164. package/src/services/Signer/SignerService.ts +518 -0
  1165. package/src/services/Signer/actions/addChain.test.ts +178 -0
  1166. package/src/services/Signer/actions/addChain.ts +80 -0
  1167. package/src/services/Signer/actions/deployContract.test.ts +523 -0
  1168. package/src/services/Signer/actions/deployContract.ts +165 -0
  1169. package/src/services/Signer/actions/getAddresses.test.ts +118 -0
  1170. package/src/services/Signer/actions/getAddresses.ts +60 -0
  1171. package/src/services/Signer/actions/getPermissions.test.ts +122 -0
  1172. package/src/services/Signer/actions/getPermissions.ts +54 -0
  1173. package/src/services/Signer/actions/index.ts +49 -0
  1174. package/src/services/Signer/actions/prepareAuthorization.test.ts +206 -0
  1175. package/src/services/Signer/actions/prepareAuthorization.ts +92 -0
  1176. package/src/services/Signer/actions/requestPermissions.test.ts +164 -0
  1177. package/src/services/Signer/actions/requestPermissions.ts +66 -0
  1178. package/src/services/Signer/actions/signAuthorization.test.ts +279 -0
  1179. package/src/services/Signer/actions/signAuthorization.ts +127 -0
  1180. package/src/services/Signer/actions/switchChain.test.ts +129 -0
  1181. package/src/services/Signer/actions/switchChain.ts +56 -0
  1182. package/src/services/Signer/actions/watchAsset.test.ts +175 -0
  1183. package/src/services/Signer/actions/watchAsset.ts +110 -0
  1184. package/src/services/Signer/actions/writeContract.test.ts +281 -0
  1185. package/src/services/Signer/actions/writeContract.ts +109 -0
  1186. package/src/services/Signer/index.ts +108 -0
  1187. package/src/services/TransactionSerializer/DefaultTransactionSerializer.ts +110 -0
  1188. package/src/services/TransactionSerializer/TransactionSerializer.test.ts +200 -0
  1189. package/src/services/TransactionSerializer/TransactionSerializerService.ts +114 -0
  1190. package/src/services/TransactionSerializer/index.ts +38 -0
  1191. package/src/services/Transport/BatchScheduler.test.ts +209 -0
  1192. package/src/services/Transport/BatchScheduler.ts +298 -0
  1193. package/src/services/Transport/BrowserTransport.test.ts +354 -0
  1194. package/src/services/Transport/BrowserTransport.ts +209 -0
  1195. package/src/services/Transport/CustomTransport.test.ts +331 -0
  1196. package/src/services/Transport/CustomTransport.ts +355 -0
  1197. package/src/services/Transport/FallbackTransport.test.ts +492 -0
  1198. package/src/services/Transport/FallbackTransport.ts +240 -0
  1199. package/src/services/Transport/HttpTransport.ts +685 -0
  1200. package/src/services/Transport/HttpTransportConfig.test.ts +153 -0
  1201. package/src/services/Transport/HttpTransportConfig.ts +270 -0
  1202. package/src/services/Transport/HttpTransportHooks.test.ts +176 -0
  1203. package/src/services/Transport/IdGenerator.test.ts +117 -0
  1204. package/src/services/Transport/IdGenerator.ts +82 -0
  1205. package/src/services/Transport/IpcTransport.test.ts +222 -0
  1206. package/src/services/Transport/IpcTransport.ts +732 -0
  1207. package/src/services/Transport/RateLimitedTransport.test.ts +118 -0
  1208. package/src/services/Transport/RateLimitedTransport.ts +124 -0
  1209. package/src/services/Transport/RpcRequest.test.ts +266 -0
  1210. package/src/services/Transport/RpcRequest.ts +312 -0
  1211. package/src/services/Transport/RpcResolver.test.ts +280 -0
  1212. package/src/services/Transport/RpcResolver.ts +184 -0
  1213. package/src/services/Transport/TestTransport.ts +175 -0
  1214. package/src/services/Transport/Transport.test.ts +1755 -0
  1215. package/src/services/Transport/TransportConfig.test.ts +224 -0
  1216. package/src/services/Transport/TransportConfig.ts +285 -0
  1217. package/src/services/Transport/TransportError.test.ts +166 -0
  1218. package/src/services/Transport/TransportError.ts +134 -0
  1219. package/src/services/Transport/TransportFiberRef.test.ts +164 -0
  1220. package/src/services/Transport/TransportInterceptor.test.ts +341 -0
  1221. package/src/services/Transport/TransportInterceptor.ts +531 -0
  1222. package/src/services/Transport/TransportService.ts +124 -0
  1223. package/src/services/Transport/WebSocketTransport.test.ts +588 -0
  1224. package/src/services/Transport/WebSocketTransport.ts +765 -0
  1225. package/src/services/Transport/WebSocketTransportConfig.test.ts +185 -0
  1226. package/src/services/Transport/WebSocketTransportConfig.ts +247 -0
  1227. package/src/services/Transport/__testUtils__/mockIpcSocket.ts +106 -0
  1228. package/src/services/Transport/__testUtils__/mockWebSocket.ts +138 -0
  1229. package/src/services/Transport/config.ts +150 -0
  1230. package/src/services/Transport/index.ts +161 -0
  1231. package/src/services/errors.test.ts +570 -0
  1232. package/src/services/index.ts +439 -0
  1233. package/src/services/presets/index.ts +283 -0
  1234. package/src/services/presets/presets.test.ts +88 -0
  1235. package/src/standards/ERC1155.test.ts +324 -0
  1236. package/src/standards/ERC1155.ts +328 -0
  1237. package/src/standards/ERC165.test.ts +216 -0
  1238. package/src/standards/ERC165.ts +87 -0
  1239. package/src/standards/ERC20.test.ts +310 -0
  1240. package/src/standards/ERC20.ts +275 -0
  1241. package/src/standards/ERC721.test.ts +343 -0
  1242. package/src/standards/ERC721.ts +319 -0
  1243. package/src/standards/errors.test.ts +54 -0
  1244. package/src/standards/errors.ts +7 -0
  1245. package/src/standards/index.ts +5 -0
  1246. package/src/stream/index.test.ts +216 -0
  1247. package/src/stream/index.ts +37 -0
  1248. package/src/transaction/TransactionStream.test.ts +887 -0
  1249. package/src/transaction/TransactionStream.ts +142 -0
  1250. package/src/transaction/TransactionStreamError.test.ts +133 -0
  1251. package/src/transaction/TransactionStreamError.ts +35 -0
  1252. package/src/transaction/TransactionStreamService.ts +121 -0
  1253. package/src/transaction/index.ts +35 -0
  1254. package/src/utils/Unit/Unit.test.ts +337 -0
  1255. package/src/utils/Unit/errors.ts +16 -0
  1256. package/src/utils/Unit/formatEther.ts +24 -0
  1257. package/src/utils/Unit/formatGwei.ts +24 -0
  1258. package/src/utils/Unit/formatUnits.ts +55 -0
  1259. package/src/utils/Unit/index.ts +49 -0
  1260. package/src/utils/Unit/parseEther.ts +24 -0
  1261. package/src/utils/Unit/parseGwei.ts +24 -0
  1262. package/src/utils/Unit/parseUnits.ts +68 -0
@@ -0,0 +1,1562 @@
1
+ import { describe, expect, it } from "@effect/vitest";
2
+ import type { AddressType } from "@tevm/voltaire/Address";
3
+ import type { HashType } from "@tevm/voltaire/Hash";
4
+ import * as S from "effect/Schema";
5
+ import * as Transaction from "./index.js";
6
+
7
+ function createAddress(byte: number): AddressType {
8
+ const addr = new Uint8Array(20);
9
+ addr.fill(byte);
10
+ return addr as AddressType;
11
+ }
12
+
13
+ function createHash(byte: number): HashType {
14
+ const hash = new Uint8Array(32);
15
+ hash.fill(byte);
16
+ return hash as HashType;
17
+ }
18
+
19
+ function createBytes(length: number, fill = 0): Uint8Array {
20
+ const bytes = new Uint8Array(length);
21
+ bytes.fill(fill);
22
+ return bytes;
23
+ }
24
+
25
+ const testAddress = createAddress(0x42);
26
+ const testSignature = {
27
+ r: createBytes(32, 1),
28
+ s: createBytes(32, 2),
29
+ };
30
+
31
+ describe("Transaction.Serialized", () => {
32
+ describe("Legacy transactions", () => {
33
+ const legacyTx: Transaction.Legacy = {
34
+ type: Transaction.Type.Legacy,
35
+ nonce: 5n,
36
+ gasPrice: 25000000000n,
37
+ gasLimit: 50000n,
38
+ to: testAddress,
39
+ value: 100n,
40
+ data: new Uint8Array([1, 2, 3]),
41
+ v: 27n,
42
+ r: testSignature.r,
43
+ s: testSignature.s,
44
+ };
45
+
46
+ it("serializes and deserializes legacy transaction", () => {
47
+ const bytes = S.encodeSync(Transaction.Serialized)(legacyTx);
48
+ expect(bytes).toBeInstanceOf(Uint8Array);
49
+ expect(bytes.length).toBeGreaterThan(0);
50
+
51
+ const decoded = S.decodeSync(Transaction.Serialized)(bytes);
52
+ expect(decoded.type).toBe(Transaction.Type.Legacy);
53
+ expect(decoded.nonce).toBe(legacyTx.nonce);
54
+ expect((decoded as Transaction.Legacy).gasPrice).toBe(legacyTx.gasPrice);
55
+ expect(decoded.gasLimit).toBe(legacyTx.gasLimit);
56
+ expect(decoded.value).toBe(legacyTx.value);
57
+ });
58
+
59
+ it("handles contract creation (to: null)", () => {
60
+ const contractTx: Transaction.Legacy = {
61
+ ...legacyTx,
62
+ to: null,
63
+ data: new Uint8Array([0x60, 0x80, 0x60, 0x40]),
64
+ };
65
+ const bytes = S.encodeSync(Transaction.Serialized)(contractTx);
66
+ const decoded = S.decodeSync(Transaction.Serialized)(bytes);
67
+ expect(decoded.to).toBeNull();
68
+ });
69
+
70
+ it("round-trips empty data", () => {
71
+ const tx: Transaction.Legacy = { ...legacyTx, data: new Uint8Array() };
72
+ const bytes = S.encodeSync(Transaction.Serialized)(tx);
73
+ const decoded = S.decodeSync(Transaction.Serialized)(bytes);
74
+ expect(decoded.data.length).toBe(0);
75
+ });
76
+ });
77
+
78
+ describe("EIP-2930 transactions", () => {
79
+ const eip2930Tx: Transaction.EIP2930 = {
80
+ type: Transaction.Type.EIP2930,
81
+ chainId: 1n,
82
+ nonce: 0n,
83
+ gasPrice: 20000000000n,
84
+ gasLimit: 21000n,
85
+ to: testAddress,
86
+ value: 1000000000000000000n,
87
+ data: new Uint8Array(),
88
+ accessList: [
89
+ {
90
+ address: testAddress,
91
+ storageKeys: [createHash(0x11)],
92
+ },
93
+ ],
94
+ yParity: 0,
95
+ r: testSignature.r,
96
+ s: testSignature.s,
97
+ };
98
+
99
+ it("serializes and deserializes EIP-2930 transaction", () => {
100
+ const bytes = S.encodeSync(Transaction.Serialized)(eip2930Tx);
101
+ expect(bytes[0]).toBe(0x01);
102
+
103
+ const decoded = S.decodeSync(Transaction.Serialized)(bytes);
104
+ expect(decoded.type).toBe(Transaction.Type.EIP2930);
105
+ expect((decoded as Transaction.EIP2930).chainId).toBe(1n);
106
+ expect((decoded as Transaction.EIP2930).accessList.length).toBe(1);
107
+ });
108
+
109
+ it("handles empty access list", () => {
110
+ const tx: Transaction.EIP2930 = { ...eip2930Tx, accessList: [] };
111
+ const bytes = S.encodeSync(Transaction.Serialized)(tx);
112
+ const decoded = S.decodeSync(Transaction.Serialized)(
113
+ bytes,
114
+ ) as Transaction.EIP2930;
115
+ expect(decoded.accessList.length).toBe(0);
116
+ });
117
+
118
+ it("handles multiple storage keys", () => {
119
+ const tx: Transaction.EIP2930 = {
120
+ ...eip2930Tx,
121
+ accessList: [
122
+ {
123
+ address: testAddress,
124
+ storageKeys: [createHash(1), createHash(2), createHash(3)],
125
+ },
126
+ ],
127
+ };
128
+ const bytes = S.encodeSync(Transaction.Serialized)(tx);
129
+ const decoded = S.decodeSync(Transaction.Serialized)(
130
+ bytes,
131
+ ) as Transaction.EIP2930;
132
+ expect(decoded.accessList[0]?.storageKeys.length).toBe(3);
133
+ });
134
+ });
135
+
136
+ describe("EIP-1559 transactions", () => {
137
+ const eip1559Tx: Transaction.EIP1559 = {
138
+ type: Transaction.Type.EIP1559,
139
+ chainId: 1n,
140
+ nonce: 42n,
141
+ maxPriorityFeePerGas: 2000000000n,
142
+ maxFeePerGas: 30000000000n,
143
+ gasLimit: 21000n,
144
+ to: testAddress,
145
+ value: 1000000000000000000n,
146
+ data: new Uint8Array([0xab, 0xcd]),
147
+ accessList: [],
148
+ yParity: 1,
149
+ r: testSignature.r,
150
+ s: testSignature.s,
151
+ };
152
+
153
+ it("serializes and deserializes EIP-1559 transaction", () => {
154
+ const bytes = S.encodeSync(Transaction.Serialized)(eip1559Tx);
155
+ expect(bytes[0]).toBe(0x02);
156
+
157
+ const decoded = S.decodeSync(Transaction.Serialized)(bytes);
158
+ expect(decoded.type).toBe(Transaction.Type.EIP1559);
159
+ expect((decoded as Transaction.EIP1559).maxFeePerGas).toBe(30000000000n);
160
+ expect((decoded as Transaction.EIP1559).maxPriorityFeePerGas).toBe(
161
+ 2000000000n,
162
+ );
163
+ });
164
+
165
+ it("round-trips high gas values", () => {
166
+ const tx: Transaction.EIP1559 = {
167
+ ...eip1559Tx,
168
+ maxFeePerGas: 1000000000000000000n,
169
+ maxPriorityFeePerGas: 100000000000000000n,
170
+ };
171
+ const bytes = S.encodeSync(Transaction.Serialized)(tx);
172
+ const decoded = S.decodeSync(Transaction.Serialized)(
173
+ bytes,
174
+ ) as Transaction.EIP1559;
175
+ expect(decoded.maxFeePerGas).toBe(tx.maxFeePerGas);
176
+ expect(decoded.maxPriorityFeePerGas).toBe(tx.maxPriorityFeePerGas);
177
+ });
178
+
179
+ it("handles different chain IDs", () => {
180
+ for (const chainId of [1n, 137n, 42161n, 10n, 56n]) {
181
+ const tx: Transaction.EIP1559 = { ...eip1559Tx, chainId };
182
+ const bytes = S.encodeSync(Transaction.Serialized)(tx);
183
+ const decoded = S.decodeSync(Transaction.Serialized)(
184
+ bytes,
185
+ ) as Transaction.EIP1559;
186
+ expect(decoded.chainId).toBe(chainId);
187
+ }
188
+ });
189
+ });
190
+
191
+ describe("EIP-4844 transactions", () => {
192
+ const blobHash = new Uint8Array(32);
193
+ blobHash[0] = 0x01;
194
+
195
+ const eip4844Tx: Transaction.EIP4844 = {
196
+ type: Transaction.Type.EIP4844,
197
+ chainId: 1n,
198
+ nonce: 0n,
199
+ maxPriorityFeePerGas: 1000000000n,
200
+ maxFeePerGas: 20000000000n,
201
+ gasLimit: 21000n,
202
+ to: testAddress,
203
+ value: 0n,
204
+ data: new Uint8Array(),
205
+ accessList: [],
206
+ maxFeePerBlobGas: 1000000000n,
207
+ blobVersionedHashes: [blobHash as HashType],
208
+ yParity: 0,
209
+ r: testSignature.r,
210
+ s: testSignature.s,
211
+ };
212
+
213
+ it("serializes and deserializes EIP-4844 transaction", () => {
214
+ const bytes = S.encodeSync(Transaction.Serialized)(eip4844Tx);
215
+ expect(bytes[0]).toBe(0x03);
216
+
217
+ const decoded = S.decodeSync(Transaction.Serialized)(bytes);
218
+ expect(decoded.type).toBe(Transaction.Type.EIP4844);
219
+ expect((decoded as Transaction.EIP4844).maxFeePerBlobGas).toBe(
220
+ 1000000000n,
221
+ );
222
+ });
223
+
224
+ it("handles multiple blob versioned hashes", () => {
225
+ const createBlobHash = (index: number): HashType => {
226
+ const hash = new Uint8Array(32);
227
+ hash[0] = 0x01;
228
+ hash[31] = index;
229
+ return hash as HashType;
230
+ };
231
+ const tx: Transaction.EIP4844 = {
232
+ ...eip4844Tx,
233
+ blobVersionedHashes: [
234
+ createBlobHash(1),
235
+ createBlobHash(2),
236
+ createBlobHash(3),
237
+ createBlobHash(4),
238
+ ],
239
+ };
240
+ const bytes = S.encodeSync(Transaction.Serialized)(tx);
241
+ const decoded = S.decodeSync(Transaction.Serialized)(
242
+ bytes,
243
+ ) as Transaction.EIP4844;
244
+ expect(decoded.blobVersionedHashes.length).toBe(4);
245
+ });
246
+ });
247
+
248
+ describe("EIP-7702 transactions", () => {
249
+ const eip7702Tx: Transaction.EIP7702 = {
250
+ type: Transaction.Type.EIP7702,
251
+ chainId: 1n,
252
+ nonce: 0n,
253
+ maxPriorityFeePerGas: 1000000000n,
254
+ maxFeePerGas: 20000000000n,
255
+ gasLimit: 21000n,
256
+ to: testAddress,
257
+ value: 0n,
258
+ data: new Uint8Array(),
259
+ accessList: [],
260
+ authorizationList: [
261
+ {
262
+ chainId: 1n,
263
+ address: testAddress,
264
+ nonce: 0n,
265
+ yParity: 0,
266
+ r: testSignature.r,
267
+ s: testSignature.s,
268
+ },
269
+ ],
270
+ yParity: 0,
271
+ r: testSignature.r,
272
+ s: testSignature.s,
273
+ };
274
+
275
+ it("serializes and deserializes EIP-7702 transaction", () => {
276
+ const bytes = S.encodeSync(Transaction.Serialized)(eip7702Tx);
277
+ expect(bytes[0]).toBe(0x04);
278
+
279
+ const decoded = S.decodeSync(Transaction.Serialized)(bytes);
280
+ expect(decoded.type).toBe(Transaction.Type.EIP7702);
281
+ expect((decoded as Transaction.EIP7702).authorizationList.length).toBe(1);
282
+ });
283
+
284
+ it("handles empty authorization list", () => {
285
+ const tx: Transaction.EIP7702 = { ...eip7702Tx, authorizationList: [] };
286
+ const bytes = S.encodeSync(Transaction.Serialized)(tx);
287
+ const decoded = S.decodeSync(Transaction.Serialized)(
288
+ bytes,
289
+ ) as Transaction.EIP7702;
290
+ expect(decoded.authorizationList.length).toBe(0);
291
+ });
292
+
293
+ it("handles multiple authorizations", () => {
294
+ const auth = {
295
+ chainId: 1n,
296
+ address: testAddress,
297
+ nonce: 0n,
298
+ yParity: 0,
299
+ r: testSignature.r,
300
+ s: testSignature.s,
301
+ };
302
+ const tx: Transaction.EIP7702 = {
303
+ ...eip7702Tx,
304
+ authorizationList: [
305
+ auth,
306
+ { ...auth, nonce: 1n },
307
+ { ...auth, nonce: 2n },
308
+ ],
309
+ };
310
+ const bytes = S.encodeSync(Transaction.Serialized)(tx);
311
+ const decoded = S.decodeSync(Transaction.Serialized)(
312
+ bytes,
313
+ ) as Transaction.EIP7702;
314
+ expect(decoded.authorizationList.length).toBe(3);
315
+ });
316
+ });
317
+
318
+ describe("error handling", () => {
319
+ it("rejects invalid bytes", () => {
320
+ expect(() =>
321
+ S.decodeSync(Transaction.Serialized)(new Uint8Array([0xff])),
322
+ ).toThrow();
323
+ });
324
+
325
+ it("rejects empty bytes", () => {
326
+ expect(() =>
327
+ S.decodeSync(Transaction.Serialized)(new Uint8Array()),
328
+ ).toThrow();
329
+ });
330
+
331
+ it("rejects truncated transaction", () => {
332
+ const tx: Transaction.Legacy = {
333
+ type: Transaction.Type.Legacy,
334
+ nonce: 0n,
335
+ gasPrice: 20000000000n,
336
+ gasLimit: 21000n,
337
+ to: testAddress,
338
+ value: 0n,
339
+ data: new Uint8Array(),
340
+ v: 27n,
341
+ r: testSignature.r,
342
+ s: testSignature.s,
343
+ };
344
+ const bytes = S.encodeSync(Transaction.Serialized)(tx);
345
+ const truncated = bytes.slice(0, bytes.length - 10);
346
+ expect(() => S.decodeSync(Transaction.Serialized)(truncated)).toThrow();
347
+ });
348
+ });
349
+ });
350
+
351
+ describe("Transaction.Rpc", () => {
352
+ it("parses EIP-1559 RPC format", () => {
353
+ const rpc = {
354
+ type: "0x2",
355
+ chainId: "0x1",
356
+ nonce: "0x0",
357
+ maxPriorityFeePerGas: "0x3b9aca00",
358
+ maxFeePerGas: "0x6fc23ac00",
359
+ gasLimit: "0x5208",
360
+ to: `0x${"42".repeat(20)}`,
361
+ value: "0xde0b6b3a7640000",
362
+ data: "0x",
363
+ accessList: [],
364
+ };
365
+ const tx = S.decodeSync(Transaction.Rpc)(rpc);
366
+ expect(tx.type).toBe(Transaction.Type.EIP1559);
367
+ expect((tx as Transaction.EIP1559).chainId).toBe(1n);
368
+ expect(tx.nonce).toBe(0n);
369
+ });
370
+
371
+ it("parses legacy RPC format", () => {
372
+ const rpc = {
373
+ type: "0x0",
374
+ nonce: "0x5",
375
+ gasPrice: "0x5d21dba00",
376
+ gas: "0xc350",
377
+ to: `0x${"42".repeat(20)}`,
378
+ value: "0x64",
379
+ data: "0x010203",
380
+ };
381
+ const tx = S.decodeSync(Transaction.Rpc)(rpc);
382
+ expect(tx.type).toBe(Transaction.Type.Legacy);
383
+ expect(tx.nonce).toBe(5n);
384
+ });
385
+
386
+ it("round-trips EIP-1559 through RPC format", () => {
387
+ const eip1559Tx: Transaction.EIP1559 = {
388
+ type: Transaction.Type.EIP1559,
389
+ chainId: 1n,
390
+ nonce: 10n,
391
+ maxPriorityFeePerGas: 2000000000n,
392
+ maxFeePerGas: 30000000000n,
393
+ gasLimit: 21000n,
394
+ to: testAddress,
395
+ value: 1000000000000000000n,
396
+ data: new Uint8Array(),
397
+ accessList: [],
398
+ yParity: 0,
399
+ r: testSignature.r,
400
+ s: testSignature.s,
401
+ };
402
+ const rpc = S.encodeSync(Transaction.Rpc)(eip1559Tx);
403
+ expect(rpc.type).toBe("0x2");
404
+ expect(rpc.chainId).toBe("0x1");
405
+ expect(rpc.nonce).toBe("0xa");
406
+ });
407
+ });
408
+
409
+ describe("Transaction pure functions", () => {
410
+ const eip1559Tx: Transaction.EIP1559 = {
411
+ type: Transaction.Type.EIP1559,
412
+ chainId: 1n,
413
+ nonce: 0n,
414
+ maxPriorityFeePerGas: 2000000000n,
415
+ maxFeePerGas: 30000000000n,
416
+ gasLimit: 21000n,
417
+ to: testAddress,
418
+ value: 1000000000000000000n,
419
+ data: new Uint8Array(),
420
+ accessList: [],
421
+ yParity: 1,
422
+ r: testSignature.r,
423
+ s: testSignature.s,
424
+ };
425
+
426
+ describe("hash", () => {
427
+ it("returns 32-byte hash", () => {
428
+ const h = Transaction.hash(eip1559Tx);
429
+ expect(h.length).toBe(32);
430
+ });
431
+
432
+ it("produces same hash for same transaction", () => {
433
+ const h1 = Transaction.hash(eip1559Tx);
434
+ const h2 = Transaction.hash(eip1559Tx);
435
+ expect(h1).toEqual(h2);
436
+ });
437
+
438
+ it("produces different hash for different transactions", () => {
439
+ const h1 = Transaction.hash(eip1559Tx);
440
+ const h2 = Transaction.hash({ ...eip1559Tx, nonce: 1n });
441
+ expect(h1).not.toEqual(h2);
442
+ });
443
+ });
444
+
445
+ describe("signingHash", () => {
446
+ it("returns 32-byte signing hash", () => {
447
+ const h = Transaction.signingHash(eip1559Tx);
448
+ expect(h.length).toBe(32);
449
+ });
450
+
451
+ it("differs from transaction hash", () => {
452
+ const txHash = Transaction.hash(eip1559Tx);
453
+ const signHash = Transaction.signingHash(eip1559Tx);
454
+ expect(txHash).not.toEqual(signHash);
455
+ });
456
+ });
457
+
458
+ describe("getChainId", () => {
459
+ it("returns chain ID for EIP-1559", () => {
460
+ expect(Transaction.getChainId(eip1559Tx)).toBe(1n);
461
+ });
462
+
463
+ it("returns chain ID for legacy with EIP-155", () => {
464
+ const legacyTx: Transaction.Legacy = {
465
+ type: Transaction.Type.Legacy,
466
+ nonce: 0n,
467
+ gasPrice: 20000000000n,
468
+ gasLimit: 21000n,
469
+ to: testAddress,
470
+ value: 0n,
471
+ data: new Uint8Array(),
472
+ v: 37n,
473
+ r: testSignature.r,
474
+ s: testSignature.s,
475
+ };
476
+ expect(Transaction.getChainId(legacyTx)).toBe(1n);
477
+ });
478
+ });
479
+
480
+ describe("getGasPrice", () => {
481
+ it("returns gas price for legacy", () => {
482
+ const legacyTx: Transaction.Legacy = {
483
+ type: Transaction.Type.Legacy,
484
+ nonce: 0n,
485
+ gasPrice: 25000000000n,
486
+ gasLimit: 21000n,
487
+ to: testAddress,
488
+ value: 0n,
489
+ data: new Uint8Array(),
490
+ v: 27n,
491
+ r: testSignature.r,
492
+ s: testSignature.s,
493
+ };
494
+ expect(Transaction.getGasPrice(legacyTx)).toBe(25000000000n);
495
+ });
496
+
497
+ it("returns effective gas price for EIP-1559 with base fee", () => {
498
+ const baseFee = 10000000000n;
499
+ const effectivePrice = Transaction.getGasPrice(eip1559Tx, baseFee);
500
+ expect(effectivePrice).toBe(baseFee + eip1559Tx.maxPriorityFeePerGas);
501
+ });
502
+ });
503
+
504
+ describe("isContractCreation", () => {
505
+ it("returns true for null to", () => {
506
+ const legacyTx: Transaction.Legacy = {
507
+ type: Transaction.Type.Legacy,
508
+ nonce: 0n,
509
+ gasPrice: 20000000000n,
510
+ gasLimit: 1000000n,
511
+ to: null,
512
+ value: 0n,
513
+ data: new Uint8Array([0x60, 0x80]),
514
+ v: 27n,
515
+ r: testSignature.r,
516
+ s: testSignature.s,
517
+ };
518
+ expect(Transaction.isContractCreation(legacyTx)).toBe(true);
519
+ });
520
+
521
+ it("returns false for non-null to", () => {
522
+ expect(Transaction.isContractCreation(eip1559Tx)).toBe(false);
523
+ });
524
+ });
525
+
526
+ describe("isSigned", () => {
527
+ it("returns true for signed transaction", () => {
528
+ expect(Transaction.isSigned(eip1559Tx)).toBe(true);
529
+ });
530
+
531
+ it("returns false for unsigned transaction", () => {
532
+ const unsignedTx: Transaction.EIP1559 = {
533
+ ...eip1559Tx,
534
+ yParity: 0,
535
+ r: new Uint8Array(32),
536
+ s: new Uint8Array(32),
537
+ };
538
+ expect(Transaction.isSigned(unsignedTx)).toBe(false);
539
+ });
540
+ });
541
+
542
+ describe("detectType", () => {
543
+ it("detects legacy transaction", () => {
544
+ const legacyTx: Transaction.Legacy = {
545
+ type: Transaction.Type.Legacy,
546
+ nonce: 0n,
547
+ gasPrice: 20000000000n,
548
+ gasLimit: 21000n,
549
+ to: testAddress,
550
+ value: 0n,
551
+ data: new Uint8Array(),
552
+ v: 27n,
553
+ r: testSignature.r,
554
+ s: testSignature.s,
555
+ };
556
+ const bytes = S.encodeSync(Transaction.Serialized)(legacyTx);
557
+ expect(Transaction.detectType(bytes)).toBe(Transaction.Type.Legacy);
558
+ });
559
+
560
+ it("detects EIP-1559 transaction", () => {
561
+ const bytes = S.encodeSync(Transaction.Serialized)(eip1559Tx);
562
+ expect(Transaction.detectType(bytes)).toBe(Transaction.Type.EIP1559);
563
+ });
564
+
565
+ it("detects EIP-4844 transaction", () => {
566
+ const blobH = new Uint8Array(32);
567
+ blobH[0] = 0x01;
568
+ const eip4844Tx: Transaction.EIP4844 = {
569
+ type: Transaction.Type.EIP4844,
570
+ chainId: 1n,
571
+ nonce: 0n,
572
+ maxPriorityFeePerGas: 1000000000n,
573
+ maxFeePerGas: 20000000000n,
574
+ gasLimit: 21000n,
575
+ to: testAddress,
576
+ value: 0n,
577
+ data: new Uint8Array(),
578
+ accessList: [],
579
+ maxFeePerBlobGas: 1000000000n,
580
+ blobVersionedHashes: [blobH as HashType],
581
+ yParity: 0,
582
+ r: testSignature.r,
583
+ s: testSignature.s,
584
+ };
585
+ const bytes = S.encodeSync(Transaction.Serialized)(eip4844Tx);
586
+ expect(Transaction.detectType(bytes)).toBe(Transaction.Type.EIP4844);
587
+ });
588
+ });
589
+ });
590
+
591
+ describe("Transaction.Type", () => {
592
+ it("has correct enum values", () => {
593
+ expect(Transaction.Type.Legacy).toBe(0x00);
594
+ expect(Transaction.Type.EIP2930).toBe(0x01);
595
+ expect(Transaction.Type.EIP1559).toBe(0x02);
596
+ expect(Transaction.Type.EIP4844).toBe(0x03);
597
+ expect(Transaction.Type.EIP7702).toBe(0x04);
598
+ });
599
+ });
600
+
601
+ describe("Transaction.Schema (direct struct validation)", () => {
602
+ // Schemas expect hex string addresses for the encoded (input) side
603
+ const testAddressHex = `0x${"42".repeat(20)}`;
604
+
605
+ describe("LegacySchema", () => {
606
+ it("validates valid legacy transaction", () => {
607
+ const tx: S.Schema.Encoded<typeof Transaction.LegacySchema> = {
608
+ type: Transaction.Type.Legacy,
609
+ nonce: 0n,
610
+ gasPrice: 20000000000n,
611
+ gasLimit: 21000n,
612
+ to: testAddressHex,
613
+ value: 0n,
614
+ data: new Uint8Array(),
615
+ v: 27n,
616
+ r: testSignature.r,
617
+ s: testSignature.s,
618
+ };
619
+ const decoded = S.decodeSync(Transaction.LegacySchema)(tx);
620
+ expect(decoded.type).toBe(Transaction.Type.Legacy);
621
+ });
622
+
623
+ it("rejects wrong type field", () => {
624
+ const tx = {
625
+ type: Transaction.Type.EIP1559,
626
+ nonce: 0n,
627
+ gasPrice: 20000000000n,
628
+ gasLimit: 21000n,
629
+ to: testAddressHex,
630
+ value: 0n,
631
+ data: new Uint8Array(),
632
+ v: 27n,
633
+ r: testSignature.r,
634
+ s: testSignature.s,
635
+ };
636
+ expect(() =>
637
+ S.decodeSync(Transaction.LegacySchema)(tx as never),
638
+ ).toThrow();
639
+ });
640
+
641
+ it("rejects missing required fields", () => {
642
+ const tx = {
643
+ type: Transaction.Type.Legacy,
644
+ nonce: 0n,
645
+ // missing gasPrice
646
+ gasLimit: 21000n,
647
+ to: testAddressHex,
648
+ value: 0n,
649
+ data: new Uint8Array(),
650
+ v: 27n,
651
+ r: testSignature.r,
652
+ s: testSignature.s,
653
+ };
654
+ expect(() => S.decodeSync(Transaction.LegacySchema)(tx as any)).toThrow();
655
+ });
656
+
657
+ it("validates contract creation with null to", () => {
658
+ const tx: S.Schema.Encoded<typeof Transaction.LegacySchema> = {
659
+ type: Transaction.Type.Legacy,
660
+ nonce: 0n,
661
+ gasPrice: 20000000000n,
662
+ gasLimit: 1000000n,
663
+ to: null,
664
+ value: 0n,
665
+ data: new Uint8Array([0x60, 0x80]),
666
+ v: 27n,
667
+ r: testSignature.r,
668
+ s: testSignature.s,
669
+ };
670
+ const decoded = S.decodeSync(Transaction.LegacySchema)(tx);
671
+ expect(decoded.to).toBeNull();
672
+ });
673
+ });
674
+
675
+ describe("EIP2930Schema", () => {
676
+ it("validates valid EIP-2930 transaction", () => {
677
+ const tx: S.Schema.Encoded<typeof Transaction.EIP2930Schema> = {
678
+ type: Transaction.Type.EIP2930,
679
+ chainId: 1n,
680
+ nonce: 0n,
681
+ gasPrice: 20000000000n,
682
+ gasLimit: 21000n,
683
+ to: testAddressHex,
684
+ value: 0n,
685
+ data: new Uint8Array(),
686
+ accessList: [],
687
+ yParity: 0,
688
+ r: testSignature.r,
689
+ s: testSignature.s,
690
+ };
691
+ const decoded = S.decodeSync(Transaction.EIP2930Schema)(tx);
692
+ expect(decoded.type).toBe(Transaction.Type.EIP2930);
693
+ expect(decoded.chainId).toBe(1n);
694
+ });
695
+
696
+ it("validates with access list containing storage keys", () => {
697
+ const tx: S.Schema.Encoded<typeof Transaction.EIP2930Schema> = {
698
+ type: Transaction.Type.EIP2930,
699
+ chainId: 1n,
700
+ nonce: 0n,
701
+ gasPrice: 20000000000n,
702
+ gasLimit: 21000n,
703
+ to: testAddressHex,
704
+ value: 0n,
705
+ data: new Uint8Array(),
706
+ accessList: [
707
+ {
708
+ address: testAddressHex,
709
+ storageKeys: [createHash(1), createHash(2)],
710
+ },
711
+ ],
712
+ yParity: 0,
713
+ r: testSignature.r,
714
+ s: testSignature.s,
715
+ };
716
+ const decoded = S.decodeSync(Transaction.EIP2930Schema)(tx);
717
+ expect(decoded.accessList.length).toBe(1);
718
+ expect(decoded.accessList[0]?.storageKeys.length).toBe(2);
719
+ });
720
+ });
721
+
722
+ describe("EIP1559Schema", () => {
723
+ it("validates valid EIP-1559 transaction", () => {
724
+ const tx: S.Schema.Encoded<typeof Transaction.EIP1559Schema> = {
725
+ type: Transaction.Type.EIP1559,
726
+ chainId: 1n,
727
+ nonce: 0n,
728
+ maxPriorityFeePerGas: 1000000000n,
729
+ maxFeePerGas: 20000000000n,
730
+ gasLimit: 21000n,
731
+ to: testAddressHex,
732
+ value: 0n,
733
+ data: new Uint8Array(),
734
+ accessList: [],
735
+ yParity: 0,
736
+ r: testSignature.r,
737
+ s: testSignature.s,
738
+ };
739
+ const decoded = S.decodeSync(Transaction.EIP1559Schema)(tx);
740
+ expect(decoded.type).toBe(Transaction.Type.EIP1559);
741
+ expect(decoded.maxFeePerGas).toBe(20000000000n);
742
+ });
743
+
744
+ it("rejects wrong type field", () => {
745
+ const tx = {
746
+ type: Transaction.Type.Legacy,
747
+ chainId: 1n,
748
+ nonce: 0n,
749
+ maxPriorityFeePerGas: 1000000000n,
750
+ maxFeePerGas: 20000000000n,
751
+ gasLimit: 21000n,
752
+ to: testAddressHex,
753
+ value: 0n,
754
+ data: new Uint8Array(),
755
+ accessList: [],
756
+ yParity: 0,
757
+ r: testSignature.r,
758
+ s: testSignature.s,
759
+ };
760
+ expect(() =>
761
+ S.decodeSync(Transaction.EIP1559Schema)(tx as any),
762
+ ).toThrow();
763
+ });
764
+ });
765
+
766
+ describe("EIP4844Schema", () => {
767
+ const blobHash = createHash(0x01);
768
+
769
+ it("validates valid EIP-4844 transaction", () => {
770
+ const tx: S.Schema.Encoded<typeof Transaction.EIP4844Schema> = {
771
+ type: Transaction.Type.EIP4844,
772
+ chainId: 1n,
773
+ nonce: 0n,
774
+ maxPriorityFeePerGas: 1000000000n,
775
+ maxFeePerGas: 20000000000n,
776
+ gasLimit: 21000n,
777
+ to: testAddressHex,
778
+ value: 0n,
779
+ data: new Uint8Array(),
780
+ accessList: [],
781
+ maxFeePerBlobGas: 1000000000n,
782
+ blobVersionedHashes: [blobHash],
783
+ yParity: 0,
784
+ r: testSignature.r,
785
+ s: testSignature.s,
786
+ };
787
+ const decoded = S.decodeSync(Transaction.EIP4844Schema)(tx);
788
+ expect(decoded.type).toBe(Transaction.Type.EIP4844);
789
+ expect(decoded.maxFeePerBlobGas).toBe(1000000000n);
790
+ });
791
+
792
+ it("validates with empty blob hashes", () => {
793
+ const tx: S.Schema.Encoded<typeof Transaction.EIP4844Schema> = {
794
+ type: Transaction.Type.EIP4844,
795
+ chainId: 1n,
796
+ nonce: 0n,
797
+ maxPriorityFeePerGas: 1000000000n,
798
+ maxFeePerGas: 20000000000n,
799
+ gasLimit: 21000n,
800
+ to: testAddressHex,
801
+ value: 0n,
802
+ data: new Uint8Array(),
803
+ accessList: [],
804
+ maxFeePerBlobGas: 1000000000n,
805
+ blobVersionedHashes: [],
806
+ yParity: 0,
807
+ r: testSignature.r,
808
+ s: testSignature.s,
809
+ };
810
+ const decoded = S.decodeSync(Transaction.EIP4844Schema)(tx);
811
+ expect(decoded.blobVersionedHashes.length).toBe(0);
812
+ });
813
+ });
814
+
815
+ describe("EIP7702Schema", () => {
816
+ it("validates valid EIP-7702 transaction", () => {
817
+ const tx: S.Schema.Encoded<typeof Transaction.EIP7702Schema> = {
818
+ type: Transaction.Type.EIP7702,
819
+ chainId: 1n,
820
+ nonce: 0n,
821
+ maxPriorityFeePerGas: 1000000000n,
822
+ maxFeePerGas: 20000000000n,
823
+ gasLimit: 21000n,
824
+ to: testAddressHex,
825
+ value: 0n,
826
+ data: new Uint8Array(),
827
+ accessList: [],
828
+ authorizationList: [
829
+ {
830
+ chainId: 1n,
831
+ address: testAddressHex,
832
+ nonce: 0n,
833
+ yParity: 0,
834
+ r: testSignature.r,
835
+ s: testSignature.s,
836
+ },
837
+ ],
838
+ yParity: 0,
839
+ r: testSignature.r,
840
+ s: testSignature.s,
841
+ };
842
+ const decoded = S.decodeSync(Transaction.EIP7702Schema)(tx);
843
+ expect(decoded.type).toBe(Transaction.Type.EIP7702);
844
+ expect(decoded.authorizationList.length).toBe(1);
845
+ });
846
+ });
847
+
848
+ describe("Schema (union)", () => {
849
+ it("accepts any valid transaction type", () => {
850
+ const legacyTx: S.Schema.Encoded<typeof Transaction.LegacySchema> = {
851
+ type: Transaction.Type.Legacy,
852
+ nonce: 0n,
853
+ gasPrice: 20000000000n,
854
+ gasLimit: 21000n,
855
+ to: testAddressHex,
856
+ value: 0n,
857
+ data: new Uint8Array(),
858
+ v: 27n,
859
+ r: testSignature.r,
860
+ s: testSignature.s,
861
+ };
862
+ const decoded = S.decodeSync(Transaction.Schema)(legacyTx);
863
+ expect(decoded.type).toBe(Transaction.Type.Legacy);
864
+ });
865
+
866
+ it("discriminates based on type field", () => {
867
+ const eip1559: S.Schema.Encoded<typeof Transaction.EIP1559Schema> = {
868
+ type: Transaction.Type.EIP1559,
869
+ chainId: 1n,
870
+ nonce: 0n,
871
+ maxPriorityFeePerGas: 1000000000n,
872
+ maxFeePerGas: 20000000000n,
873
+ gasLimit: 21000n,
874
+ to: testAddressHex,
875
+ value: 0n,
876
+ data: new Uint8Array(),
877
+ accessList: [],
878
+ yParity: 0,
879
+ r: testSignature.r,
880
+ s: testSignature.s,
881
+ };
882
+ const decoded = S.decodeSync(Transaction.Schema)(eip1559);
883
+ expect(decoded.type).toBe(Transaction.Type.EIP1559);
884
+ });
885
+ });
886
+ });
887
+
888
+ describe("Transaction.Rpc additional coverage", () => {
889
+ describe("EIP-2930 RPC", () => {
890
+ it("parses EIP-2930 RPC format", () => {
891
+ const rpc = {
892
+ type: "0x1",
893
+ chainId: "0x1",
894
+ nonce: "0x0",
895
+ gasPrice: "0x4a817c800",
896
+ gasLimit: "0x5208",
897
+ to: `0x${"42".repeat(20)}`,
898
+ value: "0x0",
899
+ data: "0x",
900
+ accessList: [
901
+ {
902
+ address: `0x${"11".repeat(20)}`,
903
+ storageKeys: [`0x${"22".repeat(32)}`],
904
+ },
905
+ ],
906
+ };
907
+ const tx = S.decodeSync(Transaction.Rpc)(rpc);
908
+ expect(tx.type).toBe(Transaction.Type.EIP2930);
909
+ expect((tx as Transaction.EIP2930).accessList.length).toBe(1);
910
+ });
911
+
912
+ it("round-trips EIP-2930 through RPC format", () => {
913
+ const eip2930Tx: Transaction.EIP2930 = {
914
+ type: Transaction.Type.EIP2930,
915
+ chainId: 1n,
916
+ nonce: 5n,
917
+ gasPrice: 20000000000n,
918
+ gasLimit: 21000n,
919
+ to: testAddress,
920
+ value: 1000000000000000000n,
921
+ data: new Uint8Array(),
922
+ accessList: [],
923
+ yParity: 0,
924
+ r: testSignature.r,
925
+ s: testSignature.s,
926
+ };
927
+ const rpc = S.encodeSync(Transaction.Rpc)(eip2930Tx);
928
+ expect(rpc.type).toBe("0x1");
929
+ expect(rpc.chainId).toBe("0x1");
930
+ });
931
+ });
932
+
933
+ describe("EIP-4844 RPC", () => {
934
+ it("parses EIP-4844 RPC format", () => {
935
+ const rpc = {
936
+ type: "0x3",
937
+ chainId: "0x1",
938
+ nonce: "0x0",
939
+ maxPriorityFeePerGas: "0x3b9aca00",
940
+ maxFeePerGas: "0x4a817c800",
941
+ gasLimit: "0x5208",
942
+ to: `0x${"42".repeat(20)}`,
943
+ value: "0x0",
944
+ data: "0x",
945
+ accessList: [],
946
+ maxFeePerBlobGas: "0x3b9aca00",
947
+ blobVersionedHashes: [`0x01${"00".repeat(31)}`],
948
+ };
949
+ const tx = S.decodeSync(Transaction.Rpc)(rpc);
950
+ expect(tx.type).toBe(Transaction.Type.EIP4844);
951
+ expect((tx as Transaction.EIP4844).maxFeePerBlobGas).toBe(1000000000n);
952
+ });
953
+
954
+ it("round-trips EIP-4844 through RPC format", () => {
955
+ const blobHash = createHash(0x01);
956
+ const eip4844Tx: Transaction.EIP4844 = {
957
+ type: Transaction.Type.EIP4844,
958
+ chainId: 1n,
959
+ nonce: 0n,
960
+ maxPriorityFeePerGas: 1000000000n,
961
+ maxFeePerGas: 20000000000n,
962
+ gasLimit: 21000n,
963
+ to: testAddress,
964
+ value: 0n,
965
+ data: new Uint8Array(),
966
+ accessList: [],
967
+ maxFeePerBlobGas: 1000000000n,
968
+ blobVersionedHashes: [blobHash],
969
+ yParity: 0,
970
+ r: testSignature.r,
971
+ s: testSignature.s,
972
+ };
973
+ const rpc = S.encodeSync(Transaction.Rpc)(eip4844Tx);
974
+ expect(rpc.type).toBe("0x3");
975
+ });
976
+ });
977
+
978
+ describe("EIP-7702 RPC", () => {
979
+ it("parses EIP-7702 RPC format", () => {
980
+ const rpc = {
981
+ type: "0x4",
982
+ chainId: "0x1",
983
+ nonce: "0x0",
984
+ maxPriorityFeePerGas: "0x3b9aca00",
985
+ maxFeePerGas: "0x4a817c800",
986
+ gasLimit: "0x5208",
987
+ to: `0x${"42".repeat(20)}`,
988
+ value: "0x0",
989
+ data: "0x",
990
+ accessList: [],
991
+ authorizationList: [
992
+ {
993
+ chainId: "0x1",
994
+ address: `0x${"42".repeat(20)}`,
995
+ nonce: "0x0",
996
+ yParity: "0x0",
997
+ r: `0x${"11".repeat(32)}`,
998
+ s: `0x${"22".repeat(32)}`,
999
+ },
1000
+ ],
1001
+ };
1002
+ const tx = S.decodeSync(Transaction.Rpc)(rpc);
1003
+ expect(tx.type).toBe(Transaction.Type.EIP7702);
1004
+ expect((tx as Transaction.EIP7702).authorizationList.length).toBe(1);
1005
+ });
1006
+
1007
+ it("round-trips EIP-7702 through RPC format", () => {
1008
+ const eip7702Tx: Transaction.EIP7702 = {
1009
+ type: Transaction.Type.EIP7702,
1010
+ chainId: 1n,
1011
+ nonce: 0n,
1012
+ maxPriorityFeePerGas: 1000000000n,
1013
+ maxFeePerGas: 20000000000n,
1014
+ gasLimit: 21000n,
1015
+ to: testAddress,
1016
+ value: 0n,
1017
+ data: new Uint8Array(),
1018
+ accessList: [],
1019
+ authorizationList: [
1020
+ {
1021
+ chainId: 1n,
1022
+ address: testAddress,
1023
+ nonce: 0n,
1024
+ yParity: 0,
1025
+ r: testSignature.r,
1026
+ s: testSignature.s,
1027
+ },
1028
+ ],
1029
+ yParity: 0,
1030
+ r: testSignature.r,
1031
+ s: testSignature.s,
1032
+ };
1033
+ const rpc = S.encodeSync(Transaction.Rpc)(eip7702Tx);
1034
+ expect(rpc.type).toBe("0x4");
1035
+ });
1036
+ });
1037
+
1038
+ describe("RPC error handling", () => {
1039
+ it("rejects invalid type prefix", () => {
1040
+ const rpc = {
1041
+ type: "0xff",
1042
+ nonce: "0x0",
1043
+ gasPrice: "0x4a817c800",
1044
+ gasLimit: "0x5208",
1045
+ to: `0x${"42".repeat(20)}`,
1046
+ value: "0x0",
1047
+ data: "0x",
1048
+ };
1049
+ expect(() => S.decodeSync(Transaction.Rpc)(rpc)).toThrow();
1050
+ });
1051
+
1052
+ it("handles null to field for contract creation", () => {
1053
+ const rpc = {
1054
+ type: "0x2",
1055
+ chainId: "0x1",
1056
+ nonce: "0x0",
1057
+ maxPriorityFeePerGas: "0x3b9aca00",
1058
+ maxFeePerGas: "0x4a817c800",
1059
+ gasLimit: "0xf4240",
1060
+ to: null,
1061
+ value: "0x0",
1062
+ data: "0x608060405234801561001057600080fd5b50",
1063
+ accessList: [],
1064
+ };
1065
+ const tx = S.decodeSync(Transaction.Rpc)(rpc);
1066
+ expect(tx.to).toBeNull();
1067
+ });
1068
+ });
1069
+ });
1070
+
1071
+ describe("Transaction edge cases", () => {
1072
+ describe("value edge cases", () => {
1073
+ it("handles zero value transaction", () => {
1074
+ const tx: Transaction.EIP1559 = {
1075
+ type: Transaction.Type.EIP1559,
1076
+ chainId: 1n,
1077
+ nonce: 0n,
1078
+ maxPriorityFeePerGas: 1000000000n,
1079
+ maxFeePerGas: 20000000000n,
1080
+ gasLimit: 21000n,
1081
+ to: testAddress,
1082
+ value: 0n,
1083
+ data: new Uint8Array(),
1084
+ accessList: [],
1085
+ yParity: 0,
1086
+ r: testSignature.r,
1087
+ s: testSignature.s,
1088
+ };
1089
+ const bytes = S.encodeSync(Transaction.Serialized)(tx);
1090
+ const decoded = S.decodeSync(Transaction.Serialized)(
1091
+ bytes,
1092
+ ) as Transaction.EIP1559;
1093
+ expect(decoded.value).toBe(0n);
1094
+ });
1095
+
1096
+ it("handles max uint256 value", () => {
1097
+ const maxUint256 = 2n ** 256n - 1n;
1098
+ const tx: Transaction.EIP1559 = {
1099
+ type: Transaction.Type.EIP1559,
1100
+ chainId: 1n,
1101
+ nonce: 0n,
1102
+ maxPriorityFeePerGas: 1000000000n,
1103
+ maxFeePerGas: 20000000000n,
1104
+ gasLimit: 21000n,
1105
+ to: testAddress,
1106
+ value: maxUint256,
1107
+ data: new Uint8Array(),
1108
+ accessList: [],
1109
+ yParity: 0,
1110
+ r: testSignature.r,
1111
+ s: testSignature.s,
1112
+ };
1113
+ const bytes = S.encodeSync(Transaction.Serialized)(tx);
1114
+ const decoded = S.decodeSync(Transaction.Serialized)(
1115
+ bytes,
1116
+ ) as Transaction.EIP1559;
1117
+ expect(decoded.value).toBe(maxUint256);
1118
+ });
1119
+ });
1120
+
1121
+ describe("nonce edge cases", () => {
1122
+ it("handles zero nonce", () => {
1123
+ const tx: Transaction.Legacy = {
1124
+ type: Transaction.Type.Legacy,
1125
+ nonce: 0n,
1126
+ gasPrice: 20000000000n,
1127
+ gasLimit: 21000n,
1128
+ to: testAddress,
1129
+ value: 0n,
1130
+ data: new Uint8Array(),
1131
+ v: 27n,
1132
+ r: testSignature.r,
1133
+ s: testSignature.s,
1134
+ };
1135
+ const bytes = S.encodeSync(Transaction.Serialized)(tx);
1136
+ const decoded = S.decodeSync(Transaction.Serialized)(bytes);
1137
+ expect(decoded.nonce).toBe(0n);
1138
+ });
1139
+
1140
+ it("handles large nonce", () => {
1141
+ const tx: Transaction.EIP1559 = {
1142
+ type: Transaction.Type.EIP1559,
1143
+ chainId: 1n,
1144
+ nonce: 2n ** 64n - 1n,
1145
+ maxPriorityFeePerGas: 1000000000n,
1146
+ maxFeePerGas: 20000000000n,
1147
+ gasLimit: 21000n,
1148
+ to: testAddress,
1149
+ value: 0n,
1150
+ data: new Uint8Array(),
1151
+ accessList: [],
1152
+ yParity: 0,
1153
+ r: testSignature.r,
1154
+ s: testSignature.s,
1155
+ };
1156
+ const bytes = S.encodeSync(Transaction.Serialized)(tx);
1157
+ const decoded = S.decodeSync(Transaction.Serialized)(
1158
+ bytes,
1159
+ ) as Transaction.EIP1559;
1160
+ expect(decoded.nonce).toBe(2n ** 64n - 1n);
1161
+ });
1162
+ });
1163
+
1164
+ describe("gas limit edge cases", () => {
1165
+ it("handles minimum gas limit (21000)", () => {
1166
+ const tx: Transaction.EIP1559 = {
1167
+ type: Transaction.Type.EIP1559,
1168
+ chainId: 1n,
1169
+ nonce: 0n,
1170
+ maxPriorityFeePerGas: 1000000000n,
1171
+ maxFeePerGas: 20000000000n,
1172
+ gasLimit: 21000n,
1173
+ to: testAddress,
1174
+ value: 0n,
1175
+ data: new Uint8Array(),
1176
+ accessList: [],
1177
+ yParity: 0,
1178
+ r: testSignature.r,
1179
+ s: testSignature.s,
1180
+ };
1181
+ const bytes = S.encodeSync(Transaction.Serialized)(tx);
1182
+ const decoded = S.decodeSync(Transaction.Serialized)(
1183
+ bytes,
1184
+ ) as Transaction.EIP1559;
1185
+ expect(decoded.gasLimit).toBe(21000n);
1186
+ });
1187
+
1188
+ it("handles high gas limit", () => {
1189
+ const tx: Transaction.EIP1559 = {
1190
+ type: Transaction.Type.EIP1559,
1191
+ chainId: 1n,
1192
+ nonce: 0n,
1193
+ maxPriorityFeePerGas: 1000000000n,
1194
+ maxFeePerGas: 20000000000n,
1195
+ gasLimit: 30000000n, // ~30M gas (block limit)
1196
+ to: testAddress,
1197
+ value: 0n,
1198
+ data: new Uint8Array(),
1199
+ accessList: [],
1200
+ yParity: 0,
1201
+ r: testSignature.r,
1202
+ s: testSignature.s,
1203
+ };
1204
+ const bytes = S.encodeSync(Transaction.Serialized)(tx);
1205
+ const decoded = S.decodeSync(Transaction.Serialized)(
1206
+ bytes,
1207
+ ) as Transaction.EIP1559;
1208
+ expect(decoded.gasLimit).toBe(30000000n);
1209
+ });
1210
+ });
1211
+
1212
+ describe("access list edge cases", () => {
1213
+ it("handles access list with multiple addresses", () => {
1214
+ const addr1 = createAddress(0x11);
1215
+ const addr2 = createAddress(0x22);
1216
+ const addr3 = createAddress(0x33);
1217
+ const tx: Transaction.EIP1559 = {
1218
+ type: Transaction.Type.EIP1559,
1219
+ chainId: 1n,
1220
+ nonce: 0n,
1221
+ maxPriorityFeePerGas: 1000000000n,
1222
+ maxFeePerGas: 20000000000n,
1223
+ gasLimit: 100000n,
1224
+ to: testAddress,
1225
+ value: 0n,
1226
+ data: new Uint8Array(),
1227
+ accessList: [
1228
+ { address: addr1, storageKeys: [createHash(1)] },
1229
+ { address: addr2, storageKeys: [createHash(2), createHash(3)] },
1230
+ { address: addr3, storageKeys: [] },
1231
+ ],
1232
+ yParity: 0,
1233
+ r: testSignature.r,
1234
+ s: testSignature.s,
1235
+ };
1236
+ const bytes = S.encodeSync(Transaction.Serialized)(tx);
1237
+ const decoded = S.decodeSync(Transaction.Serialized)(
1238
+ bytes,
1239
+ ) as Transaction.EIP1559;
1240
+ expect(decoded.accessList.length).toBe(3);
1241
+ expect(decoded.accessList[0]?.storageKeys.length).toBe(1);
1242
+ expect(decoded.accessList[1]?.storageKeys.length).toBe(2);
1243
+ expect(decoded.accessList[2]?.storageKeys.length).toBe(0);
1244
+ });
1245
+ });
1246
+
1247
+ describe("data field edge cases", () => {
1248
+ it("handles large data field", () => {
1249
+ const largeData = new Uint8Array(10000);
1250
+ largeData.fill(0xab);
1251
+ const tx: Transaction.EIP1559 = {
1252
+ type: Transaction.Type.EIP1559,
1253
+ chainId: 1n,
1254
+ nonce: 0n,
1255
+ maxPriorityFeePerGas: 1000000000n,
1256
+ maxFeePerGas: 20000000000n,
1257
+ gasLimit: 1000000n,
1258
+ to: testAddress,
1259
+ value: 0n,
1260
+ data: largeData,
1261
+ accessList: [],
1262
+ yParity: 0,
1263
+ r: testSignature.r,
1264
+ s: testSignature.s,
1265
+ };
1266
+ const bytes = S.encodeSync(Transaction.Serialized)(tx);
1267
+ const decoded = S.decodeSync(Transaction.Serialized)(
1268
+ bytes,
1269
+ ) as Transaction.EIP1559;
1270
+ expect(decoded.data.length).toBe(10000);
1271
+ expect(decoded.data[0]).toBe(0xab);
1272
+ });
1273
+ });
1274
+ });
1275
+
1276
+ describe("Transaction pure functions additional coverage", () => {
1277
+ const eip1559Tx: Transaction.EIP1559 = {
1278
+ type: Transaction.Type.EIP1559,
1279
+ chainId: 1n,
1280
+ nonce: 42n,
1281
+ maxPriorityFeePerGas: 2000000000n,
1282
+ maxFeePerGas: 30000000000n,
1283
+ gasLimit: 100000n,
1284
+ to: testAddress,
1285
+ value: 1000000000000000000n,
1286
+ data: new Uint8Array([0xab, 0xcd, 0xef]),
1287
+ accessList: [],
1288
+ yParity: 1,
1289
+ r: testSignature.r,
1290
+ s: testSignature.s,
1291
+ };
1292
+
1293
+ describe("getNonce", () => {
1294
+ it("returns nonce from transaction", () => {
1295
+ expect(Transaction.getNonce(eip1559Tx)).toBe(42n);
1296
+ });
1297
+ });
1298
+
1299
+ describe("getGasLimit", () => {
1300
+ it("returns gas limit from transaction", () => {
1301
+ expect(Transaction.getGasLimit(eip1559Tx)).toBe(100000n);
1302
+ });
1303
+ });
1304
+
1305
+ describe("getValue", () => {
1306
+ it("returns value from transaction", () => {
1307
+ expect(Transaction.getValue(eip1559Tx)).toBe(1000000000000000000n);
1308
+ });
1309
+ });
1310
+
1311
+ describe("getData", () => {
1312
+ it("returns data from transaction", () => {
1313
+ const data = Transaction.getData(eip1559Tx);
1314
+ expect(data.length).toBe(3);
1315
+ expect(data[0]).toBe(0xab);
1316
+ });
1317
+ });
1318
+
1319
+ describe("getRecipient", () => {
1320
+ it("returns recipient address", () => {
1321
+ const recipient = Transaction.getRecipient(eip1559Tx);
1322
+ expect(recipient).toEqual(testAddress);
1323
+ });
1324
+
1325
+ it("returns null for contract creation", () => {
1326
+ const contractTx: Transaction.EIP1559 = {
1327
+ ...eip1559Tx,
1328
+ to: null,
1329
+ };
1330
+ const recipient = Transaction.getRecipient(contractTx);
1331
+ expect(recipient).toBeNull();
1332
+ });
1333
+ });
1334
+
1335
+ describe("getChainId additional cases", () => {
1336
+ it("returns chain ID for EIP-2930", () => {
1337
+ const eip2930Tx: Transaction.EIP2930 = {
1338
+ type: Transaction.Type.EIP2930,
1339
+ chainId: 137n,
1340
+ nonce: 0n,
1341
+ gasPrice: 20000000000n,
1342
+ gasLimit: 21000n,
1343
+ to: testAddress,
1344
+ value: 0n,
1345
+ data: new Uint8Array(),
1346
+ accessList: [],
1347
+ yParity: 0,
1348
+ r: testSignature.r,
1349
+ s: testSignature.s,
1350
+ };
1351
+ expect(Transaction.getChainId(eip2930Tx)).toBe(137n);
1352
+ });
1353
+
1354
+ it("returns chain ID for EIP-4844", () => {
1355
+ const blobHash = createHash(0x01);
1356
+ const eip4844Tx: Transaction.EIP4844 = {
1357
+ type: Transaction.Type.EIP4844,
1358
+ chainId: 42161n,
1359
+ nonce: 0n,
1360
+ maxPriorityFeePerGas: 1000000000n,
1361
+ maxFeePerGas: 20000000000n,
1362
+ gasLimit: 21000n,
1363
+ to: testAddress,
1364
+ value: 0n,
1365
+ data: new Uint8Array(),
1366
+ accessList: [],
1367
+ maxFeePerBlobGas: 1000000000n,
1368
+ blobVersionedHashes: [blobHash],
1369
+ yParity: 0,
1370
+ r: testSignature.r,
1371
+ s: testSignature.s,
1372
+ };
1373
+ expect(Transaction.getChainId(eip4844Tx)).toBe(42161n);
1374
+ });
1375
+
1376
+ it("returns null for pre-EIP-155 legacy", () => {
1377
+ const legacyTx: Transaction.Legacy = {
1378
+ type: Transaction.Type.Legacy,
1379
+ nonce: 0n,
1380
+ gasPrice: 20000000000n,
1381
+ gasLimit: 21000n,
1382
+ to: testAddress,
1383
+ value: 0n,
1384
+ data: new Uint8Array(),
1385
+ v: 27n,
1386
+ r: testSignature.r,
1387
+ s: testSignature.s,
1388
+ };
1389
+ expect(Transaction.getChainId(legacyTx)).toBeNull();
1390
+ });
1391
+ });
1392
+
1393
+ describe("getGasPrice additional cases", () => {
1394
+ it("returns baseFee when base fee exceeds maxFee", () => {
1395
+ const baseFee = 50000000000n; // Higher than maxFeePerGas (30000000000n)
1396
+ const effectivePrice = Transaction.getGasPrice(eip1559Tx, baseFee);
1397
+ // When baseFee > maxFee, effectivePriorityFee clamps to 0, returns baseFee
1398
+ expect(effectivePrice).toBe(baseFee);
1399
+ });
1400
+
1401
+ it("returns gas price for EIP-2930", () => {
1402
+ const eip2930Tx: Transaction.EIP2930 = {
1403
+ type: Transaction.Type.EIP2930,
1404
+ chainId: 1n,
1405
+ nonce: 0n,
1406
+ gasPrice: 25000000000n,
1407
+ gasLimit: 21000n,
1408
+ to: testAddress,
1409
+ value: 0n,
1410
+ data: new Uint8Array(),
1411
+ accessList: [],
1412
+ yParity: 0,
1413
+ r: testSignature.r,
1414
+ s: testSignature.s,
1415
+ };
1416
+ expect(Transaction.getGasPrice(eip2930Tx)).toBe(25000000000n);
1417
+ });
1418
+ });
1419
+
1420
+ describe("detectType additional cases", () => {
1421
+ it("detects EIP-2930 transaction", () => {
1422
+ const eip2930Tx: Transaction.EIP2930 = {
1423
+ type: Transaction.Type.EIP2930,
1424
+ chainId: 1n,
1425
+ nonce: 0n,
1426
+ gasPrice: 20000000000n,
1427
+ gasLimit: 21000n,
1428
+ to: testAddress,
1429
+ value: 0n,
1430
+ data: new Uint8Array(),
1431
+ accessList: [],
1432
+ yParity: 0,
1433
+ r: testSignature.r,
1434
+ s: testSignature.s,
1435
+ };
1436
+ const bytes = S.encodeSync(Transaction.Serialized)(eip2930Tx);
1437
+ expect(Transaction.detectType(bytes)).toBe(Transaction.Type.EIP2930);
1438
+ });
1439
+
1440
+ it("detects EIP-7702 transaction", () => {
1441
+ const eip7702Tx: Transaction.EIP7702 = {
1442
+ type: Transaction.Type.EIP7702,
1443
+ chainId: 1n,
1444
+ nonce: 0n,
1445
+ maxPriorityFeePerGas: 1000000000n,
1446
+ maxFeePerGas: 20000000000n,
1447
+ gasLimit: 21000n,
1448
+ to: testAddress,
1449
+ value: 0n,
1450
+ data: new Uint8Array(),
1451
+ accessList: [],
1452
+ authorizationList: [],
1453
+ yParity: 0,
1454
+ r: testSignature.r,
1455
+ s: testSignature.s,
1456
+ };
1457
+ const bytes = S.encodeSync(Transaction.Serialized)(eip7702Tx);
1458
+ expect(Transaction.detectType(bytes)).toBe(Transaction.Type.EIP7702);
1459
+ });
1460
+ });
1461
+
1462
+ describe("isSigned additional cases", () => {
1463
+ it("returns true for legacy with valid signature", () => {
1464
+ const legacyTx: Transaction.Legacy = {
1465
+ type: Transaction.Type.Legacy,
1466
+ nonce: 0n,
1467
+ gasPrice: 20000000000n,
1468
+ gasLimit: 21000n,
1469
+ to: testAddress,
1470
+ value: 0n,
1471
+ data: new Uint8Array(),
1472
+ v: 27n,
1473
+ r: testSignature.r,
1474
+ s: testSignature.s,
1475
+ };
1476
+ expect(Transaction.isSigned(legacyTx)).toBe(true);
1477
+ });
1478
+
1479
+ it("returns false for legacy with zero signature", () => {
1480
+ const legacyTx: Transaction.Legacy = {
1481
+ type: Transaction.Type.Legacy,
1482
+ nonce: 0n,
1483
+ gasPrice: 20000000000n,
1484
+ gasLimit: 21000n,
1485
+ to: testAddress,
1486
+ value: 0n,
1487
+ data: new Uint8Array(),
1488
+ v: 0n,
1489
+ r: new Uint8Array(32),
1490
+ s: new Uint8Array(32),
1491
+ };
1492
+ expect(Transaction.isSigned(legacyTx)).toBe(false);
1493
+ });
1494
+ });
1495
+
1496
+ describe("isContractCreation additional cases", () => {
1497
+ it("returns true for EIP-1559 contract creation", () => {
1498
+ const contractTx: Transaction.EIP1559 = {
1499
+ ...eip1559Tx,
1500
+ to: null,
1501
+ data: new Uint8Array([0x60, 0x80, 0x60, 0x40, 0x52]),
1502
+ };
1503
+ expect(Transaction.isContractCreation(contractTx)).toBe(true);
1504
+ });
1505
+
1506
+ it("returns true for EIP-2930 contract creation", () => {
1507
+ const contractTx: Transaction.EIP2930 = {
1508
+ type: Transaction.Type.EIP2930,
1509
+ chainId: 1n,
1510
+ nonce: 0n,
1511
+ gasPrice: 20000000000n,
1512
+ gasLimit: 1000000n,
1513
+ to: null,
1514
+ value: 0n,
1515
+ data: new Uint8Array([0x60, 0x80]),
1516
+ accessList: [],
1517
+ yParity: 0,
1518
+ r: testSignature.r,
1519
+ s: testSignature.s,
1520
+ };
1521
+ expect(Transaction.isContractCreation(contractTx)).toBe(true);
1522
+ });
1523
+ });
1524
+
1525
+ describe("hash consistency", () => {
1526
+ it("produces consistent hashes across transaction types", () => {
1527
+ const legacyTx: Transaction.Legacy = {
1528
+ type: Transaction.Type.Legacy,
1529
+ nonce: 0n,
1530
+ gasPrice: 20000000000n,
1531
+ gasLimit: 21000n,
1532
+ to: testAddress,
1533
+ value: 0n,
1534
+ data: new Uint8Array(),
1535
+ v: 27n,
1536
+ r: testSignature.r,
1537
+ s: testSignature.s,
1538
+ };
1539
+ const h1 = Transaction.hash(legacyTx);
1540
+ const h2 = Transaction.hash(legacyTx);
1541
+ expect(h1).toEqual(h2);
1542
+
1543
+ const eip2930Tx: Transaction.EIP2930 = {
1544
+ type: Transaction.Type.EIP2930,
1545
+ chainId: 1n,
1546
+ nonce: 0n,
1547
+ gasPrice: 20000000000n,
1548
+ gasLimit: 21000n,
1549
+ to: testAddress,
1550
+ value: 0n,
1551
+ data: new Uint8Array(),
1552
+ accessList: [],
1553
+ yParity: 0,
1554
+ r: testSignature.r,
1555
+ s: testSignature.s,
1556
+ };
1557
+ const h3 = Transaction.hash(eip2930Tx);
1558
+ const h4 = Transaction.hash(eip2930Tx);
1559
+ expect(h3).toEqual(h4);
1560
+ });
1561
+ });
1562
+ });