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