viem 0.0.1-sushi.26 → 0.1.0

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 (525) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +132 -2
  3. package/abi/package.json +4 -0
  4. package/dist/abi.d.ts +6 -0
  5. package/dist/abi.js +21 -0
  6. package/dist/abi.js.map +1 -0
  7. package/dist/abi.mjs +21 -0
  8. package/dist/abi.mjs.map +1 -0
  9. package/dist/chain-819c7ff7.d.ts +553 -0
  10. package/dist/{chain-c4ccb458.d.ts → chain-a4f98ba3.d.ts} +1 -1
  11. package/dist/chains.d.ts +5 -3
  12. package/dist/chains.js +46 -46
  13. package/dist/chains.mjs +1 -1
  14. package/dist/chunk-APZXOA44.mjs +208 -0
  15. package/dist/chunk-APZXOA44.mjs.map +1 -0
  16. package/dist/chunk-HCZO3OIX.js +208 -0
  17. package/dist/chunk-HCZO3OIX.js.map +1 -0
  18. package/dist/{chunk-SD5X7F4U.mjs → chunk-I7AINPMM.mjs} +2756 -456
  19. package/dist/chunk-I7AINPMM.mjs.map +1 -0
  20. package/dist/chunk-QJNPIGP5.js +5326 -0
  21. package/dist/chunk-QJNPIGP5.js.map +1 -0
  22. package/dist/contract.d.ts +9 -122
  23. package/dist/contract.js +4 -4
  24. package/dist/contract.mjs +18 -18
  25. package/dist/{createClient-68ee4bb4.d.ts → createClient-a47ae6f5.d.ts} +13 -13
  26. package/dist/createPublicClient-e2eae0fc.d.ts +771 -0
  27. package/dist/{eip1193-6f9ba163.d.ts → eip1193-a882d1b8.d.ts} +14 -3
  28. package/dist/encodeFunctionResult-9eb553ce.d.ts +75 -0
  29. package/dist/encodePacked-4c019ed8.d.ts +12 -0
  30. package/dist/ens.d.ts +8 -69
  31. package/dist/ens.js +4 -199
  32. package/dist/ens.js.map +1 -1
  33. package/dist/ens.mjs +6 -201
  34. package/dist/ens.mjs.map +1 -1
  35. package/dist/formatAbiItem-622d2303.d.ts +14 -0
  36. package/dist/getAbiItem-159f3263.d.ts +22 -0
  37. package/dist/index.d.ts +106 -55
  38. package/dist/index.js +451 -41
  39. package/dist/index.js.map +1 -1
  40. package/dist/index.mjs +445 -35
  41. package/dist/index.mjs.map +1 -1
  42. package/dist/namehash-afff0feb.d.ts +25 -0
  43. package/dist/parseGwei-a2d0d77a.d.ts +497 -0
  44. package/dist/public.d.ts +11 -336
  45. package/dist/public.js +4 -3
  46. package/dist/public.mjs +3 -2
  47. package/dist/test-13f4413b.d.ts +205 -0
  48. package/dist/test.d.ts +8 -149
  49. package/dist/test.js +19 -222
  50. package/dist/test.js.map +1 -1
  51. package/dist/test.mjs +29 -232
  52. package/dist/test.mjs.map +1 -1
  53. package/dist/utils/index.d.ts +44 -231
  54. package/dist/utils/index.js +30 -2
  55. package/dist/utils/index.mjs +61 -33
  56. package/dist/wallet.d.ts +6 -41
  57. package/dist/wallet.js +2 -3
  58. package/dist/wallet.mjs +5 -6
  59. package/dist/window.d.ts +4 -2
  60. package/package.json +11 -6
  61. package/public/package.json +4 -0
  62. package/test/package.json +4 -0
  63. package/dist/call-ac509982.d.ts +0 -23
  64. package/dist/chain-f16512e8.d.ts +0 -372
  65. package/dist/chunk-2PFNLP3F.js +0 -192
  66. package/dist/chunk-2PFNLP3F.js.map +0 -1
  67. package/dist/chunk-5ND4P6QL.mjs +0 -192
  68. package/dist/chunk-5ND4P6QL.mjs.map +0 -1
  69. package/dist/chunk-NXCI5KQC.js +0 -3026
  70. package/dist/chunk-NXCI5KQC.js.map +0 -1
  71. package/dist/chunk-O7T5NQLB.mjs +0 -1091
  72. package/dist/chunk-O7T5NQLB.mjs.map +0 -1
  73. package/dist/chunk-SD5X7F4U.mjs.map +0 -1
  74. package/dist/chunk-UTL6F7UN.js +0 -1091
  75. package/dist/chunk-UTL6F7UN.js.map +0 -1
  76. package/dist/contract-9e76e561.d.ts +0 -166
  77. package/dist/createPublicClient-b732194e.d.ts +0 -19
  78. package/dist/createTestClient-dedf321e.d.ts +0 -34
  79. package/dist/createWalletClient-75813d83.d.ts +0 -30
  80. package/dist/decodeErrorResult-0b934d23.d.ts +0 -16
  81. package/dist/getAbiItem-c8e6e7d4.d.ts +0 -97
  82. package/dist/readContract-4f6e2692.d.ts +0 -10
  83. package/dist/rpc-a5a7f376.d.ts +0 -121
  84. package/dist/sendTransaction-e713f90c.d.ts +0 -12
  85. package/dist/transactionReceipt-2a86c7c7.d.ts +0 -26
  86. package/dist/transactionRequest-c7794f5e.d.ts +0 -15
  87. package/dist/watchEvent-c346c12d.d.ts +0 -41
  88. package/src/_test/abis.ts +0 -1420
  89. package/src/_test/bench.ts +0 -15
  90. package/src/_test/constants.ts +0 -63
  91. package/src/_test/generated.ts +0 -128
  92. package/src/_test/globalSetup.ts +0 -11
  93. package/src/_test/index.ts +0 -25
  94. package/src/_test/setup.ts +0 -8
  95. package/src/_test/utils.ts +0 -155
  96. package/src/actions/ens/getEnsAddress.bench.ts +0 -26
  97. package/src/actions/ens/getEnsAddress.test.ts +0 -97
  98. package/src/actions/ens/getEnsAddress.ts +0 -122
  99. package/src/actions/ens/getEnsName.bench.ts +0 -30
  100. package/src/actions/ens/getEnsName.test.ts +0 -101
  101. package/src/actions/ens/getEnsName.ts +0 -106
  102. package/src/actions/ens/index.test.ts +0 -12
  103. package/src/actions/ens/index.ts +0 -3
  104. package/src/actions/index.test.ts +0 -81
  105. package/src/actions/index.ts +0 -182
  106. package/src/actions/public/call.bench.ts +0 -48
  107. package/src/actions/public/call.test.ts +0 -99
  108. package/src/actions/public/call.ts +0 -97
  109. package/src/actions/public/createBlockFilter.bench.ts +0 -11
  110. package/src/actions/public/createBlockFilter.test.ts +0 -9
  111. package/src/actions/public/createBlockFilter.ts +0 -14
  112. package/src/actions/public/createContractEventFilter.test.ts +0 -119
  113. package/src/actions/public/createContractEventFilter.ts +0 -69
  114. package/src/actions/public/createEventFilter.test.ts +0 -277
  115. package/src/actions/public/createEventFilter.ts +0 -93
  116. package/src/actions/public/createPendingTransactionFilter.bench.ts +0 -11
  117. package/src/actions/public/createPendingTransactionFilter.test.ts +0 -9
  118. package/src/actions/public/createPendingTransactionFilter.ts +0 -14
  119. package/src/actions/public/estimateGas.bench.ts +0 -46
  120. package/src/actions/public/estimateGas.test.ts +0 -92
  121. package/src/actions/public/estimateGas.ts +0 -61
  122. package/src/actions/public/getBalance.test.ts +0 -83
  123. package/src/actions/public/getBalance.ts +0 -37
  124. package/src/actions/public/getBlock.bench.ts +0 -28
  125. package/src/actions/public/getBlock.test.ts +0 -575
  126. package/src/actions/public/getBlock.ts +0 -65
  127. package/src/actions/public/getBlockNumber.bench.ts +0 -28
  128. package/src/actions/public/getBlockNumber.test.ts +0 -27
  129. package/src/actions/public/getBlockNumber.ts +0 -32
  130. package/src/actions/public/getBlockTransactionCount.bench.ts +0 -15
  131. package/src/actions/public/getBlockTransactionCount.test.ts +0 -57
  132. package/src/actions/public/getBlockTransactionCount.ts +0 -52
  133. package/src/actions/public/getBytecode.test.ts +0 -27
  134. package/src/actions/public/getBytecode.ts +0 -32
  135. package/src/actions/public/getChainId.bench.ts +0 -15
  136. package/src/actions/public/getChainId.test.ts +0 -8
  137. package/src/actions/public/getChainId.ts +0 -7
  138. package/src/actions/public/getFeeHistory.bench.ts +0 -18
  139. package/src/actions/public/getFeeHistory.test.ts +0 -137
  140. package/src/actions/public/getFeeHistory.ts +0 -44
  141. package/src/actions/public/getFilterChanges.bench.ts +0 -13
  142. package/src/actions/public/getFilterChanges.test.ts +0 -383
  143. package/src/actions/public/getFilterChanges.ts +0 -23
  144. package/src/actions/public/getFilterLogs.test.ts +0 -297
  145. package/src/actions/public/getFilterLogs.ts +0 -20
  146. package/src/actions/public/getGasPrice.bench.ts +0 -19
  147. package/src/actions/public/getGasPrice.test.ts +0 -8
  148. package/src/actions/public/getGasPrice.ts +0 -15
  149. package/src/actions/public/getLogs.test.ts +0 -306
  150. package/src/actions/public/getLogs.ts +0 -84
  151. package/src/actions/public/getStorageAt.test.ts +0 -34
  152. package/src/actions/public/getStorageAt.ts +0 -32
  153. package/src/actions/public/getTransaction.bench.ts +0 -33
  154. package/src/actions/public/getTransaction.test.ts +0 -311
  155. package/src/actions/public/getTransaction.ts +0 -95
  156. package/src/actions/public/getTransactionConfirmations.test.ts +0 -69
  157. package/src/actions/public/getTransactionConfirmations.ts +0 -38
  158. package/src/actions/public/getTransactionCount.test.ts +0 -56
  159. package/src/actions/public/getTransactionCount.ts +0 -34
  160. package/src/actions/public/getTransactionReceipt.bench.ts +0 -33
  161. package/src/actions/public/getTransactionReceipt.test.ts +0 -179
  162. package/src/actions/public/getTransactionReceipt.ts +0 -34
  163. package/src/actions/public/index.test.ts +0 -43
  164. package/src/actions/public/index.ts +0 -146
  165. package/src/actions/public/multicall.test.ts +0 -452
  166. package/src/actions/public/multicall.ts +0 -108
  167. package/src/actions/public/readContract.test.ts +0 -328
  168. package/src/actions/public/readContract.ts +0 -73
  169. package/src/actions/public/simulateContract.bench.ts +0 -41
  170. package/src/actions/public/simulateContract.test.ts +0 -410
  171. package/src/actions/public/simulateContract.ts +0 -91
  172. package/src/actions/public/uninstallFilter.bench.ts +0 -13
  173. package/src/actions/public/uninstallFilter.test.ts +0 -65
  174. package/src/actions/public/uninstallFilter.ts +0 -17
  175. package/src/actions/public/waitForTransactionReceipt.test.ts +0 -322
  176. package/src/actions/public/waitForTransactionReceipt.ts +0 -170
  177. package/src/actions/public/watchBlockNumber.test.ts +0 -166
  178. package/src/actions/public/watchBlockNumber.ts +0 -79
  179. package/src/actions/public/watchBlocks.test.ts +0 -210
  180. package/src/actions/public/watchBlocks.ts +0 -114
  181. package/src/actions/public/watchContractEvent.test.ts +0 -305
  182. package/src/actions/public/watchContractEvent.ts +0 -108
  183. package/src/actions/public/watchEvent.test.ts +0 -195
  184. package/src/actions/public/watchEvent.ts +0 -95
  185. package/src/actions/public/watchPendingTransactions.test.ts +0 -116
  186. package/src/actions/public/watchPendingTransactions.ts +0 -74
  187. package/src/actions/test/dropTransaction.test.ts +0 -34
  188. package/src/actions/test/dropTransaction.ts +0 -17
  189. package/src/actions/test/getAutomine.test.ts +0 -14
  190. package/src/actions/test/getAutomine.ts +0 -11
  191. package/src/actions/test/getTxpoolContent.test.ts +0 -45
  192. package/src/actions/test/getTxpoolContent.ts +0 -7
  193. package/src/actions/test/getTxpoolStatus.test.ts +0 -41
  194. package/src/actions/test/getTxpoolStatus.ts +0 -12
  195. package/src/actions/test/impersonateAccount.test.ts +0 -26
  196. package/src/actions/test/impersonateAccount.ts +0 -17
  197. package/src/actions/test/increaseTime.test.ts +0 -18
  198. package/src/actions/test/increaseTime.ts +0 -17
  199. package/src/actions/test/index.test.ts +0 -38
  200. package/src/actions/test/index.ts +0 -77
  201. package/src/actions/test/inspectTxpool.test.ts +0 -50
  202. package/src/actions/test/inspectTxpool.ts +0 -7
  203. package/src/actions/test/mine.test.ts +0 -20
  204. package/src/actions/test/mine.ts +0 -16
  205. package/src/actions/test/removeBlockTimestampInterval.test.ts +0 -23
  206. package/src/actions/test/removeBlockTimestampInterval.ts +0 -7
  207. package/src/actions/test/reset.test.ts +0 -19
  208. package/src/actions/test/reset.ts +0 -18
  209. package/src/actions/test/revert.test.ts +0 -39
  210. package/src/actions/test/revert.ts +0 -14
  211. package/src/actions/test/sendUnsignedTransaction.test.ts +0 -52
  212. package/src/actions/test/sendUnsignedTransaction.ts +0 -19
  213. package/src/actions/test/setAutomine.test.ts +0 -14
  214. package/src/actions/test/setAutomine.ts +0 -8
  215. package/src/actions/test/setBalance.test.ts +0 -29
  216. package/src/actions/test/setBalance.ts +0 -20
  217. package/src/actions/test/setBlockGasLimit.test.ts +0 -21
  218. package/src/actions/test/setBlockGasLimit.ts +0 -17
  219. package/src/actions/test/setBlockTimestampInterval.test.ts +0 -23
  220. package/src/actions/test/setBlockTimestampInterval.ts +0 -16
  221. package/src/actions/test/setCode.test.ts +0 -26
  222. package/src/actions/test/setCode.ts +0 -19
  223. package/src/actions/test/setCoinbase.test.ts +0 -11
  224. package/src/actions/test/setCoinbase.ts +0 -17
  225. package/src/actions/test/setIntervalMining.test.ts +0 -30
  226. package/src/actions/test/setIntervalMining.ts +0 -16
  227. package/src/actions/test/setLoggingEnabled.test.ts +0 -10
  228. package/src/actions/test/setLoggingEnabled.ts +0 -8
  229. package/src/actions/test/setMinGasPrice.test.ts +0 -22
  230. package/src/actions/test/setMinGasPrice.ts +0 -17
  231. package/src/actions/test/setNextBlockBaseFeePerGas.test.ts +0 -23
  232. package/src/actions/test/setNextBlockBaseFeePerGas.ts +0 -17
  233. package/src/actions/test/setNextBlockTimestamp.test.ts +0 -19
  234. package/src/actions/test/setNextBlockTimestamp.ts +0 -17
  235. package/src/actions/test/setNonce.test.ts +0 -28
  236. package/src/actions/test/setNonce.ts +0 -20
  237. package/src/actions/test/setRpcUrl.test.ts +0 -9
  238. package/src/actions/test/setRpcUrl.ts +0 -8
  239. package/src/actions/test/setStorageAt.test.ts +0 -36
  240. package/src/actions/test/setStorageAt.ts +0 -26
  241. package/src/actions/test/snapshot.test.ts +0 -18
  242. package/src/actions/test/snapshot.ts +0 -7
  243. package/src/actions/test/stopImpersonatingAccount.test.ts +0 -29
  244. package/src/actions/test/stopImpersonatingAccount.ts +0 -17
  245. package/src/actions/wallet/addChain.test.ts +0 -14
  246. package/src/actions/wallet/addChain.ts +0 -21
  247. package/src/actions/wallet/deployContract.test.ts +0 -55
  248. package/src/actions/wallet/deployContract.ts +0 -38
  249. package/src/actions/wallet/getAccounts.test.ts +0 -22
  250. package/src/actions/wallet/getAccounts.ts +0 -7
  251. package/src/actions/wallet/getPermissions.test.ts +0 -24
  252. package/src/actions/wallet/getPermissions.ts +0 -9
  253. package/src/actions/wallet/index.test.ts +0 -21
  254. package/src/actions/wallet/index.ts +0 -36
  255. package/src/actions/wallet/requestAccounts.test.ts +0 -13
  256. package/src/actions/wallet/requestAccounts.ts +0 -7
  257. package/src/actions/wallet/requestPermissions.test.ts +0 -26
  258. package/src/actions/wallet/requestPermissions.ts +0 -19
  259. package/src/actions/wallet/sendTransaction.bench.ts +0 -57
  260. package/src/actions/wallet/sendTransaction.test.ts +0 -440
  261. package/src/actions/wallet/sendTransaction.ts +0 -77
  262. package/src/actions/wallet/signMessage.test.ts +0 -61
  263. package/src/actions/wallet/signMessage.ts +0 -35
  264. package/src/actions/wallet/switchChain.test.ts +0 -21
  265. package/src/actions/wallet/switchChain.ts +0 -19
  266. package/src/actions/wallet/watchAsset.test.ts +0 -40
  267. package/src/actions/wallet/watchAsset.ts +0 -16
  268. package/src/actions/wallet/writeContract.test.ts +0 -84
  269. package/src/actions/wallet/writeContract.ts +0 -47
  270. package/src/chains.test.ts +0 -439
  271. package/src/chains.ts +0 -99
  272. package/src/clients/createClient.test.ts +0 -295
  273. package/src/clients/createClient.ts +0 -81
  274. package/src/clients/createPublicClient.test.ts +0 -165
  275. package/src/clients/createPublicClient.ts +0 -49
  276. package/src/clients/createTestClient.test.ts +0 -145
  277. package/src/clients/createTestClient.ts +0 -72
  278. package/src/clients/createWalletClient.test.ts +0 -121
  279. package/src/clients/createWalletClient.ts +0 -54
  280. package/src/clients/index.test.ts +0 -19
  281. package/src/clients/index.ts +0 -31
  282. package/src/clients/transports/createTransport.test.ts +0 -58
  283. package/src/clients/transports/createTransport.ts +0 -48
  284. package/src/clients/transports/custom.test.ts +0 -98
  285. package/src/clients/transports/custom.ts +0 -34
  286. package/src/clients/transports/fallback.test.ts +0 -393
  287. package/src/clients/transports/fallback.ts +0 -58
  288. package/src/clients/transports/http.test.ts +0 -109
  289. package/src/clients/transports/http.ts +0 -51
  290. package/src/clients/transports/index.test.ts +0 -15
  291. package/src/clients/transports/index.ts +0 -17
  292. package/src/clients/transports/webSocket.test.ts +0 -164
  293. package/src/clients/transports/webSocket.ts +0 -118
  294. package/src/constants/abis.test.ts +0 -53
  295. package/src/constants/abis.ts +0 -44
  296. package/src/constants/index.test.ts +0 -14
  297. package/src/constants/index.ts +0 -3
  298. package/src/constants/solidity.test.ts +0 -41
  299. package/src/constants/solidity.ts +0 -35
  300. package/src/contract.test.ts +0 -32
  301. package/src/contract.ts +0 -68
  302. package/src/ens.test.ts +0 -15
  303. package/src/ens.ts +0 -8
  304. package/src/errors/abi.test.ts +0 -81
  305. package/src/errors/abi.ts +0 -254
  306. package/src/errors/address.test.ts +0 -14
  307. package/src/errors/address.ts +0 -9
  308. package/src/errors/base.test.ts +0 -114
  309. package/src/errors/base.ts +0 -57
  310. package/src/errors/block.test.ts +0 -24
  311. package/src/errors/block.ts +0 -18
  312. package/src/errors/chain.test.ts +0 -46
  313. package/src/errors/chain.ts +0 -33
  314. package/src/errors/contract.test.ts +0 -233
  315. package/src/errors/contract.ts +0 -178
  316. package/src/errors/data.ts +0 -20
  317. package/src/errors/encoding.ts +0 -60
  318. package/src/errors/index.ts +0 -82
  319. package/src/errors/log.ts +0 -8
  320. package/src/errors/request.test.ts +0 -330
  321. package/src/errors/request.ts +0 -163
  322. package/src/errors/rpc.test.ts +0 -87
  323. package/src/errors/rpc.ts +0 -113
  324. package/src/errors/transaction.test.ts +0 -83
  325. package/src/errors/transaction.ts +0 -54
  326. package/src/errors/transport.test.ts +0 -11
  327. package/src/errors/transport.ts +0 -12
  328. package/src/index.test.ts +0 -116
  329. package/src/index.ts +0 -132
  330. package/src/public.test.ts +0 -36
  331. package/src/public.ts +0 -76
  332. package/src/test.test.ts +0 -38
  333. package/src/test.ts +0 -52
  334. package/src/types/block.ts +0 -71
  335. package/src/types/chain.ts +0 -6
  336. package/src/types/contract.ts +0 -497
  337. package/src/types/eip1193.ts +0 -1041
  338. package/src/types/fee.ts +0 -47
  339. package/src/types/filter.ts +0 -8
  340. package/src/types/formatter.ts +0 -23
  341. package/src/types/index.ts +0 -84
  342. package/src/types/log.ts +0 -22
  343. package/src/types/misc.ts +0 -5
  344. package/src/types/multicall.ts +0 -82
  345. package/src/types/rpc.ts +0 -35
  346. package/src/types/transaction.ts +0 -145
  347. package/src/types/utils.ts +0 -88
  348. package/src/types/window.ts +0 -9
  349. package/src/utils/abi/decodeAbi.bench.ts +0 -135
  350. package/src/utils/abi/decodeAbi.test.ts +0 -1614
  351. package/src/utils/abi/decodeAbi.ts +0 -300
  352. package/src/utils/abi/decodeDeployData.test.ts +0 -151
  353. package/src/utils/abi/decodeDeployData.ts +0 -44
  354. package/src/utils/abi/decodeErrorResult.test.ts +0 -230
  355. package/src/utils/abi/decodeErrorResult.ts +0 -45
  356. package/src/utils/abi/decodeEventLog.test.ts +0 -542
  357. package/src/utils/abi/decodeEventLog.ts +0 -107
  358. package/src/utils/abi/decodeFunctionData.test.ts +0 -138
  359. package/src/utils/abi/decodeFunctionData.ts +0 -32
  360. package/src/utils/abi/decodeFunctionResult.test.ts +0 -333
  361. package/src/utils/abi/decodeFunctionResult.ts +0 -57
  362. package/src/utils/abi/encodeAbi.bench.ts +0 -163
  363. package/src/utils/abi/encodeAbi.test.ts +0 -1447
  364. package/src/utils/abi/encodeAbi.ts +0 -273
  365. package/src/utils/abi/encodeDeployData.test.ts +0 -124
  366. package/src/utils/abi/encodeDeployData.ts +0 -40
  367. package/src/utils/abi/encodeErrorResult.test.ts +0 -192
  368. package/src/utils/abi/encodeErrorResult.ts +0 -47
  369. package/src/utils/abi/encodeEventTopics.test.ts +0 -345
  370. package/src/utils/abi/encodeEventTopics.ts +0 -75
  371. package/src/utils/abi/encodeFunctionData.test.ts +0 -138
  372. package/src/utils/abi/encodeFunctionData.ts +0 -42
  373. package/src/utils/abi/encodeFunctionResult.test.ts +0 -279
  374. package/src/utils/abi/encodeFunctionResult.ts +0 -41
  375. package/src/utils/abi/formatAbiItem.test.ts +0 -335
  376. package/src/utils/abi/formatAbiItem.ts +0 -41
  377. package/src/utils/abi/formatAbiItemWithArgs.test.ts +0 -291
  378. package/src/utils/abi/formatAbiItemWithArgs.ts +0 -27
  379. package/src/utils/abi/getAbiItem.test.ts +0 -547
  380. package/src/utils/abi/getAbiItem.ts +0 -95
  381. package/src/utils/abi/index.test.ts +0 -24
  382. package/src/utils/abi/index.ts +0 -48
  383. package/src/utils/address/getAddress.bench.ts +0 -22
  384. package/src/utils/address/getAddress.test.ts +0 -46
  385. package/src/utils/address/getAddress.ts +0 -28
  386. package/src/utils/address/getContractAddress.bench.ts +0 -20
  387. package/src/utils/address/getContractAddress.test.ts +0 -78
  388. package/src/utils/address/getContractAddress.ts +0 -59
  389. package/src/utils/address/index.test.ts +0 -17
  390. package/src/utils/address/index.ts +0 -16
  391. package/src/utils/address/isAddress.test.ts +0 -10
  392. package/src/utils/address/isAddress.ts +0 -10
  393. package/src/utils/address/isAddressEqual.test.ts +0 -55
  394. package/src/utils/address/isAddressEqual.ts +0 -6
  395. package/src/utils/buildRequest.test.ts +0 -428
  396. package/src/utils/buildRequest.ts +0 -72
  397. package/src/utils/chain.test.ts +0 -43
  398. package/src/utils/chain.ts +0 -8
  399. package/src/utils/contract/extractFunctionParts.test.ts +0 -109
  400. package/src/utils/contract/extractFunctionParts.ts +0 -27
  401. package/src/utils/contract/getContractError.test.ts +0 -282
  402. package/src/utils/contract/getContractError.ts +0 -58
  403. package/src/utils/contract/index.test.ts +0 -15
  404. package/src/utils/contract/index.ts +0 -8
  405. package/src/utils/data/concat.test.ts +0 -35
  406. package/src/utils/data/concat.ts +0 -34
  407. package/src/utils/data/index.test.ts +0 -23
  408. package/src/utils/data/index.ts +0 -13
  409. package/src/utils/data/isBytes.test.ts +0 -9
  410. package/src/utils/data/isBytes.ts +0 -7
  411. package/src/utils/data/isHex.test.ts +0 -13
  412. package/src/utils/data/isHex.ts +0 -5
  413. package/src/utils/data/pad.bench.ts +0 -30
  414. package/src/utils/data/pad.test.ts +0 -367
  415. package/src/utils/data/pad.ts +0 -53
  416. package/src/utils/data/size.test.ts +0 -18
  417. package/src/utils/data/size.ts +0 -13
  418. package/src/utils/data/slice.test.ts +0 -203
  419. package/src/utils/data/slice.ts +0 -60
  420. package/src/utils/data/trim.bench.ts +0 -34
  421. package/src/utils/data/trim.test.ts +0 -175
  422. package/src/utils/data/trim.ts +0 -33
  423. package/src/utils/encoding/decodeBytes.bench.ts +0 -40
  424. package/src/utils/encoding/decodeBytes.test.ts +0 -144
  425. package/src/utils/encoding/decodeBytes.ts +0 -63
  426. package/src/utils/encoding/decodeHex.bench.ts +0 -24
  427. package/src/utils/encoding/decodeHex.test.ts +0 -167
  428. package/src/utils/encoding/decodeHex.ts +0 -76
  429. package/src/utils/encoding/decodeRlp.bench.ts +0 -34
  430. package/src/utils/encoding/decodeRlp.test.ts +0 -350
  431. package/src/utils/encoding/decodeRlp.ts +0 -121
  432. package/src/utils/encoding/encodeBytes.bench.ts +0 -29
  433. package/src/utils/encoding/encodeBytes.test.ts +0 -676
  434. package/src/utils/encoding/encodeBytes.ts +0 -59
  435. package/src/utils/encoding/encodeHex.bench.ts +0 -49
  436. package/src/utils/encoding/encodeHex.test.ts +0 -232
  437. package/src/utils/encoding/encodeHex.ts +0 -104
  438. package/src/utils/encoding/encodeRlp.bench.ts +0 -54
  439. package/src/utils/encoding/encodeRlp.test.ts +0 -254
  440. package/src/utils/encoding/encodeRlp.ts +0 -48
  441. package/src/utils/encoding/index.test.ts +0 -32
  442. package/src/utils/encoding/index.ts +0 -36
  443. package/src/utils/ens/index.test.ts +0 -14
  444. package/src/utils/ens/index.ts +0 -7
  445. package/src/utils/ens/labelhash.test.ts +0 -55
  446. package/src/utils/ens/labelhash.ts +0 -16
  447. package/src/utils/ens/namehash.test.ts +0 -65
  448. package/src/utils/ens/namehash.ts +0 -28
  449. package/src/utils/ens/normalize.bench.ts +0 -14
  450. package/src/utils/ens/normalize.test.ts +0 -35
  451. package/src/utils/ens/normalize.ts +0 -14
  452. package/src/utils/ens/packetToBytes.test.ts +0 -11
  453. package/src/utils/ens/packetToBytes.ts +0 -29
  454. package/src/utils/formatters/block.bench.ts +0 -51
  455. package/src/utils/formatters/block.test.ts +0 -115
  456. package/src/utils/formatters/block.ts +0 -37
  457. package/src/utils/formatters/extract.test.ts +0 -14
  458. package/src/utils/formatters/extract.ts +0 -18
  459. package/src/utils/formatters/feeHistory.test.ts +0 -66
  460. package/src/utils/formatters/feeHistory.ts +0 -12
  461. package/src/utils/formatters/format.test.ts +0 -93
  462. package/src/utils/formatters/format.ts +0 -90
  463. package/src/utils/formatters/index.test.ts +0 -27
  464. package/src/utils/formatters/index.ts +0 -34
  465. package/src/utils/formatters/log.test.ts +0 -79
  466. package/src/utils/formatters/log.ts +0 -12
  467. package/src/utils/formatters/transaction.test.ts +0 -271
  468. package/src/utils/formatters/transaction.ts +0 -63
  469. package/src/utils/formatters/transactionReceipt.bench.ts +0 -73
  470. package/src/utils/formatters/transactionReceipt.test.ts +0 -151
  471. package/src/utils/formatters/transactionReceipt.ts +0 -63
  472. package/src/utils/formatters/transactionRequest.bench.ts +0 -29
  473. package/src/utils/formatters/transactionRequest.test.ts +0 -237
  474. package/src/utils/formatters/transactionRequest.ts +0 -56
  475. package/src/utils/hash/getEventSignature.test.ts +0 -61
  476. package/src/utils/hash/getEventSignature.ts +0 -4
  477. package/src/utils/hash/getFunctionSignature.test.ts +0 -22
  478. package/src/utils/hash/getFunctionSignature.ts +0 -5
  479. package/src/utils/hash/hashFunction.test.ts +0 -65
  480. package/src/utils/hash/hashFunction.ts +0 -12
  481. package/src/utils/hash/index.test.ts +0 -13
  482. package/src/utils/hash/index.ts +0 -5
  483. package/src/utils/hash/keccak256.test.ts +0 -59
  484. package/src/utils/hash/keccak256.ts +0 -21
  485. package/src/utils/index.test.ts +0 -111
  486. package/src/utils/index.ts +0 -142
  487. package/src/utils/observe.test.ts +0 -176
  488. package/src/utils/observe.ts +0 -66
  489. package/src/utils/poll.test.ts +0 -127
  490. package/src/utils/poll.ts +0 -42
  491. package/src/utils/promise/index.test.ts +0 -14
  492. package/src/utils/promise/index.ts +0 -3
  493. package/src/utils/promise/withCache.test.ts +0 -97
  494. package/src/utils/promise/withCache.ts +0 -73
  495. package/src/utils/promise/withRetry.test.ts +0 -231
  496. package/src/utils/promise/withRetry.ts +0 -61
  497. package/src/utils/promise/withTimeout.test.ts +0 -37
  498. package/src/utils/promise/withTimeout.ts +0 -39
  499. package/src/utils/rpc.test.ts +0 -990
  500. package/src/utils/rpc.ts +0 -294
  501. package/src/utils/stringify.test.ts +0 -13
  502. package/src/utils/stringify.ts +0 -5
  503. package/src/utils/uid.ts +0 -14
  504. package/src/utils/unit/constants.test.ts +0 -22
  505. package/src/utils/unit/constants.ts +0 -12
  506. package/src/utils/unit/formatEther.test.ts +0 -75
  507. package/src/utils/unit/formatEther.ts +0 -6
  508. package/src/utils/unit/formatGwei.test.ts +0 -32
  509. package/src/utils/unit/formatGwei.ts +0 -6
  510. package/src/utils/unit/formatUnit.bench.ts +0 -21
  511. package/src/utils/unit/formatUnit.test.ts +0 -40
  512. package/src/utils/unit/formatUnit.ts +0 -16
  513. package/src/utils/unit/index.test.ts +0 -28
  514. package/src/utils/unit/index.ts +0 -7
  515. package/src/utils/unit/parseEther.test.ts +0 -126
  516. package/src/utils/unit/parseEther.ts +0 -6
  517. package/src/utils/unit/parseGwei.test.ts +0 -50
  518. package/src/utils/unit/parseGwei.ts +0 -6
  519. package/src/utils/unit/parseUnit.bench.ts +0 -21
  520. package/src/utils/unit/parseUnit.test.ts +0 -54
  521. package/src/utils/unit/parseUnit.ts +0 -27
  522. package/src/utils/wait.ts +0 -3
  523. package/src/wallet.test.ts +0 -19
  524. package/src/wallet.ts +0 -23
  525. package/src/window.ts +0 -1
@@ -1,3026 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
-
8
- // package.json
9
- var package_default = {
10
- name: "viem",
11
- description: "TypeScript Interface for Ethereum",
12
- version: "0.0.1-alpha.25",
13
- scripts: {
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
- bench: "vitest bench --no-threads",
16
- "bench:ci": "CI=true vitest bench --no-threads",
17
- build: "tsup",
18
- changeset: "changeset",
19
- "changeset:release": "pnpm build && changeset publish",
20
- "changeset:version": "changeset version && pnpm install --lockfile-only",
21
- "contracts:build": "wagmi generate",
22
- dev: "DEV=true tsup",
23
- "dev:docs": "pnpm -r --filter site dev",
24
- format: "rome format src/ test/ --write",
25
- lint: "rome check .",
26
- "lint:fix": "pnpm lint --apply-suggested",
27
- playground: "pnpm --filter playground-dev dev",
28
- postinstall: "pnpm dev && pnpm contracts:build",
29
- preinstall: "npx only-allow pnpm",
30
- prepublishOnly: "pnpm ts-node scripts/generate-package-json.ts",
31
- prepare: "npx simple-git-hooks",
32
- test: "vitest dev --no-threads",
33
- "test:ci": "CI=true vitest --coverage --no-threads",
34
- "test:ui": "vitest dev --ui --no-threads",
35
- "ts-node": "node --loader esbuild-register/loader -r esbuild-register",
36
- typecheck: "tsc --noEmit"
37
- },
38
- files: [
39
- "/chains",
40
- "/contract",
41
- "/dist",
42
- "/ens",
43
- "/src",
44
- "/types",
45
- "/utils",
46
- "/wallet",
47
- "/window"
48
- ],
49
- exports: {
50
- ".": {
51
- types: "./dist/index.d.ts",
52
- module: "./dist/index.mjs",
53
- default: "./dist/index.js"
54
- },
55
- "./chains": {
56
- types: "./dist/chains.d.ts",
57
- module: "./dist/chains.mjs",
58
- default: "./dist/chains.js"
59
- },
60
- "./contract": {
61
- types: "./dist/contract.d.ts",
62
- module: "./dist/contract.mjs",
63
- default: "./dist/contract.js"
64
- },
65
- "./ens": {
66
- types: "./dist/ens.d.ts",
67
- module: "./dist/ens.mjs",
68
- default: "./dist/ens.js"
69
- },
70
- "./public": {
71
- types: "./dist/public.d.ts",
72
- module: "./dist/public.mjs",
73
- default: "./dist/public.js"
74
- },
75
- "./test": {
76
- types: "./dist/test.d.ts",
77
- module: "./dist/test.mjs",
78
- default: "./dist/test.js"
79
- },
80
- "./utils": {
81
- types: "./dist/utils/index.d.ts",
82
- module: "./dist/utils/index.mjs",
83
- default: "./dist/utils/index.js"
84
- },
85
- "./wallet": {
86
- types: "./dist/wallet.d.ts",
87
- module: "./dist/wallet.mjs",
88
- default: "./dist/wallet.js"
89
- },
90
- "./window": {
91
- types: "./dist/window.d.ts",
92
- module: "./dist/window.mjs",
93
- default: "./dist/window.js"
94
- },
95
- "./package.json": "./package.json"
96
- },
97
- main: "dist/index.js",
98
- module: "dist/index.mjs",
99
- types: "dist/index.d.ts",
100
- sideEffects: false,
101
- dependencies: {
102
- "@noble/hashes": "^1.1.2",
103
- "@wagmi/chains": "~0.2.8",
104
- abitype: "~0.3.0",
105
- "idna-uts46-hx": "^4.1.2",
106
- "isomorphic-unfetch": "^4.0.2",
107
- "isomorphic-ws": "^5.0.0",
108
- ws: "^8.12.0"
109
- },
110
- devDependencies: {
111
- "@actions/core": "^1.10.0",
112
- "@actions/github": "^5.1.1",
113
- "@adraffy/ens-normalize": "^1.8.9",
114
- "@changesets/changelog-github": "^0.4.5",
115
- "@changesets/cli": "^2.23.2",
116
- "@types/dedent": "^0.7.0",
117
- "@types/fs-extra": "^9.0.13",
118
- "@types/node": "^17.0.45",
119
- "@types/ws": "^8.5.4",
120
- "@vitest/coverage-c8": "^0.24.3",
121
- "@vitest/ui": "^0.19.1",
122
- "@wagmi/cli": "^0.1.6",
123
- bundlewatch: "^0.3.3",
124
- dedent: "^0.7.0",
125
- esbuild: "^0.16.17",
126
- "esbuild-register": "^3.4.2",
127
- ethers: "^5.7.2",
128
- "ethers@6": "npm:ethers@^6.0.2",
129
- execa: "^6.1.0",
130
- "fs-extra": "^10.1.0",
131
- rome: "^11.0.0",
132
- "simple-git-hooks": "^2.8.1",
133
- tsup: "^6.6.0",
134
- typescript: "^4.9.4",
135
- vite: "^3.2.5",
136
- vitest: "^0.25.8",
137
- web3: "^1.8.1"
138
- },
139
- license: "MIT",
140
- repository: "wagmi-dev/viem",
141
- authors: [
142
- "awkweb.eth",
143
- "jxom.eth"
144
- ],
145
- keywords: [
146
- "eth",
147
- "ethereum",
148
- "dapps",
149
- "wallet",
150
- "web3"
151
- ],
152
- "simple-git-hooks": {
153
- "pre-commit": "pnpm format & pnpm lint:fix"
154
- },
155
- pnpm: {
156
- patchedDependencies: {
157
- "vitepress@1.0.0-alpha.34": "patches/vitepress@1.0.0-alpha.34.patch"
158
- }
159
- }
160
- };
161
-
162
- // src/errors/base.ts
163
- var version = process.env.TEST ? "1.0.2" : package_default.version;
164
- var BaseError = class extends Error {
165
- constructor(shortMessage, args = {}) {
166
- const details = args.cause instanceof BaseError ? args.cause.details : _optionalChain([args, 'access', _2 => _2.cause, 'optionalAccess', _3 => _3.message]) ? args.cause.message : args.details;
167
- const docsPath5 = args.cause instanceof BaseError ? args.cause.docsPath || args.docsPath : args.docsPath;
168
- const message = [
169
- shortMessage || "An error occurred.",
170
- "",
171
- ...args.metaMessages ? [...args.metaMessages, ""] : [],
172
- ...docsPath5 ? [`Docs: https://viem.sh${docsPath5}`] : [],
173
- ...details ? [`Details: ${details}`] : [],
174
- `Version: viem@${version}`
175
- ].join("\n");
176
- super(message);
177
- __publicField(this, "details");
178
- __publicField(this, "docsPath");
179
- __publicField(this, "metaMessages");
180
- __publicField(this, "shortMessage");
181
- __publicField(this, "name", "ViemError");
182
- if (args.cause)
183
- this.cause = args.cause;
184
- this.details = details;
185
- this.docsPath = docsPath5;
186
- this.metaMessages = args.metaMessages;
187
- this.shortMessage = shortMessage;
188
- }
189
- };
190
-
191
- // src/errors/abi.ts
192
- var AbiConstructorNotFoundError = class extends BaseError {
193
- constructor({ docsPath: docsPath5 }) {
194
- super(
195
- [
196
- "A constructor was not found on the ABI.",
197
- "Make sure you are using the correct ABI and that the constructor exists on it."
198
- ].join("\n"),
199
- {
200
- docsPath: docsPath5
201
- }
202
- );
203
- __publicField(this, "name", "AbiConstructorNotFoundError");
204
- }
205
- };
206
- var AbiConstructorParamsNotFoundError = class extends BaseError {
207
- constructor({ docsPath: docsPath5 }) {
208
- super(
209
- [
210
- "Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.",
211
- "Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."
212
- ].join("\n"),
213
- {
214
- docsPath: docsPath5
215
- }
216
- );
217
- __publicField(this, "name", "AbiConstructorParamsNotFoundError");
218
- }
219
- };
220
- var AbiDecodingDataSizeInvalidError = class extends BaseError {
221
- constructor(size2) {
222
- super(
223
- [
224
- `Data size of ${size2} bytes is invalid.`,
225
- "Size must be in increments of 32 bytes (size % 32 === 0)."
226
- ].join("\n")
227
- );
228
- __publicField(this, "name", "AbiDecodingDataSizeInvalidError");
229
- }
230
- };
231
- var AbiDecodingZeroDataError = class extends BaseError {
232
- constructor() {
233
- super('Cannot decode zero data ("0x") with ABI parameters.');
234
- __publicField(this, "name", "AbiDecodingZeroDataError");
235
- }
236
- };
237
- var AbiEncodingArrayLengthMismatchError = class extends BaseError {
238
- constructor({
239
- expectedLength,
240
- givenLength,
241
- type
242
- }) {
243
- super(
244
- [
245
- `ABI encoding array length mismatch for type ${type}.`,
246
- `Expected length: ${expectedLength}`,
247
- `Given length: ${givenLength}`
248
- ].join("\n")
249
- );
250
- __publicField(this, "name", "AbiEncodingArrayLengthMismatchError");
251
- }
252
- };
253
- var AbiEncodingLengthMismatchError = class extends BaseError {
254
- constructor({
255
- expectedLength,
256
- givenLength
257
- }) {
258
- super(
259
- [
260
- "ABI encoding params/values length mismatch.",
261
- `Expected length (params): ${expectedLength}`,
262
- `Given length (values): ${givenLength}`
263
- ].join("\n")
264
- );
265
- __publicField(this, "name", "AbiEncodingLengthMismatchError");
266
- }
267
- };
268
- var AbiErrorInputsNotFoundError = class extends BaseError {
269
- constructor(errorName, { docsPath: docsPath5 }) {
270
- super(
271
- [
272
- `Arguments (\`args\`) were provided to "${errorName}", but "${errorName}" on the ABI does not contain any parameters (\`inputs\`).`,
273
- "Cannot encode error result without knowing what the parameter types are.",
274
- "Make sure you are using the correct ABI and that the inputs exist on it."
275
- ].join("\n"),
276
- {
277
- docsPath: docsPath5
278
- }
279
- );
280
- __publicField(this, "name", "AbiErrorInputsNotFoundError");
281
- }
282
- };
283
- var AbiErrorNotFoundError = class extends BaseError {
284
- constructor(errorName, { docsPath: docsPath5 }) {
285
- super(
286
- [
287
- `Error "${errorName}" not found on ABI.`,
288
- "Make sure you are using the correct ABI and that the error exists on it."
289
- ].join("\n"),
290
- {
291
- docsPath: docsPath5
292
- }
293
- );
294
- __publicField(this, "name", "AbiErrorNotFoundError");
295
- }
296
- };
297
- var AbiErrorSignatureNotFoundError = class extends BaseError {
298
- constructor(signature, { docsPath: docsPath5 }) {
299
- super(
300
- [
301
- `Encoded error signature "${signature}" not found on ABI.`,
302
- "Make sure you are using the correct ABI and that the error exists on it.",
303
- `You can look up the signature here: https://openchain.xyz/signatures?query=${signature}.`
304
- ].join("\n"),
305
- {
306
- docsPath: docsPath5
307
- }
308
- );
309
- __publicField(this, "name", "AbiErrorSignatureNotFoundError");
310
- }
311
- };
312
- var AbiEventSignatureNotFoundError = class extends BaseError {
313
- constructor(signature, { docsPath: docsPath5 }) {
314
- super(
315
- [
316
- `Encoded event signature "${signature}" not found on ABI.`,
317
- "Make sure you are using the correct ABI and that the event exists on it.",
318
- `You can look up the signature here: https://openchain.xyz/signatures?query=${signature}.`
319
- ].join("\n"),
320
- {
321
- docsPath: docsPath5
322
- }
323
- );
324
- __publicField(this, "name", "AbiEventSignatureNotFoundError");
325
- }
326
- };
327
- var AbiEventNotFoundError = class extends BaseError {
328
- constructor(eventName, { docsPath: docsPath5 }) {
329
- super(
330
- [
331
- `Event "${eventName}" not found on ABI.`,
332
- "Make sure you are using the correct ABI and that the event exists on it."
333
- ].join("\n"),
334
- {
335
- docsPath: docsPath5
336
- }
337
- );
338
- __publicField(this, "name", "AbiEventNotFoundError");
339
- }
340
- };
341
- var AbiFunctionNotFoundError = class extends BaseError {
342
- constructor(functionName, { docsPath: docsPath5 }) {
343
- super(
344
- [
345
- `Function "${functionName}" not found on ABI.`,
346
- "Make sure you are using the correct ABI and that the function exists on it."
347
- ].join("\n"),
348
- {
349
- docsPath: docsPath5
350
- }
351
- );
352
- __publicField(this, "name", "AbiFunctionNotFoundError");
353
- }
354
- };
355
- var AbiFunctionOutputsNotFoundError = class extends BaseError {
356
- constructor(functionName, { docsPath: docsPath5 }) {
357
- super(
358
- [
359
- `Function "${functionName}" does not contain any \`outputs\` on ABI.`,
360
- "Cannot decode function result without knowing what the parameter types are.",
361
- "Make sure you are using the correct ABI and that the function exists on it."
362
- ].join("\n"),
363
- {
364
- docsPath: docsPath5
365
- }
366
- );
367
- __publicField(this, "name", "AbiFunctionOutputsNotFoundError");
368
- }
369
- };
370
- var AbiFunctionSignatureNotFoundError = class extends BaseError {
371
- constructor(signature, { docsPath: docsPath5 }) {
372
- super(
373
- [
374
- `Encoded function signature "${signature}" not found on ABI.`,
375
- "Make sure you are using the correct ABI and that the function exists on it.",
376
- `You can look up the signature here: https://openchain.xyz/signatures?query=${signature}.`
377
- ].join("\n"),
378
- {
379
- docsPath: docsPath5
380
- }
381
- );
382
- __publicField(this, "name", "AbiFunctionSignatureNotFoundError");
383
- }
384
- };
385
- var InvalidAbiEncodingTypeError = class extends BaseError {
386
- constructor(type, { docsPath: docsPath5 }) {
387
- super(
388
- [
389
- `Type "${type}" is not a valid encoding type.`,
390
- "Please provide a valid ABI type."
391
- ].join("\n"),
392
- { docsPath: docsPath5 }
393
- );
394
- __publicField(this, "name", "InvalidAbiEncodingType");
395
- }
396
- };
397
- var InvalidAbiDecodingTypeError = class extends BaseError {
398
- constructor(type, { docsPath: docsPath5 }) {
399
- super(
400
- [
401
- `Type "${type}" is not a valid decoding type.`,
402
- "Please provide a valid ABI type."
403
- ].join("\n"),
404
- { docsPath: docsPath5 }
405
- );
406
- __publicField(this, "name", "InvalidAbiDecodingType");
407
- }
408
- };
409
- var InvalidArrayError = class extends BaseError {
410
- constructor(value) {
411
- super([`Value "${value}" is not a valid array.`].join("\n"));
412
- __publicField(this, "name", "InvalidArrayError");
413
- }
414
- };
415
- var InvalidDefinitionTypeError = class extends BaseError {
416
- constructor(type) {
417
- super(
418
- [
419
- `"${type}" is not a valid definition type.`,
420
- 'Valid types: "function", "event", "error"'
421
- ].join("\n")
422
- );
423
- __publicField(this, "name", "InvalidDefinitionTypeError");
424
- }
425
- };
426
-
427
- // src/errors/address.ts
428
- var InvalidAddressError = class extends BaseError {
429
- constructor({ address }) {
430
- super(`Address "${address}" is invalid.`);
431
- __publicField(this, "name", "InvalidAddressError");
432
- }
433
- };
434
-
435
- // src/errors/block.ts
436
- var BlockNotFoundError = class extends BaseError {
437
- constructor({
438
- blockHash,
439
- blockNumber
440
- }) {
441
- let identifier = "Block";
442
- if (blockHash)
443
- identifier = `Block at hash "${blockHash}"`;
444
- if (blockNumber)
445
- identifier = `Block at number "${blockNumber}"`;
446
- super(`${identifier} could not be found.`);
447
- __publicField(this, "name", "BlockNotFoundError");
448
- }
449
- };
450
-
451
- // src/errors/chain.ts
452
- var ChainDoesNotSupportContract = class extends BaseError {
453
- constructor({
454
- blockNumber,
455
- chain,
456
- contract
457
- }) {
458
- super(
459
- `Chain "${chain.name}" does not support contract "${contract.name}".`,
460
- {
461
- metaMessages: [
462
- "This could be due to any of the following:",
463
- ...blockNumber && contract.blockCreated && contract.blockCreated > blockNumber ? [
464
- `- The contract "${contract.name}" was not deployed until block ${contract.blockCreated} (current block ${blockNumber}).`
465
- ] : [
466
- `- The chain does not have the contract "${contract.name}" configured.`
467
- ]
468
- ]
469
- }
470
- );
471
- __publicField(this, "name", "ChainDoesNotSupportContract");
472
- }
473
- };
474
-
475
- // src/constants/abis.ts
476
- var multicall3Abi = [
477
- {
478
- inputs: [
479
- {
480
- components: [
481
- {
482
- name: "target",
483
- type: "address"
484
- },
485
- {
486
- name: "allowFailure",
487
- type: "bool"
488
- },
489
- {
490
- name: "callData",
491
- type: "bytes"
492
- }
493
- ],
494
- name: "calls",
495
- type: "tuple[]"
496
- }
497
- ],
498
- name: "aggregate3",
499
- outputs: [
500
- {
501
- components: [
502
- {
503
- name: "success",
504
- type: "bool"
505
- },
506
- {
507
- name: "returnData",
508
- type: "bytes"
509
- }
510
- ],
511
- name: "returnData",
512
- type: "tuple[]"
513
- }
514
- ],
515
- stateMutability: "view",
516
- type: "function"
517
- }
518
- ];
519
-
520
- // src/constants/solidity.ts
521
- var panicReasons = {
522
- 1: "An `assert` condition failed.",
523
- 17: "Arithmic operation resulted in underflow or overflow.",
524
- 18: "Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",
525
- 33: "Attempted to convert to an invalid type.",
526
- 34: "Attempted to access a storage byte array that is incorrectly encoded.",
527
- 49: "Performed `.pop()` on an empty array",
528
- 50: "Array index is out of bounds.",
529
- 65: "Allocated too much memory or created an array which is too large.",
530
- 81: "Attempted to call a zero-initialized variable of internal function type."
531
- };
532
- var solidityError = {
533
- inputs: [
534
- {
535
- name: "message",
536
- type: "string"
537
- }
538
- ],
539
- name: "Error",
540
- type: "error"
541
- };
542
- var solidityPanic = {
543
- inputs: [
544
- {
545
- name: "reason",
546
- type: "uint256"
547
- }
548
- ],
549
- name: "Panic",
550
- type: "error"
551
- };
552
-
553
- // src/errors/contract.ts
554
- var ContractFunctionExecutionError = class extends BaseError {
555
- constructor(cause, {
556
- abi,
557
- args,
558
- contractAddress,
559
- docsPath: docsPath5,
560
- functionName,
561
- sender
562
- }) {
563
- const abiItem = getAbiItem({ abi, args, name: functionName });
564
- const formattedArgs = abiItem ? formatAbiItemWithArgs({
565
- abiItem,
566
- args,
567
- includeFunctionName: false,
568
- includeName: false
569
- }) : void 0;
570
- const functionWithParams = abiItem ? formatAbiItem(abiItem, { includeName: true }) : void 0;
571
- super(
572
- cause.shortMessage || `An unknown error occurred while executing the contract function "${functionName}".`,
573
- {
574
- cause,
575
- docsPath: docsPath5,
576
- metaMessages: [
577
- ...cause.metaMessages ? [...cause.metaMessages, " "] : [],
578
- contractAddress && `Contract: ${/* c8 ignore start */
579
- process.env.TEST ? "0x0000000000000000000000000000000000000000" : contractAddress}`,
580
- functionWithParams && `Function: ${functionWithParams}`,
581
- formattedArgs && formattedArgs !== "()" && `Arguments: ${[...Array(_nullishCoalesce(_optionalChain([functionName, 'optionalAccess', _4 => _4.length]), () => ( 0))).keys()].map(() => " ").join("")}${formattedArgs}`,
582
- sender && `Sender: ${sender}`
583
- ].filter(Boolean)
584
- }
585
- );
586
- __publicField(this, "abi");
587
- __publicField(this, "args");
588
- __publicField(this, "cause");
589
- __publicField(this, "contractAddress");
590
- __publicField(this, "formattedArgs");
591
- __publicField(this, "functionName");
592
- __publicField(this, "sender");
593
- __publicField(this, "name", "ContractFunctionExecutionError");
594
- this.abi = abi;
595
- this.args = args;
596
- this.cause = cause;
597
- this.contractAddress = contractAddress;
598
- this.functionName = functionName;
599
- this.sender = sender;
600
- }
601
- };
602
- var ContractFunctionRevertedError = class extends BaseError {
603
- constructor({
604
- abi,
605
- data,
606
- functionName,
607
- message
608
- }) {
609
- let decodedData = void 0;
610
- let metaMessages;
611
- let reason;
612
- if (data && data !== "0x") {
613
- decodedData = decodeErrorResult({ abi, data });
614
- const { abiItem, errorName, args: errorArgs } = decodedData;
615
- if (errorName === "Error") {
616
- reason = errorArgs[0];
617
- } else if (errorName === "Panic") {
618
- const [firstArg] = errorArgs;
619
- reason = panicReasons[firstArg];
620
- } else if (errorArgs) {
621
- const errorWithParams = abiItem ? formatAbiItem(abiItem, { includeName: true }) : void 0;
622
- const formattedArgs = abiItem ? formatAbiItemWithArgs({
623
- abiItem,
624
- args: errorArgs,
625
- includeFunctionName: false,
626
- includeName: false
627
- }) : void 0;
628
- metaMessages = [
629
- errorWithParams ? `Error: ${errorWithParams}` : "",
630
- formattedArgs && formattedArgs !== "()" ? `Arguments: ${[...Array(_nullishCoalesce(_optionalChain([errorName, 'optionalAccess', _5 => _5.length]), () => ( 0))).keys()].map(() => " ").join("")}${formattedArgs}` : ""
631
- ];
632
- }
633
- } else if (message)
634
- reason = message;
635
- super(
636
- reason ? [
637
- `The contract function "${functionName}" reverted with the following reason:`,
638
- reason
639
- ].join("\n") : `The contract function "${functionName}" reverted.`,
640
- {
641
- metaMessages
642
- }
643
- );
644
- __publicField(this, "name", "ContractFunctionRevertedError");
645
- __publicField(this, "data");
646
- __publicField(this, "reason");
647
- this.reason = reason;
648
- this.data = decodedData;
649
- }
650
- };
651
- var ContractFunctionZeroDataError = class extends BaseError {
652
- constructor({ functionName }) {
653
- super(`The contract function "${functionName}" returned no data ("0x").`, {
654
- metaMessages: [
655
- "This could be due to any of the following:",
656
- `- The contract does not have the function "${functionName}",`,
657
- "- The parameters passed to the contract function may be invalid, or",
658
- "- The address is not a contract."
659
- ]
660
- });
661
- __publicField(this, "name", "ContractFunctionZeroDataError");
662
- }
663
- };
664
- var RawContractError = class extends BaseError {
665
- constructor({ data, message }) {
666
- super(message || "");
667
- __publicField(this, "code", 3);
668
- __publicField(this, "name", "RawContractError");
669
- __publicField(this, "data");
670
- this.data = data;
671
- }
672
- };
673
-
674
- // src/errors/data.ts
675
- var SizeExceedsPaddingSizeError = class extends BaseError {
676
- constructor({
677
- size: size2,
678
- targetSize,
679
- type
680
- }) {
681
- super(
682
- `${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size2}) exceeds padding size (${targetSize}).`
683
- );
684
- __publicField(this, "name", "SizeExceedsPaddingSizeError");
685
- }
686
- };
687
-
688
- // src/errors/encoding.ts
689
- var DataLengthTooLongError = class extends BaseError {
690
- constructor({ consumed, length }) {
691
- super(
692
- `Consumed bytes (${consumed}) is shorter than data length (${length - 1}).`
693
- );
694
- __publicField(this, "name", "DataLengthTooLongError");
695
- }
696
- };
697
- var DataLengthTooShortError = class extends BaseError {
698
- constructor({ length, dataLength }) {
699
- super(
700
- `Data length (${dataLength - 1}) is shorter than prefix length (${length - 1}).`
701
- );
702
- __publicField(this, "name", "DataLengthTooShortError");
703
- }
704
- };
705
- var InvalidBytesBooleanError = class extends BaseError {
706
- constructor(bytes) {
707
- super(
708
- `Bytes value "${bytes}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`
709
- );
710
- __publicField(this, "name", "InvalidBytesBooleanError");
711
- }
712
- };
713
- var InvalidHexBooleanError = class extends BaseError {
714
- constructor(hex) {
715
- super(
716
- `Hex value "${hex}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`
717
- );
718
- __publicField(this, "name", "InvalidHexBooleanError");
719
- }
720
- };
721
- var InvalidHexValueError = class extends BaseError {
722
- constructor(value) {
723
- super(
724
- `Hex value "${value}" is an odd length (${value.length}). It must be an even length.`
725
- );
726
- __publicField(this, "name", "InvalidHexValueError");
727
- }
728
- };
729
- var OffsetOutOfBoundsError = class extends BaseError {
730
- constructor({ nextOffset, offset }) {
731
- super(
732
- `Next offset (${nextOffset}) is greater than previous offset + consumed bytes (${offset})`
733
- );
734
- __publicField(this, "name", "OffsetOutOfBoundsError");
735
- }
736
- };
737
-
738
- // src/errors/log.ts
739
- var FilterTypeNotSupportedError = class extends BaseError {
740
- constructor(type) {
741
- super(`Filter type "${type}" is not supported.`);
742
- __publicField(this, "name", "FilterTypeNotSupportedError");
743
- }
744
- };
745
-
746
- // src/errors/request.ts
747
- var RequestError = class extends BaseError {
748
- constructor(err, { docsPath: docsPath5, shortMessage }) {
749
- super(shortMessage, {
750
- cause: err,
751
- docsPath: docsPath5
752
- });
753
- this.name = err.name;
754
- }
755
- };
756
- var RpcRequestError = class extends RequestError {
757
- constructor(err, { docsPath: docsPath5, shortMessage }) {
758
- super(err, { docsPath: docsPath5, shortMessage });
759
- __publicField(this, "code");
760
- this.code = err.code;
761
- this.name = err.name;
762
- }
763
- };
764
- var ParseRpcError = class extends RpcRequestError {
765
- constructor(err) {
766
- super(err, {
767
- shortMessage: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."
768
- });
769
- __publicField(this, "name", "ParseRpcError");
770
- __publicField(this, "code", -32700);
771
- }
772
- };
773
- var InvalidRequestRpcError = class extends RpcRequestError {
774
- constructor(err) {
775
- super(err, { shortMessage: "JSON is not a valid request object." });
776
- __publicField(this, "name", "InvalidRequestRpcError");
777
- __publicField(this, "code", -32600);
778
- }
779
- };
780
- var MethodNotFoundRpcError = class extends RpcRequestError {
781
- constructor(err) {
782
- super(err, {
783
- shortMessage: "The method does not exist / is not available."
784
- });
785
- __publicField(this, "name", "MethodNotFoundRpcError");
786
- __publicField(this, "code", -32601);
787
- }
788
- };
789
- var InvalidParamsRpcError = class extends RpcRequestError {
790
- constructor(err) {
791
- super(err, {
792
- shortMessage: [
793
- "Invalid parameters were provided to the RPC method.",
794
- "Double check you have provided the correct parameters."
795
- ].join("\n")
796
- });
797
- __publicField(this, "name", "InvalidParamsRpcError");
798
- __publicField(this, "code", -32602);
799
- }
800
- };
801
- var InternalRpcError = class extends RpcRequestError {
802
- constructor(err) {
803
- super(err, { shortMessage: "An internal error was received." });
804
- __publicField(this, "name", "InternalRpcError");
805
- __publicField(this, "code", -32603);
806
- }
807
- };
808
- var InvalidInputRpcError = class extends RpcRequestError {
809
- constructor(err) {
810
- super(err, {
811
- shortMessage: [
812
- "Missing or invalid parameters.",
813
- "Double check you have provided the correct parameters."
814
- ].join("\n")
815
- });
816
- __publicField(this, "name", "InvalidInputRpcError");
817
- __publicField(this, "code", -32e3);
818
- }
819
- };
820
- var ResourceNotFoundRpcError = class extends RpcRequestError {
821
- constructor(err) {
822
- super(err, { shortMessage: "Requested resource not found." });
823
- __publicField(this, "name", "ResourceNotFoundRpcError");
824
- __publicField(this, "code", -32001);
825
- }
826
- };
827
- var ResourceUnavailableRpcError = class extends RpcRequestError {
828
- constructor(err) {
829
- super(err, { shortMessage: "Requested resource not available." });
830
- __publicField(this, "name", "ResourceUnavailableRpcError");
831
- __publicField(this, "code", -32002);
832
- }
833
- };
834
- var TransactionRejectedRpcError = class extends RpcRequestError {
835
- constructor(err) {
836
- super(err, { shortMessage: "Transaction creation failed." });
837
- __publicField(this, "name", "TransactionRejectedRpcError");
838
- __publicField(this, "code", -32003);
839
- }
840
- };
841
- var MethodNotSupportedRpcError = class extends RpcRequestError {
842
- constructor(err) {
843
- super(err, { shortMessage: "Method is not implemented." });
844
- __publicField(this, "name", "MethodNotSupportedRpcError");
845
- __publicField(this, "code", -32004);
846
- }
847
- };
848
- var LimitExceededRpcError = class extends RpcRequestError {
849
- constructor(err) {
850
- super(err, { shortMessage: "Request exceeds defined limit." });
851
- __publicField(this, "name", "LimitExceededRpcError");
852
- __publicField(this, "code", -32005);
853
- }
854
- };
855
- var JsonRpcVersionUnsupportedError = class extends RpcRequestError {
856
- constructor(err) {
857
- super(err, {
858
- shortMessage: "Version of JSON-RPC protocol is not supported."
859
- });
860
- __publicField(this, "name", "JsonRpcVersionUnsupportedError");
861
- __publicField(this, "code", -32006);
862
- }
863
- };
864
- var UnknownRpcError = class extends RequestError {
865
- constructor(err) {
866
- super(err, {
867
- shortMessage: "An unknown RPC error occurred."
868
- });
869
- __publicField(this, "name", "UnknownRpcError");
870
- }
871
- };
872
-
873
- // src/errors/rpc.ts
874
- var HttpRequestError = class extends BaseError {
875
- constructor({
876
- body,
877
- details,
878
- status,
879
- url
880
- }) {
881
- super(
882
- [
883
- "HTTP request failed.",
884
- "",
885
- `Status: ${status}`,
886
- `URL: ${url}`,
887
- `Request body: ${stringify(body)}`
888
- ].join("\n"),
889
- {
890
- details
891
- }
892
- );
893
- __publicField(this, "name", "HttpRequestError");
894
- __publicField(this, "status");
895
- this.status = status;
896
- }
897
- };
898
- var WebSocketRequestError = class extends BaseError {
899
- constructor({
900
- body,
901
- details,
902
- url
903
- }) {
904
- super(
905
- [
906
- "WebSocket request failed.",
907
- "",
908
- `URL: ${url}`,
909
- `Request body: ${stringify(body)}`
910
- ].join("\n"),
911
- {
912
- details
913
- }
914
- );
915
- __publicField(this, "name", "WebSocketRequestError");
916
- }
917
- };
918
- var RpcError = class extends BaseError {
919
- constructor({
920
- body,
921
- error,
922
- url
923
- }) {
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
- );
936
- __publicField(this, "code");
937
- __publicField(this, "name", "RpcError");
938
- this.code = error.code;
939
- }
940
- };
941
- var TimeoutError = class extends BaseError {
942
- constructor({
943
- body,
944
- url
945
- }) {
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
- __publicField(this, "name", "TimeoutError");
958
- }
959
- };
960
-
961
- // src/errors/transaction.ts
962
- var InvalidGasArgumentsError = class extends BaseError {
963
- constructor() {
964
- super("`maxFeePerGas` cannot be less than `maxPriorityFeePerGas`");
965
- __publicField(this, "name", "InvalidGasArgumentsError");
966
- }
967
- };
968
- var TransactionNotFoundError = class extends BaseError {
969
- constructor({
970
- blockHash,
971
- blockNumber,
972
- blockTag,
973
- hash: hash2,
974
- index
975
- }) {
976
- let identifier = "Transaction";
977
- if (blockTag && index !== void 0)
978
- identifier = `Transaction at block time "${blockTag}" at index "${index}"`;
979
- if (blockHash && index !== void 0)
980
- identifier = `Transaction at block hash "${blockHash}" at index "${index}"`;
981
- if (blockNumber && index !== void 0)
982
- identifier = `Transaction at block number "${blockNumber}" at index "${index}"`;
983
- if (hash2)
984
- identifier = `Transaction with hash "${hash2}"`;
985
- super(`${identifier} could not be found.`);
986
- __publicField(this, "name", "TransactionNotFoundError");
987
- }
988
- };
989
- var TransactionReceiptNotFoundError = class extends BaseError {
990
- constructor({ hash: hash2 }) {
991
- super(
992
- `Transaction receipt with hash "${hash2}" could not be found. The Transaction may not be processed on a block yet.`
993
- );
994
- __publicField(this, "name", "TransactionReceiptNotFoundError");
995
- }
996
- };
997
- var WaitForTransactionReceiptTimeoutError = class extends BaseError {
998
- constructor({ hash: hash2 }) {
999
- super(
1000
- `Timed out while waiting for transaction with hash "${hash2}" to be confirmed.`
1001
- );
1002
- __publicField(this, "name", "WaitForTransactionReceiptTimeoutError");
1003
- }
1004
- };
1005
-
1006
- // src/errors/transport.ts
1007
- var UrlRequiredError = class extends BaseError {
1008
- constructor() {
1009
- super(
1010
- "No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",
1011
- {
1012
- docsPath: "/docs/clients/intro"
1013
- }
1014
- );
1015
- }
1016
- };
1017
-
1018
- // src/utils/data/concat.ts
1019
- function concat(values) {
1020
- if (typeof values[0] === "string")
1021
- return concatHex(values);
1022
- return concatBytes(values);
1023
- }
1024
- function concatBytes(values) {
1025
- let length = 0;
1026
- for (const arr of values) {
1027
- length += arr.length;
1028
- }
1029
- const result = new Uint8Array(length);
1030
- let offset = 0;
1031
- for (const arr of values) {
1032
- result.set(arr, offset);
1033
- offset += arr.length;
1034
- }
1035
- return result;
1036
- }
1037
- function concatHex(values) {
1038
- return `0x${values.reduce(
1039
- (acc, x) => acc + x.replace("0x", ""),
1040
- ""
1041
- )}`;
1042
- }
1043
-
1044
- // src/utils/data/isBytes.ts
1045
- function isBytes(value) {
1046
- if (!value)
1047
- return false;
1048
- if (typeof value !== "object")
1049
- return false;
1050
- return value.BYTES_PER_ELEMENT === 1 && value.constructor.name === "Uint8Array";
1051
- }
1052
-
1053
- // src/utils/data/isHex.ts
1054
- function isHex(value) {
1055
- if (!value)
1056
- return false;
1057
- if (typeof value !== "string")
1058
- return false;
1059
- return /^0x[0-9a-fA-F]*$/.test(value);
1060
- }
1061
-
1062
- // src/utils/data/pad.ts
1063
- function pad(hexOrBytes, { dir, size: size2 = 32 } = {}) {
1064
- if (typeof hexOrBytes === "string")
1065
- return padHex(hexOrBytes, { dir, size: size2 });
1066
- return padBytes(hexOrBytes, { dir, size: size2 });
1067
- }
1068
- function padHex(hex_, { dir, size: size2 = 32 } = {}) {
1069
- let hex = hex_.replace("0x", "");
1070
- if (hex.length > size2 * 2)
1071
- throw new SizeExceedsPaddingSizeError({
1072
- size: Math.ceil(hex.length / 2),
1073
- targetSize: size2,
1074
- type: "hex"
1075
- });
1076
- return `0x${hex[dir === "right" ? "padEnd" : "padStart"](
1077
- size2 * 2,
1078
- "0"
1079
- )}`;
1080
- }
1081
- function padBytes(bytes, { dir, size: size2 = 32 } = {}) {
1082
- if (bytes.length > size2)
1083
- throw new SizeExceedsPaddingSizeError({
1084
- size: bytes.length,
1085
- targetSize: size2,
1086
- type: "bytes"
1087
- });
1088
- const paddedBytes = new Uint8Array(size2);
1089
- for (let i = 0; i < size2; i++) {
1090
- const padEnd = dir === "right";
1091
- paddedBytes[padEnd ? i : size2 - i - 1] = bytes[padEnd ? i : bytes.length - i - 1];
1092
- }
1093
- return paddedBytes;
1094
- }
1095
-
1096
- // src/utils/data/trim.ts
1097
- function trim(hexOrBytes, { dir = "left" } = {}) {
1098
- let data = typeof hexOrBytes === "string" ? hexOrBytes.replace("0x", "") : hexOrBytes;
1099
- let sliceLength = 0;
1100
- for (let i = 0; i < data.length - 1; i++) {
1101
- if (data[dir === "left" ? i : data.length - i - 1].toString() === "0")
1102
- sliceLength++;
1103
- else
1104
- break;
1105
- }
1106
- data = dir === "left" ? data.slice(sliceLength) : data.slice(0, data.length - sliceLength);
1107
- if (typeof hexOrBytes === "string") {
1108
- if (data.length === 1 && dir === "right")
1109
- data = `${data}0`;
1110
- return `0x${data}`;
1111
- }
1112
- return data;
1113
- }
1114
-
1115
- // src/utils/data/size.ts
1116
- function size(value) {
1117
- if (isHex(value))
1118
- return Math.ceil((value.length - 2) / 2);
1119
- return value.length;
1120
- }
1121
-
1122
- // src/utils/data/slice.ts
1123
- function slice(value, start, end) {
1124
- if (isHex(value))
1125
- return sliceHex(value, start, end);
1126
- return sliceBytes(value, start, end);
1127
- }
1128
- function assertStartOffset(value, start) {
1129
- if (typeof start === "number" && start > 0 && start > size(value) - 1)
1130
- throw new Error(
1131
- `Slice starting at offset "${start}" is out-of-bounds (size: ${size(
1132
- value
1133
- )}).`
1134
- );
1135
- }
1136
- function sliceBytes(value, start, end) {
1137
- assertStartOffset(value, start);
1138
- return value.slice(start, end);
1139
- }
1140
- function sliceHex(value_, start, end) {
1141
- assertStartOffset(value_, start);
1142
- const value = value_.replace("0x", "").slice((_nullishCoalesce(start, () => ( 0))) * 2, (_nullishCoalesce(end, () => ( value_.length))) * 2);
1143
- return `0x${value}`;
1144
- }
1145
-
1146
- // src/utils/encoding/encodeHex.ts
1147
- var hexes = Array.from(
1148
- { length: 256 },
1149
- (v, i) => i.toString(16).padStart(2, "0")
1150
- );
1151
- function boolToHex(value) {
1152
- return `0x${Number(value)}`;
1153
- }
1154
- function bytesToHex(value) {
1155
- let hex = "";
1156
- for (let i = 0; i < value.length; i++) {
1157
- hex += hexes[value[i]];
1158
- }
1159
- return `0x${hex}`;
1160
- }
1161
- function encodeHex(value) {
1162
- if (typeof value === "number" || typeof value === "bigint")
1163
- return numberToHex(value);
1164
- if (typeof value === "string") {
1165
- return stringToHex(value);
1166
- }
1167
- if (typeof value === "boolean")
1168
- return boolToHex(value);
1169
- return bytesToHex(value);
1170
- }
1171
- function numberToHex(value_, opts = {}) {
1172
- const { signed, size: size2 } = opts;
1173
- let value = BigInt(value_);
1174
- let maxValue;
1175
- if (size2) {
1176
- if (signed)
1177
- maxValue = (1n << BigInt(size2) * 8n - 1n) - 1n;
1178
- else
1179
- maxValue = 2n ** (BigInt(size2) * 8n) - 1n;
1180
- } else if (typeof value_ === "number") {
1181
- maxValue = BigInt(Number.MAX_SAFE_INTEGER);
1182
- }
1183
- const minValue = typeof maxValue === "bigint" && signed ? -maxValue - 1n : 0;
1184
- if (maxValue && value > maxValue || value < minValue) {
1185
- const suffix = typeof value_ === "bigint" ? "n" : "";
1186
- throw new Error(
1187
- `Number "${value_}${suffix}" is not in safe ${size2 ? `${size2 * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${maxValue ? `(${minValue}${suffix} to ${maxValue}${suffix})` : `(above ${minValue})`}`
1188
- );
1189
- }
1190
- const hex = `0x${(signed && value < 0 ? (1n << BigInt(size2 * 8)) + BigInt(value) : value).toString(16)}`;
1191
- if (size2)
1192
- return pad(hex, { size: size2 });
1193
- return hex;
1194
- }
1195
- function stringToHex(value) {
1196
- let hex = "";
1197
- for (let i = 0; i < value.length; i++) {
1198
- hex += value.charCodeAt(i).toString(16);
1199
- }
1200
- return `0x${hex}`;
1201
- }
1202
-
1203
- // src/utils/encoding/encodeBytes.ts
1204
- var encoder = new TextEncoder();
1205
- function boolToBytes(value) {
1206
- const bytes = new Uint8Array(1);
1207
- bytes[0] = Number(value);
1208
- return bytes;
1209
- }
1210
- function encodeBytes(value) {
1211
- if (typeof value === "number" || typeof value === "bigint")
1212
- return numberToBytes(value);
1213
- if (typeof value === "boolean")
1214
- return boolToBytes(value);
1215
- if (value.startsWith("0x"))
1216
- return hexToBytes(value);
1217
- return stringToBytes(value);
1218
- }
1219
- function hexToBytes(hex_) {
1220
- let hex = hex_.slice(2);
1221
- if (hex.length % 2)
1222
- hex = `0${hex}`;
1223
- const bytes = new Uint8Array(hex.length / 2);
1224
- for (let index = 0; index < bytes.length; index++) {
1225
- const start = index * 2;
1226
- const hexByte = hex.slice(start, start + 2);
1227
- const byte = Number.parseInt(hexByte, 16);
1228
- if (Number.isNaN(byte) || byte < 0)
1229
- throw new Error("Invalid byte sequence");
1230
- bytes[index] = byte;
1231
- }
1232
- return bytes;
1233
- }
1234
- function numberToBytes(value, opts) {
1235
- const hex = numberToHex(value, opts);
1236
- return hexToBytes(hex);
1237
- }
1238
- function stringToBytes(value) {
1239
- return encoder.encode(value);
1240
- }
1241
-
1242
- // src/utils/encoding/encodeRlp.ts
1243
- function encodeRlp(hexOrBytes, to_) {
1244
- const to = to_ || "hex";
1245
- return format(bytesToRlp(parse(hexOrBytes)), to);
1246
- }
1247
- function parse(hexOrBytes) {
1248
- if (Array.isArray(hexOrBytes))
1249
- return hexOrBytes.map(parse);
1250
- return typeof hexOrBytes === "string" ? encodeBytes(hexOrBytes) : hexOrBytes;
1251
- }
1252
- function format(bytes, type = "bytes") {
1253
- return type === "hex" ? bytesToHex(bytes) : bytes;
1254
- }
1255
- function bytesToRlp(bytes) {
1256
- if (Array.isArray(bytes)) {
1257
- const encoded = concat(bytes.map(bytesToRlp));
1258
- return new Uint8Array([...encodeLength(encoded.length, 192), ...encoded]);
1259
- }
1260
- if (bytes.length === 1 && bytes[0] < 128)
1261
- return bytes;
1262
- return new Uint8Array([...encodeLength(bytes.length, 128), ...bytes]);
1263
- }
1264
- function encodeLength(length, offset) {
1265
- if (length < 56)
1266
- return [offset + length];
1267
- return [encodeBytes(length).length + offset + 55, ...encodeBytes(length)];
1268
- }
1269
-
1270
- // src/utils/encoding/decodeHex.ts
1271
- function decodeHex(hex, to) {
1272
- if (to === "number")
1273
- return hexToNumber(hex);
1274
- if (to === "bigint")
1275
- return hexToBigInt(hex);
1276
- if (to === "string")
1277
- return hexToString(hex);
1278
- if (to === "boolean")
1279
- return hexToBool(hex);
1280
- return hexToBytes(hex);
1281
- }
1282
- function hexToBigInt(hex, opts = {}) {
1283
- const { signed } = opts;
1284
- const value = BigInt(hex);
1285
- if (!signed)
1286
- return value;
1287
- const size2 = (hex.length - 2) / 2;
1288
- const max = (1n << BigInt(size2) * 8n - 1n) - 1n;
1289
- if (value <= max)
1290
- return value;
1291
- return value - BigInt(`0x${"f".padStart(size2 * 2, "f")}`) - 1n;
1292
- }
1293
- function hexToBool(hex) {
1294
- if (trim(hex) === "0x0")
1295
- return false;
1296
- if (trim(hex) === "0x1")
1297
- return true;
1298
- throw new InvalidHexBooleanError(hex);
1299
- }
1300
- function hexToNumber(hex, opts = {}) {
1301
- return Number(hexToBigInt(hex, opts));
1302
- }
1303
- function hexToString(hex) {
1304
- const bytes = hexToBytes(hex);
1305
- return new TextDecoder().decode(bytes);
1306
- }
1307
-
1308
- // src/utils/encoding/decodeBytes.ts
1309
- function decodeBytes(bytes, to) {
1310
- if (to === "number")
1311
- return bytesToNumber(bytes);
1312
- if (to === "bigint")
1313
- return bytesToBigint(bytes);
1314
- if (to === "boolean")
1315
- return bytesToBool(bytes);
1316
- if (to === "string")
1317
- return bytesToString(bytes);
1318
- return bytesToHex(bytes);
1319
- }
1320
- function bytesToBigint(bytes) {
1321
- const hex = bytesToHex(bytes);
1322
- return hexToBigInt(hex);
1323
- }
1324
- function bytesToBool(bytes) {
1325
- if (bytes.length > 1 || bytes[0] > 1)
1326
- throw new InvalidBytesBooleanError(bytes);
1327
- return Boolean(bytes[0]);
1328
- }
1329
- function bytesToNumber(bytes) {
1330
- const hex = bytesToHex(bytes);
1331
- return hexToNumber(hex);
1332
- }
1333
- function bytesToString(bytes) {
1334
- return new TextDecoder().decode(bytes);
1335
- }
1336
-
1337
- // src/utils/encoding/decodeRlp.ts
1338
- function decodeRlp(value, to) {
1339
- const bytes = parse2(value);
1340
- const [data, consumed] = rlpToBytes(bytes);
1341
- if (consumed < bytes.length)
1342
- throw new DataLengthTooLongError({
1343
- consumed,
1344
- length: bytes.length
1345
- });
1346
- return format2(data, to);
1347
- }
1348
- function parse2(value) {
1349
- if (typeof value === "string") {
1350
- if (value.length > 3 && value.length % 2 !== 0)
1351
- throw new InvalidHexValueError(value);
1352
- return hexToBytes(value);
1353
- }
1354
- return value;
1355
- }
1356
- function format2(bytes, to) {
1357
- if (Array.isArray(bytes))
1358
- return bytes.map((b) => format2(b, to));
1359
- return to === "hex" ? trim(bytesToHex(bytes)) : bytes;
1360
- }
1361
- function rlpToBytes(bytes, offset = 0) {
1362
- if (bytes.length === 0)
1363
- return [new Uint8Array([]), 0];
1364
- const prefix = bytes[offset];
1365
- if (prefix <= 127)
1366
- return [new Uint8Array([bytes[offset]]), 1];
1367
- if (prefix <= 183) {
1368
- const length2 = prefix - 128;
1369
- const offset_ = offset + 1;
1370
- if (offset_ + length2 > bytes.length)
1371
- throw new DataLengthTooShortError({
1372
- length: offset_ + length2,
1373
- dataLength: bytes.length
1374
- });
1375
- return [bytes.slice(offset_, offset_ + length2), 1 + length2];
1376
- }
1377
- if (prefix <= 191) {
1378
- const lengthOfLength2 = prefix - 183;
1379
- const offset_ = offset + 1;
1380
- const length2 = bytesToNumber(bytes.slice(offset_, offset_ + lengthOfLength2));
1381
- if (offset_ + lengthOfLength2 + length2 > bytes.length)
1382
- throw new DataLengthTooShortError({
1383
- length: lengthOfLength2 + length2,
1384
- dataLength: bytes.length - lengthOfLength2
1385
- });
1386
- return [
1387
- bytes.slice(offset_ + lengthOfLength2, offset_ + lengthOfLength2 + length2),
1388
- 1 + lengthOfLength2 + length2
1389
- ];
1390
- }
1391
- let lengthOfLength = 0;
1392
- let length = prefix - 192;
1393
- if (prefix > 247) {
1394
- lengthOfLength = prefix - 247;
1395
- length = bytesToNumber(bytes.slice(offset + 1, offset + 1 + lengthOfLength));
1396
- }
1397
- let nextOffset = offset + 1 + lengthOfLength;
1398
- if (nextOffset > bytes.length)
1399
- throw new DataLengthTooShortError({
1400
- length: nextOffset,
1401
- dataLength: bytes.length
1402
- });
1403
- let consumed = 1 + lengthOfLength + length;
1404
- let result = [];
1405
- while (nextOffset < offset + consumed) {
1406
- const decoded = rlpToBytes(bytes, nextOffset);
1407
- result.push(decoded[0]);
1408
- nextOffset += decoded[1];
1409
- if (nextOffset > offset + consumed)
1410
- throw new OffsetOutOfBoundsError({
1411
- nextOffset,
1412
- offset: offset + consumed
1413
- });
1414
- }
1415
- return [result, consumed];
1416
- }
1417
-
1418
- // src/utils/contract/extractFunctionParts.ts
1419
- var paramsRegex = /((function|event)\s)?(.*)(\((.*)\))/;
1420
- function extractFunctionParts(def) {
1421
- const parts = def.match(paramsRegex);
1422
- const type = _optionalChain([parts, 'optionalAccess', _6 => _6[2]]) || void 0;
1423
- const name = _optionalChain([parts, 'optionalAccess', _7 => _7[3]]);
1424
- const params = _optionalChain([parts, 'optionalAccess', _8 => _8[5]]) || void 0;
1425
- return { type, name, params };
1426
- }
1427
- function extractFunctionName(def) {
1428
- return extractFunctionParts(def).name;
1429
- }
1430
- function extractFunctionParams(def) {
1431
- const params = extractFunctionParts(def).params;
1432
- const splitParams = _optionalChain([params, 'optionalAccess', _9 => _9.split, 'call', _10 => _10(","), 'access', _11 => _11.map, 'call', _12 => _12((x) => x.trim().split(" "))]);
1433
- return _optionalChain([splitParams, 'optionalAccess', _13 => _13.map, 'call', _14 => _14((param) => ({
1434
- type: param[0],
1435
- name: param[1] === "indexed" ? param[2] : param[1],
1436
- ...param[1] === "indexed" ? { indexed: true } : {}
1437
- }))]);
1438
- }
1439
- function extractFunctionType(def) {
1440
- return extractFunctionParts(def).type;
1441
- }
1442
-
1443
- // src/utils/contract/getContractError.ts
1444
- var EXECUTION_REVERTED_ERROR_CODE = 3;
1445
- function getContractError(err, {
1446
- abi,
1447
- address,
1448
- args,
1449
- docsPath: docsPath5,
1450
- functionName,
1451
- sender
1452
- }) {
1453
- const { code, data, message } = err instanceof RawContractError ? err : err.cause || {};
1454
- let cause = err;
1455
- if (err instanceof AbiDecodingZeroDataError) {
1456
- cause = new ContractFunctionZeroDataError({ functionName });
1457
- } else if (code === EXECUTION_REVERTED_ERROR_CODE && (data || message)) {
1458
- cause = new ContractFunctionRevertedError({
1459
- abi,
1460
- data,
1461
- functionName,
1462
- message
1463
- });
1464
- }
1465
- return new ContractFunctionExecutionError(cause, {
1466
- abi,
1467
- args,
1468
- contractAddress: address,
1469
- docsPath: docsPath5,
1470
- functionName,
1471
- sender
1472
- });
1473
- }
1474
-
1475
- // src/utils/hash/keccak256.ts
1476
- var _sha3 = require('@noble/hashes/sha3');
1477
- function keccak256(value, to_) {
1478
- const to = to_ || "hex";
1479
- const bytes = _sha3.keccak_256.call(void 0, value);
1480
- if (to === "bytes")
1481
- return bytes;
1482
- return encodeHex(bytes);
1483
- }
1484
-
1485
- // src/utils/hash/hashFunction.ts
1486
- var hash = (value) => keccak256(encodeBytes(value));
1487
- function hashFunction(def) {
1488
- const name = extractFunctionName(def);
1489
- const params = extractFunctionParams(def);
1490
- if (!params || params.length === 0)
1491
- return hash(def.replace(/ /g, ""));
1492
- return hash(`${name}(${params.map(({ type }) => type).join(",")})`);
1493
- }
1494
-
1495
- // src/utils/hash/getEventSignature.ts
1496
- var getEventSignature = (event) => hashFunction(event);
1497
-
1498
- // src/utils/hash/getFunctionSignature.ts
1499
- var getFunctionSignature = (fn) => slice(hashFunction(fn), 0, 4);
1500
-
1501
- // src/utils/address/getAddress.ts
1502
- var addressRegex = /^(0x)?[a-fA-F0-9]{40}$/;
1503
- function checksumAddress(address_) {
1504
- const hexAddress = address_.substring(2).toLowerCase();
1505
- const hash2 = keccak256(stringToBytes(hexAddress), "bytes");
1506
- let address = hexAddress.split("");
1507
- for (let i = 0; i < 40; i += 2) {
1508
- if (_optionalChain([hash2, 'optionalAccess', _15 => _15[i >> 1]]) >> 4 >= 8 && address[i]) {
1509
- address[i] = address[i].toUpperCase();
1510
- }
1511
- if ((hash2[i >> 1] & 15) >= 8 && address[i + 1]) {
1512
- address[i + 1] = address[i + 1].toUpperCase();
1513
- }
1514
- }
1515
- return `0x${address.join("")}`;
1516
- }
1517
- function getAddress(address) {
1518
- if (!addressRegex.test(address))
1519
- throw new InvalidAddressError({ address });
1520
- return checksumAddress(address);
1521
- }
1522
-
1523
- // src/utils/address/getContractAddress.ts
1524
- function getContractAddress(opts) {
1525
- if (opts.opcode === "CREATE2")
1526
- return getCreate2Address(opts);
1527
- return getCreateAddress(opts);
1528
- }
1529
- function getCreateAddress(opts) {
1530
- const from = encodeBytes(getAddress(opts.from));
1531
- let nonce = encodeBytes(opts.nonce);
1532
- if (nonce[0] === 0)
1533
- nonce = new Uint8Array([]);
1534
- return getAddress(
1535
- `0x${keccak256(encodeRlp([from, nonce], "bytes")).slice(26)}`
1536
- );
1537
- }
1538
- 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(
1545
- keccak256(
1546
- isBytes(opts.bytecode) ? opts.bytecode : encodeBytes(opts.bytecode)
1547
- )
1548
- );
1549
- return getAddress(
1550
- slice(
1551
- keccak256(concat([encodeBytes("0xff"), from, salt, bytecodeHash])),
1552
- 12
1553
- )
1554
- );
1555
- }
1556
-
1557
- // src/utils/address/isAddress.ts
1558
- function isAddress(address) {
1559
- try {
1560
- return Boolean(getAddress(address));
1561
- } catch (e) {
1562
- return false;
1563
- }
1564
- }
1565
-
1566
- // src/utils/address/isAddressEqual.ts
1567
- function isAddressEqual(a, b) {
1568
- return getAddress(a) === getAddress(b);
1569
- }
1570
-
1571
- // src/utils/abi/encodeAbi.ts
1572
- function encodeAbi({ params, values }) {
1573
- if (params.length !== values.length)
1574
- throw new AbiEncodingLengthMismatchError({
1575
- expectedLength: params.length,
1576
- givenLength: values.length
1577
- });
1578
- const preparedParams = prepareParams({
1579
- params,
1580
- values
1581
- });
1582
- const data = encodeParams(preparedParams);
1583
- if (data.length === 0)
1584
- return "0x";
1585
- return data;
1586
- }
1587
- function prepareParams({
1588
- params,
1589
- values
1590
- }) {
1591
- let preparedParams = [];
1592
- for (let i = 0; i < params.length; i++) {
1593
- preparedParams.push(prepareParam({ param: params[i], value: values[i] }));
1594
- }
1595
- return preparedParams;
1596
- }
1597
- function prepareParam({
1598
- param,
1599
- value
1600
- }) {
1601
- const arrayComponents = getArrayComponents(param.type);
1602
- if (arrayComponents) {
1603
- const [length, type] = arrayComponents;
1604
- return encodeArray(value, { length, param: { ...param, type } });
1605
- }
1606
- if (param.type === "tuple") {
1607
- return encodeTuple(value, {
1608
- param
1609
- });
1610
- }
1611
- if (param.type === "address") {
1612
- return encodeAddress(value);
1613
- }
1614
- if (param.type === "bool") {
1615
- return encodeBool(value);
1616
- }
1617
- if (param.type.startsWith("uint") || param.type.startsWith("int")) {
1618
- const signed = param.type.startsWith("int");
1619
- return encodeNumber(value, { signed });
1620
- }
1621
- if (param.type.startsWith("bytes")) {
1622
- return encodeBytes2(value, { param });
1623
- }
1624
- if (param.type === "string") {
1625
- return encodeString(value);
1626
- }
1627
- throw new InvalidAbiEncodingTypeError(param.type, {
1628
- docsPath: "/docs/contract/encodeAbi"
1629
- });
1630
- }
1631
- function encodeParams(preparedParams) {
1632
- let staticSize = 0;
1633
- for (let i = 0; i < preparedParams.length; i++) {
1634
- const { dynamic, encoded } = preparedParams[i];
1635
- if (dynamic)
1636
- staticSize += 32;
1637
- else
1638
- staticSize += size(encoded);
1639
- }
1640
- let staticParams = [];
1641
- let dynamicParams = [];
1642
- let dynamicSize = 0;
1643
- for (let i = 0; i < preparedParams.length; i++) {
1644
- const { dynamic, encoded } = preparedParams[i];
1645
- if (dynamic) {
1646
- staticParams.push(numberToHex(staticSize + dynamicSize, { size: 32 }));
1647
- dynamicParams.push(encoded);
1648
- dynamicSize += size(encoded);
1649
- } else {
1650
- staticParams.push(encoded);
1651
- }
1652
- }
1653
- return concat([...staticParams, ...dynamicParams]);
1654
- }
1655
- function encodeAddress(value) {
1656
- return { dynamic: false, encoded: padHex(value.toLowerCase()) };
1657
- }
1658
- function encodeArray(value, {
1659
- length,
1660
- param
1661
- }) {
1662
- let dynamic = length === null;
1663
- if (!Array.isArray(value))
1664
- throw new InvalidArrayError(value);
1665
- if (!dynamic && value.length !== length)
1666
- throw new AbiEncodingArrayLengthMismatchError({
1667
- expectedLength: length,
1668
- givenLength: value.length,
1669
- type: `${param.type}[${length}]`
1670
- });
1671
- let dynamicChild = false;
1672
- let preparedParams = [];
1673
- for (let i = 0; i < value.length; i++) {
1674
- const preparedParam = prepareParam({ param, value: value[i] });
1675
- if (preparedParam.dynamic)
1676
- dynamicChild = true;
1677
- preparedParams.push(preparedParam);
1678
- }
1679
- if (dynamic || dynamicChild) {
1680
- const data = encodeParams(preparedParams);
1681
- if (dynamic) {
1682
- const length2 = numberToHex(preparedParams.length, { size: 32 });
1683
- return {
1684
- dynamic: true,
1685
- encoded: preparedParams.length > 0 ? concat([length2, data]) : length2
1686
- };
1687
- }
1688
- if (dynamicChild)
1689
- return { dynamic: true, encoded: data };
1690
- }
1691
- return {
1692
- dynamic: false,
1693
- encoded: concat(preparedParams.map(({ encoded }) => encoded))
1694
- };
1695
- }
1696
- function encodeBytes2(value, { param }) {
1697
- const [_, size_] = param.type.split("bytes");
1698
- if (!size_) {
1699
- const partsLength = Math.floor(size(value) / 32);
1700
- const parts = [];
1701
- for (let i = 0; i < partsLength + 1; i++) {
1702
- parts.push(padHex(slice(value, i * 32, (i + 1) * 32), { dir: "right" }));
1703
- }
1704
- return {
1705
- dynamic: true,
1706
- encoded: concat([
1707
- padHex(numberToHex(size(value), { size: 32 })),
1708
- ...parts
1709
- ])
1710
- };
1711
- }
1712
- return { dynamic: false, encoded: padHex(value, { dir: "right" }) };
1713
- }
1714
- function encodeBool(value) {
1715
- return { dynamic: false, encoded: padHex(boolToHex(value)) };
1716
- }
1717
- function encodeNumber(value, { signed }) {
1718
- return {
1719
- dynamic: false,
1720
- encoded: numberToHex(value, {
1721
- size: 32,
1722
- signed
1723
- })
1724
- };
1725
- }
1726
- function encodeString(value) {
1727
- return {
1728
- dynamic: true,
1729
- encoded: concat([
1730
- padHex(numberToHex(value.length, { size: 32 })),
1731
- padHex(stringToHex(value), { dir: "right" })
1732
- ])
1733
- };
1734
- }
1735
- function encodeTuple(value, { param }) {
1736
- let dynamic = false;
1737
- let preparedParams = [];
1738
- for (let i = 0; i < param.components.length; i++) {
1739
- const param_ = param.components[i];
1740
- const index = Array.isArray(value) ? i : param_.name;
1741
- const preparedParam = prepareParam({
1742
- param: param_,
1743
- value: value[index]
1744
- });
1745
- preparedParams.push(preparedParam);
1746
- dynamic = preparedParam.dynamic;
1747
- }
1748
- return {
1749
- dynamic,
1750
- encoded: dynamic ? encodeParams(preparedParams) : concat(preparedParams.map(({ encoded }) => encoded))
1751
- };
1752
- }
1753
- function getArrayComponents(type) {
1754
- const matches = type.match(/^(.*)\[(\d+)?\]$/);
1755
- return matches ? (
1756
- // Return `null` if the array is dynamic.
1757
- [matches[2] ? Number(matches[2]) : null, matches[1]]
1758
- ) : void 0;
1759
- }
1760
-
1761
- // src/utils/abi/decodeAbi.ts
1762
- function decodeAbi({ data, params }) {
1763
- if (data === "0x" && params.length > 0)
1764
- throw new AbiDecodingZeroDataError();
1765
- if (size(data) % 32 !== 0)
1766
- throw new AbiDecodingDataSizeInvalidError(size(data));
1767
- const values = decodeParams({
1768
- data,
1769
- params
1770
- });
1771
- if (values.length === 0)
1772
- return void 0;
1773
- return values;
1774
- }
1775
- function decodeParams({
1776
- data,
1777
- params
1778
- }) {
1779
- let decodedValues = [];
1780
- let position = 0;
1781
- for (let i = 0; i < params.length; i++) {
1782
- const param = params[i];
1783
- const { consumed, value } = decodeParam({ data, param, position });
1784
- decodedValues.push(value);
1785
- position += consumed;
1786
- }
1787
- return decodedValues;
1788
- }
1789
- function decodeParam({
1790
- data,
1791
- param,
1792
- position
1793
- }) {
1794
- const arrayComponents = getArrayComponents(param.type);
1795
- if (arrayComponents) {
1796
- const [length, type] = arrayComponents;
1797
- return decodeArray(data, {
1798
- length,
1799
- param: { ...param, type },
1800
- position
1801
- });
1802
- }
1803
- if (param.type === "tuple") {
1804
- return decodeTuple(data, { param, position });
1805
- }
1806
- if (param.type === "string") {
1807
- return decodeString(data, { position });
1808
- }
1809
- if (param.type.startsWith("bytes")) {
1810
- return decodeBytes2(data, { param, position });
1811
- }
1812
- let value = slice(data, position, position + 32);
1813
- if (param.type.startsWith("uint") || param.type.startsWith("int")) {
1814
- return decodeNumber(value, { param });
1815
- }
1816
- if (param.type === "address") {
1817
- return decodeAddress(value);
1818
- }
1819
- if (param.type === "bool") {
1820
- return decodeBool(value);
1821
- }
1822
- throw new InvalidAbiDecodingTypeError(param.type, {
1823
- docsPath: "/docs/contract/decodeAbi"
1824
- });
1825
- }
1826
- function decodeAddress(value) {
1827
- return { consumed: 32, value: checksumAddress(slice(value, -20)) };
1828
- }
1829
- function decodeArray(data, {
1830
- param,
1831
- length,
1832
- position
1833
- }) {
1834
- if (!length) {
1835
- const offset = hexToNumber(slice(data, position, position + 32));
1836
- const length2 = hexToNumber(slice(data, offset, offset + 32));
1837
- let consumed2 = 0;
1838
- let value2 = [];
1839
- for (let i = 0; i < length2; ++i) {
1840
- const decodedChild = decodeParam({
1841
- data: slice(data, offset + 32),
1842
- param,
1843
- position: consumed2
1844
- });
1845
- consumed2 += decodedChild.consumed;
1846
- value2.push(decodedChild.value);
1847
- }
1848
- return { value: value2, consumed: 32 };
1849
- }
1850
- if (hasDynamicChild(param)) {
1851
- const arrayComponents = getArrayComponents(param.type);
1852
- const dynamicChild = !_optionalChain([arrayComponents, 'optionalAccess', _16 => _16[0]]);
1853
- let consumed2 = 0;
1854
- let value2 = [];
1855
- for (let i = 0; i < length; ++i) {
1856
- const offset = hexToNumber(slice(data, position, position + 32));
1857
- const decodedChild = decodeParam({
1858
- data: slice(data, offset),
1859
- param,
1860
- position: dynamicChild ? consumed2 : i * 32
1861
- });
1862
- consumed2 += decodedChild.consumed;
1863
- value2.push(decodedChild.value);
1864
- }
1865
- return { value: value2, consumed: consumed2 };
1866
- }
1867
- let consumed = 0;
1868
- let value = [];
1869
- for (let i = 0; i < length; ++i) {
1870
- const decodedChild = decodeParam({
1871
- data,
1872
- param,
1873
- position: position + consumed
1874
- });
1875
- consumed += decodedChild.consumed;
1876
- value.push(decodedChild.value);
1877
- }
1878
- return { value, consumed };
1879
- }
1880
- function decodeBool(value) {
1881
- return { consumed: 32, value: hexToBool(value) };
1882
- }
1883
- function decodeBytes2(data, { param, position }) {
1884
- const [_, size2] = param.type.split("bytes");
1885
- if (!size2) {
1886
- const offset = hexToNumber(slice(data, position, position + 32));
1887
- const length = hexToNumber(slice(data, offset, offset + 32));
1888
- const value2 = slice(data, offset + 32, offset + 32 + length);
1889
- return { consumed: 32, value: value2 };
1890
- }
1891
- const value = slice(data, position, position + parseInt(size2));
1892
- return { consumed: 32, value };
1893
- }
1894
- function decodeNumber(value, { param }) {
1895
- const signed = param.type.startsWith("int");
1896
- const size2 = parseInt(param.type.split("int")[1] || "256");
1897
- return {
1898
- consumed: 32,
1899
- value: size2 > 48 ? hexToBigInt(value, { signed }) : hexToNumber(value, { signed })
1900
- };
1901
- }
1902
- function decodeString(data, { position }) {
1903
- const offset = hexToNumber(slice(data, position, position + 32));
1904
- const length = hexToNumber(slice(data, offset, offset + 32));
1905
- const value = hexToString(
1906
- trim(slice(data, offset + 32, offset + 32 + length))
1907
- );
1908
- return { consumed: 32, value };
1909
- }
1910
- function decodeTuple(data, { param, position }) {
1911
- const hasUnnamedChild = param.components.length === 0 || param.components.some(({ name }) => !name);
1912
- let value = hasUnnamedChild ? [] : {};
1913
- let consumed = 0;
1914
- if (hasDynamicChild(param)) {
1915
- const offset = hexToNumber(slice(data, position, position + 32));
1916
- for (let i = 0; i < param.components.length; ++i) {
1917
- const component = param.components[i];
1918
- const decodedChild = decodeParam({
1919
- data: slice(data, offset),
1920
- param: component,
1921
- position: consumed
1922
- });
1923
- consumed += decodedChild.consumed;
1924
- value[hasUnnamedChild ? i : _optionalChain([component, 'optionalAccess', _17 => _17.name])] = decodedChild.value;
1925
- }
1926
- return { consumed: 32, value };
1927
- }
1928
- for (let i = 0; i < param.components.length; ++i) {
1929
- const component = param.components[i];
1930
- const decodedChild = decodeParam({
1931
- data,
1932
- param: component,
1933
- position: position + consumed
1934
- });
1935
- consumed += decodedChild.consumed;
1936
- value[hasUnnamedChild ? i : _optionalChain([component, 'optionalAccess', _18 => _18.name])] = decodedChild.value;
1937
- }
1938
- return { consumed, value };
1939
- }
1940
- function hasDynamicChild(param) {
1941
- const { type } = param;
1942
- if (type === "string")
1943
- return true;
1944
- if (type === "bytes")
1945
- return true;
1946
- if (type.endsWith("[]"))
1947
- return true;
1948
- if (type === "tuple")
1949
- return _optionalChain([param, 'access', _19 => _19.components, 'optionalAccess', _20 => _20.some, 'call', _21 => _21(hasDynamicChild)]);
1950
- const arrayComponents = getArrayComponents(param.type);
1951
- if (arrayComponents && hasDynamicChild({ ...param, type: arrayComponents[1] }))
1952
- return true;
1953
- return false;
1954
- }
1955
-
1956
- // src/utils/abi/formatAbiItem.ts
1957
- function formatAbiItem(abiItem, { includeName = false } = {}) {
1958
- if (abiItem.type !== "function" && abiItem.type !== "event" && abiItem.type !== "error")
1959
- throw new InvalidDefinitionTypeError(abiItem.type);
1960
- return `${abiItem.name}(${getParams(abiItem.inputs, { includeName })})`;
1961
- }
1962
- function getParams(params, { includeName }) {
1963
- if (!params)
1964
- return "";
1965
- return params.map((param) => getParam(param, { includeName })).join(includeName ? ", " : ",");
1966
- }
1967
- function getParam(param, { includeName }) {
1968
- if (param.type.startsWith("tuple")) {
1969
- return `(${getParams(
1970
- param.components,
1971
- { includeName }
1972
- )})${param.type.slice("tuple".length)}`;
1973
- }
1974
- return param.type + (includeName && param.name ? ` ${param.name}` : "");
1975
- }
1976
-
1977
- // src/utils/abi/decodeErrorResult.ts
1978
- function decodeErrorResult({
1979
- abi,
1980
- data
1981
- }) {
1982
- const signature = slice(data, 0, 4);
1983
- if (signature === "0x")
1984
- throw new AbiDecodingZeroDataError();
1985
- const abi_ = [...abi || [], solidityError, solidityPanic];
1986
- const abiItem = abi_.find(
1987
- (x) => x.type === "error" && signature === getFunctionSignature(formatAbiItem(x))
1988
- );
1989
- if (!abiItem)
1990
- throw new AbiErrorSignatureNotFoundError(signature, {
1991
- docsPath: "/docs/contract/decodeErrorResult"
1992
- });
1993
- return {
1994
- abiItem,
1995
- args: "inputs" in abiItem && abiItem.inputs && abiItem.inputs.length > 0 ? decodeAbi({ data: slice(data, 4), params: abiItem.inputs }) : void 0,
1996
- errorName: abiItem.name
1997
- };
1998
- }
1999
-
2000
- // src/utils/abi/decodeEventLog.ts
2001
- function decodeEventLog({
2002
- abi,
2003
- data,
2004
- topics
2005
- }) {
2006
- const [signature, ...argTopics] = topics;
2007
- const abiItem = abi.find(
2008
- (x) => signature === getEventSignature(formatAbiItem(x))
2009
- );
2010
- if (!(abiItem && "name" in abiItem))
2011
- throw new AbiEventSignatureNotFoundError(signature, {
2012
- docsPath: "/docs/contract/decodeEventLog"
2013
- });
2014
- const { name, inputs } = abiItem;
2015
- const isUnnamed = _optionalChain([inputs, 'optionalAccess', _22 => _22.some, 'call', _23 => _23((x) => !("name" in x && x.name))]);
2016
- let args = isUnnamed ? [] : {};
2017
- for (let i = 0; i < inputs.length; i++) {
2018
- const param = inputs[i];
2019
- const topic = argTopics[i];
2020
- if (topic === null)
2021
- args[param.name || i] = null;
2022
- if (!topic)
2023
- continue;
2024
- if (Array.isArray(topic)) {
2025
- args[param.name || i] = topic.map((t) => decodeTopic({ param, value: t }));
2026
- } else {
2027
- args[param.name || i] = decodeTopic({ param, value: topic });
2028
- }
2029
- }
2030
- if (data) {
2031
- const params = inputs.filter((x) => !("indexed" in x && x.indexed));
2032
- const decodedData = decodeAbi({ params, data });
2033
- if (decodedData) {
2034
- if (isUnnamed)
2035
- args = [...args, ...decodedData];
2036
- else {
2037
- for (let i = 0; i < params.length; i++) {
2038
- args[params[i].name] = decodedData[i];
2039
- }
2040
- }
2041
- }
2042
- }
2043
- return {
2044
- eventName: name,
2045
- args: Object.values(args).length > 0 ? args : void 0
2046
- };
2047
- }
2048
- function decodeTopic({ param, value }) {
2049
- if (param.type === "string" || param.type === "bytes" || param.type === "tuple" || param.type.match(/^(.*)\[(\d+)?\]$/))
2050
- return value;
2051
- const decodedArg = decodeAbi({ params: [param], data: value }) || [];
2052
- return decodedArg[0];
2053
- }
2054
-
2055
- // src/utils/abi/decodeFunctionData.ts
2056
- function decodeFunctionData({ abi, data }) {
2057
- const signature = slice(data, 0, 4);
2058
- const description = abi.find(
2059
- (x) => signature === getFunctionSignature(formatAbiItem(x))
2060
- );
2061
- if (!description)
2062
- throw new AbiFunctionSignatureNotFoundError(signature, {
2063
- docsPath: "/docs/contract/decodeFunctionData"
2064
- });
2065
- return {
2066
- functionName: description.name,
2067
- args: "inputs" in description && description.inputs && description.inputs.length > 0 ? decodeAbi({ data: slice(data, 4), params: description.inputs }) : void 0
2068
- };
2069
- }
2070
-
2071
- // src/utils/abi/getAbiItem.ts
2072
- function getAbiItem({ abi, args = [], name }) {
2073
- const abiItems = abi.filter((x) => "name" in x && x.name === name);
2074
- if (abiItems.length === 0)
2075
- return void 0;
2076
- if (abiItems.length === 1)
2077
- return abiItems[0];
2078
- for (const abiItem of abiItems) {
2079
- if (!("inputs" in abiItem))
2080
- continue;
2081
- if (!args || args.length === 0) {
2082
- if (!abiItem.inputs || abiItem.inputs.length === 0)
2083
- return abiItem;
2084
- continue;
2085
- }
2086
- if (!abiItem.inputs)
2087
- continue;
2088
- if (abiItem.inputs.length === 0)
2089
- continue;
2090
- const matched = args.every((arg, index) => {
2091
- const abiParameter = "inputs" in abiItem && abiItem.inputs[index];
2092
- if (!abiParameter)
2093
- return false;
2094
- return isArgOfType(arg, abiParameter);
2095
- });
2096
- if (matched)
2097
- return abiItem;
2098
- }
2099
- return abiItems[0];
2100
- }
2101
- function isArgOfType(arg, abiParameter) {
2102
- const argType = typeof arg;
2103
- const abiParameterType = abiParameter.type;
2104
- switch (abiParameterType) {
2105
- case "address":
2106
- return isAddress(arg);
2107
- case "bool":
2108
- return argType === "boolean";
2109
- case "function":
2110
- return argType === "string";
2111
- case "string":
2112
- return argType === "string";
2113
- default: {
2114
- if (abiParameterType === "tuple" && "components" in abiParameter)
2115
- return Object.values(abiParameter.components).every(
2116
- (component, index) => {
2117
- return isArgOfType(
2118
- Object.values(arg)[index],
2119
- component
2120
- );
2121
- }
2122
- );
2123
- if (/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(
2124
- abiParameterType
2125
- ))
2126
- return argType === "number" || argType === "bigint";
2127
- if (/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(abiParameterType))
2128
- return argType === "string" || arg instanceof Uint8Array;
2129
- if (/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(abiParameterType)) {
2130
- return Array.isArray(arg) && arg.every(
2131
- (x) => isArgOfType(x, {
2132
- ...abiParameter,
2133
- // Pop off `[]` or `[M]` from end of type
2134
- type: abiParameterType.replace(/(\[[0-9]{0,}\])$/, "")
2135
- })
2136
- );
2137
- }
2138
- return false;
2139
- }
2140
- }
2141
- }
2142
-
2143
- // src/utils/abi/decodeFunctionResult.ts
2144
- var docsPath = "/docs/contract/decodeFunctionResult";
2145
- function decodeFunctionResult({
2146
- abi,
2147
- args,
2148
- functionName,
2149
- data
2150
- }) {
2151
- const description = getAbiItem({
2152
- abi,
2153
- args,
2154
- name: functionName
2155
- });
2156
- if (!description)
2157
- throw new AbiFunctionNotFoundError(functionName, { docsPath });
2158
- if (!("outputs" in description))
2159
- throw new AbiFunctionOutputsNotFoundError(functionName, { docsPath });
2160
- const values = decodeAbi({ data, params: description.outputs });
2161
- if (values && values.length > 1)
2162
- return values;
2163
- if (values && values.length === 1)
2164
- return values[0];
2165
- return void 0;
2166
- }
2167
-
2168
- // src/utils/abi/encodeDeployData.ts
2169
- var docsPath2 = "/docs/contract/encodeDeployData";
2170
- function encodeDeployData({
2171
- abi,
2172
- args,
2173
- bytecode
2174
- }) {
2175
- if (!args || args.length === 0)
2176
- return bytecode;
2177
- const description = abi.find(
2178
- (x) => "type" in x && x.type === "constructor"
2179
- );
2180
- if (!description)
2181
- throw new AbiConstructorNotFoundError({ docsPath: docsPath2 });
2182
- if (!("inputs" in description))
2183
- throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath2 });
2184
- if (!description.inputs || description.inputs.length === 0)
2185
- throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath2 });
2186
- const data = encodeAbi({
2187
- params: description.inputs,
2188
- values: args
2189
- });
2190
- return concatHex([bytecode, data]);
2191
- }
2192
-
2193
- // src/utils/abi/encodeErrorResult.ts
2194
- var docsPath3 = "/docs/contract/encodeErrorResult";
2195
- function encodeErrorResult({ abi, errorName, args }) {
2196
- const description = getAbiItem({
2197
- abi,
2198
- args,
2199
- name: errorName
2200
- });
2201
- if (!description)
2202
- throw new AbiErrorNotFoundError(errorName, { docsPath: docsPath3 });
2203
- const definition = formatAbiItem(description);
2204
- const signature = getFunctionSignature(definition);
2205
- let data = "0x";
2206
- if (args && args.length > 0) {
2207
- if (!("inputs" in description && description.inputs))
2208
- throw new AbiErrorInputsNotFoundError(errorName, { docsPath: docsPath3 });
2209
- data = encodeAbi({ params: description.inputs, values: args });
2210
- }
2211
- return concatHex([signature, data]);
2212
- }
2213
-
2214
- // src/utils/abi/encodeEventTopics.ts
2215
- function encodeEventTopics({ abi, eventName, args }) {
2216
- const abiItem = getAbiItem({ abi, args, name: eventName });
2217
- if (!abiItem)
2218
- throw new AbiEventNotFoundError(eventName, {
2219
- docsPath: "/docs/contract/encodeEventTopics"
2220
- });
2221
- const definition = formatAbiItem(abiItem);
2222
- const signature = getEventSignature(definition);
2223
- let topics = [];
2224
- if (args && "inputs" in abiItem) {
2225
- const args_ = Array.isArray(args) ? args : _nullishCoalesce(_optionalChain([abiItem, 'access', _24 => _24.inputs, 'optionalAccess', _25 => _25.map, 'call', _26 => _26((x) => args[x.name])]), () => ( []));
2226
- topics = _nullishCoalesce(_optionalChain([abiItem, 'access', _27 => _27.inputs, 'optionalAccess', _28 => _28.filter, 'call', _29 => _29((param) => "indexed" in param && param.indexed), 'access', _30 => _30.map, 'call', _31 => _31(
2227
- (param, i) => Array.isArray(args_[i]) ? args_[i].map(
2228
- (_, j) => encodeArg({ param, value: args_[i][j] })
2229
- ) : args_[i] ? encodeArg({ param, value: args_[i] }) : null
2230
- )]), () => ( []));
2231
- }
2232
- return [signature, ...topics];
2233
- }
2234
- function encodeArg({
2235
- param,
2236
- value
2237
- }) {
2238
- if (param.type === "string" || param.type === "bytes")
2239
- return keccak256(encodeBytes(value));
2240
- if (param.type === "tuple" || param.type.match(/^(.*)\[(\d+)?\]$/))
2241
- throw new FilterTypeNotSupportedError(param.type);
2242
- return encodeAbi({ params: [param], values: [value] });
2243
- }
2244
-
2245
- // src/utils/abi/encodeFunctionData.ts
2246
- function encodeFunctionData({ abi, args, functionName }) {
2247
- const description = getAbiItem({
2248
- abi,
2249
- args,
2250
- name: functionName
2251
- });
2252
- if (!description)
2253
- throw new AbiFunctionNotFoundError(functionName, {
2254
- docsPath: "/docs/contract/encodeFunctionData"
2255
- });
2256
- const definition = formatAbiItem(description);
2257
- const signature = getFunctionSignature(definition);
2258
- const data = "inputs" in description && description.inputs ? encodeAbi({
2259
- params: description.inputs,
2260
- values: _nullishCoalesce(args, () => ( []))
2261
- }) : void 0;
2262
- return concatHex([signature, _nullishCoalesce(data, () => ( "0x"))]);
2263
- }
2264
-
2265
- // src/utils/abi/encodeFunctionResult.ts
2266
- var docsPath4 = "/docs/contract/encodeFunctionResult";
2267
- function encodeFunctionResult({
2268
- abi,
2269
- functionName,
2270
- result
2271
- }) {
2272
- const description = abi.find(
2273
- (x) => "name" in x && x.name === functionName
2274
- );
2275
- if (!description)
2276
- throw new AbiFunctionNotFoundError(functionName, { docsPath: docsPath4 });
2277
- if (!("outputs" in description))
2278
- throw new AbiFunctionOutputsNotFoundError(functionName, { docsPath: docsPath4 });
2279
- let values = Array.isArray(result) ? result : [result];
2280
- if (description.outputs.length === 0 && !values[0])
2281
- values = [];
2282
- return encodeAbi({ params: description.outputs, values });
2283
- }
2284
-
2285
- // src/utils/abi/formatAbiItemWithArgs.ts
2286
- function formatAbiItemWithArgs({
2287
- abiItem,
2288
- args,
2289
- includeFunctionName = true,
2290
- includeName = false
2291
- }) {
2292
- if (!("name" in abiItem))
2293
- return;
2294
- if (!("inputs" in abiItem))
2295
- return;
2296
- if (!abiItem.inputs)
2297
- return;
2298
- return `${includeFunctionName ? abiItem.name : ""}(${abiItem.inputs.map(
2299
- (input, i) => `${includeName && input.name ? `${input.name}: ` : ""}${typeof args[i] === "object" ? stringify(args[i]) : args[i]}`
2300
- ).join(", ")})`;
2301
- }
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
- shouldRetryOnResponse = () => false,
2355
- shouldRetryOnError = () => false
2356
- } = {}) {
2357
- return new Promise((resolve, reject) => {
2358
- const attemptRetry = async ({ count = 0 } = {}) => {
2359
- const retry = async ({ data } = {}) => {
2360
- const delay = typeof delay_ === "function" ? delay_({ count, data }) : delay_;
2361
- if (delay)
2362
- await wait(delay);
2363
- attemptRetry({ count: count + 1 });
2364
- };
2365
- try {
2366
- const data = await fn();
2367
- if (count < retryCount && await shouldRetryOnResponse({ count, data }))
2368
- return retry({ data });
2369
- resolve(data);
2370
- } catch (err) {
2371
- if (count < retryCount && await shouldRetryOnError({ count, error: err }))
2372
- return retry();
2373
- reject(err);
2374
- }
2375
- };
2376
- attemptRetry();
2377
- });
2378
- }
2379
-
2380
- // src/utils/promise/withTimeout.ts
2381
- function withTimeout(fn, {
2382
- errorInstance,
2383
- timeout,
2384
- signal
2385
- }) {
2386
- return new Promise((resolve, reject) => {
2387
- ;
2388
- (async () => {
2389
- let timeoutId;
2390
- try {
2391
- const controller = new AbortController();
2392
- if (timeout > 0) {
2393
- timeoutId = setTimeout(() => {
2394
- if (signal) {
2395
- controller.abort();
2396
- } else {
2397
- reject(errorInstance);
2398
- }
2399
- }, timeout);
2400
- }
2401
- resolve(await fn({ signal: _optionalChain([controller, 'optionalAccess', _32 => _32.signal]) }));
2402
- } catch (err) {
2403
- if (err.name === "AbortError")
2404
- reject(errorInstance);
2405
- reject(err);
2406
- } finally {
2407
- clearTimeout(timeoutId);
2408
- }
2409
- })();
2410
- });
2411
- }
2412
-
2413
- // src/utils/buildRequest.ts
2414
- var isNonDeterministicError = (error) => {
2415
- if (error instanceof UnknownRpcError)
2416
- return true;
2417
- if ("code" in error)
2418
- return error.code === -32603 || error.code === -32e3 || error.code === -32005;
2419
- return false;
2420
- };
2421
- function buildRequest(request, {
2422
- retryDelay = 150,
2423
- retryCount = 3
2424
- } = {}) {
2425
- return async (args) => withRetry(
2426
- async () => {
2427
- try {
2428
- return await request(args);
2429
- } catch (err_) {
2430
- let err = err_;
2431
- if (err.code === -32700)
2432
- throw new ParseRpcError(err);
2433
- if (err.code === -32600)
2434
- throw new InvalidRequestRpcError(err);
2435
- if (err.code === -32601)
2436
- throw new MethodNotFoundRpcError(err);
2437
- if (err.code === -32602)
2438
- throw new InvalidParamsRpcError(err);
2439
- if (err.code === -32603)
2440
- throw new InternalRpcError(err);
2441
- if (err.code === -32e3)
2442
- throw new InvalidInputRpcError(err);
2443
- if (err.code === -32001)
2444
- throw new ResourceNotFoundRpcError(err);
2445
- if (err.code === -32002)
2446
- throw new ResourceUnavailableRpcError(err);
2447
- if (err.code === -32003)
2448
- throw new TransactionRejectedRpcError(err);
2449
- if (err.code === -32004)
2450
- throw new MethodNotSupportedRpcError(err);
2451
- if (err.code === -32005)
2452
- throw new LimitExceededRpcError(err);
2453
- if (err.code === -32006)
2454
- throw new JsonRpcVersionUnsupportedError(err);
2455
- if (err_ instanceof BaseError)
2456
- throw err_;
2457
- throw new UnknownRpcError(err);
2458
- }
2459
- },
2460
- {
2461
- delay: ({ count }) => ~~(1 << count) * retryDelay,
2462
- retryCount,
2463
- shouldRetryOnError: ({ error }) => isNonDeterministicError(error)
2464
- }
2465
- );
2466
- }
2467
-
2468
- // src/utils/chain.ts
2469
- function defineChain(chain) {
2470
- return chain;
2471
- }
2472
-
2473
- // src/utils/formatters/format.ts
2474
- function format3(data, { formatter }) {
2475
- return formatter(data);
2476
- }
2477
- function defineFormatter({
2478
- format: format4
2479
- }) {
2480
- return ({
2481
- exclude,
2482
- format: formatOverride
2483
- }) => (data) => {
2484
- const formatted = format4(data);
2485
- if (exclude) {
2486
- for (const key of exclude) {
2487
- delete formatted[key];
2488
- }
2489
- }
2490
- return {
2491
- ...formatted,
2492
- ..._optionalChain([formatOverride, 'optionalCall', _33 => _33(data)])
2493
- };
2494
- };
2495
- }
2496
-
2497
- // src/utils/formatters/transaction.ts
2498
- var transactionType = {
2499
- "0x0": "legacy",
2500
- "0x1": "eip2930",
2501
- "0x2": "eip1559"
2502
- };
2503
- function formatTransaction(transaction) {
2504
- const transaction_ = {
2505
- ...transaction,
2506
- blockNumber: transaction.blockNumber ? BigInt(transaction.blockNumber) : null,
2507
- gas: transaction.gas ? BigInt(transaction.gas) : void 0,
2508
- gasPrice: transaction.gasPrice ? BigInt(transaction.gasPrice) : void 0,
2509
- maxFeePerGas: transaction.maxFeePerGas ? BigInt(transaction.maxFeePerGas) : void 0,
2510
- maxPriorityFeePerGas: transaction.maxPriorityFeePerGas ? BigInt(transaction.maxPriorityFeePerGas) : void 0,
2511
- nonce: transaction.nonce ? hexToNumber(transaction.nonce) : void 0,
2512
- transactionIndex: transaction.transactionIndex ? Number(transaction.transactionIndex) : null,
2513
- type: transaction.type ? transactionType[transaction.type] : void 0,
2514
- value: transaction.value ? BigInt(transaction.value) : void 0,
2515
- v: transaction.v ? BigInt(transaction.v) : void 0
2516
- };
2517
- if (transaction_.type === "legacy") {
2518
- delete transaction_["accessList"];
2519
- delete transaction_["maxFeePerGas"];
2520
- delete transaction_["maxPriorityFeePerGas"];
2521
- }
2522
- if (transaction_.type === "eip2930") {
2523
- delete transaction_["maxFeePerGas"];
2524
- delete transaction_["maxPriorityFeePerGas"];
2525
- }
2526
- return transaction_;
2527
- }
2528
- var defineTransaction = defineFormatter({ format: formatTransaction });
2529
-
2530
- // src/utils/formatters/block.ts
2531
- function formatBlock(block) {
2532
- const transactions = _optionalChain([block, 'access', _34 => _34.transactions, 'optionalAccess', _35 => _35.map, 'call', _36 => _36((transaction) => {
2533
- if (typeof transaction === "string")
2534
- return transaction;
2535
- return formatTransaction(transaction);
2536
- })]);
2537
- return {
2538
- ...block,
2539
- baseFeePerGas: block.baseFeePerGas ? BigInt(block.baseFeePerGas) : null,
2540
- difficulty: block.difficulty ? BigInt(block.difficulty) : void 0,
2541
- gasLimit: block.gasLimit ? BigInt(block.gasLimit) : void 0,
2542
- gasUsed: block.gasUsed ? BigInt(block.gasUsed) : void 0,
2543
- number: block.number ? BigInt(block.number) : null,
2544
- size: block.size ? BigInt(block.size) : void 0,
2545
- timestamp: block.timestamp ? BigInt(block.timestamp) : void 0,
2546
- transactions,
2547
- totalDifficulty: block.totalDifficulty ? BigInt(block.totalDifficulty) : null
2548
- };
2549
- }
2550
- var defineBlock = defineFormatter({ format: formatBlock });
2551
-
2552
- // src/utils/formatters/extract.ts
2553
- function extract(value, { formatter }) {
2554
- if (!formatter)
2555
- return {};
2556
- const keys = Object.keys(formatter({}));
2557
- return keys.reduce((data, key) => {
2558
- if (_optionalChain([value, 'optionalAccess', _37 => _37.hasOwnProperty, 'call', _38 => _38(key)])) {
2559
- ;
2560
- data[key] = value[key];
2561
- }
2562
- return data;
2563
- }, {});
2564
- }
2565
-
2566
- // src/utils/formatters/feeHistory.ts
2567
- function formatFeeHistory(feeHistory) {
2568
- return {
2569
- baseFeePerGas: feeHistory.baseFeePerGas.map((value) => BigInt(value)),
2570
- gasUsedRatio: feeHistory.gasUsedRatio,
2571
- oldestBlock: BigInt(feeHistory.oldestBlock),
2572
- reward: _optionalChain([feeHistory, 'access', _39 => _39.reward, 'optionalAccess', _40 => _40.map, 'call', _41 => _41(
2573
- (reward) => reward.map((value) => BigInt(value))
2574
- )])
2575
- };
2576
- }
2577
-
2578
- // src/utils/formatters/log.ts
2579
- function formatLog(log) {
2580
- return {
2581
- ...log,
2582
- blockNumber: log.blockNumber ? BigInt(log.blockNumber) : null,
2583
- logIndex: log.logIndex ? BigInt(log.logIndex) : null,
2584
- transactionIndex: log.transactionIndex ? BigInt(log.transactionIndex) : null
2585
- };
2586
- }
2587
-
2588
- // src/utils/formatters/transactionReceipt.ts
2589
- var statuses = {
2590
- "0x0": "reverted",
2591
- "0x1": "success"
2592
- };
2593
- function formatTransactionReceipt(transactionReceipt) {
2594
- return {
2595
- ...transactionReceipt,
2596
- blockNumber: transactionReceipt.blockNumber ? BigInt(transactionReceipt.blockNumber) : null,
2597
- cumulativeGasUsed: transactionReceipt.cumulativeGasUsed ? BigInt(transactionReceipt.cumulativeGasUsed) : null,
2598
- effectiveGasPrice: transactionReceipt.effectiveGasPrice ? BigInt(transactionReceipt.effectiveGasPrice) : null,
2599
- gasUsed: transactionReceipt.gasUsed ? BigInt(transactionReceipt.gasUsed) : null,
2600
- logs: transactionReceipt.logs ? transactionReceipt.logs.map(formatLog) : null,
2601
- transactionIndex: transactionReceipt.transactionIndex ? hexToNumber(transactionReceipt.transactionIndex) : null,
2602
- status: transactionReceipt.status ? statuses[transactionReceipt.status] : null,
2603
- type: transactionReceipt.type ? transactionType[transactionReceipt.type] : null
2604
- };
2605
- }
2606
- var defineTransactionReceipt = defineFormatter({
2607
- format: formatTransactionReceipt
2608
- });
2609
-
2610
- // src/utils/formatters/transactionRequest.ts
2611
- function formatTransactionRequest(transactionRequest) {
2612
- return {
2613
- ...transactionRequest,
2614
- gas: typeof transactionRequest.gas !== "undefined" ? numberToHex(transactionRequest.gas) : void 0,
2615
- gasPrice: typeof transactionRequest.gasPrice !== "undefined" ? numberToHex(transactionRequest.gasPrice) : void 0,
2616
- maxFeePerGas: typeof transactionRequest.maxFeePerGas !== "undefined" ? numberToHex(transactionRequest.maxFeePerGas) : void 0,
2617
- maxPriorityFeePerGas: typeof transactionRequest.maxPriorityFeePerGas !== "undefined" ? numberToHex(transactionRequest.maxPriorityFeePerGas) : void 0,
2618
- nonce: typeof transactionRequest.nonce !== "undefined" ? numberToHex(transactionRequest.nonce) : void 0,
2619
- value: typeof transactionRequest.value !== "undefined" ? numberToHex(transactionRequest.value) : void 0
2620
- };
2621
- }
2622
- var defineTransactionRequest = defineFormatter({
2623
- format: formatTransactionRequest
2624
- });
2625
-
2626
- // src/utils/rpc.ts
2627
- var _isomorphicunfetch = require('isomorphic-unfetch'); var _isomorphicunfetch2 = _interopRequireDefault(_isomorphicunfetch);
2628
- var _isomorphicws = require('isomorphic-ws'); var _isomorphicws2 = _interopRequireDefault(_isomorphicws);
2629
-
2630
- // src/utils/stringify.ts
2631
- function stringify(value) {
2632
- return JSON.stringify(
2633
- value,
2634
- (_, value2) => typeof value2 === "bigint" ? value2.toString() : value2
2635
- );
2636
- }
2637
-
2638
- // src/utils/rpc.ts
2639
- var id = 0;
2640
- async function http(url, {
2641
- body,
2642
- retryDelay = 150,
2643
- retryCount = 3,
2644
- timeout = 0
2645
- }) {
2646
- const response = await withRetry(
2647
- () => withTimeout(
2648
- async ({ signal }) => {
2649
- const response2 = await _isomorphicunfetch2.default.call(void 0, url, {
2650
- headers: {
2651
- "Content-Type": "application/json"
2652
- },
2653
- method: "POST",
2654
- body: stringify({ jsonrpc: "2.0", id: id++, ...body }),
2655
- signal: timeout > 0 ? signal : void 0
2656
- });
2657
- return response2;
2658
- },
2659
- {
2660
- errorInstance: new TimeoutError({ body, url }),
2661
- timeout,
2662
- signal: true
2663
- }
2664
- ),
2665
- {
2666
- delay: ({ count, data: data2 }) => {
2667
- const retryAfter = _optionalChain([data2, 'optionalAccess', _42 => _42.headers, 'access', _43 => _43.get, 'call', _44 => _44("Retry-After")]);
2668
- if (_optionalChain([retryAfter, 'optionalAccess', _45 => _45.match, 'call', _46 => _46(/\d/)]))
2669
- return parseInt(retryAfter) * 1e3;
2670
- return ~~(1 << count) * retryDelay;
2671
- },
2672
- retryCount,
2673
- shouldRetryOnResponse: async ({ data: data2 }) => {
2674
- if (data2.status >= 500)
2675
- return true;
2676
- if ([408, 413, 429].includes(data2.status))
2677
- return true;
2678
- return false;
2679
- }
2680
- }
2681
- );
2682
- let data;
2683
- 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")])) {
2684
- data = await response.json();
2685
- } else {
2686
- data = await response.text();
2687
- }
2688
- if (!response.ok) {
2689
- throw new HttpRequestError({
2690
- body,
2691
- details: stringify(data.error) || response.statusText,
2692
- status: response.status,
2693
- url
2694
- });
2695
- }
2696
- if (data.error) {
2697
- throw new RpcError({ body, error: data.error, url });
2698
- }
2699
- return data;
2700
- }
2701
- var sockets = /* @__PURE__ */ new Map();
2702
- async function getSocket(url_) {
2703
- const url = new URL(url_);
2704
- const urlKey = url.toString();
2705
- let socket = sockets.get(urlKey);
2706
- if (socket)
2707
- return socket;
2708
- const webSocket2 = new (0, _isomorphicws2.default)(url);
2709
- const requests = /* @__PURE__ */ new Map();
2710
- const subscriptions = /* @__PURE__ */ new Map();
2711
- const onMessage = ({ data }) => {
2712
- const message = JSON.parse(data);
2713
- const isSubscription = message.method === "eth_subscription";
2714
- const id2 = isSubscription ? message.params.subscription : message.id;
2715
- const cache = isSubscription ? subscriptions : requests;
2716
- const callback = cache.get(id2);
2717
- if (callback)
2718
- callback({ data });
2719
- if (!isSubscription)
2720
- cache.delete(id2);
2721
- };
2722
- const onClose = () => {
2723
- sockets.delete(urlKey);
2724
- webSocket2.removeEventListener("close", onClose);
2725
- webSocket2.removeEventListener("message", onMessage);
2726
- };
2727
- webSocket2.addEventListener("close", onClose);
2728
- webSocket2.addEventListener("message", onMessage);
2729
- if (webSocket2.readyState === _isomorphicws2.default.CONNECTING) {
2730
- await new Promise((resolve, reject) => {
2731
- if (!webSocket2)
2732
- return;
2733
- webSocket2.onopen = resolve;
2734
- webSocket2.onerror = reject;
2735
- });
2736
- }
2737
- socket = Object.assign(webSocket2, {
2738
- requests,
2739
- subscriptions
2740
- });
2741
- sockets.set(urlKey, socket);
2742
- return socket;
2743
- }
2744
- function webSocket(socket, {
2745
- body,
2746
- onData,
2747
- onError
2748
- }) {
2749
- if (socket.readyState === socket.CLOSED || socket.readyState === socket.CLOSING)
2750
- throw new WebSocketRequestError({
2751
- body,
2752
- url: socket.url,
2753
- details: "Socket is closed."
2754
- });
2755
- const id_ = id++;
2756
- const callback = ({ data }) => {
2757
- const message = JSON.parse(data);
2758
- if (typeof message.id === "number" && id_ !== message.id)
2759
- return;
2760
- if (message.error) {
2761
- _optionalChain([onError, 'optionalCall', _52 => _52(new RpcError({ body, error: message.error, url: socket.url }))]);
2762
- } else {
2763
- _optionalChain([onData, 'optionalCall', _53 => _53(message)]);
2764
- }
2765
- if (body.method === "eth_subscribe" && typeof message.result === "string") {
2766
- socket.subscriptions.set(message.result, callback);
2767
- }
2768
- if (body.method === "eth_unsubscribe") {
2769
- socket.subscriptions.delete(_optionalChain([body, 'access', _54 => _54.params, 'optionalAccess', _55 => _55[0]]));
2770
- }
2771
- };
2772
- socket.requests.set(id_, callback);
2773
- socket.send(JSON.stringify({ jsonrpc: "2.0", ...body, id: id_ }));
2774
- return socket;
2775
- }
2776
- async function webSocketAsync(socket, {
2777
- body,
2778
- timeout = 0
2779
- }) {
2780
- return withTimeout(
2781
- () => new Promise(
2782
- (onData, onError) => rpc.webSocket(socket, {
2783
- body,
2784
- onData,
2785
- onError
2786
- })
2787
- ),
2788
- {
2789
- errorInstance: new TimeoutError({ body, url: socket.url }),
2790
- timeout
2791
- }
2792
- );
2793
- }
2794
- var rpc = {
2795
- http,
2796
- webSocket,
2797
- webSocketAsync
2798
- };
2799
-
2800
- // src/utils/unit/constants.ts
2801
- var etherUnits = {
2802
- gwei: 9,
2803
- wei: 18
2804
- };
2805
- var gweiUnits = {
2806
- ether: -9,
2807
- wei: 9
2808
- };
2809
- var weiUnits = {
2810
- ether: -18,
2811
- gwei: -9
2812
- };
2813
-
2814
- // src/utils/unit/formatUnit.ts
2815
- function formatUnit(value, decimals) {
2816
- let display = value.toString();
2817
- const negative = display.startsWith("-");
2818
- if (negative)
2819
- display = display.slice(1);
2820
- let [integer, fraction] = [
2821
- display.slice(0, display.length - decimals),
2822
- display.slice(display.length - decimals)
2823
- ];
2824
- fraction = fraction.padStart(decimals, "0");
2825
- fraction = fraction.replace(/(0+)$/, "");
2826
- return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
2827
- }
2828
-
2829
- // src/utils/unit/formatEther.ts
2830
- function formatEther(wei, unit = "wei") {
2831
- return formatUnit(wei, etherUnits[unit]);
2832
- }
2833
-
2834
- // src/utils/unit/formatGwei.ts
2835
- function formatGwei(wei, unit = "wei") {
2836
- return formatUnit(wei, gweiUnits[unit]);
2837
- }
2838
-
2839
- // src/utils/unit/parseUnit.ts
2840
- function parseUnit(value, decimals) {
2841
- let [integer, fraction = "0"] = value.split(".");
2842
- const negative = integer.startsWith("-");
2843
- if (negative)
2844
- integer = integer.slice(1);
2845
- fraction = fraction.replace(/(0+)$/, "");
2846
- if (decimals === 0) {
2847
- integer = `${Math.round(Number(`${integer}.${fraction}`))}`;
2848
- fraction = "";
2849
- } else if (fraction.length > decimals) {
2850
- const [before, after] = [
2851
- fraction.slice(0, decimals),
2852
- fraction.slice(decimals)
2853
- ];
2854
- fraction = `${/^0+$/.test(before) ? before.slice(0, before.length - 1) : ""}${Math.round(Number(`${before}.${after}`))}`;
2855
- } else {
2856
- fraction = fraction.padEnd(decimals, "0");
2857
- }
2858
- return BigInt(`${negative ? "-" : ""}${integer}${fraction}`);
2859
- }
2860
-
2861
- // src/utils/unit/parseEther.ts
2862
- function parseEther(ether, unit = "wei") {
2863
- return parseUnit(ether, etherUnits[unit]);
2864
- }
2865
-
2866
- // src/utils/unit/parseGwei.ts
2867
- function parseGwei(ether, unit = "wei") {
2868
- return parseUnit(ether, gweiUnits[unit]);
2869
- }
2870
-
2871
-
2872
-
2873
-
2874
-
2875
-
2876
-
2877
-
2878
-
2879
-
2880
-
2881
-
2882
-
2883
-
2884
-
2885
-
2886
-
2887
-
2888
-
2889
-
2890
-
2891
-
2892
-
2893
-
2894
-
2895
-
2896
-
2897
-
2898
-
2899
-
2900
-
2901
-
2902
-
2903
-
2904
-
2905
-
2906
-
2907
-
2908
-
2909
-
2910
-
2911
-
2912
-
2913
-
2914
-
2915
-
2916
-
2917
-
2918
-
2919
-
2920
-
2921
-
2922
-
2923
-
2924
-
2925
-
2926
-
2927
-
2928
-
2929
-
2930
-
2931
-
2932
-
2933
-
2934
-
2935
-
2936
-
2937
-
2938
-
2939
-
2940
-
2941
-
2942
-
2943
-
2944
-
2945
-
2946
-
2947
-
2948
-
2949
-
2950
-
2951
-
2952
-
2953
-
2954
-
2955
-
2956
-
2957
-
2958
-
2959
-
2960
-
2961
-
2962
-
2963
-
2964
-
2965
-
2966
-
2967
-
2968
-
2969
-
2970
-
2971
-
2972
-
2973
-
2974
-
2975
-
2976
-
2977
-
2978
-
2979
-
2980
-
2981
-
2982
-
2983
-
2984
-
2985
-
2986
-
2987
-
2988
-
2989
-
2990
-
2991
-
2992
-
2993
-
2994
-
2995
-
2996
-
2997
-
2998
-
2999
-
3000
-
3001
-
3002
-
3003
-
3004
-
3005
-
3006
-
3007
-
3008
-
3009
-
3010
-
3011
-
3012
-
3013
-
3014
-
3015
-
3016
-
3017
-
3018
-
3019
-
3020
-
3021
-
3022
-
3023
-
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.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.getCache = getCache; exports.withCache = withCache; exports.wait = wait; exports.isNonDeterministicError = isNonDeterministicError; 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; 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;
3026
- //# sourceMappingURL=chunk-NXCI5KQC.js.map