viem 0.3.3 → 0.3.5

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 (672) hide show
  1. package/README.md +6 -0
  2. package/dist/cjs/actions/public/call.js +97 -10
  3. package/dist/cjs/actions/public/call.js.map +1 -1
  4. package/dist/cjs/actions/public/simulateContract.js +1 -0
  5. package/dist/cjs/actions/public/simulateContract.js.map +1 -1
  6. package/dist/cjs/chains.js +1 -24
  7. package/dist/cjs/chains.js.map +1 -1
  8. package/dist/cjs/clients/createPublicClient.js +12 -9
  9. package/dist/cjs/clients/createPublicClient.js.map +1 -1
  10. package/dist/cjs/clients/transports/fallback.js +1 -1
  11. package/dist/cjs/clients/transports/fallback.js.map +1 -1
  12. package/dist/cjs/constants/contract.js +5 -0
  13. package/dist/cjs/constants/contract.js.map +1 -0
  14. package/dist/cjs/constants/index.js +3 -1
  15. package/dist/cjs/constants/index.js.map +1 -1
  16. package/dist/cjs/errors/chain.js +13 -1
  17. package/dist/cjs/errors/chain.js.map +1 -1
  18. package/dist/cjs/errors/contract.js +1 -1
  19. package/dist/cjs/errors/contract.js.map +1 -1
  20. package/dist/cjs/errors/encoding.js +13 -1
  21. package/dist/cjs/errors/encoding.js.map +1 -1
  22. package/dist/cjs/errors/index.js +5 -2
  23. package/dist/cjs/errors/index.js.map +1 -1
  24. package/dist/cjs/errors/version.js +1 -1
  25. package/dist/cjs/index.js +5 -4
  26. package/dist/cjs/index.js.map +1 -1
  27. package/dist/cjs/utils/encoding/fromBytes.js +29 -12
  28. package/dist/cjs/utils/encoding/fromBytes.js.map +1 -1
  29. package/dist/cjs/utils/encoding/fromHex.js +32 -10
  30. package/dist/cjs/utils/encoding/fromHex.js.map +1 -1
  31. package/dist/cjs/utils/encoding/toBytes.js +31 -15
  32. package/dist/cjs/utils/encoding/toBytes.js.map +1 -1
  33. package/dist/cjs/utils/encoding/toHex.js +31 -20
  34. package/dist/cjs/utils/encoding/toHex.js.map +1 -1
  35. package/dist/cjs/utils/errors/getContractError.js +7 -5
  36. package/dist/cjs/utils/errors/getContractError.js.map +1 -1
  37. package/dist/cjs/utils/promise/createBatchScheduler.js +47 -0
  38. package/dist/cjs/utils/promise/createBatchScheduler.js.map +1 -0
  39. package/dist/cjs/utils/promise/index.js +3 -1
  40. package/dist/cjs/utils/promise/index.js.map +1 -1
  41. package/dist/esm/actions/public/call.js +91 -4
  42. package/dist/esm/actions/public/call.js.map +1 -1
  43. package/dist/esm/actions/public/simulateContract.js +1 -0
  44. package/dist/esm/actions/public/simulateContract.js.map +1 -1
  45. package/dist/esm/clients/createPublicClient.js +12 -9
  46. package/dist/esm/clients/createPublicClient.js.map +1 -1
  47. package/dist/esm/clients/transports/fallback.js +1 -1
  48. package/dist/esm/clients/transports/fallback.js.map +1 -1
  49. package/dist/esm/constants/contract.js +2 -0
  50. package/dist/esm/constants/contract.js.map +1 -0
  51. package/dist/esm/constants/index.js +1 -0
  52. package/dist/esm/constants/index.js.map +1 -1
  53. package/dist/esm/errors/chain.js +11 -0
  54. package/dist/esm/errors/chain.js.map +1 -1
  55. package/dist/esm/errors/contract.js +1 -1
  56. package/dist/esm/errors/contract.js.map +1 -1
  57. package/dist/esm/errors/encoding.js +11 -0
  58. package/dist/esm/errors/encoding.js.map +1 -1
  59. package/dist/esm/errors/index.js +2 -2
  60. package/dist/esm/errors/index.js.map +1 -1
  61. package/dist/esm/errors/version.js +1 -1
  62. package/dist/esm/index.js +1 -1
  63. package/dist/esm/index.js.map +1 -1
  64. package/dist/esm/utils/encoding/fromBytes.js +30 -13
  65. package/dist/esm/utils/encoding/fromBytes.js.map +1 -1
  66. package/dist/esm/utils/encoding/fromHex.js +31 -10
  67. package/dist/esm/utils/encoding/fromHex.js.map +1 -1
  68. package/dist/esm/utils/encoding/toBytes.js +31 -15
  69. package/dist/esm/utils/encoding/toBytes.js.map +1 -1
  70. package/dist/esm/utils/encoding/toHex.js +28 -17
  71. package/dist/esm/utils/encoding/toHex.js.map +1 -1
  72. package/dist/esm/utils/errors/getContractError.js +7 -5
  73. package/dist/esm/utils/errors/getContractError.js.map +1 -1
  74. package/dist/esm/utils/promise/createBatchScheduler.js +43 -0
  75. package/dist/esm/utils/promise/createBatchScheduler.js.map +1 -0
  76. package/dist/esm/utils/promise/index.js +1 -0
  77. package/dist/esm/utils/promise/index.js.map +1 -1
  78. package/package.json +1 -1
  79. package/src/actions/public/call.ts +141 -7
  80. package/src/actions/public/simulateContract.ts +2 -1
  81. package/src/clients/createPublicClient.ts +27 -9
  82. package/src/clients/transports/fallback.ts +1 -1
  83. package/src/constants/contract.ts +1 -0
  84. package/src/constants/index.ts +2 -0
  85. package/src/errors/chain.ts +8 -0
  86. package/src/errors/contract.ts +1 -1
  87. package/src/errors/encoding.ts +9 -0
  88. package/src/errors/index.ts +2 -0
  89. package/src/errors/version.ts +1 -1
  90. package/src/index.ts +1 -0
  91. package/src/types/eip1193.ts +1 -1
  92. package/src/utils/encoding/fromBytes.ts +147 -18
  93. package/src/utils/encoding/fromHex.ts +162 -19
  94. package/src/utils/encoding/toBytes.ts +148 -18
  95. package/src/utils/encoding/toHex.ts +151 -26
  96. package/src/utils/errors/getContractError.ts +9 -5
  97. package/src/utils/promise/createBatchScheduler.ts +82 -0
  98. package/src/utils/promise/index.ts +1 -0
  99. package/dist/types/abi.d.ts +0 -3
  100. package/dist/types/abi.d.ts.map +0 -1
  101. package/dist/types/accounts/generateMnemonic.d.ts +0 -9
  102. package/dist/types/accounts/generateMnemonic.d.ts.map +0 -1
  103. package/dist/types/accounts/generatePrivateKey.d.ts +0 -8
  104. package/dist/types/accounts/generatePrivateKey.d.ts.map +0 -1
  105. package/dist/types/accounts/hdKeyToAccount.d.ts +0 -9
  106. package/dist/types/accounts/hdKeyToAccount.d.ts.map +0 -1
  107. package/dist/types/accounts/index.d.ts +0 -21
  108. package/dist/types/accounts/index.d.ts.map +0 -1
  109. package/dist/types/accounts/mnemonicToAccount.d.ts +0 -8
  110. package/dist/types/accounts/mnemonicToAccount.d.ts.map +0 -1
  111. package/dist/types/accounts/privateKeyToAccount.d.ts +0 -9
  112. package/dist/types/accounts/privateKeyToAccount.d.ts.map +0 -1
  113. package/dist/types/accounts/toAccount.d.ts +0 -11
  114. package/dist/types/accounts/toAccount.d.ts.map +0 -1
  115. package/dist/types/accounts/types.d.ts +0 -45
  116. package/dist/types/accounts/types.d.ts.map +0 -1
  117. package/dist/types/accounts/utils/index.d.ts +0 -10
  118. package/dist/types/accounts/utils/index.d.ts.map +0 -1
  119. package/dist/types/accounts/utils/parseAccount.d.ts +0 -4
  120. package/dist/types/accounts/utils/parseAccount.d.ts.map +0 -1
  121. package/dist/types/accounts/utils/publicKeyToAddress.d.ts +0 -10
  122. package/dist/types/accounts/utils/publicKeyToAddress.d.ts.map +0 -1
  123. package/dist/types/accounts/utils/sign.d.ts +0 -16
  124. package/dist/types/accounts/utils/sign.d.ts.map +0 -1
  125. package/dist/types/accounts/utils/signMessage.d.ts +0 -16
  126. package/dist/types/accounts/utils/signMessage.d.ts.map +0 -1
  127. package/dist/types/accounts/utils/signTransaction.d.ts +0 -9
  128. package/dist/types/accounts/utils/signTransaction.d.ts.map +0 -1
  129. package/dist/types/accounts/utils/signTypedData.d.ts +0 -19
  130. package/dist/types/accounts/utils/signTypedData.d.ts.map +0 -1
  131. package/dist/types/accounts/utils/signatureToHex.d.ts +0 -3
  132. package/dist/types/accounts/utils/signatureToHex.d.ts.map +0 -1
  133. package/dist/types/accounts/wordlists/czech.d.ts +0 -2
  134. package/dist/types/accounts/wordlists/czech.d.ts.map +0 -1
  135. package/dist/types/accounts/wordlists/english.d.ts +0 -2
  136. package/dist/types/accounts/wordlists/english.d.ts.map +0 -1
  137. package/dist/types/accounts/wordlists/french.d.ts +0 -2
  138. package/dist/types/accounts/wordlists/french.d.ts.map +0 -1
  139. package/dist/types/accounts/wordlists/italian.d.ts +0 -2
  140. package/dist/types/accounts/wordlists/italian.d.ts.map +0 -1
  141. package/dist/types/accounts/wordlists/japanese.d.ts +0 -2
  142. package/dist/types/accounts/wordlists/japanese.d.ts.map +0 -1
  143. package/dist/types/accounts/wordlists/korean.d.ts +0 -2
  144. package/dist/types/accounts/wordlists/korean.d.ts.map +0 -1
  145. package/dist/types/accounts/wordlists/simplifiedChinese.d.ts +0 -2
  146. package/dist/types/accounts/wordlists/simplifiedChinese.d.ts.map +0 -1
  147. package/dist/types/accounts/wordlists/spanish.d.ts +0 -2
  148. package/dist/types/accounts/wordlists/spanish.d.ts.map +0 -1
  149. package/dist/types/accounts/wordlists/traditionalChinese.d.ts +0 -2
  150. package/dist/types/accounts/wordlists/traditionalChinese.d.ts.map +0 -1
  151. package/dist/types/actions/ens/getEnsAddress.d.ts +0 -40
  152. package/dist/types/actions/ens/getEnsAddress.d.ts.map +0 -1
  153. package/dist/types/actions/ens/getEnsAvatar.d.ts +0 -38
  154. package/dist/types/actions/ens/getEnsAvatar.d.ts.map +0 -1
  155. package/dist/types/actions/ens/getEnsName.d.ts +0 -38
  156. package/dist/types/actions/ens/getEnsName.d.ts.map +0 -1
  157. package/dist/types/actions/ens/getEnsResolver.d.ts +0 -40
  158. package/dist/types/actions/ens/getEnsResolver.d.ts.map +0 -1
  159. package/dist/types/actions/ens/getEnsText.d.ts +0 -43
  160. package/dist/types/actions/ens/getEnsText.d.ts.map +0 -1
  161. package/dist/types/actions/ens/index.d.ts +0 -6
  162. package/dist/types/actions/ens/index.d.ts.map +0 -1
  163. package/dist/types/actions/getContract.d.ts +0 -261
  164. package/dist/types/actions/getContract.d.ts.map +0 -1
  165. package/dist/types/actions/index.d.ts +0 -11
  166. package/dist/types/actions/index.d.ts.map +0 -1
  167. package/dist/types/actions/public/call.d.ts +0 -48
  168. package/dist/types/actions/public/call.d.ts.map +0 -1
  169. package/dist/types/actions/public/createBlockFilter.d.ts +0 -26
  170. package/dist/types/actions/public/createBlockFilter.d.ts.map +0 -1
  171. package/dist/types/actions/public/createContractEventFilter.d.ts +0 -41
  172. package/dist/types/actions/public/createContractEventFilter.d.ts.map +0 -1
  173. package/dist/types/actions/public/createEventFilter.d.ts +0 -46
  174. package/dist/types/actions/public/createEventFilter.d.ts.map +0 -1
  175. package/dist/types/actions/public/createPendingTransactionFilter.d.ts +0 -26
  176. package/dist/types/actions/public/createPendingTransactionFilter.d.ts.map +0 -1
  177. package/dist/types/actions/public/estimateContractGas.d.ts +0 -35
  178. package/dist/types/actions/public/estimateContractGas.d.ts.map +0 -1
  179. package/dist/types/actions/public/estimateGas.d.ts +0 -45
  180. package/dist/types/actions/public/estimateGas.d.ts.map +0 -1
  181. package/dist/types/actions/public/getBalance.d.ts +0 -52
  182. package/dist/types/actions/public/getBalance.d.ts.map +0 -1
  183. package/dist/types/actions/public/getBlock.d.ts +0 -52
  184. package/dist/types/actions/public/getBlock.d.ts.map +0 -1
  185. package/dist/types/actions/public/getBlockNumber.d.ts +0 -54
  186. package/dist/types/actions/public/getBlockNumber.d.ts.map +0 -1
  187. package/dist/types/actions/public/getBlockTransactionCount.d.ts +0 -44
  188. package/dist/types/actions/public/getBlockTransactionCount.d.ts.map +0 -1
  189. package/dist/types/actions/public/getBytecode.d.ts +0 -37
  190. package/dist/types/actions/public/getBytecode.d.ts.map +0 -1
  191. package/dist/types/actions/public/getChainId.d.ts +0 -26
  192. package/dist/types/actions/public/getChainId.d.ts.map +0 -1
  193. package/dist/types/actions/public/getFeeHistory.d.ts +0 -50
  194. package/dist/types/actions/public/getFeeHistory.d.ts.map +0 -1
  195. package/dist/types/actions/public/getFilterChanges.d.ts +0 -91
  196. package/dist/types/actions/public/getFilterChanges.d.ts.map +0 -1
  197. package/dist/types/actions/public/getFilterLogs.d.ts +0 -36
  198. package/dist/types/actions/public/getFilterLogs.d.ts.map +0 -1
  199. package/dist/types/actions/public/getGasPrice.d.ts +0 -25
  200. package/dist/types/actions/public/getGasPrice.d.ts.map +0 -1
  201. package/dist/types/actions/public/getLogs.d.ts +0 -49
  202. package/dist/types/actions/public/getLogs.d.ts.map +0 -1
  203. package/dist/types/actions/public/getStorageAt.d.ts +0 -39
  204. package/dist/types/actions/public/getStorageAt.d.ts.map +0 -1
  205. package/dist/types/actions/public/getTransaction.d.ts +0 -62
  206. package/dist/types/actions/public/getTransaction.d.ts.map +0 -1
  207. package/dist/types/actions/public/getTransactionConfirmations.d.ts +0 -39
  208. package/dist/types/actions/public/getTransactionConfirmations.d.ts.map +0 -1
  209. package/dist/types/actions/public/getTransactionCount.d.ts +0 -40
  210. package/dist/types/actions/public/getTransactionCount.d.ts.map +0 -1
  211. package/dist/types/actions/public/getTransactionReceipt.d.ts +0 -34
  212. package/dist/types/actions/public/getTransactionReceipt.d.ts.map +0 -1
  213. package/dist/types/actions/public/index.d.ts +0 -67
  214. package/dist/types/actions/public/index.d.ts.map +0 -1
  215. package/dist/types/actions/public/multicall.d.ts +0 -52
  216. package/dist/types/actions/public/multicall.d.ts.map +0 -1
  217. package/dist/types/actions/public/readContract.d.ts +0 -39
  218. package/dist/types/actions/public/readContract.d.ts.map +0 -1
  219. package/dist/types/actions/public/simulateContract.d.ts +0 -47
  220. package/dist/types/actions/public/simulateContract.d.ts.map +0 -1
  221. package/dist/types/actions/public/uninstallFilter.d.ts +0 -32
  222. package/dist/types/actions/public/uninstallFilter.d.ts.map +0 -1
  223. package/dist/types/actions/public/waitForTransactionReceipt.d.ts +0 -69
  224. package/dist/types/actions/public/waitForTransactionReceipt.d.ts.map +0 -1
  225. package/dist/types/actions/public/watchBlockNumber.d.ts +0 -57
  226. package/dist/types/actions/public/watchBlockNumber.d.ts.map +0 -1
  227. package/dist/types/actions/public/watchBlocks.d.ts +0 -64
  228. package/dist/types/actions/public/watchBlocks.d.ts.map +0 -1
  229. package/dist/types/actions/public/watchContractEvent.d.ts +0 -55
  230. package/dist/types/actions/public/watchContractEvent.d.ts.map +0 -1
  231. package/dist/types/actions/public/watchEvent.d.ts +0 -61
  232. package/dist/types/actions/public/watchEvent.d.ts.map +0 -1
  233. package/dist/types/actions/public/watchPendingTransactions.d.ts +0 -71
  234. package/dist/types/actions/public/watchPendingTransactions.d.ts.map +0 -1
  235. package/dist/types/actions/test/dropTransaction.d.ts +0 -30
  236. package/dist/types/actions/test/dropTransaction.d.ts.map +0 -1
  237. package/dist/types/actions/test/getAutomine.d.ts +0 -25
  238. package/dist/types/actions/test/getAutomine.d.ts.map +0 -1
  239. package/dist/types/actions/test/getTxpoolContent.d.ts +0 -31
  240. package/dist/types/actions/test/getTxpoolContent.d.ts.map +0 -1
  241. package/dist/types/actions/test/getTxpoolStatus.d.ts +0 -28
  242. package/dist/types/actions/test/getTxpoolStatus.d.ts.map +0 -1
  243. package/dist/types/actions/test/impersonateAccount.d.ts +0 -30
  244. package/dist/types/actions/test/impersonateAccount.d.ts.map +0 -1
  245. package/dist/types/actions/test/increaseTime.d.ts +0 -30
  246. package/dist/types/actions/test/increaseTime.d.ts.map +0 -1
  247. package/dist/types/actions/test/index.d.ts +0 -52
  248. package/dist/types/actions/test/index.d.ts.map +0 -1
  249. package/dist/types/actions/test/inspectTxpool.d.ts +0 -28
  250. package/dist/types/actions/test/inspectTxpool.d.ts.map +0 -1
  251. package/dist/types/actions/test/mine.d.ts +0 -30
  252. package/dist/types/actions/test/mine.d.ts.map +0 -1
  253. package/dist/types/actions/test/removeBlockTimestampInterval.d.ts +0 -23
  254. package/dist/types/actions/test/removeBlockTimestampInterval.d.ts.map +0 -1
  255. package/dist/types/actions/test/reset.d.ts +0 -30
  256. package/dist/types/actions/test/reset.d.ts.map +0 -1
  257. package/dist/types/actions/test/revert.d.ts +0 -28
  258. package/dist/types/actions/test/revert.d.ts.map +0 -1
  259. package/dist/types/actions/test/sendUnsignedTransaction.d.ts +0 -31
  260. package/dist/types/actions/test/sendUnsignedTransaction.d.ts.map +0 -1
  261. package/dist/types/actions/test/setAutomine.d.ts +0 -23
  262. package/dist/types/actions/test/setAutomine.d.ts.map +0 -1
  263. package/dist/types/actions/test/setBalance.d.ts +0 -33
  264. package/dist/types/actions/test/setBalance.d.ts.map +0 -1
  265. package/dist/types/actions/test/setBlockGasLimit.d.ts +0 -28
  266. package/dist/types/actions/test/setBlockGasLimit.d.ts.map +0 -1
  267. package/dist/types/actions/test/setBlockTimestampInterval.d.ts +0 -28
  268. package/dist/types/actions/test/setBlockTimestampInterval.d.ts.map +0 -1
  269. package/dist/types/actions/test/setCode.d.ts +0 -33
  270. package/dist/types/actions/test/setCode.d.ts.map +0 -1
  271. package/dist/types/actions/test/setCoinbase.d.ts +0 -30
  272. package/dist/types/actions/test/setCoinbase.d.ts.map +0 -1
  273. package/dist/types/actions/test/setIntervalMining.d.ts +0 -28
  274. package/dist/types/actions/test/setIntervalMining.d.ts.map +0 -1
  275. package/dist/types/actions/test/setLoggingEnabled.d.ts +0 -23
  276. package/dist/types/actions/test/setLoggingEnabled.d.ts.map +0 -1
  277. package/dist/types/actions/test/setMinGasPrice.d.ts +0 -32
  278. package/dist/types/actions/test/setMinGasPrice.d.ts.map +0 -1
  279. package/dist/types/actions/test/setNextBlockBaseFeePerGas.d.ts +0 -30
  280. package/dist/types/actions/test/setNextBlockBaseFeePerGas.d.ts.map +0 -1
  281. package/dist/types/actions/test/setNextBlockTimestamp.d.ts +0 -28
  282. package/dist/types/actions/test/setNextBlockTimestamp.d.ts.map +0 -1
  283. package/dist/types/actions/test/setNonce.d.ts +0 -33
  284. package/dist/types/actions/test/setNonce.d.ts.map +0 -1
  285. package/dist/types/actions/test/setRpcUrl.d.ts +0 -24
  286. package/dist/types/actions/test/setRpcUrl.d.ts.map +0 -1
  287. package/dist/types/actions/test/setStorageAt.d.ts +0 -36
  288. package/dist/types/actions/test/setStorageAt.d.ts.map +0 -1
  289. package/dist/types/actions/test/snapshot.d.ts +0 -23
  290. package/dist/types/actions/test/snapshot.d.ts.map +0 -1
  291. package/dist/types/actions/test/stopImpersonatingAccount.d.ts +0 -30
  292. package/dist/types/actions/test/stopImpersonatingAccount.d.ts.map +0 -1
  293. package/dist/types/actions/wallet/addChain.d.ts +0 -27
  294. package/dist/types/actions/wallet/addChain.d.ts.map +0 -1
  295. package/dist/types/actions/wallet/deployContract.d.ts +0 -38
  296. package/dist/types/actions/wallet/deployContract.d.ts.map +0 -1
  297. package/dist/types/actions/wallet/getAddresses.d.ts +0 -26
  298. package/dist/types/actions/wallet/getAddresses.d.ts.map +0 -1
  299. package/dist/types/actions/wallet/getPermissions.d.ts +0 -26
  300. package/dist/types/actions/wallet/getPermissions.d.ts.map +0 -1
  301. package/dist/types/actions/wallet/index.d.ts +0 -27
  302. package/dist/types/actions/wallet/index.d.ts.map +0 -1
  303. package/dist/types/actions/wallet/requestAddresses.d.ts +0 -30
  304. package/dist/types/actions/wallet/requestAddresses.d.ts.map +0 -1
  305. package/dist/types/actions/wallet/requestPermissions.d.ts +0 -34
  306. package/dist/types/actions/wallet/requestPermissions.d.ts.map +0 -1
  307. package/dist/types/actions/wallet/sendTransaction.d.ts +0 -53
  308. package/dist/types/actions/wallet/sendTransaction.d.ts.map +0 -1
  309. package/dist/types/actions/wallet/signMessage.d.ts +0 -54
  310. package/dist/types/actions/wallet/signMessage.d.ts.map +0 -1
  311. package/dist/types/actions/wallet/signTypedData.d.ts +0 -109
  312. package/dist/types/actions/wallet/signTypedData.d.ts.map +0 -1
  313. package/dist/types/actions/wallet/switchChain.d.ts +0 -28
  314. package/dist/types/actions/wallet/switchChain.d.ts.map +0 -1
  315. package/dist/types/actions/wallet/watchAsset.d.ts +0 -35
  316. package/dist/types/actions/wallet/watchAsset.d.ts.map +0 -1
  317. package/dist/types/actions/wallet/writeContract.d.ts +0 -58
  318. package/dist/types/actions/wallet/writeContract.d.ts.map +0 -1
  319. package/dist/types/adapters/ethers.d.ts +0 -27
  320. package/dist/types/adapters/ethers.d.ts.map +0 -1
  321. package/dist/types/chains.d.ts +0 -2487
  322. package/dist/types/chains.d.ts.map +0 -1
  323. package/dist/types/clients/createClient.d.ts +0 -43
  324. package/dist/types/clients/createClient.d.ts.map +0 -1
  325. package/dist/types/clients/createPublicClient.d.ts +0 -28
  326. package/dist/types/clients/createPublicClient.d.ts.map +0 -1
  327. package/dist/types/clients/createTestClient.d.ts +0 -38
  328. package/dist/types/clients/createTestClient.d.ts.map +0 -1
  329. package/dist/types/clients/createWalletClient.d.ts +0 -51
  330. package/dist/types/clients/createWalletClient.d.ts.map +0 -1
  331. package/dist/types/clients/decorators/index.d.ts +0 -7
  332. package/dist/types/clients/decorators/index.d.ts.map +0 -1
  333. package/dist/types/clients/decorators/public.d.ts +0 -1043
  334. package/dist/types/clients/decorators/public.d.ts.map +0 -1
  335. package/dist/types/clients/decorators/test.d.ts +0 -572
  336. package/dist/types/clients/decorators/test.d.ts.map +0 -1
  337. package/dist/types/clients/decorators/wallet.d.ts +0 -436
  338. package/dist/types/clients/decorators/wallet.d.ts.map +0 -1
  339. package/dist/types/clients/index.d.ts +0 -11
  340. package/dist/types/clients/index.d.ts.map +0 -1
  341. package/dist/types/clients/transports/createTransport.d.ts +0 -37
  342. package/dist/types/clients/transports/createTransport.d.ts.map +0 -1
  343. package/dist/types/clients/transports/custom.d.ts +0 -21
  344. package/dist/types/clients/transports/custom.d.ts.map +0 -1
  345. package/dist/types/clients/transports/fallback.d.ts +0 -75
  346. package/dist/types/clients/transports/fallback.d.ts.map +0 -1
  347. package/dist/types/clients/transports/http.d.ts +0 -29
  348. package/dist/types/clients/transports/http.d.ts.map +0 -1
  349. package/dist/types/clients/transports/index.d.ts +0 -11
  350. package/dist/types/clients/transports/index.d.ts.map +0 -1
  351. package/dist/types/clients/transports/webSocket.d.ts +0 -46
  352. package/dist/types/clients/transports/webSocket.d.ts.map +0 -1
  353. package/dist/types/constants/abis.d.ts +0 -79
  354. package/dist/types/constants/abis.d.ts.map +0 -1
  355. package/dist/types/constants/index.d.ts +0 -4
  356. package/dist/types/constants/index.d.ts.map +0 -1
  357. package/dist/types/constants/solidity.d.ts +0 -15
  358. package/dist/types/constants/solidity.d.ts.map +0 -1
  359. package/dist/types/constants/unit.d.ts +0 -13
  360. package/dist/types/constants/unit.d.ts.map +0 -1
  361. package/dist/types/contract.d.ts +0 -7
  362. package/dist/types/contract.d.ts.map +0 -1
  363. package/dist/types/ens.d.ts +0 -5
  364. package/dist/types/ens.d.ts.map +0 -1
  365. package/dist/types/errors/abi.d.ts +0 -165
  366. package/dist/types/errors/abi.d.ts.map +0 -1
  367. package/dist/types/errors/account.d.ts +0 -8
  368. package/dist/types/errors/account.d.ts.map +0 -1
  369. package/dist/types/errors/address.d.ts +0 -8
  370. package/dist/types/errors/address.d.ts.map +0 -1
  371. package/dist/types/errors/base.d.ts +0 -22
  372. package/dist/types/errors/base.d.ts.map +0 -1
  373. package/dist/types/errors/block.d.ts +0 -10
  374. package/dist/types/errors/block.d.ts.map +0 -1
  375. package/dist/types/errors/chain.d.ts +0 -31
  376. package/dist/types/errors/chain.d.ts.map +0 -1
  377. package/dist/types/errors/contract.d.ts +0 -58
  378. package/dist/types/errors/contract.d.ts.map +0 -1
  379. package/dist/types/errors/data.d.ts +0 -10
  380. package/dist/types/errors/data.d.ts.map +0 -1
  381. package/dist/types/errors/encoding.d.ts +0 -46
  382. package/dist/types/errors/encoding.d.ts.map +0 -1
  383. package/dist/types/errors/ens.d.ts +0 -26
  384. package/dist/types/errors/ens.d.ts.map +0 -1
  385. package/dist/types/errors/estimateGas.d.ts +0 -13
  386. package/dist/types/errors/estimateGas.d.ts.map +0 -1
  387. package/dist/types/errors/index.d.ts +0 -18
  388. package/dist/types/errors/index.d.ts.map +0 -1
  389. package/dist/types/errors/log.d.ts +0 -6
  390. package/dist/types/errors/log.d.ts.map +0 -1
  391. package/dist/types/errors/node.d.ts +0 -105
  392. package/dist/types/errors/node.d.ts.map +0 -1
  393. package/dist/types/errors/request.d.ts +0 -53
  394. package/dist/types/errors/request.d.ts.map +0 -1
  395. package/dist/types/errors/rpc.d.ts +0 -199
  396. package/dist/types/errors/rpc.d.ts.map +0 -1
  397. package/dist/types/errors/transaction.d.ts +0 -75
  398. package/dist/types/errors/transaction.d.ts.map +0 -1
  399. package/dist/types/errors/transport.d.ts +0 -5
  400. package/dist/types/errors/transport.d.ts.map +0 -1
  401. package/dist/types/errors/utils.d.ts +0 -5
  402. package/dist/types/errors/utils.d.ts.map +0 -1
  403. package/dist/types/errors/version.d.ts +0 -2
  404. package/dist/types/errors/version.d.ts.map +0 -1
  405. package/dist/types/ethers.d.ts +0 -2
  406. package/dist/types/ethers.d.ts.map +0 -1
  407. package/dist/types/index.d.ts +0 -12
  408. package/dist/types/index.d.ts.map +0 -1
  409. package/dist/types/public.d.ts +0 -3
  410. package/dist/types/public.d.ts.map +0 -1
  411. package/dist/types/test.d.ts +0 -3
  412. package/dist/types/test.d.ts.map +0 -1
  413. package/dist/types/types/account.d.ts +0 -11
  414. package/dist/types/types/account.d.ts.map +0 -1
  415. package/dist/types/types/block.d.ts +0 -62
  416. package/dist/types/types/block.d.ts.map +0 -1
  417. package/dist/types/types/chain.d.ts +0 -17
  418. package/dist/types/types/chain.d.ts.map +0 -1
  419. package/dist/types/types/contract.d.ts +0 -159
  420. package/dist/types/types/contract.d.ts.map +0 -1
  421. package/dist/types/types/eip1193.d.ts +0 -1002
  422. package/dist/types/types/eip1193.d.ts.map +0 -1
  423. package/dist/types/types/ens.d.ts +0 -5
  424. package/dist/types/types/ens.d.ts.map +0 -1
  425. package/dist/types/types/fee.d.ts +0 -28
  426. package/dist/types/types/fee.d.ts.map +0 -1
  427. package/dist/types/types/filter.d.ts +0 -27
  428. package/dist/types/types/filter.d.ts.map +0 -1
  429. package/dist/types/types/formatter.d.ts +0 -13
  430. package/dist/types/types/formatter.d.ts.map +0 -1
  431. package/dist/types/types/index.d.ts +0 -19
  432. package/dist/types/types/index.d.ts.map +0 -1
  433. package/dist/types/types/log.d.ts +0 -42
  434. package/dist/types/types/log.d.ts.map +0 -1
  435. package/dist/types/types/misc.d.ts +0 -10
  436. package/dist/types/types/misc.d.ts.map +0 -1
  437. package/dist/types/types/multicall.d.ts +0 -48
  438. package/dist/types/types/multicall.d.ts.map +0 -1
  439. package/dist/types/types/rpc.d.ts +0 -19
  440. package/dist/types/types/rpc.d.ts.map +0 -1
  441. package/dist/types/types/transaction.d.ts +0 -132
  442. package/dist/types/types/transaction.d.ts.map +0 -1
  443. package/dist/types/types/transport.d.ts +0 -3
  444. package/dist/types/types/transport.d.ts.map +0 -1
  445. package/dist/types/types/typedData.d.ts +0 -47
  446. package/dist/types/types/typedData.d.ts.map +0 -1
  447. package/dist/types/types/utils.d.ts +0 -156
  448. package/dist/types/types/utils.d.ts.map +0 -1
  449. package/dist/types/types/window.d.ts +0 -7
  450. package/dist/types/types/window.d.ts.map +0 -1
  451. package/dist/types/utils/abi/decodeAbiParameters.d.ts +0 -5
  452. package/dist/types/utils/abi/decodeAbiParameters.d.ts.map +0 -1
  453. package/dist/types/utils/abi/decodeDeployData.d.ts +0 -13
  454. package/dist/types/utils/abi/decodeDeployData.d.ts.map +0 -1
  455. package/dist/types/utils/abi/decodeErrorResult.d.ts +0 -13
  456. package/dist/types/utils/abi/decodeErrorResult.d.ts.map +0 -1
  457. package/dist/types/utils/abi/decodeEventLog.d.ts +0 -13
  458. package/dist/types/utils/abi/decodeEventLog.d.ts.map +0 -1
  459. package/dist/types/utils/abi/decodeFunctionData.d.ts +0 -14
  460. package/dist/types/utils/abi/decodeFunctionData.d.ts.map +0 -1
  461. package/dist/types/utils/abi/decodeFunctionResult.d.ts +0 -10
  462. package/dist/types/utils/abi/decodeFunctionResult.d.ts.map +0 -1
  463. package/dist/types/utils/abi/encodeAbiParameters.d.ts +0 -9
  464. package/dist/types/utils/abi/encodeAbiParameters.d.ts.map +0 -1
  465. package/dist/types/utils/abi/encodeDeployData.d.ts +0 -8
  466. package/dist/types/utils/abi/encodeDeployData.d.ts.map +0 -1
  467. package/dist/types/utils/abi/encodeErrorResult.d.ts +0 -8
  468. package/dist/types/utils/abi/encodeErrorResult.d.ts.map +0 -1
  469. package/dist/types/utils/abi/encodeEventTopics.d.ts +0 -9
  470. package/dist/types/utils/abi/encodeEventTopics.d.ts.map +0 -1
  471. package/dist/types/utils/abi/encodeFunctionData.d.ts +0 -8
  472. package/dist/types/utils/abi/encodeFunctionData.d.ts.map +0 -1
  473. package/dist/types/utils/abi/encodeFunctionResult.d.ts +0 -9
  474. package/dist/types/utils/abi/encodeFunctionResult.d.ts.map +0 -1
  475. package/dist/types/utils/abi/encodePacked.d.ts +0 -11
  476. package/dist/types/utils/abi/encodePacked.d.ts.map +0 -1
  477. package/dist/types/utils/abi/formatAbiItem.d.ts +0 -9
  478. package/dist/types/utils/abi/formatAbiItem.d.ts.map +0 -1
  479. package/dist/types/utils/abi/formatAbiItemWithArgs.d.ts +0 -8
  480. package/dist/types/utils/abi/formatAbiItemWithArgs.d.ts.map +0 -1
  481. package/dist/types/utils/abi/getAbiItem.d.ts +0 -12
  482. package/dist/types/utils/abi/getAbiItem.d.ts.map +0 -1
  483. package/dist/types/utils/abi/index.d.ts +0 -30
  484. package/dist/types/utils/abi/index.d.ts.map +0 -1
  485. package/dist/types/utils/accounts.d.ts +0 -3
  486. package/dist/types/utils/accounts.d.ts.map +0 -1
  487. package/dist/types/utils/address/getAddress.d.ts +0 -4
  488. package/dist/types/utils/address/getAddress.d.ts.map +0 -1
  489. package/dist/types/utils/address/getContractAddress.d.ts +0 -19
  490. package/dist/types/utils/address/getContractAddress.d.ts.map +0 -1
  491. package/dist/types/utils/address/index.d.ts +0 -6
  492. package/dist/types/utils/address/index.d.ts.map +0 -1
  493. package/dist/types/utils/address/isAddress.d.ts +0 -3
  494. package/dist/types/utils/address/isAddress.d.ts.map +0 -1
  495. package/dist/types/utils/address/isAddressEqual.d.ts +0 -3
  496. package/dist/types/utils/address/isAddressEqual.d.ts.map +0 -1
  497. package/dist/types/utils/buildRequest.d.ts +0 -6
  498. package/dist/types/utils/buildRequest.d.ts.map +0 -1
  499. package/dist/types/utils/chain.d.ts +0 -8
  500. package/dist/types/utils/chain.d.ts.map +0 -1
  501. package/dist/types/utils/contract/extractFunctionParts.d.ts +0 -13
  502. package/dist/types/utils/contract/extractFunctionParts.d.ts.map +0 -1
  503. package/dist/types/utils/contract/index.d.ts +0 -2
  504. package/dist/types/utils/contract/index.d.ts.map +0 -1
  505. package/dist/types/utils/data/concat.d.ts +0 -6
  506. package/dist/types/utils/data/concat.d.ts.map +0 -1
  507. package/dist/types/utils/data/index.d.ts +0 -8
  508. package/dist/types/utils/data/index.d.ts.map +0 -1
  509. package/dist/types/utils/data/isBytes.d.ts +0 -3
  510. package/dist/types/utils/data/isBytes.d.ts.map +0 -1
  511. package/dist/types/utils/data/isHex.d.ts +0 -3
  512. package/dist/types/utils/data/isHex.d.ts.map +0 -1
  513. package/dist/types/utils/data/pad.d.ts +0 -11
  514. package/dist/types/utils/data/pad.d.ts.map +0 -1
  515. package/dist/types/utils/data/size.d.ts +0 -9
  516. package/dist/types/utils/data/size.d.ts.map +0 -1
  517. package/dist/types/utils/data/slice.d.ts +0 -27
  518. package/dist/types/utils/data/slice.d.ts.map +0 -1
  519. package/dist/types/utils/data/trim.d.ts +0 -8
  520. package/dist/types/utils/data/trim.d.ts.map +0 -1
  521. package/dist/types/utils/encoding/fromBytes.d.ts +0 -25
  522. package/dist/types/utils/encoding/fromBytes.d.ts.map +0 -1
  523. package/dist/types/utils/encoding/fromHex.d.ts +0 -28
  524. package/dist/types/utils/encoding/fromHex.d.ts.map +0 -1
  525. package/dist/types/utils/encoding/fromRlp.d.ts +0 -6
  526. package/dist/types/utils/encoding/fromRlp.d.ts.map +0 -1
  527. package/dist/types/utils/encoding/index.d.ts +0 -8
  528. package/dist/types/utils/encoding/index.d.ts.map +0 -1
  529. package/dist/types/utils/encoding/toBytes.d.ts +0 -21
  530. package/dist/types/utils/encoding/toBytes.d.ts.map +0 -1
  531. package/dist/types/utils/encoding/toHex.d.ts +0 -29
  532. package/dist/types/utils/encoding/toHex.d.ts.map +0 -1
  533. package/dist/types/utils/encoding/toRlp.d.ts +0 -8
  534. package/dist/types/utils/encoding/toRlp.d.ts.map +0 -1
  535. package/dist/types/utils/ens/avatar/index.d.ts +0 -2
  536. package/dist/types/utils/ens/avatar/index.d.ts.map +0 -1
  537. package/dist/types/utils/ens/avatar/parseAvatarRecord.d.ts +0 -7
  538. package/dist/types/utils/ens/avatar/parseAvatarRecord.d.ts.map +0 -1
  539. package/dist/types/utils/ens/avatar/utils.d.ts +0 -34
  540. package/dist/types/utils/ens/avatar/utils.d.ts.map +0 -1
  541. package/dist/types/utils/ens/index.d.ts +0 -5
  542. package/dist/types/utils/ens/index.d.ts.map +0 -1
  543. package/dist/types/utils/ens/labelhash.d.ts +0 -11
  544. package/dist/types/utils/ens/labelhash.d.ts.map +0 -1
  545. package/dist/types/utils/ens/namehash.d.ts +0 -13
  546. package/dist/types/utils/ens/namehash.d.ts.map +0 -1
  547. package/dist/types/utils/ens/normalize.d.ts +0 -12
  548. package/dist/types/utils/ens/normalize.d.ts.map +0 -1
  549. package/dist/types/utils/ens/packetToBytes.d.ts +0 -3
  550. package/dist/types/utils/ens/packetToBytes.d.ts.map +0 -1
  551. package/dist/types/utils/errors/getCallError.d.ts +0 -9
  552. package/dist/types/utils/errors/getCallError.d.ts.map +0 -1
  553. package/dist/types/utils/errors/getContractError.d.ts +0 -13
  554. package/dist/types/utils/errors/getContractError.d.ts.map +0 -1
  555. package/dist/types/utils/errors/getEstimateGasError.d.ts +0 -10
  556. package/dist/types/utils/errors/getEstimateGasError.d.ts.map +0 -1
  557. package/dist/types/utils/errors/getNodeError.d.ts +0 -6
  558. package/dist/types/utils/errors/getNodeError.d.ts.map +0 -1
  559. package/dist/types/utils/errors/getTransactionError.d.ts +0 -10
  560. package/dist/types/utils/errors/getTransactionError.d.ts.map +0 -1
  561. package/dist/types/utils/errors/index.d.ts +0 -6
  562. package/dist/types/utils/errors/index.d.ts.map +0 -1
  563. package/dist/types/utils/filters/createFilterRequestScope.d.ts +0 -16
  564. package/dist/types/utils/filters/createFilterRequestScope.d.ts.map +0 -1
  565. package/dist/types/utils/formatters/block.d.ts +0 -14
  566. package/dist/types/utils/formatters/block.d.ts.map +0 -1
  567. package/dist/types/utils/formatters/extract.d.ts +0 -8
  568. package/dist/types/utils/formatters/extract.d.ts.map +0 -1
  569. package/dist/types/utils/formatters/feeHistory.d.ts +0 -3
  570. package/dist/types/utils/formatters/feeHistory.d.ts.map +0 -1
  571. package/dist/types/utils/formatters/format.d.ts +0 -36
  572. package/dist/types/utils/formatters/format.d.ts.map +0 -1
  573. package/dist/types/utils/formatters/index.d.ts +0 -13
  574. package/dist/types/utils/formatters/index.d.ts.map +0 -1
  575. package/dist/types/utils/formatters/log.d.ts +0 -16
  576. package/dist/types/utils/formatters/log.d.ts.map +0 -1
  577. package/dist/types/utils/formatters/transaction.d.ts +0 -19
  578. package/dist/types/utils/formatters/transaction.d.ts.map +0 -1
  579. package/dist/types/utils/formatters/transactionReceipt.d.ts +0 -14
  580. package/dist/types/utils/formatters/transactionReceipt.d.ts.map +0 -1
  581. package/dist/types/utils/formatters/transactionRequest.d.ts +0 -14
  582. package/dist/types/utils/formatters/transactionRequest.d.ts.map +0 -1
  583. package/dist/types/utils/hash/getEventSelector.d.ts +0 -3
  584. package/dist/types/utils/hash/getEventSelector.d.ts.map +0 -1
  585. package/dist/types/utils/hash/getFunctionSelector.d.ts +0 -2
  586. package/dist/types/utils/hash/getFunctionSelector.d.ts.map +0 -1
  587. package/dist/types/utils/hash/hashFunction.d.ts +0 -2
  588. package/dist/types/utils/hash/hashFunction.d.ts.map +0 -1
  589. package/dist/types/utils/hash/index.d.ts +0 -5
  590. package/dist/types/utils/hash/index.d.ts.map +0 -1
  591. package/dist/types/utils/hash/isHash.d.ts +0 -3
  592. package/dist/types/utils/hash/isHash.d.ts.map +0 -1
  593. package/dist/types/utils/hash/keccak256.d.ts +0 -6
  594. package/dist/types/utils/hash/keccak256.d.ts.map +0 -1
  595. package/dist/types/utils/index.d.ts +0 -26
  596. package/dist/types/utils/index.d.ts.map +0 -1
  597. package/dist/types/utils/observe.d.ts +0 -17
  598. package/dist/types/utils/observe.d.ts.map +0 -1
  599. package/dist/types/utils/poll.d.ts +0 -13
  600. package/dist/types/utils/poll.d.ts.map +0 -1
  601. package/dist/types/utils/promise/index.d.ts +0 -4
  602. package/dist/types/utils/promise/index.d.ts.map +0 -1
  603. package/dist/types/utils/promise/withCache.d.ts +0 -36
  604. package/dist/types/utils/promise/withCache.d.ts.map +0 -1
  605. package/dist/types/utils/promise/withRetry.d.ts +0 -12
  606. package/dist/types/utils/promise/withRetry.d.ts.map +0 -1
  607. package/dist/types/utils/promise/withTimeout.d.ts +0 -8
  608. package/dist/types/utils/promise/withTimeout.d.ts.map +0 -1
  609. package/dist/types/utils/regex.d.ts +0 -4
  610. package/dist/types/utils/regex.d.ts.map +0 -1
  611. package/dist/types/utils/rpc.d.ts +0 -64
  612. package/dist/types/utils/rpc.d.ts.map +0 -1
  613. package/dist/types/utils/signature/hashMessage.d.ts +0 -6
  614. package/dist/types/utils/signature/hashMessage.d.ts.map +0 -1
  615. package/dist/types/utils/signature/hashTypedData.d.ts +0 -10
  616. package/dist/types/utils/signature/hashTypedData.d.ts.map +0 -1
  617. package/dist/types/utils/signature/index.d.ts +0 -16
  618. package/dist/types/utils/signature/index.d.ts.map +0 -1
  619. package/dist/types/utils/signature/recoverAddress.d.ts +0 -8
  620. package/dist/types/utils/signature/recoverAddress.d.ts.map +0 -1
  621. package/dist/types/utils/signature/recoverMessageAddress.d.ts +0 -8
  622. package/dist/types/utils/signature/recoverMessageAddress.d.ts.map +0 -1
  623. package/dist/types/utils/signature/recoverPublicKey.d.ts +0 -8
  624. package/dist/types/utils/signature/recoverPublicKey.d.ts.map +0 -1
  625. package/dist/types/utils/signature/recoverTypedDataAddress.d.ts +0 -12
  626. package/dist/types/utils/signature/recoverTypedDataAddress.d.ts.map +0 -1
  627. package/dist/types/utils/signature/verifyMessage.d.ts +0 -10
  628. package/dist/types/utils/signature/verifyMessage.d.ts.map +0 -1
  629. package/dist/types/utils/signature/verifyTypedData.d.ts +0 -13
  630. package/dist/types/utils/signature/verifyTypedData.d.ts.map +0 -1
  631. package/dist/types/utils/stringify.d.ts +0 -2
  632. package/dist/types/utils/stringify.d.ts.map +0 -1
  633. package/dist/types/utils/transaction/assertRequest.d.ts +0 -4
  634. package/dist/types/utils/transaction/assertRequest.d.ts.map +0 -1
  635. package/dist/types/utils/transaction/assertTransaction.d.ts +0 -5
  636. package/dist/types/utils/transaction/assertTransaction.d.ts.map +0 -1
  637. package/dist/types/utils/transaction/getSerializedTransactionType.d.ts +0 -4
  638. package/dist/types/utils/transaction/getSerializedTransactionType.d.ts.map +0 -1
  639. package/dist/types/utils/transaction/getTransactionType.d.ts +0 -4
  640. package/dist/types/utils/transaction/getTransactionType.d.ts.map +0 -1
  641. package/dist/types/utils/transaction/index.d.ts +0 -10
  642. package/dist/types/utils/transaction/index.d.ts.map +0 -1
  643. package/dist/types/utils/transaction/parseTransaction.d.ts +0 -5
  644. package/dist/types/utils/transaction/parseTransaction.d.ts.map +0 -1
  645. package/dist/types/utils/transaction/prepareRequest.d.ts +0 -21
  646. package/dist/types/utils/transaction/prepareRequest.d.ts.map +0 -1
  647. package/dist/types/utils/transaction/serializeTransaction.d.ts +0 -5
  648. package/dist/types/utils/transaction/serializeTransaction.d.ts.map +0 -1
  649. package/dist/types/utils/typedData.d.ts +0 -6
  650. package/dist/types/utils/typedData.d.ts.map +0 -1
  651. package/dist/types/utils/uid.d.ts +0 -2
  652. package/dist/types/utils/uid.d.ts.map +0 -1
  653. package/dist/types/utils/unit/formatEther.d.ts +0 -2
  654. package/dist/types/utils/unit/formatEther.d.ts.map +0 -1
  655. package/dist/types/utils/unit/formatGwei.d.ts +0 -2
  656. package/dist/types/utils/unit/formatGwei.d.ts.map +0 -1
  657. package/dist/types/utils/unit/formatUnits.d.ts +0 -2
  658. package/dist/types/utils/unit/formatUnits.d.ts.map +0 -1
  659. package/dist/types/utils/unit/index.d.ts +0 -7
  660. package/dist/types/utils/unit/index.d.ts.map +0 -1
  661. package/dist/types/utils/unit/parseEther.d.ts +0 -2
  662. package/dist/types/utils/unit/parseEther.d.ts.map +0 -1
  663. package/dist/types/utils/unit/parseGwei.d.ts +0 -2
  664. package/dist/types/utils/unit/parseGwei.d.ts.map +0 -1
  665. package/dist/types/utils/unit/parseUnits.d.ts +0 -2
  666. package/dist/types/utils/unit/parseUnits.d.ts.map +0 -1
  667. package/dist/types/utils/wait.d.ts +0 -2
  668. package/dist/types/utils/wait.d.ts.map +0 -1
  669. package/dist/types/wallet.d.ts +0 -3
  670. package/dist/types/wallet.d.ts.map +0 -1
  671. package/dist/types/window.d.ts +0 -2
  672. package/dist/types/window.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"getContractError.js","sourceRoot":"","sources":["../../../../src/utils/errors/getContractError.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,wBAAwB,EACxB,8BAA8B,EAC9B,yBAAyB,EACzB,gBAAgB,GACjB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,kBAAkB,EAClB,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,0BAA0B,CAAA;AAGjC,MAAM,6BAA6B,GAAG,CAAC,CAAA;AAEvC,MAAM,UAAU,gBAAgB,CAC9B,GAAc,EACd,EACE,GAAG,EACH,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,MAAM,GAQP;IAED,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAC9B,GAAG,YAAY,gBAAgB;QAC7B,CAAC,CAAC,GAAG;QACL,CAAC,CAAC,GAAG,YAAY,kBAAkB;YACjC,GAAG,YAAY,yBAAyB;YAC1C,CAAC,CAAG,GAAG,CAAC,KAAmB,EAAE,KAAmB,EAAE,KAAK,IAAI,EAAE;YAC7D,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CACA,CAAA;IAErB,IAAI,KAAK,GAAG,GAAG,CAAA;IACf,IAAI,GAAG,YAAY,wBAAwB,EAAE;QAC3C,KAAK,GAAG,IAAI,6BAA6B,CAAC,EAAE,YAAY,EAAE,CAAC,CAAA;KAC5D;SAAM,IAAI,IAAI,KAAK,6BAA6B,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,EAAE;QACtE,KAAK,GAAG,IAAI,6BAA6B,CAAC;YACxC,GAAG;YACH,IAAI;YACJ,YAAY;YACZ,OAAO;SACR,CAAC,CAAA;KACH;IAED,OAAO,IAAI,8BAA8B,CAAC,KAAK,EAAE;QAC/C,GAAG;QACH,IAAI;QACJ,eAAe,EAAE,OAAO;QACxB,QAAQ;QACR,YAAY;QACZ,MAAM;KACP,CAAC,CAAA;AACJ,CAAC"}
1
+ {"version":3,"file":"getContractError.js","sourceRoot":"","sources":["../../../../src/utils/errors/getContractError.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,wBAAwB,EACxB,8BAA8B,EAC9B,yBAAyB,EACzB,gBAAgB,GACjB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,kBAAkB,EAClB,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,0BAA0B,CAAA;AAGjC,MAAM,6BAA6B,GAAG,CAAC,CAAA;AAEvC,MAAM,UAAU,gBAAgB,CAC9B,GAAc,EACd,EACE,GAAG,EACH,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,MAAM,GAQP;IAED,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,CAC5C,GAAG,YAAY,gBAAgB;QAC7B,CAAC,CAAC,GAAG;QACL,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,MAAM,IAAK,GAAG,CAAC,KAAmB,CAAC;YAClD,CAAC,GAAG,YAAY,kBAAkB;gBAChC,GAAG,YAAY,yBAAyB,CAAC;YAC7C,CAAC,CAAG,GAAG,CAAC,KAAmB,EAAE,KAAmB,EAAE,KAAK,IAAI,EAAE;YAC7D,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CACA,CAAA;IAErB,IAAI,KAAK,GAAG,GAAG,CAAA;IACf,IAAI,GAAG,YAAY,wBAAwB,EAAE;QAC3C,KAAK,GAAG,IAAI,6BAA6B,CAAC,EAAE,YAAY,EAAE,CAAC,CAAA;KAC5D;SAAM,IACL,IAAI,KAAK,6BAA6B;QACtC,CAAC,IAAI,IAAI,OAAO,IAAI,YAAY,CAAC,EACjC;QACA,KAAK,GAAG,IAAI,6BAA6B,CAAC;YACxC,GAAG;YACH,IAAI;YACJ,YAAY;YACZ,OAAO,EAAE,YAAY,IAAI,OAAO;SACjC,CAAC,CAAA;KACH;IAED,OAAO,IAAI,8BAA8B,CAAC,KAAK,EAAE;QAC/C,GAAG;QACH,IAAI;QACJ,eAAe,EAAE,OAAO;QACxB,QAAQ;QACR,YAAY;QACZ,MAAM;KACP,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,43 @@
1
+ const schedulerCache = new Map();
2
+ export function createBatchScheduler({ fn, id, shouldSplitBatch, wait = 0, }) {
3
+ const exec = async () => {
4
+ const scheduler = getScheduler();
5
+ flush();
6
+ const args = scheduler.map(({ args }) => args);
7
+ if (args.length === 0)
8
+ return;
9
+ fn(args)
10
+ .then((data) => {
11
+ scheduler.forEach(({ pendingPromise }, i) => pendingPromise.resolve?.([data[i], data]));
12
+ })
13
+ .catch((err) => {
14
+ scheduler.forEach(({ pendingPromise }) => pendingPromise.reject?.(err));
15
+ });
16
+ };
17
+ const flush = () => schedulerCache.delete(id);
18
+ const getBatchedArgs = () => getScheduler().map(({ args }) => args);
19
+ const getScheduler = () => schedulerCache.get(id) || [];
20
+ const setScheduler = (item) => schedulerCache.set(id, [...getScheduler(), item]);
21
+ return {
22
+ flush,
23
+ async schedule(args) {
24
+ const pendingPromise = {};
25
+ const promise = new Promise((resolve, reject) => {
26
+ pendingPromise.resolve = resolve;
27
+ pendingPromise.reject = reject;
28
+ });
29
+ const split = shouldSplitBatch?.([...getBatchedArgs(), args]);
30
+ if (split)
31
+ exec();
32
+ const hasActiveScheduler = getScheduler().length > 0;
33
+ if (hasActiveScheduler) {
34
+ setScheduler({ args, pendingPromise });
35
+ return promise;
36
+ }
37
+ setScheduler({ args, pendingPromise });
38
+ setTimeout(exec, wait);
39
+ return promise;
40
+ },
41
+ };
42
+ }
43
+ //# sourceMappingURL=createBatchScheduler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBatchScheduler.js","sourceRoot":"","sources":["../../../../src/utils/promise/createBatchScheduler.ts"],"names":[],"mappings":"AAYA,MAAM,cAAc,GAAG,IAAI,GAAG,EAAoC,CAAA;AAElE,MAAM,UAAU,oBAAoB,CAGlC,EACA,EAAE,EACF,EAAE,EACF,gBAAgB,EAChB,IAAI,GAAG,CAAC,GAMT;IACC,MAAM,IAAI,GAAG,KAAK,IAAI,EAAE;QACtB,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;QAChC,KAAK,EAAE,CAAA;QAEP,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAA;QAE9C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAM;QAE7B,EAAE,CAAC,IAAqB,CAAC;aACtB,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YACb,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,cAAc,EAAE,EAAE,CAAC,EAAE,EAAE,CAC1C,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAC1C,CAAA;QACH,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;QACzE,CAAC,CAAC,CAAA;IACN,CAAC,CAAA;IAED,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAE7C,MAAM,cAAc,GAAG,GAAG,EAAE,CAC1B,YAAY,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAkB,CAAA;IAEzD,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,CAAA;IAEvD,MAAM,YAAY,GAAG,CAAC,IAAmB,EAAE,EAAE,CAC3C,cAAc,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,YAAY,EAAE,EAAE,IAAI,CAAC,CAAC,CAAA;IAEnD,OAAO;QACL,KAAK;QACL,KAAK,CAAC,QAAQ,CAAC,IAAiB;YAC9B,MAAM,cAAc,GAAgC,EAAE,CAAA;YACtD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACrE,cAAc,CAAC,OAAO,GAAG,OAAO,CAAA;gBAChC,cAAc,CAAC,MAAM,GAAG,MAAM,CAAA;YAChC,CAAC,CAAC,CAAA;YAEF,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC,CAAC,GAAG,cAAc,EAAE,EAAE,IAAI,CAAC,CAAC,CAAA;YAE7D,IAAI,KAAK;gBAAE,IAAI,EAAE,CAAA;YAEjB,MAAM,kBAAkB,GAAG,YAAY,EAAE,CAAC,MAAM,GAAG,CAAC,CAAA;YACpD,IAAI,kBAAkB,EAAE;gBACtB,YAAY,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAA;gBACtC,OAAO,OAAO,CAAA;aACf;YAED,YAAY,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAA;YACtC,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;YACtB,OAAO,OAAO,CAAA;QAChB,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -1,3 +1,4 @@
1
+ export { createBatchScheduler } from './createBatchScheduler.js';
1
2
  export { getCache, withCache } from './withCache.js';
2
3
  export { withRetry } from './withRetry.js';
3
4
  export { withTimeout } from './withTimeout.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/promise/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/promise/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA"}
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "isomorphic-ws": "5.0.0",
13
13
  "ws": "8.12.0"
14
14
  },
15
- "version": "0.3.3",
15
+ "version": "0.3.5",
16
16
  "files": [
17
17
  "dist",
18
18
  "!dist/**/*.tsbuildinfo",
@@ -1,5 +1,11 @@
1
1
  import type { PublicClient, Transport } from '../../clients/index.js'
2
+ import { aggregate3Signature, multicall3Abi } from '../../constants/index.js'
2
3
  import type { BaseError } from '../../errors/index.js'
4
+ import {
5
+ ChainDoesNotSupportContract,
6
+ ClientChainNotConfiguredError,
7
+ RawContractError,
8
+ } from '../../errors/index.js'
3
9
  import type {
4
10
  Account,
5
11
  Address,
@@ -10,19 +16,23 @@ import type {
10
16
  MergeIntersectionProperties,
11
17
  TransactionRequest,
12
18
  } from '../../types/index.js'
19
+ import type {
20
+ Formatted,
21
+ TransactionRequestFormatter,
22
+ } from '../../utils/index.js'
13
23
  import {
14
24
  assertRequest,
25
+ decodeFunctionResult,
26
+ encodeFunctionData,
15
27
  extract,
16
28
  format,
17
29
  formatTransactionRequest,
18
30
  getCallError,
31
+ getChainContractAddress,
19
32
  numberToHex,
20
33
  parseAccount,
21
34
  } from '../../utils/index.js'
22
- import type {
23
- Formatted,
24
- TransactionRequestFormatter,
25
- } from '../../utils/index.js'
35
+ import { createBatchScheduler } from '../../utils/promise/createBatchScheduler.js'
26
36
 
27
37
  export type FormattedCall<
28
38
  TFormatter extends Formatter | undefined = Formatter,
@@ -35,6 +45,7 @@ export type CallParameters<
35
45
  TChain extends Chain | undefined = Chain | undefined,
36
46
  > = FormattedCall<TransactionRequestFormatter<TChain>> & {
37
47
  account?: Account | Address
48
+ batch?: boolean
38
49
  } & (
39
50
  | {
40
51
  /** The balance of the account at a block number. */
@@ -84,6 +95,7 @@ export async function call<TChain extends Chain | undefined>(
84
95
  ): Promise<CallReturnType> {
85
96
  const {
86
97
  account: account_,
98
+ batch = Boolean(client.batch?.multicall),
87
99
  blockNumber,
88
100
  blockTag = 'latest',
89
101
  accessList,
@@ -104,7 +116,7 @@ export async function call<TChain extends Chain | undefined>(
104
116
 
105
117
  const blockNumberHex = blockNumber ? numberToHex(blockNumber) : undefined
106
118
  const formatter = client.chain?.formatters?.transactionRequest
107
- const request_ = format(
119
+ const request = format(
108
120
  {
109
121
  from: account?.address,
110
122
  accessList,
@@ -122,11 +134,27 @@ export async function call<TChain extends Chain | undefined>(
122
134
  {
123
135
  formatter: formatter || formatTransactionRequest,
124
136
  },
125
- )
137
+ ) as TransactionRequest
138
+
139
+ if (batch && shouldPerformMulticall({ request })) {
140
+ try {
141
+ return await scheduleMulticall(client, {
142
+ ...request,
143
+ blockNumber,
144
+ blockTag,
145
+ } as unknown as ScheduleMulticallParameters<TChain>)
146
+ } catch (err) {
147
+ if (
148
+ !(err instanceof ClientChainNotConfiguredError) &&
149
+ !(err instanceof ChainDoesNotSupportContract)
150
+ )
151
+ throw err
152
+ }
153
+ }
126
154
 
127
155
  const response = await client.request({
128
156
  method: 'eth_call',
129
- params: [request_, blockNumberHex || blockTag],
157
+ params: [request as any, blockNumberHex || blockTag],
130
158
  })
131
159
  if (response === '0x') return { data: undefined }
132
160
  return { data: response }
@@ -138,3 +166,109 @@ export async function call<TChain extends Chain | undefined>(
138
166
  })
139
167
  }
140
168
  }
169
+
170
+ // We only want to perform a scheduled multicall if:
171
+ // - The request has calldata,
172
+ // - The request has a target address,
173
+ // - The target address is not already the aggregate3 signature,
174
+ // - The request has no other properties (`nonce`, `gas`, etc cannot be sent with a multicall).
175
+ function shouldPerformMulticall({ request }: { request: TransactionRequest }) {
176
+ const { data, to, ...request_ } = request
177
+ if (!data) return false
178
+ if (data.startsWith(aggregate3Signature)) return false
179
+ if (!to) return false
180
+ if (
181
+ Object.values(request_).filter((x) => typeof x !== 'undefined').length > 0
182
+ )
183
+ return false
184
+ return true
185
+ }
186
+
187
+ type ScheduleMulticallParameters<TChain extends Chain | undefined> = Pick<
188
+ CallParameters<TChain>,
189
+ 'blockNumber' | 'blockTag'
190
+ > & {
191
+ data: Hex
192
+ multicallAddress?: Address
193
+ to: Address
194
+ }
195
+
196
+ async function scheduleMulticall<TChain extends Chain | undefined>(
197
+ client: PublicClient<Transport, TChain>,
198
+ args: ScheduleMulticallParameters<TChain>,
199
+ ) {
200
+ const { batchSize = 1024, wait = 0 } =
201
+ typeof client.batch?.multicall === 'object' ? client.batch?.multicall : {}
202
+ const {
203
+ blockNumber,
204
+ blockTag = 'latest',
205
+ data,
206
+ multicallAddress: multicallAddress_,
207
+ to,
208
+ } = args
209
+
210
+ let multicallAddress = multicallAddress_
211
+ if (!multicallAddress) {
212
+ if (!client.chain) throw new ClientChainNotConfiguredError()
213
+
214
+ multicallAddress = getChainContractAddress({
215
+ blockNumber,
216
+ chain: client.chain,
217
+ contract: 'multicall3',
218
+ })
219
+ }
220
+
221
+ const blockNumberHex = blockNumber ? numberToHex(blockNumber) : undefined
222
+ const block = blockNumberHex || blockTag
223
+
224
+ const { schedule } = createBatchScheduler({
225
+ id: `${client.uid}.${block}`,
226
+ wait,
227
+ shouldSplitBatch(args) {
228
+ const size = args.reduce((size, { data }) => size + (data.length - 2), 0)
229
+ return size > batchSize * 2
230
+ },
231
+ fn: async (
232
+ requests: {
233
+ data: Hex
234
+ to: Address
235
+ }[],
236
+ ) => {
237
+ const calls = requests.map((request) => ({
238
+ allowFailure: true,
239
+ callData: request.data,
240
+ target: request.to,
241
+ }))
242
+
243
+ const calldata = encodeFunctionData({
244
+ abi: multicall3Abi,
245
+ args: [calls],
246
+ functionName: 'aggregate3',
247
+ })
248
+
249
+ const data = await client.request({
250
+ method: 'eth_call',
251
+ params: [
252
+ {
253
+ data: calldata,
254
+ to: multicallAddress,
255
+ },
256
+ block,
257
+ ],
258
+ })
259
+
260
+ return decodeFunctionResult({
261
+ abi: multicall3Abi,
262
+ args: [calls],
263
+ functionName: 'aggregate3',
264
+ data: data || '0x',
265
+ })
266
+ },
267
+ })
268
+
269
+ const [{ returnData, success }] = await schedule({ data, to })
270
+
271
+ if (!success) throw new RawContractError({ data: returnData })
272
+ if (returnData === '0x') return { data: undefined }
273
+ return { data: returnData }
274
+ }
@@ -32,7 +32,7 @@ export type SimulateContractParameters<
32
32
  } & ContractFunctionConfig<TAbi, TFunctionName, 'payable' | 'nonpayable'> &
33
33
  Omit<
34
34
  CallParameters<TChainOverride extends Chain ? TChainOverride : TChain>,
35
- 'to' | 'data' | 'value'
35
+ 'batch' | 'to' | 'data' | 'value'
36
36
  > &
37
37
  GetValue<TAbi, TFunctionName, CallParameters<TChain>['value']>
38
38
 
@@ -115,6 +115,7 @@ export async function simulateContract<
115
115
  } as unknown as EncodeFunctionDataParameters<TAbi, TFunctionName>)
116
116
  try {
117
117
  const { data } = await call(client, {
118
+ batch: false,
118
119
  data: calldata,
119
120
  to: address,
120
121
  ...callRequest,
@@ -6,13 +6,26 @@ import { publicActions } from './decorators/index.js'
6
6
  import type { PublicActions } from './decorators/index.js'
7
7
  import type { Chain, Prettify } from '../types/index.js'
8
8
 
9
+ export type MulticallBatchOptions = {
10
+ /** The maximum size (in bytes) for each calldata chunk. @default 1_024 */
11
+ batchSize?: number
12
+ /** The maximum number of milliseconds to wait before sending a batch. @default 16 */
13
+ wait?: number
14
+ }
15
+
9
16
  export type PublicClientConfig<
10
17
  TTransport extends Transport = Transport,
11
18
  TChain extends Chain | undefined = Chain | undefined,
12
19
  > = Pick<
13
20
  ClientConfig<TTransport, TChain>,
14
21
  'chain' | 'key' | 'name' | 'pollingInterval' | 'transport'
15
- >
22
+ > & {
23
+ /** Flags for batch settings. */
24
+ batch?: {
25
+ /** Toggle to enable `eth_call` multicall aggregation. */
26
+ multicall?: boolean | MulticallBatchOptions
27
+ }
28
+ }
16
29
 
17
30
  export type PublicClient<
18
31
  TTransport extends Transport = Transport,
@@ -20,6 +33,7 @@ export type PublicClient<
20
33
  TIncludeActions extends boolean = true,
21
34
  > = Prettify<
22
35
  Client<TTransport, PublicRequests, TChain> &
36
+ Pick<PublicClientConfig, 'batch'> &
23
37
  (TIncludeActions extends true ? PublicActions<TTransport, TChain> : unknown)
24
38
  >
25
39
 
@@ -46,6 +60,7 @@ export function createPublicClient<
46
60
  TTransport extends Transport,
47
61
  TChain extends Chain | undefined = undefined,
48
62
  >({
63
+ batch,
49
64
  chain,
50
65
  key = 'public',
51
66
  name = 'Public Client',
@@ -56,14 +71,17 @@ export function createPublicClient<
56
71
  TChain,
57
72
  true
58
73
  > {
59
- const client = createClient({
60
- chain,
61
- key,
62
- name,
63
- pollingInterval,
64
- transport,
65
- type: 'publicClient',
66
- }) as PublicClient<TTransport, TChain>
74
+ const client = {
75
+ batch,
76
+ ...(createClient({
77
+ chain,
78
+ key,
79
+ name,
80
+ pollingInterval,
81
+ transport,
82
+ type: 'publicClient',
83
+ }) as PublicClient<TTransport, TChain>),
84
+ }
67
85
  return {
68
86
  ...client,
69
87
  ...publicActions(client),
@@ -85,7 +85,7 @@ export function fallback(
85
85
  const {
86
86
  key = 'fallback',
87
87
  name = 'Fallback',
88
- rank = true,
88
+ rank = false,
89
89
  retryCount,
90
90
  retryDelay,
91
91
  } = config
@@ -0,0 +1 @@
1
+ export const aggregate3Signature = '0x82ad56cb'
@@ -1,5 +1,7 @@
1
1
  export { multicall3Abi } from './abis.js'
2
2
 
3
+ export { aggregate3Signature } from './contract.js'
4
+
3
5
  export { panicReasons, solidityError, solidityPanic } from './solidity.js'
4
6
 
5
7
  export { etherUnits, gweiUnits, weiUnits } from './unit.js'
@@ -67,6 +67,14 @@ export class ChainNotFoundError extends BaseError {
67
67
  }
68
68
  }
69
69
 
70
+ export class ClientChainNotConfiguredError extends BaseError {
71
+ override name = 'ClientChainNotConfiguredError'
72
+
73
+ constructor() {
74
+ super('No chain was provided to the Client.')
75
+ }
76
+ }
77
+
70
78
  export class InvalidChainIdError extends BaseError {
71
79
  override name = 'InvalidChainIdError'
72
80
 
@@ -194,7 +194,7 @@ export class ContractFunctionRevertedError extends BaseError {
194
194
  } else if (message) reason = message
195
195
 
196
196
  super(
197
- reason
197
+ reason && reason !== 'execution reverted'
198
198
  ? [
199
199
  `The contract function "${functionName}" reverted with the following reason:`,
200
200
  reason,
@@ -81,3 +81,12 @@ export class OffsetOutOfBoundsError extends BaseError {
81
81
  )
82
82
  }
83
83
  }
84
+
85
+ export class SizeOverflowError extends BaseError {
86
+ override name = 'SizeOverflowError'
87
+ constructor({ givenSize, maxSize }: { givenSize: number; maxSize: number }) {
88
+ super(
89
+ `Size cannot exceed ${maxSize} bytes. Given size: ${givenSize} bytes.`,
90
+ )
91
+ }
92
+ }
@@ -37,6 +37,7 @@ export {
37
37
  ChainDoesNotSupportContract,
38
38
  ChainMismatchError,
39
39
  ChainNotFoundError,
40
+ ClientChainNotConfiguredError,
40
41
  InvalidChainIdError,
41
42
  } from './chain.js'
42
43
 
@@ -58,6 +59,7 @@ export {
58
59
  InvalidHexBooleanError,
59
60
  InvalidHexValueError,
60
61
  OffsetOutOfBoundsError,
62
+ SizeOverflowError,
61
63
  } from './encoding.js'
62
64
 
63
65
  export {
@@ -1 +1 @@
1
- export const version = '0.3.3'
1
+ export const version = '0.3.5'
package/src/index.ts CHANGED
@@ -182,6 +182,7 @@ export {
182
182
  CallExecutionError,
183
183
  ChainDisconnectedError,
184
184
  ChainDoesNotSupportContract,
185
+ ClientChainNotConfiguredError,
185
186
  ContractFunctionExecutionError,
186
187
  ContractFunctionRevertedError,
187
188
  ContractFunctionZeroDataError,
@@ -207,7 +207,7 @@ export type PublicRequests = {
207
207
  */
208
208
  method: 'eth_call'
209
209
  params: [
210
- request: TransactionRequest,
210
+ request: Partial<TransactionRequest>,
211
211
  block: BlockNumber | BlockTag | BlockIdentifier,
212
212
  ]
213
213
  }): Promise<Hex>
@@ -1,8 +1,20 @@
1
1
  import { InvalidBytesBooleanError } from '../../errors/index.js'
2
2
  import type { ByteArray, Hex } from '../../types/index.js'
3
- import { hexToBigInt, hexToNumber } from './fromHex.js'
3
+ import { trim } from '../data/trim.js'
4
+ import { assertSize, hexToBigInt, hexToNumber } from './fromHex.js'
4
5
  import { bytesToHex } from './toHex.js'
5
6
 
7
+ export type FromBytesParameters<
8
+ TTo extends 'string' | 'hex' | 'bigint' | 'number' | 'boolean',
9
+ > =
10
+ | TTo
11
+ | {
12
+ /** Size of the bytes. */
13
+ size?: number
14
+ /** Type to convert to. */
15
+ to: TTo
16
+ }
17
+
6
18
  type FromBytesReturnType<TTo> = TTo extends 'string'
7
19
  ? string
8
20
  : TTo extends 'hex'
@@ -16,30 +28,106 @@ type FromBytesReturnType<TTo> = TTo extends 'string'
16
28
  : never
17
29
 
18
30
  /**
19
- * @description Decodes a byte array into a UTF-8 string, hex value, number, bigint or boolean.
31
+ * Decodes a byte array into a UTF-8 string, hex value, number, bigint or boolean.
32
+ *
33
+ * - Docs: https://viem.sh/docs/utilities/fromBytes.html
34
+ * - Example: https://viem.sh/docs/utilities/fromBytes.html#usage
35
+ *
36
+ * @param bytes Byte array to decode.
37
+ * @param toOrOpts Type to convert to or options.
38
+ * @returns Decoded value.
39
+ *
40
+ * @example
41
+ * import { fromBytes } from 'viem'
42
+ * const data = fromBytes(new Uint8Array([1, 164]), 'number')
43
+ * // 420
44
+ *
45
+ * @example
46
+ * import { fromBytes } from 'viem'
47
+ * const data = fromBytes(
48
+ * new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]),
49
+ * 'string'
50
+ * )
51
+ * // 'Hello world'
20
52
  */
21
53
  export function fromBytes<
22
54
  TTo extends 'string' | 'hex' | 'bigint' | 'number' | 'boolean',
23
- >(bytes: ByteArray, to: TTo): FromBytesReturnType<TTo> {
24
- if (to === 'number') return bytesToNumber(bytes) as FromBytesReturnType<TTo>
25
- if (to === 'bigint') return bytesToBigint(bytes) as FromBytesReturnType<TTo>
26
- if (to === 'boolean') return bytesToBool(bytes) as FromBytesReturnType<TTo>
27
- if (to === 'string') return bytesToString(bytes) as FromBytesReturnType<TTo>
28
- return bytesToHex(bytes) as FromBytesReturnType<TTo>
55
+ >(
56
+ bytes: ByteArray,
57
+ toOrOpts: FromBytesParameters<TTo>,
58
+ ): FromBytesReturnType<TTo> {
59
+ const opts = typeof toOrOpts === 'string' ? { to: toOrOpts } : toOrOpts
60
+ const to = opts.to
61
+
62
+ if (to === 'number')
63
+ return bytesToNumber(bytes, opts) as FromBytesReturnType<TTo>
64
+ if (to === 'bigint')
65
+ return bytesToBigint(bytes, opts) as FromBytesReturnType<TTo>
66
+ if (to === 'boolean')
67
+ return bytesToBool(bytes, opts) as FromBytesReturnType<TTo>
68
+ if (to === 'string')
69
+ return bytesToString(bytes, opts) as FromBytesReturnType<TTo>
70
+ return bytesToHex(bytes, opts) as FromBytesReturnType<TTo>
71
+ }
72
+
73
+ export type BytesToBigIntOpts = {
74
+ /** Whether or not the number of a signed representation. */
75
+ signed?: boolean
76
+ /** Size of the bytes. */
77
+ size?: number
29
78
  }
30
79
 
31
80
  /**
32
- * @description Decodes a byte array into a bigint.
81
+ * Decodes a byte array into a bigint.
82
+ *
83
+ * - Docs: https://viem.sh/docs/utilities/fromBytes.html#bytestobigint
84
+ *
85
+ * @param bytes Byte array to decode.
86
+ * @param opts Options.
87
+ * @returns BigInt value.
88
+ *
89
+ * @example
90
+ * import { bytesToBigint } from 'viem'
91
+ * const data = bytesToBigint(new Uint8Array([1, 164]))
92
+ * // 420n
33
93
  */
34
- export function bytesToBigint(bytes: ByteArray): bigint {
35
- const hex = bytesToHex(bytes)
94
+ export function bytesToBigint(
95
+ bytes: ByteArray,
96
+ opts: BytesToBigIntOpts = {},
97
+ ): bigint {
98
+ if (typeof opts.size !== 'undefined') assertSize(bytes, { size: opts.size })
99
+ const hex = bytesToHex(bytes, opts)
36
100
  return hexToBigInt(hex)
37
101
  }
38
102
 
103
+ export type BytesToBoolOpts = {
104
+ /** Size of the bytes. */
105
+ size?: number
106
+ }
107
+
39
108
  /**
40
- * @description Decodes a byte array into a boolean.
109
+ * Decodes a byte array into a boolean.
110
+ *
111
+ * - Docs: https://viem.sh/docs/utilities/fromBytes.html#bytestobool
112
+ *
113
+ * @param bytes Byte array to decode.
114
+ * @param opts Options.
115
+ * @returns Boolean value.
116
+ *
117
+ * @example
118
+ * import { bytesToBool } from 'viem'
119
+ * const data = bytesToBool(new Uint8Array([1]))
120
+ * // true
41
121
  */
42
- export function bytesToBool(bytes: ByteArray): boolean {
122
+ export function bytesToBool(
123
+ bytes_: ByteArray,
124
+ opts: BytesToBoolOpts = {},
125
+ ): boolean {
126
+ let bytes = bytes_
127
+ if (typeof opts.size !== 'undefined') {
128
+ assertSize(bytes, { size: opts.size })
129
+ bytes = trim(bytes)
130
+ }
43
131
  if (bytes.length > 1 || bytes[0] > 1)
44
132
  throw new InvalidBytesBooleanError(bytes)
45
133
  return Boolean(bytes[0])
@@ -47,17 +135,58 @@ export function bytesToBool(bytes: ByteArray): boolean {
47
135
 
48
136
  export { bytesToHex }
49
137
 
138
+ export type BytesToNumberOpts = BytesToBigIntOpts
139
+
50
140
  /**
51
- * @description Decodes a byte array into a number.
141
+ * Decodes a byte array into a number.
142
+ *
143
+ * - Docs: https://viem.sh/docs/utilities/fromBytes.html#bytestonumber
144
+ *
145
+ * @param bytes Byte array to decode.
146
+ * @param opts Options.
147
+ * @returns Number value.
148
+ *
149
+ * @example
150
+ * import { bytesToNumber } from 'viem'
151
+ * const data = bytesToNumber(new Uint8Array([1, 164]))
152
+ * // 420
52
153
  */
53
- export function bytesToNumber(bytes: ByteArray): number {
54
- const hex = bytesToHex(bytes)
154
+ export function bytesToNumber(
155
+ bytes: ByteArray,
156
+ opts: BytesToNumberOpts = {},
157
+ ): number {
158
+ if (typeof opts.size !== 'undefined') assertSize(bytes, { size: opts.size })
159
+ const hex = bytesToHex(bytes, opts)
55
160
  return hexToNumber(hex)
56
161
  }
57
162
 
163
+ export type BytesToStringOpts = {
164
+ /** Size of the bytes. */
165
+ size?: number
166
+ }
167
+
58
168
  /**
59
- * @description Decodes a byte array into a UTF-8 string.
169
+ * Decodes a byte array into a UTF-8 string.
170
+ *
171
+ * - Docs: https://viem.sh/docs/utilities/fromBytes.html#bytestostring
172
+ *
173
+ * @param bytes Byte array to decode.
174
+ * @param opts Options.
175
+ * @returns String value.
176
+ *
177
+ * @example
178
+ * import { bytesToString } from 'viem'
179
+ * const data = bytesToString(new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]))
180
+ * // 'Hello world'
60
181
  */
61
- export function bytesToString(bytes: ByteArray): string {
182
+ export function bytesToString(
183
+ bytes_: ByteArray,
184
+ opts: BytesToStringOpts = {},
185
+ ): string {
186
+ let bytes = bytes_
187
+ if (typeof opts.size !== 'undefined') {
188
+ assertSize(bytes, { size: opts.size })
189
+ bytes = trim(bytes, { dir: 'right' })
190
+ }
62
191
  return new TextDecoder().decode(bytes)
63
192
  }