viem 0.0.1-alpha.25 → 0.0.1-alpha.27

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 (503) hide show
  1. package/dist/{call-ac509982.d.ts → call-3476b8ee.d.ts} +4 -5
  2. package/dist/{chain-f16512e8.d.ts → chain-42de87e5.d.ts} +1 -14
  3. package/dist/{chain-c4ccb458.d.ts → chain-b0cfb141.d.ts} +1 -1
  4. package/dist/chains.d.ts +3 -3
  5. package/dist/chains.js +46 -46
  6. package/dist/chains.mjs +1 -1
  7. package/dist/{chunk-NUXMGPMK.js → chunk-2DSFM32P.js} +15 -15
  8. package/dist/{chunk-NUXMGPMK.js.map → chunk-2DSFM32P.js.map} +1 -1
  9. package/dist/{chunk-KSAO4Y4Q.mjs → chunk-AKGXRZDN.mjs} +355 -337
  10. package/dist/chunk-AKGXRZDN.mjs.map +1 -0
  11. package/dist/{chunk-2Y3UZMSP.mjs → chunk-BJJH7RYH.mjs} +61 -16
  12. package/dist/chunk-BJJH7RYH.mjs.map +1 -0
  13. package/dist/{chunk-CD2XJOBJ.js → chunk-JY7JGKSA.js} +136 -91
  14. package/dist/chunk-JY7JGKSA.js.map +1 -0
  15. package/dist/{chunk-LEPQJNVO.mjs → chunk-LF6P33WQ.mjs} +6 -6
  16. package/dist/chunk-LF6P33WQ.mjs.map +1 -0
  17. package/dist/{chunk-THMRUG4D.js → chunk-W7KWIGWO.js} +314 -296
  18. package/dist/chunk-W7KWIGWO.js.map +1 -0
  19. package/dist/{contract-9e76e561.d.ts → contract-9dd2f98b.d.ts} +1 -1
  20. package/dist/contract.d.ts +21 -15
  21. package/dist/contract.js +6 -4
  22. package/dist/contract.mjs +5 -3
  23. package/dist/{createClient-68ee4bb4.d.ts → createClient-6689596e.d.ts} +10 -4
  24. package/dist/{createPublicClient-b732194e.d.ts → createPublicClient-fd558574.d.ts} +3 -3
  25. package/dist/{createTestClient-dedf321e.d.ts → createTestClient-bc1d9028.d.ts} +3 -3
  26. package/dist/{createWalletClient-75813d83.d.ts → createWalletClient-4df88244.d.ts} +3 -3
  27. package/dist/{decodeErrorResult-0b934d23.d.ts → decodeErrorResult-ac835649.d.ts} +2 -2
  28. package/dist/{eip1193-6f9ba163.d.ts → eip1193-617a05ae.d.ts} +2 -2
  29. package/dist/ens.d.ts +8 -8
  30. package/dist/ens.js +21 -21
  31. package/dist/ens.js.map +1 -1
  32. package/dist/ens.mjs +9 -9
  33. package/dist/ens.mjs.map +1 -1
  34. package/dist/{getAbiItem-c8e6e7d4.d.ts → getAbiItem-d2e8bd76.d.ts} +2 -2
  35. package/dist/index.d.ts +44 -21
  36. package/dist/index.js +54 -32
  37. package/dist/index.js.map +1 -1
  38. package/dist/index.mjs +43 -21
  39. package/dist/index.mjs.map +1 -1
  40. package/dist/public.d.ts +13 -12
  41. package/dist/public.js +3 -3
  42. package/dist/public.mjs +2 -2
  43. package/dist/{readContract-4f6e2692.d.ts → readContract-c460f23a.d.ts} +3 -3
  44. package/dist/{rpc-a5a7f376.d.ts → rpc-8c10fc98.d.ts} +3 -5
  45. package/dist/{sendTransaction-e713f90c.d.ts → sendTransaction-7ce442c0.d.ts} +3 -3
  46. package/dist/test.d.ts +4 -4
  47. package/dist/test.js +13 -13
  48. package/dist/test.mjs +1 -1
  49. package/dist/{transactionReceipt-2a86c7c7.d.ts → transactionReceipt-44dbf122.d.ts} +1 -1
  50. package/dist/{transactionRequest-c7794f5e.d.ts → transactionRequest-f437b4ba.d.ts} +1 -1
  51. package/dist/utils/index.d.ts +25 -22
  52. package/dist/utils/index.js +2 -2
  53. package/dist/utils/index.mjs +13 -13
  54. package/dist/wallet.d.ts +6 -6
  55. package/dist/wallet.js +3 -3
  56. package/dist/wallet.mjs +2 -2
  57. package/dist/{watchEvent-c346c12d.d.ts → watchEvent-569c9976.d.ts} +3 -3
  58. package/dist/window.d.ts +2 -2
  59. package/package.json +4 -5
  60. package/public/package.json +4 -0
  61. package/test/package.json +4 -0
  62. package/dist/chunk-2Y3UZMSP.mjs.map +0 -1
  63. package/dist/chunk-CD2XJOBJ.js.map +0 -1
  64. package/dist/chunk-KSAO4Y4Q.mjs.map +0 -1
  65. package/dist/chunk-LEPQJNVO.mjs.map +0 -1
  66. package/dist/chunk-THMRUG4D.js.map +0 -1
  67. package/src/_test/abis.ts +0 -1420
  68. package/src/_test/bench.ts +0 -15
  69. package/src/_test/constants.ts +0 -63
  70. package/src/_test/globalSetup.ts +0 -11
  71. package/src/_test/index.ts +0 -25
  72. package/src/_test/setup.ts +0 -8
  73. package/src/_test/utils.ts +0 -155
  74. package/src/actions/ens/getEnsAddress.bench.ts +0 -26
  75. package/src/actions/ens/getEnsAddress.test.ts +0 -97
  76. package/src/actions/ens/getEnsAddress.ts +0 -122
  77. package/src/actions/ens/getEnsName.bench.ts +0 -30
  78. package/src/actions/ens/getEnsName.test.ts +0 -101
  79. package/src/actions/ens/getEnsName.ts +0 -106
  80. package/src/actions/ens/index.test.ts +0 -12
  81. package/src/actions/ens/index.ts +0 -3
  82. package/src/actions/index.test.ts +0 -81
  83. package/src/actions/index.ts +0 -182
  84. package/src/actions/public/call.bench.ts +0 -48
  85. package/src/actions/public/call.test.ts +0 -99
  86. package/src/actions/public/call.ts +0 -97
  87. package/src/actions/public/createBlockFilter.bench.ts +0 -11
  88. package/src/actions/public/createBlockFilter.test.ts +0 -9
  89. package/src/actions/public/createBlockFilter.ts +0 -14
  90. package/src/actions/public/createContractEventFilter.test.ts +0 -119
  91. package/src/actions/public/createContractEventFilter.ts +0 -69
  92. package/src/actions/public/createEventFilter.test.ts +0 -277
  93. package/src/actions/public/createEventFilter.ts +0 -93
  94. package/src/actions/public/createPendingTransactionFilter.bench.ts +0 -11
  95. package/src/actions/public/createPendingTransactionFilter.test.ts +0 -9
  96. package/src/actions/public/createPendingTransactionFilter.ts +0 -14
  97. package/src/actions/public/estimateGas.bench.ts +0 -46
  98. package/src/actions/public/estimateGas.test.ts +0 -92
  99. package/src/actions/public/estimateGas.ts +0 -61
  100. package/src/actions/public/getBalance.test.ts +0 -83
  101. package/src/actions/public/getBalance.ts +0 -37
  102. package/src/actions/public/getBlock.bench.ts +0 -28
  103. package/src/actions/public/getBlock.test.ts +0 -575
  104. package/src/actions/public/getBlock.ts +0 -65
  105. package/src/actions/public/getBlockNumber.bench.ts +0 -28
  106. package/src/actions/public/getBlockNumber.test.ts +0 -27
  107. package/src/actions/public/getBlockNumber.ts +0 -32
  108. package/src/actions/public/getBlockTransactionCount.bench.ts +0 -15
  109. package/src/actions/public/getBlockTransactionCount.test.ts +0 -57
  110. package/src/actions/public/getBlockTransactionCount.ts +0 -52
  111. package/src/actions/public/getBytecode.test.ts +0 -27
  112. package/src/actions/public/getBytecode.ts +0 -32
  113. package/src/actions/public/getChainId.bench.ts +0 -15
  114. package/src/actions/public/getChainId.test.ts +0 -8
  115. package/src/actions/public/getChainId.ts +0 -7
  116. package/src/actions/public/getFeeHistory.bench.ts +0 -18
  117. package/src/actions/public/getFeeHistory.test.ts +0 -137
  118. package/src/actions/public/getFeeHistory.ts +0 -44
  119. package/src/actions/public/getFilterChanges.bench.ts +0 -13
  120. package/src/actions/public/getFilterChanges.test.ts +0 -383
  121. package/src/actions/public/getFilterChanges.ts +0 -23
  122. package/src/actions/public/getFilterLogs.test.ts +0 -297
  123. package/src/actions/public/getFilterLogs.ts +0 -20
  124. package/src/actions/public/getGasPrice.bench.ts +0 -19
  125. package/src/actions/public/getGasPrice.test.ts +0 -8
  126. package/src/actions/public/getGasPrice.ts +0 -15
  127. package/src/actions/public/getLogs.test.ts +0 -306
  128. package/src/actions/public/getLogs.ts +0 -84
  129. package/src/actions/public/getStorageAt.test.ts +0 -34
  130. package/src/actions/public/getStorageAt.ts +0 -32
  131. package/src/actions/public/getTransaction.bench.ts +0 -33
  132. package/src/actions/public/getTransaction.test.ts +0 -311
  133. package/src/actions/public/getTransaction.ts +0 -95
  134. package/src/actions/public/getTransactionConfirmations.test.ts +0 -69
  135. package/src/actions/public/getTransactionConfirmations.ts +0 -38
  136. package/src/actions/public/getTransactionCount.test.ts +0 -56
  137. package/src/actions/public/getTransactionCount.ts +0 -34
  138. package/src/actions/public/getTransactionReceipt.bench.ts +0 -33
  139. package/src/actions/public/getTransactionReceipt.test.ts +0 -179
  140. package/src/actions/public/getTransactionReceipt.ts +0 -34
  141. package/src/actions/public/index.test.ts +0 -43
  142. package/src/actions/public/index.ts +0 -146
  143. package/src/actions/public/multicall.test.ts +0 -452
  144. package/src/actions/public/multicall.ts +0 -108
  145. package/src/actions/public/readContract.test.ts +0 -328
  146. package/src/actions/public/readContract.ts +0 -73
  147. package/src/actions/public/simulateContract.bench.ts +0 -41
  148. package/src/actions/public/simulateContract.test.ts +0 -410
  149. package/src/actions/public/simulateContract.ts +0 -91
  150. package/src/actions/public/uninstallFilter.bench.ts +0 -13
  151. package/src/actions/public/uninstallFilter.test.ts +0 -65
  152. package/src/actions/public/uninstallFilter.ts +0 -17
  153. package/src/actions/public/waitForTransactionReceipt.test.ts +0 -322
  154. package/src/actions/public/waitForTransactionReceipt.ts +0 -170
  155. package/src/actions/public/watchBlockNumber.test.ts +0 -166
  156. package/src/actions/public/watchBlockNumber.ts +0 -79
  157. package/src/actions/public/watchBlocks.test.ts +0 -210
  158. package/src/actions/public/watchBlocks.ts +0 -114
  159. package/src/actions/public/watchContractEvent.test.ts +0 -305
  160. package/src/actions/public/watchContractEvent.ts +0 -108
  161. package/src/actions/public/watchEvent.test.ts +0 -195
  162. package/src/actions/public/watchEvent.ts +0 -95
  163. package/src/actions/public/watchPendingTransactions.test.ts +0 -116
  164. package/src/actions/public/watchPendingTransactions.ts +0 -74
  165. package/src/actions/test/dropTransaction.test.ts +0 -34
  166. package/src/actions/test/dropTransaction.ts +0 -17
  167. package/src/actions/test/getAutomine.test.ts +0 -14
  168. package/src/actions/test/getAutomine.ts +0 -11
  169. package/src/actions/test/getTxpoolContent.test.ts +0 -45
  170. package/src/actions/test/getTxpoolContent.ts +0 -7
  171. package/src/actions/test/getTxpoolStatus.test.ts +0 -41
  172. package/src/actions/test/getTxpoolStatus.ts +0 -12
  173. package/src/actions/test/impersonateAccount.test.ts +0 -26
  174. package/src/actions/test/impersonateAccount.ts +0 -17
  175. package/src/actions/test/increaseTime.test.ts +0 -18
  176. package/src/actions/test/increaseTime.ts +0 -17
  177. package/src/actions/test/index.test.ts +0 -38
  178. package/src/actions/test/index.ts +0 -77
  179. package/src/actions/test/inspectTxpool.test.ts +0 -50
  180. package/src/actions/test/inspectTxpool.ts +0 -7
  181. package/src/actions/test/mine.test.ts +0 -20
  182. package/src/actions/test/mine.ts +0 -16
  183. package/src/actions/test/removeBlockTimestampInterval.test.ts +0 -23
  184. package/src/actions/test/removeBlockTimestampInterval.ts +0 -7
  185. package/src/actions/test/reset.test.ts +0 -19
  186. package/src/actions/test/reset.ts +0 -18
  187. package/src/actions/test/revert.test.ts +0 -39
  188. package/src/actions/test/revert.ts +0 -14
  189. package/src/actions/test/sendUnsignedTransaction.test.ts +0 -52
  190. package/src/actions/test/sendUnsignedTransaction.ts +0 -19
  191. package/src/actions/test/setAutomine.test.ts +0 -14
  192. package/src/actions/test/setAutomine.ts +0 -8
  193. package/src/actions/test/setBalance.test.ts +0 -29
  194. package/src/actions/test/setBalance.ts +0 -20
  195. package/src/actions/test/setBlockGasLimit.test.ts +0 -21
  196. package/src/actions/test/setBlockGasLimit.ts +0 -17
  197. package/src/actions/test/setBlockTimestampInterval.test.ts +0 -23
  198. package/src/actions/test/setBlockTimestampInterval.ts +0 -16
  199. package/src/actions/test/setCode.test.ts +0 -26
  200. package/src/actions/test/setCode.ts +0 -19
  201. package/src/actions/test/setCoinbase.test.ts +0 -11
  202. package/src/actions/test/setCoinbase.ts +0 -17
  203. package/src/actions/test/setIntervalMining.test.ts +0 -30
  204. package/src/actions/test/setIntervalMining.ts +0 -16
  205. package/src/actions/test/setLoggingEnabled.test.ts +0 -10
  206. package/src/actions/test/setLoggingEnabled.ts +0 -8
  207. package/src/actions/test/setMinGasPrice.test.ts +0 -22
  208. package/src/actions/test/setMinGasPrice.ts +0 -17
  209. package/src/actions/test/setNextBlockBaseFeePerGas.test.ts +0 -23
  210. package/src/actions/test/setNextBlockBaseFeePerGas.ts +0 -17
  211. package/src/actions/test/setNextBlockTimestamp.test.ts +0 -19
  212. package/src/actions/test/setNextBlockTimestamp.ts +0 -17
  213. package/src/actions/test/setNonce.test.ts +0 -28
  214. package/src/actions/test/setNonce.ts +0 -20
  215. package/src/actions/test/setRpcUrl.test.ts +0 -9
  216. package/src/actions/test/setRpcUrl.ts +0 -8
  217. package/src/actions/test/setStorageAt.test.ts +0 -36
  218. package/src/actions/test/setStorageAt.ts +0 -26
  219. package/src/actions/test/snapshot.test.ts +0 -18
  220. package/src/actions/test/snapshot.ts +0 -7
  221. package/src/actions/test/stopImpersonatingAccount.test.ts +0 -29
  222. package/src/actions/test/stopImpersonatingAccount.ts +0 -17
  223. package/src/actions/wallet/addChain.test.ts +0 -14
  224. package/src/actions/wallet/addChain.ts +0 -21
  225. package/src/actions/wallet/deployContract.test.ts +0 -55
  226. package/src/actions/wallet/deployContract.ts +0 -38
  227. package/src/actions/wallet/getAccounts.test.ts +0 -22
  228. package/src/actions/wallet/getAccounts.ts +0 -7
  229. package/src/actions/wallet/getPermissions.test.ts +0 -24
  230. package/src/actions/wallet/getPermissions.ts +0 -9
  231. package/src/actions/wallet/index.test.ts +0 -21
  232. package/src/actions/wallet/index.ts +0 -36
  233. package/src/actions/wallet/requestAccounts.test.ts +0 -13
  234. package/src/actions/wallet/requestAccounts.ts +0 -7
  235. package/src/actions/wallet/requestPermissions.test.ts +0 -26
  236. package/src/actions/wallet/requestPermissions.ts +0 -19
  237. package/src/actions/wallet/sendTransaction.bench.ts +0 -57
  238. package/src/actions/wallet/sendTransaction.test.ts +0 -440
  239. package/src/actions/wallet/sendTransaction.ts +0 -77
  240. package/src/actions/wallet/signMessage.test.ts +0 -61
  241. package/src/actions/wallet/signMessage.ts +0 -35
  242. package/src/actions/wallet/switchChain.test.ts +0 -21
  243. package/src/actions/wallet/switchChain.ts +0 -19
  244. package/src/actions/wallet/watchAsset.test.ts +0 -40
  245. package/src/actions/wallet/watchAsset.ts +0 -16
  246. package/src/actions/wallet/writeContract.test.ts +0 -84
  247. package/src/actions/wallet/writeContract.ts +0 -47
  248. package/src/chains.test.ts +0 -439
  249. package/src/chains.ts +0 -99
  250. package/src/clients/createClient.test.ts +0 -295
  251. package/src/clients/createClient.ts +0 -81
  252. package/src/clients/createPublicClient.test.ts +0 -165
  253. package/src/clients/createPublicClient.ts +0 -49
  254. package/src/clients/createTestClient.test.ts +0 -145
  255. package/src/clients/createTestClient.ts +0 -72
  256. package/src/clients/createWalletClient.test.ts +0 -121
  257. package/src/clients/createWalletClient.ts +0 -54
  258. package/src/clients/index.test.ts +0 -19
  259. package/src/clients/index.ts +0 -31
  260. package/src/clients/transports/createTransport.test.ts +0 -58
  261. package/src/clients/transports/createTransport.ts +0 -48
  262. package/src/clients/transports/custom.test.ts +0 -98
  263. package/src/clients/transports/custom.ts +0 -34
  264. package/src/clients/transports/fallback.test.ts +0 -257
  265. package/src/clients/transports/fallback.ts +0 -50
  266. package/src/clients/transports/http.test.ts +0 -109
  267. package/src/clients/transports/http.ts +0 -51
  268. package/src/clients/transports/index.test.ts +0 -15
  269. package/src/clients/transports/index.ts +0 -17
  270. package/src/clients/transports/webSocket.test.ts +0 -164
  271. package/src/clients/transports/webSocket.ts +0 -118
  272. package/src/constants/abis.test.ts +0 -53
  273. package/src/constants/abis.ts +0 -44
  274. package/src/constants/index.test.ts +0 -14
  275. package/src/constants/index.ts +0 -3
  276. package/src/constants/solidity.test.ts +0 -41
  277. package/src/constants/solidity.ts +0 -35
  278. package/src/contract.test.ts +0 -31
  279. package/src/contract.ts +0 -68
  280. package/src/ens.test.ts +0 -15
  281. package/src/ens.ts +0 -8
  282. package/src/errors/abi.test.ts +0 -81
  283. package/src/errors/abi.ts +0 -254
  284. package/src/errors/address.test.ts +0 -14
  285. package/src/errors/address.ts +0 -9
  286. package/src/errors/base.test.ts +0 -114
  287. package/src/errors/base.ts +0 -57
  288. package/src/errors/block.test.ts +0 -24
  289. package/src/errors/block.ts +0 -18
  290. package/src/errors/chain.test.ts +0 -46
  291. package/src/errors/chain.ts +0 -33
  292. package/src/errors/contract.test.ts +0 -233
  293. package/src/errors/contract.ts +0 -178
  294. package/src/errors/data.ts +0 -20
  295. package/src/errors/encoding.ts +0 -60
  296. package/src/errors/index.ts +0 -82
  297. package/src/errors/log.ts +0 -8
  298. package/src/errors/request.test.ts +0 -330
  299. package/src/errors/request.ts +0 -163
  300. package/src/errors/rpc.test.ts +0 -87
  301. package/src/errors/rpc.ts +0 -113
  302. package/src/errors/transaction.test.ts +0 -83
  303. package/src/errors/transaction.ts +0 -54
  304. package/src/errors/transport.test.ts +0 -11
  305. package/src/errors/transport.ts +0 -12
  306. package/src/index.test.ts +0 -116
  307. package/src/index.ts +0 -132
  308. package/src/public.test.ts +0 -36
  309. package/src/public.ts +0 -76
  310. package/src/test.test.ts +0 -38
  311. package/src/test.ts +0 -52
  312. package/src/types/block.ts +0 -71
  313. package/src/types/chain.ts +0 -6
  314. package/src/types/contract.ts +0 -497
  315. package/src/types/eip1193.ts +0 -1041
  316. package/src/types/fee.ts +0 -47
  317. package/src/types/filter.ts +0 -8
  318. package/src/types/formatter.ts +0 -23
  319. package/src/types/index.ts +0 -84
  320. package/src/types/log.ts +0 -22
  321. package/src/types/misc.ts +0 -5
  322. package/src/types/multicall.ts +0 -82
  323. package/src/types/rpc.ts +0 -35
  324. package/src/types/transaction.ts +0 -145
  325. package/src/types/utils.ts +0 -88
  326. package/src/types/window.ts +0 -9
  327. package/src/utils/abi/decodeAbi.bench.ts +0 -135
  328. package/src/utils/abi/decodeAbi.test.ts +0 -1614
  329. package/src/utils/abi/decodeAbi.ts +0 -300
  330. package/src/utils/abi/decodeDeployData.test.ts +0 -151
  331. package/src/utils/abi/decodeDeployData.ts +0 -44
  332. package/src/utils/abi/decodeErrorResult.test.ts +0 -230
  333. package/src/utils/abi/decodeErrorResult.ts +0 -45
  334. package/src/utils/abi/decodeEventLog.test.ts +0 -542
  335. package/src/utils/abi/decodeEventLog.ts +0 -107
  336. package/src/utils/abi/decodeFunctionData.test.ts +0 -138
  337. package/src/utils/abi/decodeFunctionData.ts +0 -32
  338. package/src/utils/abi/decodeFunctionResult.test.ts +0 -333
  339. package/src/utils/abi/decodeFunctionResult.ts +0 -57
  340. package/src/utils/abi/encodeAbi.bench.ts +0 -163
  341. package/src/utils/abi/encodeAbi.test.ts +0 -1447
  342. package/src/utils/abi/encodeAbi.ts +0 -273
  343. package/src/utils/abi/encodeDeployData.test.ts +0 -124
  344. package/src/utils/abi/encodeDeployData.ts +0 -40
  345. package/src/utils/abi/encodeErrorResult.test.ts +0 -192
  346. package/src/utils/abi/encodeErrorResult.ts +0 -47
  347. package/src/utils/abi/encodeEventTopics.test.ts +0 -345
  348. package/src/utils/abi/encodeEventTopics.ts +0 -75
  349. package/src/utils/abi/encodeFunctionData.test.ts +0 -138
  350. package/src/utils/abi/encodeFunctionData.ts +0 -42
  351. package/src/utils/abi/encodeFunctionResult.test.ts +0 -279
  352. package/src/utils/abi/encodeFunctionResult.ts +0 -41
  353. package/src/utils/abi/formatAbiItem.test.ts +0 -335
  354. package/src/utils/abi/formatAbiItem.ts +0 -41
  355. package/src/utils/abi/formatAbiItemWithArgs.test.ts +0 -291
  356. package/src/utils/abi/formatAbiItemWithArgs.ts +0 -27
  357. package/src/utils/abi/getAbiItem.test.ts +0 -547
  358. package/src/utils/abi/getAbiItem.ts +0 -95
  359. package/src/utils/abi/index.test.ts +0 -24
  360. package/src/utils/abi/index.ts +0 -48
  361. package/src/utils/address/getAddress.bench.ts +0 -22
  362. package/src/utils/address/getAddress.test.ts +0 -46
  363. package/src/utils/address/getAddress.ts +0 -28
  364. package/src/utils/address/getContractAddress.bench.ts +0 -20
  365. package/src/utils/address/getContractAddress.test.ts +0 -78
  366. package/src/utils/address/getContractAddress.ts +0 -59
  367. package/src/utils/address/index.test.ts +0 -17
  368. package/src/utils/address/index.ts +0 -16
  369. package/src/utils/address/isAddress.test.ts +0 -10
  370. package/src/utils/address/isAddress.ts +0 -10
  371. package/src/utils/address/isAddressEqual.test.ts +0 -55
  372. package/src/utils/address/isAddressEqual.ts +0 -6
  373. package/src/utils/buildRequest.test.ts +0 -365
  374. package/src/utils/buildRequest.ts +0 -45
  375. package/src/utils/chain.test.ts +0 -43
  376. package/src/utils/chain.ts +0 -8
  377. package/src/utils/contract/extractFunctionParts.test.ts +0 -109
  378. package/src/utils/contract/extractFunctionParts.ts +0 -27
  379. package/src/utils/contract/getContractError.test.ts +0 -282
  380. package/src/utils/contract/getContractError.ts +0 -58
  381. package/src/utils/contract/index.test.ts +0 -15
  382. package/src/utils/contract/index.ts +0 -8
  383. package/src/utils/data/concat.test.ts +0 -35
  384. package/src/utils/data/concat.ts +0 -34
  385. package/src/utils/data/index.test.ts +0 -23
  386. package/src/utils/data/index.ts +0 -13
  387. package/src/utils/data/isBytes.test.ts +0 -9
  388. package/src/utils/data/isBytes.ts +0 -7
  389. package/src/utils/data/isHex.test.ts +0 -13
  390. package/src/utils/data/isHex.ts +0 -5
  391. package/src/utils/data/pad.bench.ts +0 -30
  392. package/src/utils/data/pad.test.ts +0 -367
  393. package/src/utils/data/pad.ts +0 -53
  394. package/src/utils/data/size.test.ts +0 -18
  395. package/src/utils/data/size.ts +0 -13
  396. package/src/utils/data/slice.test.ts +0 -203
  397. package/src/utils/data/slice.ts +0 -60
  398. package/src/utils/data/trim.bench.ts +0 -34
  399. package/src/utils/data/trim.test.ts +0 -175
  400. package/src/utils/data/trim.ts +0 -33
  401. package/src/utils/encoding/decodeBytes.bench.ts +0 -40
  402. package/src/utils/encoding/decodeBytes.test.ts +0 -144
  403. package/src/utils/encoding/decodeBytes.ts +0 -63
  404. package/src/utils/encoding/decodeHex.bench.ts +0 -24
  405. package/src/utils/encoding/decodeHex.test.ts +0 -167
  406. package/src/utils/encoding/decodeHex.ts +0 -76
  407. package/src/utils/encoding/decodeRlp.bench.ts +0 -34
  408. package/src/utils/encoding/decodeRlp.test.ts +0 -350
  409. package/src/utils/encoding/decodeRlp.ts +0 -121
  410. package/src/utils/encoding/encodeBytes.bench.ts +0 -29
  411. package/src/utils/encoding/encodeBytes.test.ts +0 -676
  412. package/src/utils/encoding/encodeBytes.ts +0 -59
  413. package/src/utils/encoding/encodeHex.bench.ts +0 -49
  414. package/src/utils/encoding/encodeHex.test.ts +0 -232
  415. package/src/utils/encoding/encodeHex.ts +0 -104
  416. package/src/utils/encoding/encodeRlp.bench.ts +0 -54
  417. package/src/utils/encoding/encodeRlp.test.ts +0 -254
  418. package/src/utils/encoding/encodeRlp.ts +0 -48
  419. package/src/utils/encoding/index.test.ts +0 -32
  420. package/src/utils/encoding/index.ts +0 -36
  421. package/src/utils/ens/index.test.ts +0 -14
  422. package/src/utils/ens/index.ts +0 -7
  423. package/src/utils/ens/labelhash.test.ts +0 -55
  424. package/src/utils/ens/labelhash.ts +0 -16
  425. package/src/utils/ens/namehash.test.ts +0 -65
  426. package/src/utils/ens/namehash.ts +0 -28
  427. package/src/utils/ens/normalize.bench.ts +0 -14
  428. package/src/utils/ens/normalize.test.ts +0 -35
  429. package/src/utils/ens/normalize.ts +0 -14
  430. package/src/utils/ens/packetToBytes.test.ts +0 -11
  431. package/src/utils/ens/packetToBytes.ts +0 -29
  432. package/src/utils/formatters/block.bench.ts +0 -51
  433. package/src/utils/formatters/block.test.ts +0 -115
  434. package/src/utils/formatters/block.ts +0 -37
  435. package/src/utils/formatters/extract.test.ts +0 -14
  436. package/src/utils/formatters/extract.ts +0 -18
  437. package/src/utils/formatters/feeHistory.test.ts +0 -66
  438. package/src/utils/formatters/feeHistory.ts +0 -12
  439. package/src/utils/formatters/format.test.ts +0 -93
  440. package/src/utils/formatters/format.ts +0 -90
  441. package/src/utils/formatters/index.test.ts +0 -27
  442. package/src/utils/formatters/index.ts +0 -34
  443. package/src/utils/formatters/log.test.ts +0 -79
  444. package/src/utils/formatters/log.ts +0 -12
  445. package/src/utils/formatters/transaction.test.ts +0 -271
  446. package/src/utils/formatters/transaction.ts +0 -63
  447. package/src/utils/formatters/transactionReceipt.bench.ts +0 -73
  448. package/src/utils/formatters/transactionReceipt.test.ts +0 -151
  449. package/src/utils/formatters/transactionReceipt.ts +0 -63
  450. package/src/utils/formatters/transactionRequest.bench.ts +0 -29
  451. package/src/utils/formatters/transactionRequest.test.ts +0 -237
  452. package/src/utils/formatters/transactionRequest.ts +0 -56
  453. package/src/utils/hash/getEventSignature.test.ts +0 -61
  454. package/src/utils/hash/getEventSignature.ts +0 -4
  455. package/src/utils/hash/getFunctionSignature.test.ts +0 -22
  456. package/src/utils/hash/getFunctionSignature.ts +0 -5
  457. package/src/utils/hash/hashFunction.test.ts +0 -65
  458. package/src/utils/hash/hashFunction.ts +0 -12
  459. package/src/utils/hash/index.test.ts +0 -13
  460. package/src/utils/hash/index.ts +0 -5
  461. package/src/utils/hash/keccak256.test.ts +0 -59
  462. package/src/utils/hash/keccak256.ts +0 -21
  463. package/src/utils/index.test.ts +0 -111
  464. package/src/utils/index.ts +0 -142
  465. package/src/utils/observe.test.ts +0 -176
  466. package/src/utils/observe.ts +0 -66
  467. package/src/utils/poll.test.ts +0 -127
  468. package/src/utils/poll.ts +0 -42
  469. package/src/utils/promise/index.test.ts +0 -14
  470. package/src/utils/promise/index.ts +0 -3
  471. package/src/utils/promise/withCache.test.ts +0 -97
  472. package/src/utils/promise/withCache.ts +0 -73
  473. package/src/utils/promise/withRetry.test.ts +0 -231
  474. package/src/utils/promise/withRetry.ts +0 -61
  475. package/src/utils/promise/withTimeout.test.ts +0 -37
  476. package/src/utils/promise/withTimeout.ts +0 -39
  477. package/src/utils/rpc.test.ts +0 -990
  478. package/src/utils/rpc.ts +0 -294
  479. package/src/utils/stringify.test.ts +0 -13
  480. package/src/utils/stringify.ts +0 -5
  481. package/src/utils/uid.ts +0 -14
  482. package/src/utils/unit/constants.test.ts +0 -22
  483. package/src/utils/unit/constants.ts +0 -12
  484. package/src/utils/unit/formatEther.test.ts +0 -75
  485. package/src/utils/unit/formatEther.ts +0 -6
  486. package/src/utils/unit/formatGwei.test.ts +0 -32
  487. package/src/utils/unit/formatGwei.ts +0 -6
  488. package/src/utils/unit/formatUnit.bench.ts +0 -21
  489. package/src/utils/unit/formatUnit.test.ts +0 -40
  490. package/src/utils/unit/formatUnit.ts +0 -16
  491. package/src/utils/unit/index.test.ts +0 -28
  492. package/src/utils/unit/index.ts +0 -7
  493. package/src/utils/unit/parseEther.test.ts +0 -126
  494. package/src/utils/unit/parseEther.ts +0 -6
  495. package/src/utils/unit/parseGwei.test.ts +0 -50
  496. package/src/utils/unit/parseGwei.ts +0 -6
  497. package/src/utils/unit/parseUnit.bench.ts +0 -21
  498. package/src/utils/unit/parseUnit.test.ts +0 -54
  499. package/src/utils/unit/parseUnit.ts +0 -27
  500. package/src/utils/wait.ts +0 -3
  501. package/src/wallet.test.ts +0 -19
  502. package/src/wallet.ts +0 -23
  503. package/src/window.ts +0 -1
@@ -9,7 +9,7 @@ var __publicField = (obj, key, value) => {
9
9
  var package_default = {
10
10
  name: "viem",
11
11
  description: "TypeScript Interface for Ethereum",
12
- version: "0.0.1-alpha.25",
12
+ version: "0.0.1-alpha.26",
13
13
  scripts: {
14
14
  anvil: "source .env && anvil --fork-url $VITE_ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME",
15
15
  bench: "vitest bench --no-threads",
@@ -18,30 +18,45 @@ var package_default = {
18
18
  changeset: "changeset",
19
19
  "changeset:release": "pnpm build && changeset publish",
20
20
  "changeset:version": "changeset version && pnpm install --lockfile-only",
21
+ clean: "rimraf dist chains contract ens public test utils wallet window",
21
22
  "contracts:build": "wagmi generate",
22
23
  dev: "DEV=true tsup",
23
24
  "dev:docs": "pnpm -r --filter site dev",
24
- format: "rome format src/ test/ --write",
25
+ format: "rome format src/ --write",
25
26
  lint: "rome check .",
26
27
  "lint:fix": "pnpm lint --apply-suggested",
27
- playground: "pnpm --filter playground-dev dev",
28
+ playground: "pnpm --filter playground-browser dev",
28
29
  postinstall: "pnpm dev && pnpm contracts:build",
29
30
  preinstall: "npx only-allow pnpm",
30
- prepublishOnly: "pnpm ts-node scripts/generate-package-json.ts",
31
+ prepublishOnly: "pnpm bun scripts/prepublishOnly.ts",
31
32
  prepare: "npx simple-git-hooks",
32
33
  test: "vitest dev --no-threads",
34
+ "test:cov": "vitest dev --coverage --no-threads",
33
35
  "test:ci": "CI=true vitest --coverage --no-threads",
34
36
  "test:ui": "vitest dev --ui --no-threads",
35
- "ts-node": "node --loader esbuild-register/loader -r esbuild-register",
37
+ "ts-node": "bun",
36
38
  typecheck: "tsc --noEmit"
37
39
  },
40
+ tsup: {
41
+ entry: [
42
+ "src/index.ts",
43
+ "src/chains.ts",
44
+ "src/contract.ts",
45
+ "src/ens.ts",
46
+ "src/public.ts",
47
+ "src/test.ts",
48
+ "src/utils/index.ts",
49
+ "src/wallet.ts",
50
+ "src/window.ts"
51
+ ]
52
+ },
38
53
  files: [
54
+ "/dist",
39
55
  "/chains",
40
56
  "/contract",
41
- "/dist",
42
57
  "/ens",
43
- "/src",
44
- "/types",
58
+ "/public",
59
+ "/test",
45
60
  "/utils",
46
61
  "/wallet",
47
62
  "/window"
@@ -49,47 +64,47 @@ var package_default = {
49
64
  exports: {
50
65
  ".": {
51
66
  types: "./dist/index.d.ts",
52
- module: "./dist/index.mjs",
67
+ module: "./dist/index.mts",
53
68
  default: "./dist/index.js"
54
69
  },
55
70
  "./chains": {
56
71
  types: "./dist/chains.d.ts",
57
- module: "./dist/chains.mjs",
72
+ module: "./dist/chains.mts",
58
73
  default: "./dist/chains.js"
59
74
  },
60
75
  "./contract": {
61
76
  types: "./dist/contract.d.ts",
62
- module: "./dist/contract.mjs",
77
+ module: "./dist/contract.mts",
63
78
  default: "./dist/contract.js"
64
79
  },
65
80
  "./ens": {
66
81
  types: "./dist/ens.d.ts",
67
- module: "./dist/ens.mjs",
82
+ module: "./dist/ens.mts",
68
83
  default: "./dist/ens.js"
69
84
  },
70
85
  "./public": {
71
86
  types: "./dist/public.d.ts",
72
- module: "./dist/public.mjs",
87
+ module: "./dist/public.mts",
73
88
  default: "./dist/public.js"
74
89
  },
75
90
  "./test": {
76
91
  types: "./dist/test.d.ts",
77
- module: "./dist/test.mjs",
92
+ module: "./dist/test.mts",
78
93
  default: "./dist/test.js"
79
94
  },
80
95
  "./utils": {
81
96
  types: "./dist/utils/index.d.ts",
82
- module: "./dist/utils/index.mjs",
97
+ module: "./dist/utils/index.mts",
83
98
  default: "./dist/utils/index.js"
84
99
  },
85
100
  "./wallet": {
86
101
  types: "./dist/wallet.d.ts",
87
- module: "./dist/wallet.mjs",
102
+ module: "./dist/wallet.mts",
88
103
  default: "./dist/wallet.js"
89
104
  },
90
105
  "./window": {
91
106
  types: "./dist/window.d.ts",
92
- module: "./dist/window.mjs",
107
+ module: "./dist/window.mts",
93
108
  default: "./dist/window.js"
94
109
  },
95
110
  "./package.json": "./package.json"
@@ -103,7 +118,6 @@ var package_default = {
103
118
  "@wagmi/chains": "~0.2.8",
104
119
  abitype: "~0.3.0",
105
120
  "idna-uts46-hx": "^4.1.2",
106
- "isomorphic-unfetch": "^4.0.2",
107
121
  "isomorphic-ws": "^5.0.0",
108
122
  ws: "^8.12.0"
109
123
  },
@@ -120,20 +134,20 @@ var package_default = {
120
134
  "@vitest/coverage-c8": "^0.24.3",
121
135
  "@vitest/ui": "^0.19.1",
122
136
  "@wagmi/cli": "^0.1.6",
137
+ bun: "^0.5.5",
123
138
  bundlewatch: "^0.3.3",
124
139
  dedent: "^0.7.0",
125
- esbuild: "^0.16.17",
126
- "esbuild-register": "^3.4.2",
127
140
  ethers: "^5.7.2",
128
141
  "ethers@6": "npm:ethers@^6.0.2",
129
142
  execa: "^6.1.0",
130
143
  "fs-extra": "^10.1.0",
144
+ rimraf: "^4.1.2",
131
145
  rome: "^11.0.0",
132
146
  "simple-git-hooks": "^2.8.1",
133
147
  tsup: "^6.6.0",
134
148
  typescript: "^4.9.4",
135
149
  vite: "^3.2.5",
136
- vitest: "^0.25.8",
150
+ vitest: "~0.25.8",
137
151
  web3: "^1.8.1"
138
152
  },
139
153
  license: "MIT",
@@ -150,7 +164,7 @@ var package_default = {
150
164
  "web3"
151
165
  ],
152
166
  "simple-git-hooks": {
153
- "pre-commit": "pnpm format & pnpm lint:fix"
167
+ "pre-commit": "pnpm format && pnpm lint:fix"
154
168
  },
155
169
  pnpm: {
156
170
  patchedDependencies: {
@@ -159,8 +173,12 @@ var package_default = {
159
173
  }
160
174
  };
161
175
 
176
+ // src/errors/utils.ts
177
+ var getContractAddress = (address) => address;
178
+ var getUrl = (url) => url;
179
+ var getVersion = () => `${package_default.name}@${package_default.version}`;
180
+
162
181
  // src/errors/base.ts
163
- var version = process.env.TEST ? "1.0.2" : package_default.version;
164
182
  var BaseError = class extends Error {
165
183
  constructor(shortMessage, args = {}) {
166
184
  const details = args.cause instanceof BaseError ? args.cause.details : _optionalChain([args, 'access', _2 => _2.cause, 'optionalAccess', _3 => _3.message]) ? args.cause.message : args.details;
@@ -171,7 +189,7 @@ var BaseError = class extends Error {
171
189
  ...args.metaMessages ? [...args.metaMessages, ""] : [],
172
190
  ...docsPath5 ? [`Docs: https://viem.sh${docsPath5}`] : [],
173
191
  ...details ? [`Details: ${details}`] : [],
174
- `Version: viem@${version}`
192
+ `Version: ${getVersion()}`
175
193
  ].join("\n");
176
194
  super(message);
177
195
  __publicField(this, "details");
@@ -575,8 +593,7 @@ var ContractFunctionExecutionError = class extends BaseError {
575
593
  docsPath: docsPath5,
576
594
  metaMessages: [
577
595
  ...cause.metaMessages ? [...cause.metaMessages, " "] : [],
578
- contractAddress && `Contract: ${/* c8 ignore start */
579
- process.env.TEST ? "0x0000000000000000000000000000000000000000" : contractAddress}`,
596
+ contractAddress && `Contract: ${getContractAddress(contractAddress)}`,
580
597
  functionWithParams && `Function: ${functionWithParams}`,
581
598
  formattedArgs && formattedArgs !== "()" && `Arguments: ${[...Array(_nullishCoalesce(_optionalChain([functionName, 'optionalAccess', _4 => _4.length]), () => ( 0))).keys()].map(() => " ").join("")}${formattedArgs}`,
582
599
  sender && `Sender: ${sender}`
@@ -745,17 +762,22 @@ var FilterTypeNotSupportedError = class extends BaseError {
745
762
 
746
763
  // src/errors/request.ts
747
764
  var RequestError = class extends BaseError {
748
- constructor(err, { docsPath: docsPath5, shortMessage }) {
765
+ constructor(err, {
766
+ docsPath: docsPath5,
767
+ metaMessages,
768
+ shortMessage
769
+ }) {
749
770
  super(shortMessage, {
750
771
  cause: err,
751
- docsPath: docsPath5
772
+ docsPath: docsPath5,
773
+ metaMessages
752
774
  });
753
775
  this.name = err.name;
754
776
  }
755
777
  };
756
778
  var RpcRequestError = class extends RequestError {
757
779
  constructor(err, { docsPath: docsPath5, shortMessage }) {
758
- super(err, { docsPath: docsPath5, shortMessage });
780
+ super(err, { docsPath: docsPath5, metaMessages: err.metaMessages, shortMessage });
759
781
  __publicField(this, "code");
760
782
  this.code = err.code;
761
783
  this.name = err.name;
@@ -875,24 +897,27 @@ var HttpRequestError = class extends BaseError {
875
897
  constructor({
876
898
  body,
877
899
  details,
900
+ headers,
878
901
  status,
879
902
  url
880
903
  }) {
881
- super(
882
- [
883
- "HTTP request failed.",
884
- "",
885
- `Status: ${status}`,
886
- `URL: ${url}`,
904
+ super("HTTP request failed.", {
905
+ details,
906
+ metaMessages: [
907
+ status && `Status: ${status}`,
908
+ `URL: ${getUrl(url)}`,
887
909
  `Request body: ${stringify(body)}`
888
- ].join("\n"),
889
- {
890
- details
891
- }
892
- );
910
+ ].filter(Boolean)
911
+ });
893
912
  __publicField(this, "name", "HttpRequestError");
913
+ __publicField(this, "body");
914
+ __publicField(this, "headers");
894
915
  __publicField(this, "status");
916
+ __publicField(this, "url");
917
+ this.body = body;
918
+ this.headers = headers;
895
919
  this.status = status;
920
+ this.url = url;
896
921
  }
897
922
  };
898
923
  var WebSocketRequestError = class extends BaseError {
@@ -901,17 +926,10 @@ var WebSocketRequestError = class extends BaseError {
901
926
  details,
902
927
  url
903
928
  }) {
904
- super(
905
- [
906
- "WebSocket request failed.",
907
- "",
908
- `URL: ${url}`,
909
- `Request body: ${stringify(body)}`
910
- ].join("\n"),
911
- {
912
- details
913
- }
914
- );
929
+ super("WebSocket request failed.", {
930
+ details,
931
+ metaMessages: [`URL: ${getUrl(url)}`, `Request body: ${stringify(body)}`]
932
+ });
915
933
  __publicField(this, "name", "WebSocketRequestError");
916
934
  }
917
935
  };
@@ -921,18 +939,11 @@ var RpcError = class extends BaseError {
921
939
  error,
922
940
  url
923
941
  }) {
924
- super(
925
- [
926
- "RPC Request failed.",
927
- "",
928
- `URL: ${url}`,
929
- `Request body: ${stringify(body)}`
930
- ].join("\n"),
931
- {
932
- cause: error,
933
- details: error.message
934
- }
935
- );
942
+ super("RPC Request failed.", {
943
+ cause: error,
944
+ details: error.message,
945
+ metaMessages: [`URL: ${getUrl(url)}`, `Request body: ${stringify(body)}`]
946
+ });
936
947
  __publicField(this, "code");
937
948
  __publicField(this, "name", "RpcError");
938
949
  this.code = error.code;
@@ -943,17 +954,10 @@ var TimeoutError = class extends BaseError {
943
954
  body,
944
955
  url
945
956
  }) {
946
- super(
947
- [
948
- "The request took too long to respond.",
949
- "",
950
- `URL: ${url}`,
951
- `Request body: ${stringify(body)}`
952
- ].join("\n"),
953
- {
954
- details: "The request timed out."
955
- }
956
- );
957
+ super("The request took too long to respond.", {
958
+ details: "The request timed out.",
959
+ metaMessages: [`URL: ${getUrl(url)}`, `Request body: ${stringify(body)}`]
960
+ });
957
961
  __publicField(this, "name", "TimeoutError");
958
962
  }
959
963
  };
@@ -1143,7 +1147,7 @@ function sliceHex(value_, start, end) {
1143
1147
  return `0x${value}`;
1144
1148
  }
1145
1149
 
1146
- // src/utils/encoding/encodeHex.ts
1150
+ // src/utils/encoding/toHex.ts
1147
1151
  var hexes = Array.from(
1148
1152
  { length: 256 },
1149
1153
  (v, i) => i.toString(16).padStart(2, "0")
@@ -1158,7 +1162,7 @@ function bytesToHex(value) {
1158
1162
  }
1159
1163
  return `0x${hex}`;
1160
1164
  }
1161
- function encodeHex(value) {
1165
+ function toHex(value) {
1162
1166
  if (typeof value === "number" || typeof value === "bigint")
1163
1167
  return numberToHex(value);
1164
1168
  if (typeof value === "string") {
@@ -1200,14 +1204,14 @@ function stringToHex(value) {
1200
1204
  return `0x${hex}`;
1201
1205
  }
1202
1206
 
1203
- // src/utils/encoding/encodeBytes.ts
1207
+ // src/utils/encoding/toBytes.ts
1204
1208
  var encoder = new TextEncoder();
1205
1209
  function boolToBytes(value) {
1206
1210
  const bytes = new Uint8Array(1);
1207
1211
  bytes[0] = Number(value);
1208
1212
  return bytes;
1209
1213
  }
1210
- function encodeBytes(value) {
1214
+ function toBytes(value) {
1211
1215
  if (typeof value === "number" || typeof value === "bigint")
1212
1216
  return numberToBytes(value);
1213
1217
  if (typeof value === "boolean")
@@ -1239,15 +1243,15 @@ function stringToBytes(value) {
1239
1243
  return encoder.encode(value);
1240
1244
  }
1241
1245
 
1242
- // src/utils/encoding/encodeRlp.ts
1243
- function encodeRlp(hexOrBytes, to_) {
1246
+ // src/utils/encoding/toRlp.ts
1247
+ function toRlp(hexOrBytes, to_) {
1244
1248
  const to = to_ || "hex";
1245
1249
  return format(bytesToRlp(parse(hexOrBytes)), to);
1246
1250
  }
1247
1251
  function parse(hexOrBytes) {
1248
1252
  if (Array.isArray(hexOrBytes))
1249
1253
  return hexOrBytes.map(parse);
1250
- return typeof hexOrBytes === "string" ? encodeBytes(hexOrBytes) : hexOrBytes;
1254
+ return typeof hexOrBytes === "string" ? toBytes(hexOrBytes) : hexOrBytes;
1251
1255
  }
1252
1256
  function format(bytes, type = "bytes") {
1253
1257
  return type === "hex" ? bytesToHex(bytes) : bytes;
@@ -1264,11 +1268,11 @@ function bytesToRlp(bytes) {
1264
1268
  function encodeLength(length, offset) {
1265
1269
  if (length < 56)
1266
1270
  return [offset + length];
1267
- return [encodeBytes(length).length + offset + 55, ...encodeBytes(length)];
1271
+ return [toBytes(length).length + offset + 55, ...toBytes(length)];
1268
1272
  }
1269
1273
 
1270
- // src/utils/encoding/decodeHex.ts
1271
- function decodeHex(hex, to) {
1274
+ // src/utils/encoding/fromHex.ts
1275
+ function fromHex(hex, to) {
1272
1276
  if (to === "number")
1273
1277
  return hexToNumber(hex);
1274
1278
  if (to === "bigint")
@@ -1305,8 +1309,8 @@ function hexToString(hex) {
1305
1309
  return new TextDecoder().decode(bytes);
1306
1310
  }
1307
1311
 
1308
- // src/utils/encoding/decodeBytes.ts
1309
- function decodeBytes(bytes, to) {
1312
+ // src/utils/encoding/fromBytes.ts
1313
+ function fromBytes(bytes, to) {
1310
1314
  if (to === "number")
1311
1315
  return bytesToNumber(bytes);
1312
1316
  if (to === "bigint")
@@ -1334,8 +1338,8 @@ function bytesToString(bytes) {
1334
1338
  return new TextDecoder().decode(bytes);
1335
1339
  }
1336
1340
 
1337
- // src/utils/encoding/decodeRlp.ts
1338
- function decodeRlp(value, to) {
1341
+ // src/utils/encoding/fromRlp.ts
1342
+ function fromRlp(value, to) {
1339
1343
  const bytes = parse2(value);
1340
1344
  const [data, consumed] = rlpToBytes(bytes);
1341
1345
  if (consumed < bytes.length)
@@ -1479,11 +1483,11 @@ function keccak256(value, to_) {
1479
1483
  const bytes = _sha3.keccak_256.call(void 0, value);
1480
1484
  if (to === "bytes")
1481
1485
  return bytes;
1482
- return encodeHex(bytes);
1486
+ return toHex(bytes);
1483
1487
  }
1484
1488
 
1485
1489
  // src/utils/hash/hashFunction.ts
1486
- var hash = (value) => keccak256(encodeBytes(value));
1490
+ var hash = (value) => keccak256(toBytes(value));
1487
1491
  function hashFunction(def) {
1488
1492
  const name = extractFunctionName(def);
1489
1493
  const params = extractFunctionParams(def);
@@ -1521,36 +1525,32 @@ function getAddress(address) {
1521
1525
  }
1522
1526
 
1523
1527
  // src/utils/address/getContractAddress.ts
1524
- function getContractAddress(opts) {
1528
+ function getContractAddress2(opts) {
1525
1529
  if (opts.opcode === "CREATE2")
1526
1530
  return getCreate2Address(opts);
1527
1531
  return getCreateAddress(opts);
1528
1532
  }
1529
1533
  function getCreateAddress(opts) {
1530
- const from = encodeBytes(getAddress(opts.from));
1531
- let nonce = encodeBytes(opts.nonce);
1534
+ const from = toBytes(getAddress(opts.from));
1535
+ let nonce = toBytes(opts.nonce);
1532
1536
  if (nonce[0] === 0)
1533
1537
  nonce = new Uint8Array([]);
1534
1538
  return getAddress(
1535
- `0x${keccak256(encodeRlp([from, nonce], "bytes")).slice(26)}`
1539
+ `0x${keccak256(toRlp([from, nonce], "bytes")).slice(26)}`
1536
1540
  );
1537
1541
  }
1538
1542
  function getCreate2Address(opts) {
1539
- const from = encodeBytes(getAddress(opts.from));
1540
- const salt = pad(
1541
- isBytes(opts.salt) ? opts.salt : encodeBytes(opts.salt),
1542
- { size: 32 }
1543
- );
1544
- const bytecodeHash = encodeBytes(
1543
+ const from = toBytes(getAddress(opts.from));
1544
+ const salt = pad(isBytes(opts.salt) ? opts.salt : toBytes(opts.salt), {
1545
+ size: 32
1546
+ });
1547
+ const bytecodeHash = toBytes(
1545
1548
  keccak256(
1546
- isBytes(opts.bytecode) ? opts.bytecode : encodeBytes(opts.bytecode)
1549
+ isBytes(opts.bytecode) ? opts.bytecode : toBytes(opts.bytecode)
1547
1550
  )
1548
1551
  );
1549
1552
  return getAddress(
1550
- slice(
1551
- keccak256(concat([encodeBytes("0xff"), from, salt, bytecodeHash])),
1552
- 12
1553
- )
1553
+ slice(keccak256(concat([toBytes("0xff"), from, salt, bytecodeHash])), 12)
1554
1554
  );
1555
1555
  }
1556
1556
 
@@ -1619,7 +1619,7 @@ function prepareParam({
1619
1619
  return encodeNumber(value, { signed });
1620
1620
  }
1621
1621
  if (param.type.startsWith("bytes")) {
1622
- return encodeBytes2(value, { param });
1622
+ return toBytes2(value, { param });
1623
1623
  }
1624
1624
  if (param.type === "string") {
1625
1625
  return encodeString(value);
@@ -1693,7 +1693,7 @@ function encodeArray(value, {
1693
1693
  encoded: concat(preparedParams.map(({ encoded }) => encoded))
1694
1694
  };
1695
1695
  }
1696
- function encodeBytes2(value, { param }) {
1696
+ function toBytes2(value, { param }) {
1697
1697
  const [_, size_] = param.type.split("bytes");
1698
1698
  if (!size_) {
1699
1699
  const partsLength = Math.floor(size(value) / 32);
@@ -1807,7 +1807,7 @@ function decodeParam({
1807
1807
  return decodeString(data, { position });
1808
1808
  }
1809
1809
  if (param.type.startsWith("bytes")) {
1810
- return decodeBytes2(data, { param, position });
1810
+ return fromBytes2(data, { param, position });
1811
1811
  }
1812
1812
  let value = slice(data, position, position + 32);
1813
1813
  if (param.type.startsWith("uint") || param.type.startsWith("int")) {
@@ -1880,7 +1880,7 @@ function decodeArray(data, {
1880
1880
  function decodeBool(value) {
1881
1881
  return { consumed: 32, value: hexToBool(value) };
1882
1882
  }
1883
- function decodeBytes2(data, { param, position }) {
1883
+ function fromBytes2(data, { param, position }) {
1884
1884
  const [_, size2] = param.type.split("bytes");
1885
1885
  if (!size2) {
1886
1886
  const offset = hexToNumber(slice(data, position, position + 32));
@@ -2236,7 +2236,7 @@ function encodeArg({
2236
2236
  value
2237
2237
  }) {
2238
2238
  if (param.type === "string" || param.type === "bytes")
2239
- return keccak256(encodeBytes(value));
2239
+ return keccak256(toBytes(value));
2240
2240
  if (param.type === "tuple" || param.type.match(/^(.*)\[(\d+)?\]$/))
2241
2241
  throw new FilterTypeNotSupportedError(param.type);
2242
2242
  return encodeAbi({ params: [param], values: [value] });
@@ -2300,42 +2300,175 @@ function formatAbiItemWithArgs({
2300
2300
  ).join(", ")})`;
2301
2301
  }
2302
2302
 
2303
+ // src/utils/promise/withCache.ts
2304
+ var promiseCache = /* @__PURE__ */ new Map();
2305
+ var responseCache = /* @__PURE__ */ new Map();
2306
+ function getCache(cacheKey) {
2307
+ const buildCache = (cacheKey2, cache) => ({
2308
+ clear: () => cache.delete(cacheKey2),
2309
+ get: () => cache.get(cacheKey2),
2310
+ set: (data) => cache.set(cacheKey2, data)
2311
+ });
2312
+ const promise = buildCache(cacheKey, promiseCache);
2313
+ const response = buildCache(
2314
+ cacheKey,
2315
+ responseCache
2316
+ );
2317
+ return {
2318
+ clear: () => {
2319
+ promise.clear();
2320
+ response.clear();
2321
+ },
2322
+ promise,
2323
+ response
2324
+ };
2325
+ }
2326
+ async function withCache(fn, { cacheKey, maxAge = Infinity }) {
2327
+ const cache = getCache(cacheKey);
2328
+ const response = cache.response.get();
2329
+ if (response && maxAge > 0) {
2330
+ const age = (/* @__PURE__ */ new Date()).getTime() - response.created.getTime();
2331
+ if (age < maxAge)
2332
+ return response.data;
2333
+ }
2334
+ let promise = cache.promise.get();
2335
+ if (!promise) {
2336
+ promise = fn();
2337
+ cache.promise.set(promise);
2338
+ }
2339
+ const data = await promise;
2340
+ cache.promise.clear();
2341
+ cache.response.set({ created: /* @__PURE__ */ new Date(), data });
2342
+ return data;
2343
+ }
2344
+
2345
+ // src/utils/wait.ts
2346
+ async function wait(time) {
2347
+ return new Promise((res) => setTimeout(res, time));
2348
+ }
2349
+
2350
+ // src/utils/promise/withRetry.ts
2351
+ function withRetry(fn, {
2352
+ delay: delay_ = 100,
2353
+ retryCount = 2,
2354
+ shouldRetry = () => true
2355
+ } = {}) {
2356
+ return new Promise((resolve, reject) => {
2357
+ const attemptRetry = async ({ count = 0 } = {}) => {
2358
+ const retry = async ({ error }) => {
2359
+ const delay = typeof delay_ === "function" ? delay_({ count, error }) : delay_;
2360
+ if (delay)
2361
+ await wait(delay);
2362
+ attemptRetry({ count: count + 1 });
2363
+ };
2364
+ try {
2365
+ const data = await fn();
2366
+ resolve(data);
2367
+ } catch (err) {
2368
+ if (count < retryCount && await shouldRetry({ count, error: err }))
2369
+ return retry({ error: err });
2370
+ reject(err);
2371
+ }
2372
+ };
2373
+ attemptRetry();
2374
+ });
2375
+ }
2376
+
2377
+ // src/utils/promise/withTimeout.ts
2378
+ function withTimeout(fn, {
2379
+ errorInstance,
2380
+ timeout,
2381
+ signal
2382
+ }) {
2383
+ return new Promise((resolve, reject) => {
2384
+ ;
2385
+ (async () => {
2386
+ let timeoutId;
2387
+ try {
2388
+ const controller = new AbortController();
2389
+ if (timeout > 0) {
2390
+ timeoutId = setTimeout(() => {
2391
+ if (signal) {
2392
+ controller.abort();
2393
+ } else {
2394
+ reject(errorInstance);
2395
+ }
2396
+ }, timeout);
2397
+ }
2398
+ resolve(await fn({ signal: _optionalChain([controller, 'optionalAccess', _32 => _32.signal]) }));
2399
+ } catch (err) {
2400
+ if (err.name === "AbortError")
2401
+ reject(errorInstance);
2402
+ reject(err);
2403
+ } finally {
2404
+ clearTimeout(timeoutId);
2405
+ }
2406
+ })();
2407
+ });
2408
+ }
2409
+
2303
2410
  // src/utils/buildRequest.ts
2304
- function buildRequest(request) {
2305
- return async (args) => {
2306
- try {
2307
- return await request(args);
2308
- } catch (err_) {
2309
- let err = err_;
2310
- if (err.code === -32700)
2311
- throw new ParseRpcError(err);
2312
- if (err.code === -32600)
2313
- throw new InvalidRequestRpcError(err);
2314
- if (err.code === -32601)
2315
- throw new MethodNotFoundRpcError(err);
2316
- if (err.code === -32602)
2317
- throw new InvalidParamsRpcError(err);
2318
- if (err.code === -32603)
2319
- throw new InternalRpcError(err);
2320
- if (err.code === -32e3)
2321
- throw new InvalidInputRpcError(err);
2322
- if (err.code === -32001)
2323
- throw new ResourceNotFoundRpcError(err);
2324
- if (err.code === -32002)
2325
- throw new ResourceUnavailableRpcError(err);
2326
- if (err.code === -32003)
2327
- throw new TransactionRejectedRpcError(err);
2328
- if (err.code === -32004)
2329
- throw new MethodNotSupportedRpcError(err);
2330
- if (err.code === -32005)
2331
- throw new LimitExceededRpcError(err);
2332
- if (err.code === -32006)
2333
- throw new JsonRpcVersionUnsupportedError(err);
2334
- if (err_ instanceof BaseError)
2335
- throw err_;
2336
- throw new UnknownRpcError(err);
2411
+ var isDeterministicError = (error) => {
2412
+ if (error instanceof UnknownRpcError)
2413
+ return false;
2414
+ if ("code" in error)
2415
+ return error.code !== -32603 && error.code !== -32005;
2416
+ if (error instanceof HttpRequestError && error.status)
2417
+ return error.status !== 408 && error.status !== 413 && error.status !== 429 && error.status !== 500;
2418
+ return true;
2419
+ };
2420
+ function buildRequest(request, {
2421
+ retryDelay = 150,
2422
+ retryCount = 3
2423
+ } = {}) {
2424
+ return async (args) => withRetry(
2425
+ async () => {
2426
+ try {
2427
+ return await request(args);
2428
+ } catch (err_) {
2429
+ let err = err_;
2430
+ if (err.code === -32700)
2431
+ throw new ParseRpcError(err);
2432
+ if (err.code === -32600)
2433
+ throw new InvalidRequestRpcError(err);
2434
+ if (err.code === -32601)
2435
+ throw new MethodNotFoundRpcError(err);
2436
+ if (err.code === -32602)
2437
+ throw new InvalidParamsRpcError(err);
2438
+ if (err.code === -32603)
2439
+ throw new InternalRpcError(err);
2440
+ if (err.code === -32e3)
2441
+ throw new InvalidInputRpcError(err);
2442
+ if (err.code === -32001)
2443
+ throw new ResourceNotFoundRpcError(err);
2444
+ if (err.code === -32002)
2445
+ throw new ResourceUnavailableRpcError(err);
2446
+ if (err.code === -32003)
2447
+ throw new TransactionRejectedRpcError(err);
2448
+ if (err.code === -32004)
2449
+ throw new MethodNotSupportedRpcError(err);
2450
+ if (err.code === -32005)
2451
+ throw new LimitExceededRpcError(err);
2452
+ if (err.code === -32006)
2453
+ throw new JsonRpcVersionUnsupportedError(err);
2454
+ if (err_ instanceof BaseError)
2455
+ throw err_;
2456
+ throw new UnknownRpcError(err);
2457
+ }
2458
+ },
2459
+ {
2460
+ delay: ({ count, error }) => {
2461
+ if (error && error instanceof HttpRequestError) {
2462
+ const retryAfter = _optionalChain([error, 'optionalAccess', _33 => _33.headers, 'optionalAccess', _34 => _34.get, 'call', _35 => _35("Retry-After")]);
2463
+ if (_optionalChain([retryAfter, 'optionalAccess', _36 => _36.match, 'call', _37 => _37(/\d/)]))
2464
+ return parseInt(retryAfter) * 1e3;
2465
+ }
2466
+ return ~~(1 << count) * retryDelay;
2467
+ },
2468
+ retryCount,
2469
+ shouldRetry: ({ error }) => !isDeterministicError(error)
2337
2470
  }
2338
- };
2471
+ );
2339
2472
  }
2340
2473
 
2341
2474
  // src/utils/chain.ts
@@ -2362,7 +2495,7 @@ function defineFormatter({
2362
2495
  }
2363
2496
  return {
2364
2497
  ...formatted,
2365
- ..._optionalChain([formatOverride, 'optionalCall', _32 => _32(data)])
2498
+ ..._optionalChain([formatOverride, 'optionalCall', _38 => _38(data)])
2366
2499
  };
2367
2500
  };
2368
2501
  }
@@ -2402,7 +2535,7 @@ var defineTransaction = defineFormatter({ format: formatTransaction });
2402
2535
 
2403
2536
  // src/utils/formatters/block.ts
2404
2537
  function formatBlock(block) {
2405
- const transactions = _optionalChain([block, 'access', _33 => _33.transactions, 'optionalAccess', _34 => _34.map, 'call', _35 => _35((transaction) => {
2538
+ const transactions = _optionalChain([block, 'access', _39 => _39.transactions, 'optionalAccess', _40 => _40.map, 'call', _41 => _41((transaction) => {
2406
2539
  if (typeof transaction === "string")
2407
2540
  return transaction;
2408
2541
  return formatTransaction(transaction);
@@ -2428,7 +2561,7 @@ function extract(value, { formatter }) {
2428
2561
  return {};
2429
2562
  const keys = Object.keys(formatter({}));
2430
2563
  return keys.reduce((data, key) => {
2431
- if (_optionalChain([value, 'optionalAccess', _36 => _36.hasOwnProperty, 'call', _37 => _37(key)])) {
2564
+ if (_optionalChain([value, 'optionalAccess', _42 => _42.hasOwnProperty, 'call', _43 => _43(key)])) {
2432
2565
  ;
2433
2566
  data[key] = value[key];
2434
2567
  }
@@ -2442,7 +2575,7 @@ function formatFeeHistory(feeHistory) {
2442
2575
  baseFeePerGas: feeHistory.baseFeePerGas.map((value) => BigInt(value)),
2443
2576
  gasUsedRatio: feeHistory.gasUsedRatio,
2444
2577
  oldestBlock: BigInt(feeHistory.oldestBlock),
2445
- reward: _optionalChain([feeHistory, 'access', _38 => _38.reward, 'optionalAccess', _39 => _39.map, 'call', _40 => _40(
2578
+ reward: _optionalChain([feeHistory, 'access', _44 => _44.reward, 'optionalAccess', _45 => _45.map, 'call', _46 => _46(
2446
2579
  (reward) => reward.map((value) => BigInt(value))
2447
2580
  )])
2448
2581
  };
@@ -2497,119 +2630,8 @@ var defineTransactionRequest = defineFormatter({
2497
2630
  });
2498
2631
 
2499
2632
  // src/utils/rpc.ts
2500
- var _isomorphicunfetch = require('isomorphic-unfetch'); var _isomorphicunfetch2 = _interopRequireDefault(_isomorphicunfetch);
2501
2633
  var _isomorphicws = require('isomorphic-ws'); var _isomorphicws2 = _interopRequireDefault(_isomorphicws);
2502
2634
 
2503
- // src/utils/promise/withCache.ts
2504
- var promiseCache = /* @__PURE__ */ new Map();
2505
- var responseCache = /* @__PURE__ */ new Map();
2506
- function getCache(cacheKey) {
2507
- const buildCache = (cacheKey2, cache) => ({
2508
- clear: () => cache.delete(cacheKey2),
2509
- get: () => cache.get(cacheKey2),
2510
- set: (data) => cache.set(cacheKey2, data)
2511
- });
2512
- const promise = buildCache(cacheKey, promiseCache);
2513
- const response = buildCache(
2514
- cacheKey,
2515
- responseCache
2516
- );
2517
- return {
2518
- clear: () => {
2519
- promise.clear();
2520
- response.clear();
2521
- },
2522
- promise,
2523
- response
2524
- };
2525
- }
2526
- async function withCache(fn, { cacheKey, maxAge = Infinity }) {
2527
- const cache = getCache(cacheKey);
2528
- const response = cache.response.get();
2529
- if (response && maxAge > 0) {
2530
- const age = (/* @__PURE__ */ new Date()).getTime() - response.created.getTime();
2531
- if (age < maxAge)
2532
- return response.data;
2533
- }
2534
- let promise = cache.promise.get();
2535
- if (!promise) {
2536
- promise = fn();
2537
- cache.promise.set(promise);
2538
- }
2539
- const data = await promise;
2540
- cache.promise.clear();
2541
- cache.response.set({ created: /* @__PURE__ */ new Date(), data });
2542
- return data;
2543
- }
2544
-
2545
- // src/utils/wait.ts
2546
- async function wait(time) {
2547
- return new Promise((res) => setTimeout(res, time));
2548
- }
2549
-
2550
- // src/utils/promise/withRetry.ts
2551
- function withRetry(fn, {
2552
- delay: delay_ = 100,
2553
- retryCount = 2,
2554
- shouldRetryOnResponse = () => false,
2555
- shouldRetryOnError = () => false
2556
- } = {}) {
2557
- return new Promise((resolve, reject) => {
2558
- const attemptRetry = async ({ count = 0 } = {}) => {
2559
- const retry = async ({ data } = {}) => {
2560
- const delay = typeof delay_ === "function" ? delay_({ count, data }) : delay_;
2561
- if (delay)
2562
- await wait(delay);
2563
- attemptRetry({ count: count + 1 });
2564
- };
2565
- try {
2566
- const data = await fn();
2567
- if (count < retryCount && await shouldRetryOnResponse({ count, data }))
2568
- return retry({ data });
2569
- resolve(data);
2570
- } catch (err) {
2571
- if (count < retryCount && await shouldRetryOnError({ count, error: err }))
2572
- return retry();
2573
- reject(err);
2574
- }
2575
- };
2576
- attemptRetry();
2577
- });
2578
- }
2579
-
2580
- // src/utils/promise/withTimeout.ts
2581
- function withTimeout(fn, {
2582
- errorInstance,
2583
- timeout,
2584
- signal
2585
- }) {
2586
- return new Promise((resolve, reject) => {
2587
- ;
2588
- (async () => {
2589
- let timeoutId;
2590
- try {
2591
- const controller = new AbortController();
2592
- if (timeout > 0) {
2593
- timeoutId = setTimeout(() => {
2594
- if (signal) {
2595
- controller.abort();
2596
- } else {
2597
- reject(errorInstance);
2598
- }
2599
- }, timeout);
2600
- }
2601
- resolve(await fn({ signal: _optionalChain([controller, 'optionalAccess', _41 => _41.signal]) }));
2602
- } catch (err) {
2603
- if (err.name === "AbortError")
2604
- reject(errorInstance);
2605
- reject(err);
2606
- } finally {
2607
- clearTimeout(timeoutId);
2608
- }
2609
- })();
2610
- });
2611
- }
2612
-
2613
2635
  // src/utils/stringify.ts
2614
2636
  function stringify(value) {
2615
2637
  return JSON.stringify(
@@ -2622,14 +2644,12 @@ function stringify(value) {
2622
2644
  var id = 0;
2623
2645
  async function http(url, {
2624
2646
  body,
2625
- retryDelay = 100,
2626
- retryCount = 2,
2627
2647
  timeout = 0
2628
2648
  }) {
2629
- const response = await withRetry(
2630
- () => withTimeout(
2649
+ try {
2650
+ const response = await withTimeout(
2631
2651
  async ({ signal }) => {
2632
- const response2 = await _isomorphicunfetch2.default.call(void 0, url, {
2652
+ const response2 = await fetch(url, {
2633
2653
  headers: {
2634
2654
  "Content-Type": "application/json"
2635
2655
  },
@@ -2644,42 +2664,39 @@ async function http(url, {
2644
2664
  timeout,
2645
2665
  signal: true
2646
2666
  }
2647
- ),
2648
- {
2649
- delay: ({ count, data: data2 }) => {
2650
- const retryAfter = _optionalChain([data2, 'optionalAccess', _42 => _42.headers, 'access', _43 => _43.get, 'call', _44 => _44("Retry-After")]);
2651
- if (_optionalChain([retryAfter, 'optionalAccess', _45 => _45.match, 'call', _46 => _46(/\d/)]))
2652
- return parseInt(retryAfter) * 1e3;
2653
- return ~~((Math.random() + 0.5) * (1 << count)) * retryDelay;
2654
- },
2655
- retryCount,
2656
- shouldRetryOnResponse: async ({ data: data2 }) => {
2657
- if (data2.status >= 500)
2658
- return true;
2659
- if ([408, 413, 429].includes(data2.status))
2660
- return true;
2661
- return false;
2662
- }
2667
+ );
2668
+ let data;
2669
+ if (_optionalChain([response, 'access', _47 => _47.headers, 'access', _48 => _48.get, 'call', _49 => _49("Content-Type"), 'optionalAccess', _50 => _50.startsWith, 'call', _51 => _51("application/json")])) {
2670
+ data = await response.json();
2671
+ } else {
2672
+ data = await response.text();
2663
2673
  }
2664
- );
2665
- let data;
2666
- if (_optionalChain([response, 'access', _47 => _47.headers, 'access', _48 => _48.get, 'call', _49 => _49("Content-Type"), 'optionalAccess', _50 => _50.startsWith, 'call', _51 => _51("application/json")])) {
2667
- data = await response.json();
2668
- } else {
2669
- data = await response.text();
2670
- }
2671
- if (!response.ok) {
2674
+ if (!response.ok) {
2675
+ throw new HttpRequestError({
2676
+ body,
2677
+ details: stringify(data.error) || response.statusText,
2678
+ headers: response.headers,
2679
+ status: response.status,
2680
+ url
2681
+ });
2682
+ }
2683
+ if (data.error) {
2684
+ throw new RpcError({ body, error: data.error, url });
2685
+ }
2686
+ return data;
2687
+ } catch (err) {
2688
+ if (err instanceof HttpRequestError)
2689
+ throw err;
2690
+ if (err instanceof RpcError)
2691
+ throw err;
2692
+ if (err instanceof TimeoutError)
2693
+ throw err;
2672
2694
  throw new HttpRequestError({
2673
2695
  body,
2674
- details: stringify(data.error) || response.statusText,
2675
- status: response.status,
2696
+ details: err.message,
2676
2697
  url
2677
2698
  });
2678
2699
  }
2679
- if (data.error) {
2680
- throw new RpcError({ body, error: data.error, url });
2681
- }
2682
- return data;
2683
2700
  }
2684
2701
  var sockets = /* @__PURE__ */ new Map();
2685
2702
  async function getSocket(url_) {
@@ -3004,5 +3021,6 @@ function parseGwei(ether, unit = "wei") {
3004
3021
 
3005
3022
 
3006
3023
 
3007
- exports.BaseError = BaseError; exports.AbiConstructorNotFoundError = AbiConstructorNotFoundError; exports.AbiConstructorParamsNotFoundError = AbiConstructorParamsNotFoundError; exports.AbiDecodingDataSizeInvalidError = AbiDecodingDataSizeInvalidError; exports.AbiDecodingZeroDataError = AbiDecodingZeroDataError; exports.AbiEncodingArrayLengthMismatchError = AbiEncodingArrayLengthMismatchError; exports.AbiEncodingLengthMismatchError = AbiEncodingLengthMismatchError; exports.AbiErrorInputsNotFoundError = AbiErrorInputsNotFoundError; exports.AbiErrorNotFoundError = AbiErrorNotFoundError; exports.AbiErrorSignatureNotFoundError = AbiErrorSignatureNotFoundError; exports.AbiEventNotFoundError = AbiEventNotFoundError; exports.AbiFunctionNotFoundError = AbiFunctionNotFoundError; exports.AbiFunctionOutputsNotFoundError = AbiFunctionOutputsNotFoundError; exports.AbiFunctionSignatureNotFoundError = AbiFunctionSignatureNotFoundError; exports.InvalidAbiEncodingTypeError = InvalidAbiEncodingTypeError; exports.InvalidAbiDecodingTypeError = InvalidAbiDecodingTypeError; exports.InvalidArrayError = InvalidArrayError; exports.InvalidDefinitionTypeError = InvalidDefinitionTypeError; exports.InvalidAddressError = InvalidAddressError; exports.BlockNotFoundError = BlockNotFoundError; exports.ChainDoesNotSupportContract = ChainDoesNotSupportContract; exports.multicall3Abi = multicall3Abi; exports.panicReasons = panicReasons; exports.concat = concat; exports.isBytes = isBytes; exports.isHex = isHex; exports.pad = pad; exports.padHex = padHex; exports.padBytes = padBytes; exports.trim = trim; exports.size = size; exports.slice = slice; exports.sliceBytes = sliceBytes; exports.sliceHex = sliceHex; exports.boolToHex = boolToHex; exports.bytesToHex = bytesToHex; exports.encodeHex = encodeHex; exports.numberToHex = numberToHex; exports.stringToHex = stringToHex; exports.boolToBytes = boolToBytes; exports.encodeBytes = encodeBytes; exports.hexToBytes = hexToBytes; exports.numberToBytes = numberToBytes; exports.stringToBytes = stringToBytes; exports.encodeRlp = encodeRlp; exports.decodeHex = decodeHex; exports.hexToBigInt = hexToBigInt; exports.hexToBool = hexToBool; exports.hexToNumber = hexToNumber; exports.hexToString = hexToString; exports.decodeBytes = decodeBytes; exports.bytesToBigint = bytesToBigint; exports.bytesToBool = bytesToBool; exports.bytesToNumber = bytesToNumber; exports.bytesToString = bytesToString; exports.decodeRlp = decodeRlp; exports.extractFunctionParts = extractFunctionParts; exports.extractFunctionName = extractFunctionName; exports.extractFunctionParams = extractFunctionParams; exports.extractFunctionType = extractFunctionType; exports.getContractError = getContractError; exports.keccak256 = keccak256; exports.getEventSignature = getEventSignature; exports.getFunctionSignature = getFunctionSignature; exports.checksumAddress = checksumAddress; exports.getAddress = getAddress; exports.getContractAddress = getContractAddress; exports.getCreateAddress = getCreateAddress; exports.getCreate2Address = getCreate2Address; exports.isAddress = isAddress; exports.isAddressEqual = isAddressEqual; exports.encodeAbi = encodeAbi; exports.decodeAbi = decodeAbi; exports.formatAbiItem = formatAbiItem; exports.decodeErrorResult = decodeErrorResult; exports.decodeEventLog = decodeEventLog; exports.decodeFunctionData = decodeFunctionData; exports.getAbiItem = getAbiItem; exports.decodeFunctionResult = decodeFunctionResult; exports.encodeDeployData = encodeDeployData; exports.encodeErrorResult = encodeErrorResult; exports.encodeEventTopics = encodeEventTopics; exports.encodeFunctionData = encodeFunctionData; exports.encodeFunctionResult = encodeFunctionResult; exports.formatAbiItemWithArgs = formatAbiItemWithArgs; exports.buildRequest = buildRequest; exports.defineChain = defineChain; exports.format = format3; exports.defineFormatter = defineFormatter; exports.transactionType = transactionType; exports.formatTransaction = formatTransaction; exports.defineTransaction = defineTransaction; exports.formatBlock = formatBlock; exports.defineBlock = defineBlock; exports.extract = extract; exports.formatFeeHistory = formatFeeHistory; exports.formatLog = formatLog; exports.formatTransactionReceipt = formatTransactionReceipt; exports.defineTransactionReceipt = defineTransactionReceipt; exports.formatTransactionRequest = formatTransactionRequest; exports.defineTransactionRequest = defineTransactionRequest; exports.getCache = getCache; exports.withCache = withCache; exports.wait = wait; exports.stringify = stringify; exports.getSocket = getSocket; exports.rpc = rpc; exports.etherUnits = etherUnits; exports.gweiUnits = gweiUnits; exports.weiUnits = weiUnits; exports.formatUnit = formatUnit; exports.formatEther = formatEther; exports.formatGwei = formatGwei; exports.parseUnit = parseUnit; exports.parseEther = parseEther; exports.parseGwei = parseGwei; exports.ContractFunctionExecutionError = ContractFunctionExecutionError; exports.ContractFunctionRevertedError = ContractFunctionRevertedError; exports.ContractFunctionZeroDataError = ContractFunctionZeroDataError; exports.RawContractError = RawContractError; exports.SizeExceedsPaddingSizeError = SizeExceedsPaddingSizeError; exports.DataLengthTooLongError = DataLengthTooLongError; exports.DataLengthTooShortError = DataLengthTooShortError; exports.InvalidBytesBooleanError = InvalidBytesBooleanError; exports.InvalidHexBooleanError = InvalidHexBooleanError; exports.InvalidHexValueError = InvalidHexValueError; exports.OffsetOutOfBoundsError = OffsetOutOfBoundsError; exports.FilterTypeNotSupportedError = FilterTypeNotSupportedError; exports.RequestError = RequestError; exports.RpcRequestError = RpcRequestError; exports.ParseRpcError = ParseRpcError; exports.InvalidRequestRpcError = InvalidRequestRpcError; exports.MethodNotFoundRpcError = MethodNotFoundRpcError; exports.InvalidParamsRpcError = InvalidParamsRpcError; exports.InternalRpcError = InternalRpcError; exports.InvalidInputRpcError = InvalidInputRpcError; exports.ResourceNotFoundRpcError = ResourceNotFoundRpcError; exports.ResourceUnavailableRpcError = ResourceUnavailableRpcError; exports.TransactionRejectedRpcError = TransactionRejectedRpcError; exports.MethodNotSupportedRpcError = MethodNotSupportedRpcError; exports.LimitExceededRpcError = LimitExceededRpcError; exports.JsonRpcVersionUnsupportedError = JsonRpcVersionUnsupportedError; exports.UnknownRpcError = UnknownRpcError; exports.HttpRequestError = HttpRequestError; exports.WebSocketRequestError = WebSocketRequestError; exports.RpcError = RpcError; exports.TimeoutError = TimeoutError; exports.InvalidGasArgumentsError = InvalidGasArgumentsError; exports.TransactionNotFoundError = TransactionNotFoundError; exports.TransactionReceiptNotFoundError = TransactionReceiptNotFoundError; exports.WaitForTransactionReceiptTimeoutError = WaitForTransactionReceiptTimeoutError; exports.UrlRequiredError = UrlRequiredError;
3008
- //# sourceMappingURL=chunk-THMRUG4D.js.map
3024
+
3025
+ exports.BaseError = BaseError; exports.AbiConstructorNotFoundError = AbiConstructorNotFoundError; exports.AbiConstructorParamsNotFoundError = AbiConstructorParamsNotFoundError; exports.AbiDecodingDataSizeInvalidError = AbiDecodingDataSizeInvalidError; exports.AbiDecodingZeroDataError = AbiDecodingZeroDataError; exports.AbiEncodingArrayLengthMismatchError = AbiEncodingArrayLengthMismatchError; exports.AbiEncodingLengthMismatchError = AbiEncodingLengthMismatchError; exports.AbiErrorInputsNotFoundError = AbiErrorInputsNotFoundError; exports.AbiErrorNotFoundError = AbiErrorNotFoundError; exports.AbiErrorSignatureNotFoundError = AbiErrorSignatureNotFoundError; exports.AbiEventNotFoundError = AbiEventNotFoundError; exports.AbiFunctionNotFoundError = AbiFunctionNotFoundError; exports.AbiFunctionOutputsNotFoundError = AbiFunctionOutputsNotFoundError; exports.AbiFunctionSignatureNotFoundError = AbiFunctionSignatureNotFoundError; exports.InvalidAbiEncodingTypeError = InvalidAbiEncodingTypeError; exports.InvalidAbiDecodingTypeError = InvalidAbiDecodingTypeError; exports.InvalidArrayError = InvalidArrayError; exports.InvalidDefinitionTypeError = InvalidDefinitionTypeError; exports.InvalidAddressError = InvalidAddressError; exports.BlockNotFoundError = BlockNotFoundError; exports.ChainDoesNotSupportContract = ChainDoesNotSupportContract; exports.multicall3Abi = multicall3Abi; exports.panicReasons = panicReasons; exports.ContractFunctionExecutionError = ContractFunctionExecutionError; exports.ContractFunctionRevertedError = ContractFunctionRevertedError; exports.ContractFunctionZeroDataError = ContractFunctionZeroDataError; exports.RawContractError = RawContractError; exports.SizeExceedsPaddingSizeError = SizeExceedsPaddingSizeError; exports.DataLengthTooLongError = DataLengthTooLongError; exports.DataLengthTooShortError = DataLengthTooShortError; exports.InvalidBytesBooleanError = InvalidBytesBooleanError; exports.InvalidHexBooleanError = InvalidHexBooleanError; exports.InvalidHexValueError = InvalidHexValueError; exports.OffsetOutOfBoundsError = OffsetOutOfBoundsError; exports.FilterTypeNotSupportedError = FilterTypeNotSupportedError; exports.RequestError = RequestError; exports.RpcRequestError = RpcRequestError; exports.ParseRpcError = ParseRpcError; exports.InvalidRequestRpcError = InvalidRequestRpcError; exports.MethodNotFoundRpcError = MethodNotFoundRpcError; exports.InvalidParamsRpcError = InvalidParamsRpcError; exports.InternalRpcError = InternalRpcError; exports.InvalidInputRpcError = InvalidInputRpcError; exports.ResourceNotFoundRpcError = ResourceNotFoundRpcError; exports.ResourceUnavailableRpcError = ResourceUnavailableRpcError; exports.TransactionRejectedRpcError = TransactionRejectedRpcError; exports.MethodNotSupportedRpcError = MethodNotSupportedRpcError; exports.LimitExceededRpcError = LimitExceededRpcError; exports.JsonRpcVersionUnsupportedError = JsonRpcVersionUnsupportedError; exports.UnknownRpcError = UnknownRpcError; exports.HttpRequestError = HttpRequestError; exports.WebSocketRequestError = WebSocketRequestError; exports.RpcError = RpcError; exports.TimeoutError = TimeoutError; exports.InvalidGasArgumentsError = InvalidGasArgumentsError; exports.TransactionNotFoundError = TransactionNotFoundError; exports.TransactionReceiptNotFoundError = TransactionReceiptNotFoundError; exports.WaitForTransactionReceiptTimeoutError = WaitForTransactionReceiptTimeoutError; exports.UrlRequiredError = UrlRequiredError; exports.concat = concat; exports.isBytes = isBytes; exports.isHex = isHex; exports.pad = pad; exports.padHex = padHex; exports.padBytes = padBytes; exports.trim = trim; exports.size = size; exports.slice = slice; exports.sliceBytes = sliceBytes; exports.sliceHex = sliceHex; exports.boolToHex = boolToHex; exports.bytesToHex = bytesToHex; exports.toHex = toHex; exports.numberToHex = numberToHex; exports.stringToHex = stringToHex; exports.boolToBytes = boolToBytes; exports.toBytes = toBytes; exports.hexToBytes = hexToBytes; exports.numberToBytes = numberToBytes; exports.stringToBytes = stringToBytes; exports.toRlp = toRlp; exports.fromHex = fromHex; exports.hexToBigInt = hexToBigInt; exports.hexToBool = hexToBool; exports.hexToNumber = hexToNumber; exports.hexToString = hexToString; exports.fromBytes = fromBytes; exports.bytesToBigint = bytesToBigint; exports.bytesToBool = bytesToBool; exports.bytesToNumber = bytesToNumber; exports.bytesToString = bytesToString; exports.fromRlp = fromRlp; exports.extractFunctionParts = extractFunctionParts; exports.extractFunctionName = extractFunctionName; exports.extractFunctionParams = extractFunctionParams; exports.extractFunctionType = extractFunctionType; exports.getContractError = getContractError; exports.keccak256 = keccak256; exports.getEventSignature = getEventSignature; exports.getFunctionSignature = getFunctionSignature; exports.checksumAddress = checksumAddress; exports.getAddress = getAddress; exports.getContractAddress = getContractAddress2; exports.getCreateAddress = getCreateAddress; exports.getCreate2Address = getCreate2Address; exports.isAddress = isAddress; exports.isAddressEqual = isAddressEqual; exports.encodeAbi = encodeAbi; exports.decodeAbi = decodeAbi; exports.formatAbiItem = formatAbiItem; exports.decodeErrorResult = decodeErrorResult; exports.decodeEventLog = decodeEventLog; exports.decodeFunctionData = decodeFunctionData; exports.getAbiItem = getAbiItem; exports.decodeFunctionResult = decodeFunctionResult; exports.encodeDeployData = encodeDeployData; exports.encodeErrorResult = encodeErrorResult; exports.encodeEventTopics = encodeEventTopics; exports.encodeFunctionData = encodeFunctionData; exports.encodeFunctionResult = encodeFunctionResult; exports.formatAbiItemWithArgs = formatAbiItemWithArgs; exports.getCache = getCache; exports.withCache = withCache; exports.wait = wait; exports.isDeterministicError = isDeterministicError; exports.buildRequest = buildRequest; exports.defineChain = defineChain; exports.format = format3; exports.defineFormatter = defineFormatter; exports.transactionType = transactionType; exports.formatTransaction = formatTransaction; exports.defineTransaction = defineTransaction; exports.formatBlock = formatBlock; exports.defineBlock = defineBlock; exports.extract = extract; exports.formatFeeHistory = formatFeeHistory; exports.formatLog = formatLog; exports.formatTransactionReceipt = formatTransactionReceipt; exports.defineTransactionReceipt = defineTransactionReceipt; exports.formatTransactionRequest = formatTransactionRequest; exports.defineTransactionRequest = defineTransactionRequest; exports.stringify = stringify; exports.getSocket = getSocket; exports.rpc = rpc; exports.etherUnits = etherUnits; exports.gweiUnits = gweiUnits; exports.weiUnits = weiUnits; exports.formatUnit = formatUnit; exports.formatEther = formatEther; exports.formatGwei = formatGwei; exports.parseUnit = parseUnit; exports.parseEther = parseEther; exports.parseGwei = parseGwei;
3026
+ //# sourceMappingURL=chunk-W7KWIGWO.js.map