viem 0.0.0-portable-types-20230522163654 → 0.0.0-tmm-sign-typed-data-types.20230619T221425

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 (736) hide show
  1. package/README.md +12 -0
  2. package/dist/cjs/actions/ens/getEnsAddress.js +34 -23
  3. package/dist/cjs/actions/ens/getEnsAddress.js.map +1 -1
  4. package/dist/cjs/actions/getContract.js +22 -16
  5. package/dist/cjs/actions/getContract.js.map +1 -1
  6. package/dist/cjs/actions/public/call.js +1 -1
  7. package/dist/cjs/actions/public/call.js.map +1 -1
  8. package/dist/cjs/actions/public/createContractEventFilter.js +2 -1
  9. package/dist/cjs/actions/public/createContractEventFilter.js.map +1 -1
  10. package/dist/cjs/actions/public/createEventFilter.js +2 -1
  11. package/dist/cjs/actions/public/createEventFilter.js.map +1 -1
  12. package/dist/cjs/actions/public/estimateContractGas.js +1 -1
  13. package/dist/cjs/actions/public/estimateContractGas.js.map +1 -1
  14. package/dist/cjs/actions/public/estimateGas.js +3 -2
  15. package/dist/cjs/actions/public/estimateGas.js.map +1 -1
  16. package/dist/cjs/actions/public/getBlock.js.map +1 -1
  17. package/dist/cjs/actions/public/getBlockTransactionCount.js +1 -1
  18. package/dist/cjs/actions/public/getBlockTransactionCount.js.map +1 -1
  19. package/dist/cjs/actions/public/getChainId.js +3 -1
  20. package/dist/cjs/actions/public/getChainId.js.map +1 -1
  21. package/dist/cjs/actions/public/getFilterChanges.js +15 -3
  22. package/dist/cjs/actions/public/getFilterChanges.js.map +1 -1
  23. package/dist/cjs/actions/public/getFilterLogs.js +14 -2
  24. package/dist/cjs/actions/public/getFilterLogs.js.map +1 -1
  25. package/dist/cjs/actions/public/getGasPrice.js.map +1 -1
  26. package/dist/cjs/actions/public/getLogs.js +15 -3
  27. package/dist/cjs/actions/public/getLogs.js.map +1 -1
  28. package/dist/cjs/actions/public/getTransactionCount.js.map +1 -1
  29. package/dist/cjs/actions/public/verifyTypedData.js +6 -1
  30. package/dist/cjs/actions/public/verifyTypedData.js.map +1 -1
  31. package/dist/cjs/actions/public/watchContractEvent.js +3 -1
  32. package/dist/cjs/actions/public/watchContractEvent.js.map +1 -1
  33. package/dist/cjs/actions/public/watchEvent.js +3 -1
  34. package/dist/cjs/actions/public/watchEvent.js.map +1 -1
  35. package/dist/cjs/actions/test/getAutomine.js +4 -0
  36. package/dist/cjs/actions/test/getAutomine.js.map +1 -1
  37. package/dist/cjs/actions/test/mine.js +10 -4
  38. package/dist/cjs/actions/test/mine.js.map +1 -1
  39. package/dist/cjs/actions/test/sendUnsignedTransaction.js +21 -3
  40. package/dist/cjs/actions/test/sendUnsignedTransaction.js.map +1 -1
  41. package/dist/cjs/actions/test/setAutomine.js +11 -4
  42. package/dist/cjs/actions/test/setAutomine.js.map +1 -1
  43. package/dist/cjs/actions/test/setBalance.js +10 -4
  44. package/dist/cjs/actions/test/setBalance.js.map +1 -1
  45. package/dist/cjs/actions/wallet/sendTransaction.js +1 -1
  46. package/dist/cjs/actions/wallet/sendTransaction.js.map +1 -1
  47. package/dist/cjs/actions/wallet/signMessage.js +8 -1
  48. package/dist/cjs/actions/wallet/signMessage.js.map +1 -1
  49. package/dist/cjs/chains.js +14 -2
  50. package/dist/cjs/chains.js.map +1 -1
  51. package/dist/cjs/clients/createClient.js +1 -1
  52. package/dist/cjs/clients/createClient.js.map +1 -1
  53. package/dist/cjs/clients/createPublicClient.js.map +1 -1
  54. package/dist/cjs/clients/createTestClient.js.map +1 -1
  55. package/dist/cjs/clients/createWalletClient.js.map +1 -1
  56. package/dist/cjs/clients/decorators/public.js.map +1 -1
  57. package/dist/cjs/clients/decorators/test.js.map +1 -1
  58. package/dist/cjs/clients/transports/createTransport.js.map +1 -1
  59. package/dist/cjs/clients/transports/custom.js.map +1 -1
  60. package/dist/cjs/clients/transports/fallback.js.map +1 -1
  61. package/dist/cjs/clients/transports/http.js +25 -7
  62. package/dist/cjs/clients/transports/http.js.map +1 -1
  63. package/dist/cjs/clients/transports/webSocket.js +22 -14
  64. package/dist/cjs/clients/transports/webSocket.js.map +1 -1
  65. package/dist/cjs/errors/abi.js +15 -1
  66. package/dist/cjs/errors/abi.js.map +1 -1
  67. package/dist/cjs/errors/base.js +4 -11
  68. package/dist/cjs/errors/base.js.map +1 -1
  69. package/dist/cjs/errors/request.js.map +1 -1
  70. package/dist/cjs/errors/rpc.js +8 -2
  71. package/dist/cjs/errors/rpc.js.map +1 -1
  72. package/dist/cjs/errors/version.js +1 -1
  73. package/dist/cjs/errors/version.js.map +1 -1
  74. package/dist/cjs/index.js +26 -10
  75. package/dist/cjs/index.js.map +1 -1
  76. package/dist/cjs/types/eip1193.js +3 -3
  77. package/dist/cjs/types/eip1193.js.map +1 -1
  78. package/dist/cjs/utils/abi/decodeEventLog.js +33 -19
  79. package/dist/cjs/utils/abi/decodeEventLog.js.map +1 -1
  80. package/dist/cjs/utils/abi/encodeEventTopics.js +11 -7
  81. package/dist/cjs/utils/abi/encodeEventTopics.js.map +1 -1
  82. package/dist/cjs/utils/abi/getAbiItem.js +2 -0
  83. package/dist/cjs/utils/abi/getAbiItem.js.map +1 -1
  84. package/dist/cjs/utils/buildRequest.js.map +1 -1
  85. package/dist/cjs/utils/encoding/toBytes.js.map +1 -1
  86. package/dist/cjs/utils/encoding/toHex.js.map +1 -1
  87. package/dist/cjs/utils/ens/encodeLabelhash.js +8 -0
  88. package/dist/cjs/utils/ens/encodeLabelhash.js.map +1 -0
  89. package/dist/cjs/utils/ens/encodedLabelToLabelhash.js +18 -0
  90. package/dist/cjs/utils/ens/encodedLabelToLabelhash.js.map +1 -0
  91. package/dist/cjs/utils/ens/labelhash.js +2 -1
  92. package/dist/cjs/utils/ens/labelhash.js.map +1 -1
  93. package/dist/cjs/utils/ens/namehash.js +5 -1
  94. package/dist/cjs/utils/ens/namehash.js.map +1 -1
  95. package/dist/cjs/utils/ens/packetToBytes.js +10 -9
  96. package/dist/cjs/utils/ens/packetToBytes.js.map +1 -1
  97. package/dist/cjs/utils/filters/createFilterRequestScope.js.map +1 -1
  98. package/dist/cjs/utils/formatters/block.js +3 -1
  99. package/dist/cjs/utils/formatters/block.js.map +1 -1
  100. package/dist/cjs/utils/formatters/log.js +2 -2
  101. package/dist/cjs/utils/formatters/transaction.js +3 -1
  102. package/dist/cjs/utils/formatters/transaction.js.map +1 -1
  103. package/dist/cjs/utils/formatters/transactionReceipt.js +1 -1
  104. package/dist/cjs/utils/formatters/transactionReceipt.js.map +1 -1
  105. package/dist/cjs/utils/formatters/transactionRequest.js.map +1 -1
  106. package/dist/cjs/utils/hash/getEventSelector.js +5 -1
  107. package/dist/cjs/utils/hash/getEventSelector.js.map +1 -1
  108. package/dist/cjs/utils/hash/getFunctionSelector.js +5 -1
  109. package/dist/cjs/utils/hash/getFunctionSelector.js.map +1 -1
  110. package/dist/cjs/utils/hash/hashFunction.js +6 -4
  111. package/dist/cjs/utils/hash/hashFunction.js.map +1 -1
  112. package/dist/cjs/utils/index.js.map +1 -1
  113. package/dist/cjs/utils/observe.js.map +1 -1
  114. package/dist/cjs/utils/promise/createBatchScheduler.js.map +1 -1
  115. package/dist/cjs/utils/promise/withCache.js +8 -4
  116. package/dist/cjs/utils/promise/withCache.js.map +1 -1
  117. package/dist/cjs/utils/rpc.js +12 -17
  118. package/dist/cjs/utils/rpc.js.map +1 -1
  119. package/dist/cjs/utils/signature/hashMessage.js +7 -1
  120. package/dist/cjs/utils/signature/hashMessage.js.map +1 -1
  121. package/dist/cjs/utils/transaction/getTransactionType.js.map +1 -1
  122. package/dist/cjs/utils/transaction/prepareRequest.js +1 -2
  123. package/dist/cjs/utils/transaction/prepareRequest.js.map +1 -1
  124. package/dist/cjs/utils/transaction/serializeTransaction.js.map +1 -1
  125. package/dist/cjs/utils/typedData.js.map +1 -1
  126. package/dist/cjs/utils/unit/parseUnits.js +13 -3
  127. package/dist/cjs/utils/unit/parseUnits.js.map +1 -1
  128. package/dist/esm/accounts/generateMnemonic.js +7 -0
  129. package/dist/esm/accounts/generateMnemonic.js.map +1 -1
  130. package/dist/esm/accounts/generatePrivateKey.js +5 -0
  131. package/dist/esm/accounts/generatePrivateKey.js.map +1 -1
  132. package/dist/esm/accounts/hdKeyToAccount.js +5 -0
  133. package/dist/esm/accounts/hdKeyToAccount.js.map +1 -1
  134. package/dist/esm/accounts/mnemonicToAccount.js +5 -0
  135. package/dist/esm/accounts/mnemonicToAccount.js.map +1 -1
  136. package/dist/esm/accounts/privateKeyToAccount.js +5 -0
  137. package/dist/esm/accounts/privateKeyToAccount.js.map +1 -1
  138. package/dist/esm/accounts/toAccount.js +5 -0
  139. package/dist/esm/accounts/toAccount.js.map +1 -1
  140. package/dist/esm/accounts/utils/publicKeyToAddress.js +7 -0
  141. package/dist/esm/accounts/utils/publicKeyToAddress.js.map +1 -1
  142. package/dist/esm/accounts/utils/sign.js +8 -0
  143. package/dist/esm/accounts/utils/sign.js.map +1 -1
  144. package/dist/esm/accounts/utils/signMessage.js +6 -0
  145. package/dist/esm/accounts/utils/signMessage.js.map +1 -1
  146. package/dist/esm/accounts/utils/signTypedData.js +6 -0
  147. package/dist/esm/accounts/utils/signTypedData.js.map +1 -1
  148. package/dist/esm/actions/ens/getEnsAddress.js +62 -23
  149. package/dist/esm/actions/ens/getEnsAddress.js.map +1 -1
  150. package/dist/esm/actions/ens/getEnsAvatar.js +28 -0
  151. package/dist/esm/actions/ens/getEnsAvatar.js.map +1 -1
  152. package/dist/esm/actions/ens/getEnsName.js +27 -0
  153. package/dist/esm/actions/ens/getEnsName.js.map +1 -1
  154. package/dist/esm/actions/ens/getEnsResolver.js +28 -0
  155. package/dist/esm/actions/ens/getEnsResolver.js.map +1 -1
  156. package/dist/esm/actions/ens/getEnsText.js +29 -0
  157. package/dist/esm/actions/ens/getEnsText.js.map +1 -1
  158. package/dist/esm/actions/getContract.js +58 -16
  159. package/dist/esm/actions/getContract.js.map +1 -1
  160. package/dist/esm/actions/public/call.js +32 -1
  161. package/dist/esm/actions/public/call.js.map +1 -1
  162. package/dist/esm/actions/public/createBlockFilter.js +21 -0
  163. package/dist/esm/actions/public/createBlockFilter.js.map +1 -1
  164. package/dist/esm/actions/public/createContractEventFilter.js +24 -1
  165. package/dist/esm/actions/public/createContractEventFilter.js.map +1 -1
  166. package/dist/esm/actions/public/createEventFilter.js +25 -1
  167. package/dist/esm/actions/public/createEventFilter.js.map +1 -1
  168. package/dist/esm/actions/public/createPendingTransactionFilter.js +21 -0
  169. package/dist/esm/actions/public/createPendingTransactionFilter.js.map +1 -1
  170. package/dist/esm/actions/public/estimateContractGas.js +28 -1
  171. package/dist/esm/actions/public/estimateContractGas.js.map +1 -1
  172. package/dist/esm/actions/public/estimateGas.js +29 -2
  173. package/dist/esm/actions/public/estimateGas.js.map +1 -1
  174. package/dist/esm/actions/public/getBalance.js +35 -0
  175. package/dist/esm/actions/public/getBalance.js.map +1 -1
  176. package/dist/esm/actions/public/getBlock.js +24 -0
  177. package/dist/esm/actions/public/getBlock.js.map +1 -1
  178. package/dist/esm/actions/public/getBlockNumber.js +23 -0
  179. package/dist/esm/actions/public/getBlockNumber.js.map +1 -1
  180. package/dist/esm/actions/public/getBlockTransactionCount.js +24 -1
  181. package/dist/esm/actions/public/getBlockTransactionCount.js.map +1 -1
  182. package/dist/esm/actions/public/getBytecode.js +23 -0
  183. package/dist/esm/actions/public/getBytecode.js.map +1 -1
  184. package/dist/esm/actions/public/getChainId.js +24 -1
  185. package/dist/esm/actions/public/getChainId.js.map +1 -1
  186. package/dist/esm/actions/public/getFeeHistory.js +24 -0
  187. package/dist/esm/actions/public/getFeeHistory.js.map +1 -1
  188. package/dist/esm/actions/public/getFilterChanges.js +99 -3
  189. package/dist/esm/actions/public/getFilterChanges.js.map +1 -1
  190. package/dist/esm/actions/public/getFilterLogs.js +43 -2
  191. package/dist/esm/actions/public/getFilterLogs.js.map +1 -1
  192. package/dist/esm/actions/public/getGasPrice.js +20 -0
  193. package/dist/esm/actions/public/getGasPrice.js.map +1 -1
  194. package/dist/esm/actions/public/getLogs.js +39 -3
  195. package/dist/esm/actions/public/getLogs.js.map +1 -1
  196. package/dist/esm/actions/public/getStorageAt.js +24 -0
  197. package/dist/esm/actions/public/getStorageAt.js.map +1 -1
  198. package/dist/esm/actions/public/getTransaction.js +24 -0
  199. package/dist/esm/actions/public/getTransaction.js.map +1 -1
  200. package/dist/esm/actions/public/getTransactionConfirmations.js +24 -0
  201. package/dist/esm/actions/public/getTransactionConfirmations.js.map +1 -1
  202. package/dist/esm/actions/public/getTransactionCount.js +23 -0
  203. package/dist/esm/actions/public/getTransactionCount.js.map +1 -1
  204. package/dist/esm/actions/public/getTransactionReceipt.js +24 -0
  205. package/dist/esm/actions/public/getTransactionReceipt.js.map +1 -1
  206. package/dist/esm/actions/public/multicall.js +40 -0
  207. package/dist/esm/actions/public/multicall.js.map +1 -1
  208. package/dist/esm/actions/public/readContract.js +31 -0
  209. package/dist/esm/actions/public/readContract.js.map +1 -1
  210. package/dist/esm/actions/public/simulateContract.js +31 -0
  211. package/dist/esm/actions/public/simulateContract.js.map +1 -1
  212. package/dist/esm/actions/public/uninstallFilter.js +24 -0
  213. package/dist/esm/actions/public/uninstallFilter.js.map +1 -1
  214. package/dist/esm/actions/public/verifyHash.js +10 -0
  215. package/dist/esm/actions/public/verifyHash.js.map +1 -1
  216. package/dist/esm/actions/public/verifyMessage.js +11 -0
  217. package/dist/esm/actions/public/verifyMessage.js.map +1 -1
  218. package/dist/esm/actions/public/verifyTypedData.js +16 -2
  219. package/dist/esm/actions/public/verifyTypedData.js.map +1 -1
  220. package/dist/esm/actions/public/waitForTransactionReceipt.js +52 -0
  221. package/dist/esm/actions/public/waitForTransactionReceipt.js.map +1 -1
  222. package/dist/esm/actions/public/watchBlockNumber.js +31 -0
  223. package/dist/esm/actions/public/watchBlockNumber.js.map +1 -1
  224. package/dist/esm/actions/public/watchBlocks.js +35 -1
  225. package/dist/esm/actions/public/watchBlocks.js.map +1 -1
  226. package/dist/esm/actions/public/watchContractEvent.js +39 -1
  227. package/dist/esm/actions/public/watchContractEvent.js.map +1 -1
  228. package/dist/esm/actions/public/watchEvent.js +41 -1
  229. package/dist/esm/actions/public/watchEvent.js.map +1 -1
  230. package/dist/esm/actions/public/watchPendingTransactions.js +29 -0
  231. package/dist/esm/actions/public/watchPendingTransactions.js.map +1 -1
  232. package/dist/esm/actions/test/dropTransaction.js +22 -0
  233. package/dist/esm/actions/test/dropTransaction.js.map +1 -1
  234. package/dist/esm/actions/test/getAutomine.js +24 -0
  235. package/dist/esm/actions/test/getAutomine.js.map +1 -1
  236. package/dist/esm/actions/test/getTxpoolContent.js +20 -0
  237. package/dist/esm/actions/test/getTxpoolContent.js.map +1 -1
  238. package/dist/esm/actions/test/getTxpoolStatus.js +20 -0
  239. package/dist/esm/actions/test/getTxpoolStatus.js.map +1 -1
  240. package/dist/esm/actions/test/impersonateAccount.js +22 -0
  241. package/dist/esm/actions/test/impersonateAccount.js.map +1 -1
  242. package/dist/esm/actions/test/increaseTime.js +22 -0
  243. package/dist/esm/actions/test/increaseTime.js.map +1 -1
  244. package/dist/esm/actions/test/inspectTxpool.js +20 -0
  245. package/dist/esm/actions/test/inspectTxpool.js.map +1 -1
  246. package/dist/esm/actions/test/mine.js +30 -4
  247. package/dist/esm/actions/test/mine.js.map +1 -1
  248. package/dist/esm/actions/test/removeBlockTimestampInterval.js +19 -0
  249. package/dist/esm/actions/test/removeBlockTimestampInterval.js.map +1 -1
  250. package/dist/esm/actions/test/reset.js +20 -0
  251. package/dist/esm/actions/test/reset.js.map +1 -1
  252. package/dist/esm/actions/test/revert.js +20 -0
  253. package/dist/esm/actions/test/revert.js.map +1 -1
  254. package/dist/esm/actions/test/sendUnsignedTransaction.js +48 -4
  255. package/dist/esm/actions/test/sendUnsignedTransaction.js.map +1 -1
  256. package/dist/esm/actions/test/setAutomine.js +30 -4
  257. package/dist/esm/actions/test/setAutomine.js.map +1 -1
  258. package/dist/esm/actions/test/setBalance.js +33 -4
  259. package/dist/esm/actions/test/setBalance.js.map +1 -1
  260. package/dist/esm/actions/test/setBlockGasLimit.js +20 -0
  261. package/dist/esm/actions/test/setBlockGasLimit.js.map +1 -1
  262. package/dist/esm/actions/test/setBlockTimestampInterval.js +20 -0
  263. package/dist/esm/actions/test/setBlockTimestampInterval.js.map +1 -1
  264. package/dist/esm/actions/test/setCode.js +23 -0
  265. package/dist/esm/actions/test/setCode.js.map +1 -1
  266. package/dist/esm/actions/test/setCoinbase.js +22 -0
  267. package/dist/esm/actions/test/setCoinbase.js.map +1 -1
  268. package/dist/esm/actions/test/setIntervalMining.js +20 -0
  269. package/dist/esm/actions/test/setIntervalMining.js.map +1 -1
  270. package/dist/esm/actions/test/setLoggingEnabled.js +19 -0
  271. package/dist/esm/actions/test/setLoggingEnabled.js.map +1 -1
  272. package/dist/esm/actions/test/setMinGasPrice.js +24 -0
  273. package/dist/esm/actions/test/setMinGasPrice.js.map +1 -1
  274. package/dist/esm/actions/test/setNextBlockBaseFeePerGas.js +22 -0
  275. package/dist/esm/actions/test/setNextBlockBaseFeePerGas.js.map +1 -1
  276. package/dist/esm/actions/test/setNextBlockTimestamp.js +20 -0
  277. package/dist/esm/actions/test/setNextBlockTimestamp.js.map +1 -1
  278. package/dist/esm/actions/test/setNonce.js +23 -0
  279. package/dist/esm/actions/test/setNonce.js.map +1 -1
  280. package/dist/esm/actions/test/setRpcUrl.js +20 -0
  281. package/dist/esm/actions/test/setRpcUrl.js.map +1 -1
  282. package/dist/esm/actions/test/setStorageAt.js +24 -0
  283. package/dist/esm/actions/test/setStorageAt.js.map +1 -1
  284. package/dist/esm/actions/test/snapshot.js +19 -0
  285. package/dist/esm/actions/test/snapshot.js.map +1 -1
  286. package/dist/esm/actions/test/stopImpersonatingAccount.js +22 -0
  287. package/dist/esm/actions/test/stopImpersonatingAccount.js.map +1 -1
  288. package/dist/esm/actions/wallet/addChain.js +19 -0
  289. package/dist/esm/actions/wallet/addChain.js.map +1 -1
  290. package/dist/esm/actions/wallet/deployContract.js +27 -0
  291. package/dist/esm/actions/wallet/deployContract.js.map +1 -1
  292. package/dist/esm/actions/wallet/getAddresses.js +20 -0
  293. package/dist/esm/actions/wallet/getAddresses.js.map +1 -1
  294. package/dist/esm/actions/wallet/getPermissions.js +20 -0
  295. package/dist/esm/actions/wallet/getPermissions.js.map +1 -1
  296. package/dist/esm/actions/wallet/requestAddresses.js +24 -0
  297. package/dist/esm/actions/wallet/requestAddresses.js.map +1 -1
  298. package/dist/esm/actions/wallet/requestPermissions.js +23 -0
  299. package/dist/esm/actions/wallet/requestPermissions.js.map +1 -1
  300. package/dist/esm/actions/wallet/sendTransaction.js +48 -1
  301. package/dist/esm/actions/wallet/sendTransaction.js.map +1 -1
  302. package/dist/esm/actions/wallet/signMessage.js +55 -2
  303. package/dist/esm/actions/wallet/signMessage.js.map +1 -1
  304. package/dist/esm/actions/wallet/signTypedData.js +100 -0
  305. package/dist/esm/actions/wallet/signTypedData.js.map +1 -1
  306. package/dist/esm/actions/wallet/switchChain.js +20 -0
  307. package/dist/esm/actions/wallet/switchChain.js.map +1 -1
  308. package/dist/esm/actions/wallet/watchAsset.js +28 -0
  309. package/dist/esm/actions/wallet/watchAsset.js.map +1 -1
  310. package/dist/esm/actions/wallet/writeContract.js +50 -0
  311. package/dist/esm/actions/wallet/writeContract.js.map +1 -1
  312. package/dist/esm/chains.js +99 -87
  313. package/dist/esm/chains.js.map +1 -1
  314. package/dist/esm/clients/createClient.js +4 -1
  315. package/dist/esm/clients/createClient.js.map +1 -1
  316. package/dist/esm/clients/createPublicClient.js +19 -0
  317. package/dist/esm/clients/createPublicClient.js.map +1 -1
  318. package/dist/esm/clients/createTestClient.js +23 -0
  319. package/dist/esm/clients/createTestClient.js.map +1 -1
  320. package/dist/esm/clients/createWalletClient.js +36 -0
  321. package/dist/esm/clients/createWalletClient.js.map +1 -1
  322. package/dist/esm/clients/decorators/public.js.map +1 -1
  323. package/dist/esm/clients/decorators/test.js.map +1 -1
  324. package/dist/esm/clients/transports/createTransport.js +3 -0
  325. package/dist/esm/clients/transports/createTransport.js.map +1 -1
  326. package/dist/esm/clients/transports/custom.js +3 -0
  327. package/dist/esm/clients/transports/custom.js.map +1 -1
  328. package/dist/esm/clients/transports/fallback.js +11 -0
  329. package/dist/esm/clients/transports/fallback.js.map +1 -1
  330. package/dist/esm/clients/transports/http.js +31 -8
  331. package/dist/esm/clients/transports/http.js.map +1 -1
  332. package/dist/esm/clients/transports/webSocket.js +28 -15
  333. package/dist/esm/clients/transports/webSocket.js.map +1 -1
  334. package/dist/esm/constants/abis.js +6 -0
  335. package/dist/esm/constants/abis.js.map +1 -1
  336. package/dist/esm/constants/solidity.js +1 -0
  337. package/dist/esm/constants/solidity.js.map +1 -1
  338. package/dist/esm/contract.js +0 -1
  339. package/dist/esm/contract.js.map +1 -1
  340. package/dist/esm/errors/abi.js +15 -1
  341. package/dist/esm/errors/abi.js.map +1 -1
  342. package/dist/esm/errors/base.js +4 -11
  343. package/dist/esm/errors/base.js.map +1 -1
  344. package/dist/esm/errors/node.js +9 -0
  345. package/dist/esm/errors/node.js.map +1 -1
  346. package/dist/esm/errors/request.js.map +1 -1
  347. package/dist/esm/errors/rpc.js +111 -2
  348. package/dist/esm/errors/rpc.js.map +1 -1
  349. package/dist/esm/errors/version.js +1 -1
  350. package/dist/esm/errors/version.js.map +1 -1
  351. package/dist/esm/index.js +2 -51
  352. package/dist/esm/index.js.map +1 -1
  353. package/dist/esm/package.json +1 -1
  354. package/dist/esm/types/account.js +1 -1
  355. package/dist/esm/types/account.js.map +1 -1
  356. package/dist/esm/types/eip1193.js +3 -1
  357. package/dist/esm/types/eip1193.js.map +1 -1
  358. package/dist/esm/utils/abi/decodeAbiParameters.js +29 -0
  359. package/dist/esm/utils/abi/decodeAbiParameters.js.map +1 -1
  360. package/dist/esm/utils/abi/decodeEventLog.js +35 -19
  361. package/dist/esm/utils/abi/decodeEventLog.js.map +1 -1
  362. package/dist/esm/utils/abi/encodeAbiParameters.js +10 -1
  363. package/dist/esm/utils/abi/encodeAbiParameters.js.map +1 -1
  364. package/dist/esm/utils/abi/encodeEventTopics.js +11 -7
  365. package/dist/esm/utils/abi/encodeEventTopics.js.map +1 -1
  366. package/dist/esm/utils/abi/getAbiItem.js +9 -0
  367. package/dist/esm/utils/abi/getAbiItem.js.map +1 -1
  368. package/dist/esm/utils/accounts.js +3 -0
  369. package/dist/esm/utils/accounts.js.map +1 -1
  370. package/dist/esm/utils/buildRequest.js +2 -0
  371. package/dist/esm/utils/buildRequest.js.map +1 -1
  372. package/dist/esm/utils/data/size.js +6 -0
  373. package/dist/esm/utils/data/size.js.map +1 -1
  374. package/dist/esm/utils/data/slice.js +21 -0
  375. package/dist/esm/utils/data/slice.js.map +1 -1
  376. package/dist/esm/utils/encoding/fromBytes.js +79 -0
  377. package/dist/esm/utils/encoding/fromBytes.js.map +1 -1
  378. package/dist/esm/utils/encoding/fromHex.js +106 -0
  379. package/dist/esm/utils/encoding/fromHex.js.map +1 -1
  380. package/dist/esm/utils/encoding/toBytes.js +102 -1
  381. package/dist/esm/utils/encoding/toBytes.js.map +1 -1
  382. package/dist/esm/utils/encoding/toHex.js +108 -2
  383. package/dist/esm/utils/encoding/toHex.js.map +1 -1
  384. package/dist/esm/utils/ens/avatar/parseAvatarRecord.js +6 -2
  385. package/dist/esm/utils/ens/avatar/parseAvatarRecord.js.map +1 -1
  386. package/dist/esm/utils/ens/avatar/utils.js +10 -0
  387. package/dist/esm/utils/ens/avatar/utils.js.map +1 -1
  388. package/dist/esm/utils/ens/encodeLabelhash.js +4 -0
  389. package/dist/esm/utils/ens/encodeLabelhash.js.map +1 -0
  390. package/dist/esm/utils/ens/encodedLabelToLabelhash.js +14 -0
  391. package/dist/esm/utils/ens/encodedLabelToLabelhash.js.map +1 -0
  392. package/dist/esm/utils/ens/labelhash.js +11 -1
  393. package/dist/esm/utils/ens/labelhash.js.map +1 -1
  394. package/dist/esm/utils/ens/namehash.js +18 -2
  395. package/dist/esm/utils/ens/namehash.js.map +1 -1
  396. package/dist/esm/utils/ens/normalize.js +10 -0
  397. package/dist/esm/utils/ens/normalize.js.map +1 -1
  398. package/dist/esm/utils/ens/packetToBytes.js +16 -9
  399. package/dist/esm/utils/ens/packetToBytes.js.map +1 -1
  400. package/dist/esm/utils/filters/createFilterRequestScope.js +5 -0
  401. package/dist/esm/utils/filters/createFilterRequestScope.js.map +1 -1
  402. package/dist/esm/utils/formatters/block.js +4 -1
  403. package/dist/esm/utils/formatters/block.js.map +1 -1
  404. package/dist/esm/utils/formatters/extract.js +3 -0
  405. package/dist/esm/utils/formatters/extract.js.map +1 -1
  406. package/dist/esm/utils/formatters/format.js +3 -0
  407. package/dist/esm/utils/formatters/format.js.map +1 -1
  408. package/dist/esm/utils/formatters/log.js +2 -2
  409. package/dist/esm/utils/formatters/transaction.js +3 -1
  410. package/dist/esm/utils/formatters/transaction.js.map +1 -1
  411. package/dist/esm/utils/formatters/transactionReceipt.js +2 -2
  412. package/dist/esm/utils/formatters/transactionReceipt.js.map +1 -1
  413. package/dist/esm/utils/formatters/transactionRequest.js +1 -1
  414. package/dist/esm/utils/formatters/transactionRequest.js.map +1 -1
  415. package/dist/esm/utils/hash/getEventSelector.js +6 -2
  416. package/dist/esm/utils/hash/getEventSelector.js.map +1 -1
  417. package/dist/esm/utils/hash/getFunctionSelector.js +6 -2
  418. package/dist/esm/utils/hash/getFunctionSelector.js.map +1 -1
  419. package/dist/esm/utils/hash/hashFunction.js +4 -3
  420. package/dist/esm/utils/hash/hashFunction.js.map +1 -1
  421. package/dist/esm/utils/index.js.map +1 -1
  422. package/dist/esm/utils/observe.js +7 -2
  423. package/dist/esm/utils/observe.js.map +1 -1
  424. package/dist/esm/utils/poll.js +3 -0
  425. package/dist/esm/utils/poll.js.map +1 -1
  426. package/dist/esm/utils/promise/createBatchScheduler.js +1 -1
  427. package/dist/esm/utils/promise/createBatchScheduler.js.map +1 -1
  428. package/dist/esm/utils/promise/withCache.js +23 -6
  429. package/dist/esm/utils/promise/withCache.js.map +1 -1
  430. package/dist/esm/utils/regex.js +4 -0
  431. package/dist/esm/utils/regex.js.map +1 -1
  432. package/dist/esm/utils/rpc.js +27 -19
  433. package/dist/esm/utils/rpc.js.map +1 -1
  434. package/dist/esm/utils/signature/hashMessage.js +8 -2
  435. package/dist/esm/utils/signature/hashMessage.js.map +1 -1
  436. package/dist/esm/utils/signature/hashTypedData.js +3 -0
  437. package/dist/esm/utils/signature/hashTypedData.js.map +1 -1
  438. package/dist/esm/utils/signature/recoverPublicKey.js +2 -0
  439. package/dist/esm/utils/signature/recoverPublicKey.js.map +1 -1
  440. package/dist/esm/utils/signature/verifyMessage.js +12 -0
  441. package/dist/esm/utils/signature/verifyMessage.js.map +1 -1
  442. package/dist/esm/utils/signature/verifyTypedData.js +12 -0
  443. package/dist/esm/utils/signature/verifyTypedData.js.map +1 -1
  444. package/dist/esm/utils/transaction/getTransactionType.js.map +1 -1
  445. package/dist/esm/utils/transaction/prepareRequest.js +5 -2
  446. package/dist/esm/utils/transaction/prepareRequest.js.map +1 -1
  447. package/dist/esm/utils/transaction/serializeTransaction.js +4 -2
  448. package/dist/esm/utils/transaction/serializeTransaction.js.map +1 -1
  449. package/dist/esm/utils/typedData.js +4 -0
  450. package/dist/esm/utils/typedData.js.map +1 -1
  451. package/dist/esm/utils/unit/parseUnits.js +15 -3
  452. package/dist/esm/utils/unit/parseUnits.js.map +1 -1
  453. package/dist/types/accounts/types.d.ts +3 -5
  454. package/dist/types/accounts/types.d.ts.map +1 -1
  455. package/dist/types/accounts/utils/signMessage.d.ts +2 -2
  456. package/dist/types/accounts/utils/signMessage.d.ts.map +1 -1
  457. package/dist/types/accounts/utils/signTypedData.d.ts +3 -6
  458. package/dist/types/accounts/utils/signTypedData.d.ts.map +1 -1
  459. package/dist/types/actions/ens/getEnsAddress.d.ts.map +1 -1
  460. package/dist/types/actions/getContract.d.ts +65 -21
  461. package/dist/types/actions/getContract.d.ts.map +1 -1
  462. package/dist/types/actions/public/createBlockFilter.d.ts +1 -1
  463. package/dist/types/actions/public/createContractEventFilter.d.ts +9 -4
  464. package/dist/types/actions/public/createContractEventFilter.d.ts.map +1 -1
  465. package/dist/types/actions/public/createEventFilter.d.ts +18 -6
  466. package/dist/types/actions/public/createEventFilter.d.ts.map +1 -1
  467. package/dist/types/actions/public/createPendingTransactionFilter.d.ts +1 -1
  468. package/dist/types/actions/public/estimateContractGas.d.ts +5 -3
  469. package/dist/types/actions/public/estimateContractGas.d.ts.map +1 -1
  470. package/dist/types/actions/public/estimateGas.d.ts.map +1 -1
  471. package/dist/types/actions/public/getBlockNumber.d.ts +2 -2
  472. package/dist/types/actions/public/getBlockNumber.d.ts.map +1 -1
  473. package/dist/types/actions/public/getChainId.d.ts.map +1 -1
  474. package/dist/types/actions/public/getFilterChanges.d.ts +8 -8
  475. package/dist/types/actions/public/getFilterChanges.d.ts.map +1 -1
  476. package/dist/types/actions/public/getFilterLogs.d.ts +4 -4
  477. package/dist/types/actions/public/getFilterLogs.d.ts.map +1 -1
  478. package/dist/types/actions/public/getLogs.d.ts +10 -4
  479. package/dist/types/actions/public/getLogs.d.ts.map +1 -1
  480. package/dist/types/actions/public/getTransaction.d.ts +1 -1
  481. package/dist/types/actions/public/getTransactionCount.d.ts +1 -1
  482. package/dist/types/actions/public/getTransactionReceipt.d.ts +1 -1
  483. package/dist/types/actions/public/multicall.d.ts +1 -1
  484. package/dist/types/actions/public/readContract.d.ts +2 -2
  485. package/dist/types/actions/public/readContract.d.ts.map +1 -1
  486. package/dist/types/actions/public/simulateContract.d.ts +2 -2
  487. package/dist/types/actions/public/uninstallFilter.d.ts +3 -3
  488. package/dist/types/actions/public/verifyMessage.d.ts +2 -2
  489. package/dist/types/actions/public/verifyMessage.d.ts.map +1 -1
  490. package/dist/types/actions/public/verifyTypedData.d.ts +3 -4
  491. package/dist/types/actions/public/verifyTypedData.d.ts.map +1 -1
  492. package/dist/types/actions/public/watchContractEvent.d.ts +11 -6
  493. package/dist/types/actions/public/watchContractEvent.d.ts.map +1 -1
  494. package/dist/types/actions/public/watchEvent.d.ts +13 -7
  495. package/dist/types/actions/public/watchEvent.d.ts.map +1 -1
  496. package/dist/types/actions/test/getAutomine.d.ts.map +1 -1
  497. package/dist/types/actions/test/mine.d.ts.map +1 -1
  498. package/dist/types/actions/test/sendUnsignedTransaction.d.ts +8 -2
  499. package/dist/types/actions/test/sendUnsignedTransaction.d.ts.map +1 -1
  500. package/dist/types/actions/test/setAutomine.d.ts.map +1 -1
  501. package/dist/types/actions/test/setBalance.d.ts.map +1 -1
  502. package/dist/types/actions/test/setBlockTimestampInterval.d.ts +1 -1
  503. package/dist/types/actions/test/stopImpersonatingAccount.d.ts +1 -1
  504. package/dist/types/actions/wallet/deployContract.d.ts +1 -1
  505. package/dist/types/actions/wallet/signMessage.d.ts +4 -4
  506. package/dist/types/actions/wallet/signMessage.d.ts.map +1 -1
  507. package/dist/types/actions/wallet/signTypedData.d.ts +4 -7
  508. package/dist/types/actions/wallet/signTypedData.d.ts.map +1 -1
  509. package/dist/types/actions/wallet/writeContract.d.ts +3 -3
  510. package/dist/types/chains.d.ts +364 -16
  511. package/dist/types/chains.d.ts.map +1 -1
  512. package/dist/types/clients/createClient.d.ts +5 -5
  513. package/dist/types/clients/createClient.d.ts.map +1 -1
  514. package/dist/types/clients/createPublicClient.d.ts +4 -4
  515. package/dist/types/clients/createPublicClient.d.ts.map +1 -1
  516. package/dist/types/clients/createTestClient.d.ts +4 -4
  517. package/dist/types/clients/createTestClient.d.ts.map +1 -1
  518. package/dist/types/clients/createWalletClient.d.ts +4 -4
  519. package/dist/types/clients/createWalletClient.d.ts.map +1 -1
  520. package/dist/types/clients/decorators/public.d.ts +30 -30
  521. package/dist/types/clients/decorators/public.d.ts.map +1 -1
  522. package/dist/types/clients/decorators/test.d.ts +3 -3
  523. package/dist/types/clients/decorators/test.d.ts.map +1 -1
  524. package/dist/types/clients/decorators/wallet.d.ts +7 -9
  525. package/dist/types/clients/decorators/wallet.d.ts.map +1 -1
  526. package/dist/types/clients/transports/createTransport.d.ts +5 -8
  527. package/dist/types/clients/transports/createTransport.d.ts.map +1 -1
  528. package/dist/types/clients/transports/custom.d.ts +2 -2
  529. package/dist/types/clients/transports/custom.d.ts.map +1 -1
  530. package/dist/types/clients/transports/http.d.ts +11 -0
  531. package/dist/types/clients/transports/http.d.ts.map +1 -1
  532. package/dist/types/clients/transports/webSocket.d.ts.map +1 -1
  533. package/dist/types/contract.d.ts +1 -1
  534. package/dist/types/contract.d.ts.map +1 -1
  535. package/dist/types/errors/abi.d.ts +6 -4
  536. package/dist/types/errors/abi.d.ts.map +1 -1
  537. package/dist/types/errors/base.d.ts +0 -1
  538. package/dist/types/errors/base.d.ts.map +1 -1
  539. package/dist/types/errors/request.d.ts +16 -8
  540. package/dist/types/errors/request.d.ts.map +1 -1
  541. package/dist/types/errors/rpc.d.ts +12 -8
  542. package/dist/types/errors/rpc.d.ts.map +1 -1
  543. package/dist/types/errors/version.d.ts +1 -1
  544. package/dist/types/errors/version.d.ts.map +1 -1
  545. package/dist/types/index.d.ts +56 -53
  546. package/dist/types/index.d.ts.map +1 -1
  547. package/dist/types/types/account.d.ts +1 -1
  548. package/dist/types/types/account.d.ts.map +1 -1
  549. package/dist/types/types/contract.d.ts +11 -6
  550. package/dist/types/types/contract.d.ts.map +1 -1
  551. package/dist/types/types/eip1193.d.ts +1048 -834
  552. package/dist/types/types/eip1193.d.ts.map +1 -1
  553. package/dist/types/types/filter.d.ts +12 -3
  554. package/dist/types/types/filter.d.ts.map +1 -1
  555. package/dist/types/types/log.d.ts +5 -3
  556. package/dist/types/types/log.d.ts.map +1 -1
  557. package/dist/types/types/misc.d.ts +4 -0
  558. package/dist/types/types/misc.d.ts.map +1 -1
  559. package/dist/types/types/rpc.d.ts +1 -1
  560. package/dist/types/types/rpc.d.ts.map +1 -1
  561. package/dist/types/types/transaction.d.ts +14 -5
  562. package/dist/types/types/transaction.d.ts.map +1 -1
  563. package/dist/types/types/typedData.d.ts +17 -29
  564. package/dist/types/types/typedData.d.ts.map +1 -1
  565. package/dist/types/types/utils.d.ts +11 -0
  566. package/dist/types/types/utils.d.ts.map +1 -1
  567. package/dist/types/utils/abi/decodeEventLog.d.ts +6 -5
  568. package/dist/types/utils/abi/decodeEventLog.d.ts.map +1 -1
  569. package/dist/types/utils/abi/encodeEventTopics.d.ts.map +1 -1
  570. package/dist/types/utils/abi/getAbiItem.d.ts.map +1 -1
  571. package/dist/types/utils/buildRequest.d.ts.map +1 -1
  572. package/dist/types/utils/ens/encodeLabelhash.d.ts +3 -0
  573. package/dist/types/utils/ens/encodeLabelhash.d.ts.map +1 -0
  574. package/dist/types/utils/ens/encodedLabelToLabelhash.d.ts +3 -0
  575. package/dist/types/utils/ens/encodedLabelToLabelhash.d.ts.map +1 -0
  576. package/dist/types/utils/ens/labelhash.d.ts.map +1 -1
  577. package/dist/types/utils/ens/namehash.d.ts.map +1 -1
  578. package/dist/types/utils/ens/packetToBytes.d.ts.map +1 -1
  579. package/dist/types/utils/filters/createFilterRequestScope.d.ts +6 -2
  580. package/dist/types/utils/filters/createFilterRequestScope.d.ts.map +1 -1
  581. package/dist/types/utils/formatters/block.d.ts.map +1 -1
  582. package/dist/types/utils/formatters/transaction.d.ts +1 -1
  583. package/dist/types/utils/formatters/transaction.d.ts.map +1 -1
  584. package/dist/types/utils/formatters/transactionReceipt.d.ts.map +1 -1
  585. package/dist/types/utils/hash/getEventSelector.d.ts +2 -1
  586. package/dist/types/utils/hash/getEventSelector.d.ts.map +1 -1
  587. package/dist/types/utils/hash/getFunctionSelector.d.ts +2 -1
  588. package/dist/types/utils/hash/getFunctionSelector.d.ts.map +1 -1
  589. package/dist/types/utils/hash/hashFunction.d.ts +2 -0
  590. package/dist/types/utils/hash/hashFunction.d.ts.map +1 -1
  591. package/dist/types/utils/index.d.ts +1 -1
  592. package/dist/types/utils/index.d.ts.map +1 -1
  593. package/dist/types/utils/observe.d.ts.map +1 -1
  594. package/dist/types/utils/promise/withCache.d.ts.map +1 -1
  595. package/dist/types/utils/rpc.d.ts +18 -10
  596. package/dist/types/utils/rpc.d.ts.map +1 -1
  597. package/dist/types/utils/signature/hashMessage.d.ts +2 -2
  598. package/dist/types/utils/signature/hashMessage.d.ts.map +1 -1
  599. package/dist/types/utils/signature/hashTypedData.d.ts +3 -6
  600. package/dist/types/utils/signature/hashTypedData.d.ts.map +1 -1
  601. package/dist/types/utils/signature/recoverMessageAddress.d.ts +2 -2
  602. package/dist/types/utils/signature/recoverMessageAddress.d.ts.map +1 -1
  603. package/dist/types/utils/signature/recoverTypedDataAddress.d.ts +3 -6
  604. package/dist/types/utils/signature/recoverTypedDataAddress.d.ts.map +1 -1
  605. package/dist/types/utils/signature/verifyTypedData.d.ts +3 -6
  606. package/dist/types/utils/signature/verifyTypedData.d.ts.map +1 -1
  607. package/dist/types/utils/transaction/getTransactionType.d.ts +2 -2
  608. package/dist/types/utils/transaction/getTransactionType.d.ts.map +1 -1
  609. package/dist/types/utils/transaction/prepareRequest.d.ts +1 -1
  610. package/dist/types/utils/transaction/prepareRequest.d.ts.map +1 -1
  611. package/dist/types/utils/typedData.d.ts +2 -3
  612. package/dist/types/utils/typedData.d.ts.map +1 -1
  613. package/dist/types/utils/unit/parseUnits.d.ts.map +1 -1
  614. package/package.json +7 -13
  615. package/src/accounts/types.ts +4 -4
  616. package/src/accounts/utils/signMessage.ts +2 -2
  617. package/src/accounts/utils/signTypedData.ts +4 -4
  618. package/src/actions/ens/getEnsAddress.ts +37 -22
  619. package/src/actions/getContract.ts +133 -69
  620. package/src/actions/public/call.ts +1 -1
  621. package/src/actions/public/createBlockFilter.ts +1 -1
  622. package/src/actions/public/createContractEventFilter.ts +22 -5
  623. package/src/actions/public/createEventFilter.ts +35 -14
  624. package/src/actions/public/createPendingTransactionFilter.ts +1 -1
  625. package/src/actions/public/estimateContractGas.ts +11 -5
  626. package/src/actions/public/estimateGas.ts +4 -3
  627. package/src/actions/public/getBlock.ts +2 -2
  628. package/src/actions/public/getBlockTransactionCount.ts +1 -1
  629. package/src/actions/public/getChainId.ts +3 -1
  630. package/src/actions/public/getFilterChanges.ts +36 -11
  631. package/src/actions/public/getFilterLogs.ts +34 -8
  632. package/src/actions/public/getGasPrice.ts +1 -1
  633. package/src/actions/public/getLogs.ts +39 -10
  634. package/src/actions/public/getTransaction.ts +1 -1
  635. package/src/actions/public/getTransactionCount.ts +2 -2
  636. package/src/actions/public/getTransactionReceipt.ts +1 -1
  637. package/src/actions/public/multicall.ts +1 -1
  638. package/src/actions/public/readContract.ts +2 -2
  639. package/src/actions/public/simulateContract.ts +2 -2
  640. package/src/actions/public/uninstallFilter.ts +3 -3
  641. package/src/actions/public/verifyMessage.ts +2 -2
  642. package/src/actions/public/verifyTypedData.ts +18 -6
  643. package/src/actions/public/watchContractEvent.ts +17 -5
  644. package/src/actions/public/watchEvent.ts +19 -6
  645. package/src/actions/test/getAutomine.ts +4 -0
  646. package/src/actions/test/mine.ts +10 -4
  647. package/src/actions/test/sendUnsignedTransaction.ts +54 -5
  648. package/src/actions/test/setAutomine.ts +8 -4
  649. package/src/actions/test/setBalance.ts +10 -4
  650. package/src/actions/test/setBlockTimestampInterval.ts +1 -1
  651. package/src/actions/test/stopImpersonatingAccount.ts +1 -1
  652. package/src/actions/wallet/deployContract.ts +1 -1
  653. package/src/actions/wallet/sendTransaction.ts +1 -1
  654. package/src/actions/wallet/signMessage.ts +13 -6
  655. package/src/actions/wallet/signTypedData.ts +5 -5
  656. package/src/actions/wallet/writeContract.ts +3 -3
  657. package/src/chains.ts +123 -88
  658. package/src/clients/createClient.ts +13 -11
  659. package/src/clients/createPublicClient.ts +4 -5
  660. package/src/clients/createTestClient.ts +4 -5
  661. package/src/clients/createWalletClient.ts +4 -5
  662. package/src/clients/decorators/public.ts +65 -39
  663. package/src/clients/decorators/test.ts +6 -5
  664. package/src/clients/decorators/wallet.ts +8 -8
  665. package/src/clients/transports/createTransport.ts +5 -9
  666. package/src/clients/transports/custom.ts +1 -2
  667. package/src/clients/transports/fallback.ts +1 -1
  668. package/src/clients/transports/http.ts +44 -7
  669. package/src/clients/transports/webSocket.ts +23 -15
  670. package/src/contract.ts +3 -3
  671. package/src/errors/abi.ts +16 -4
  672. package/src/errors/base.ts +6 -6
  673. package/src/errors/request.ts +4 -4
  674. package/src/errors/rpc.ts +43 -15
  675. package/src/errors/version.ts +1 -1
  676. package/src/index.ts +266 -247
  677. package/src/types/account.ts +9 -9
  678. package/src/types/contract.ts +33 -15
  679. package/src/types/eip1193.ts +1093 -839
  680. package/src/types/filter.ts +15 -3
  681. package/src/types/log.ts +13 -3
  682. package/src/types/misc.ts +6 -0
  683. package/src/types/rpc.ts +1 -1
  684. package/src/types/transaction.ts +24 -6
  685. package/src/types/typedData.ts +36 -45
  686. package/src/types/utils.ts +15 -0
  687. package/src/utils/abi/decodeEventLog.ts +47 -22
  688. package/src/utils/abi/encodeEventTopics.ts +16 -11
  689. package/src/utils/abi/getAbiItem.ts +1 -0
  690. package/src/utils/buildRequest.ts +5 -1
  691. package/src/utils/encoding/toBytes.ts +1 -1
  692. package/src/utils/encoding/toHex.ts +2 -2
  693. package/src/utils/ens/encodeLabelhash.ts +5 -0
  694. package/src/utils/ens/encodedLabelToLabelhash.ts +11 -0
  695. package/src/utils/ens/labelhash.ts +2 -1
  696. package/src/utils/ens/namehash.ts +6 -2
  697. package/src/utils/ens/packetToBytes.ts +12 -8
  698. package/src/utils/filters/createFilterRequestScope.ts +12 -4
  699. package/src/utils/formatters/block.ts +3 -1
  700. package/src/utils/formatters/log.ts +2 -2
  701. package/src/utils/formatters/transaction.ts +3 -1
  702. package/src/utils/formatters/transactionReceipt.ts +4 -2
  703. package/src/utils/formatters/transactionRequest.ts +1 -1
  704. package/src/utils/hash/getEventSelector.ts +6 -2
  705. package/src/utils/hash/getFunctionSelector.ts +6 -2
  706. package/src/utils/hash/hashFunction.ts +6 -2
  707. package/src/utils/index.ts +6 -0
  708. package/src/utils/observe.ts +2 -2
  709. package/src/utils/promise/createBatchScheduler.ts +1 -1
  710. package/src/utils/promise/withCache.ts +13 -11
  711. package/src/utils/rpc.ts +53 -53
  712. package/src/utils/signature/hashMessage.ts +8 -4
  713. package/src/utils/signature/hashTypedData.ts +4 -4
  714. package/src/utils/signature/recoverMessageAddress.ts +2 -2
  715. package/src/utils/signature/recoverTypedDataAddress.ts +4 -4
  716. package/src/utils/signature/verifyTypedData.ts +4 -4
  717. package/src/utils/transaction/getTransactionType.ts +10 -9
  718. package/src/utils/transaction/prepareRequest.ts +1 -2
  719. package/src/utils/transaction/serializeTransaction.ts +3 -3
  720. package/src/utils/typedData.ts +3 -3
  721. package/src/utils/unit/parseUnits.ts +15 -5
  722. package/dist/cjs/adapters/ethers.js +0 -49
  723. package/dist/cjs/adapters/ethers.js.map +0 -1
  724. package/dist/cjs/ethers.js +0 -6
  725. package/dist/cjs/ethers.js.map +0 -1
  726. package/dist/esm/adapters/ethers.js +0 -45
  727. package/dist/esm/adapters/ethers.js.map +0 -1
  728. package/dist/esm/ethers.js +0 -2
  729. package/dist/esm/ethers.js.map +0 -1
  730. package/dist/types/adapters/ethers.d.ts +0 -27
  731. package/dist/types/adapters/ethers.d.ts.map +0 -1
  732. package/dist/types/ethers.d.ts +0 -2
  733. package/dist/types/ethers.d.ts.map +0 -1
  734. package/ethers/package.json +0 -5
  735. package/src/adapters/ethers.ts +0 -94
  736. package/src/ethers.ts +0 -1
@@ -14,26 +14,25 @@ import type {
14
14
  RpcTransactionRequest as TransactionRequest,
15
15
  RpcUncle as Uncle,
16
16
  } from './rpc.js'
17
+ import type { Prettify } from './utils.js'
17
18
 
18
19
  //////////////////////////////////////////////////
19
20
  // Provider
20
21
 
21
- export type EIP1193Provider = Requests & Events
22
+ export type EIP1474Methods = [...PublicRpcSchema, ...WalletRpcSchema]
23
+
24
+ export type EIP1193Provider = EIP1193Events & {
25
+ request: EIP1193RequestFn<EIP1474Methods>
26
+ }
22
27
 
23
28
  //////////////////////////////////////////////////
24
29
  // Errors
25
30
 
26
- // rome-ignore format: no formatting
27
- export type RpcErrorCode =
28
- // https://eips.ethereum.org/EIPS/eip-1193#provider-errors
29
- | 4_001 | 4_100 | 4_200 | 4_900 | 4_901
30
- // https://eips.ethereum.org/EIPS/eip-1474#error-codes
31
- | -32700 | -32600 | -32601 | -32602 | -32603 | -32000 | -32001 | -32002 | -32003 | -32004 | -32005 | -32006
32
- export class RpcError extends Error {
33
- code: RpcErrorCode | (number & {})
31
+ export class ProviderRpcError extends Error {
32
+ code: number
34
33
  details: string
35
34
 
36
- constructor(code: RpcErrorCode | (number & {}), message: string) {
35
+ constructor(code: number, message: string) {
37
36
  super(message)
38
37
  this.code = code
39
38
  this.details = message
@@ -52,12 +51,12 @@ export type ProviderMessage = {
52
51
  data: unknown
53
52
  }
54
53
 
55
- export type Events = {
54
+ export type EIP1193Events = {
56
55
  on(
57
56
  event: 'connect',
58
57
  listener: (connectInfo: ProviderConnectInfo) => void,
59
58
  ): void
60
- on(event: 'disconnect', listener: (error: RpcError) => void): void
59
+ on(event: 'disconnect', listener: (error: ProviderRpcError) => void): void
61
60
  on(event: 'chainChanged', listener: (chainId: string) => void): void
62
61
  on(event: 'accountsChanged', listener: (accounts: string[]) => void): void
63
62
  on(event: 'message', listener: (message: ProviderMessage) => void): void
@@ -66,7 +65,10 @@ export type Events = {
66
65
  event: 'connect',
67
66
  listener: (connectInfo: ProviderConnectInfo) => void,
68
67
  ): void
69
- removeListener(event: 'disconnect', listener: (error: RpcError) => void): void
68
+ removeListener(
69
+ event: 'disconnect',
70
+ listener: (error: ProviderRpcError) => void,
71
+ ): void
70
72
  removeListener(
71
73
  event: 'chainChanged',
72
74
  listener: (chainId: string) => void,
@@ -84,7 +86,7 @@ export type Events = {
84
86
  //////////////////////////////////////////////////
85
87
  // Provider Requests
86
88
 
87
- export type Chain = {
89
+ export type AddEthereumChainParameter = {
88
90
  /** A 0x-prefixed hexadecimal string */
89
91
  chainId: string
90
92
  /** The chain name. */
@@ -137,130 +139,153 @@ export type WatchAssetParams = {
137
139
  }
138
140
  }
139
141
 
140
- export type PublicRequests = {
141
- request(args: {
142
- /**
143
- * @description Returns the version of the current client
144
- * @link https://eips.ethereum.org/EIPS/eip-1474
145
- * @example
146
- * provider.request({ method: 'web3_clientVersion' })
147
- * // => 'MetaMask/v1.0.0'
148
- */
149
- method: 'web3_clientVersion'
150
- params?: never
151
- }): Promise<string>
152
- request(args: {
153
- /**
154
- * @description Hashes data using the Keccak-256 algorithm
155
- * @link https://eips.ethereum.org/EIPS/eip-1474
156
- * @example
157
- * provider.request({ method: 'web3_sha3', params: ['0x68656c6c6f20776f726c64'] })
158
- * // => '0xc94770007dda54cF92009BFF0dE90c06F603a09f'
159
- */
160
- method: 'web3_sha3'
161
- params: [data: Hash]
162
- }): Promise<string>
163
- request(args: {
164
- /**
165
- * @description Determines if this client is listening for new network connections
166
- * @link https://eips.ethereum.org/EIPS/eip-1474
167
- * @example
168
- * provider.request({ method: 'net_listening' })
169
- * // => true
170
- */
171
- method: 'net_listening'
172
- params?: never
173
- }): Promise<boolean>
174
- request(args: {
175
- /**
176
- * @description Returns the number of peers currently connected to this client
177
- * @link https://eips.ethereum.org/EIPS/eip-1474
178
- * @example
179
- * provider.request({ method: 'net_peerCount' })
180
- * // => '0x1'
181
- */
182
- method: 'net_peerCount'
183
- params?: never
184
- }): Promise<Quantity>
185
- request(args: {
186
- /**
187
- * @description Returns the chain ID associated with the current network
188
- * @link https://eips.ethereum.org/EIPS/eip-1474
189
- * @example
190
- * provider.request({ method: 'net_version' })
191
- * // => '1'
192
- */
193
- method: 'net_version'
194
- params?: never
195
- }): Promise<Quantity>
196
- request(args: {
197
- /**
198
- * @description Returns the number of the most recent block seen by this client
199
- * @link https://eips.ethereum.org/EIPS/eip-1474
200
- * @example
201
- * provider.request({ method: 'eth_blockNumber' })
202
- * // => '0x1b4'
203
- * */
204
- method: 'eth_blockNumber'
205
- params?: never
206
- }): Promise<Quantity>
207
- request(args: {
208
- /**
209
- * @description Executes a new message call immediately without submitting a transaction to the network
210
- * @link https://eips.ethereum.org/EIPS/eip-1474
211
- * @example
212
- * provider.request({ method: 'eth_call', params: [{ to: '0x...', data: '0x...' }] })
213
- * // => '0x...'
214
- */
215
- method: 'eth_call'
216
- params: [
217
- request: Partial<TransactionRequest>,
218
- block?: BlockNumber | BlockTag | BlockIdentifier,
219
- ]
220
- }): Promise<Hex>
221
- request(args: {
222
- /**
223
- * @description Returns the chain ID associated with the current network
224
- * @example
225
- * provider.request({ method: 'eth_chainId' })
226
- * // => '1'
227
- */
228
- method: 'eth_chainId'
229
- params?: never
230
- }): Promise<Quantity>
231
- request(args: { method: 'eth_coinbase'; params?: never }): Promise<Address>
232
- request(args: {
233
- /**
234
- * @description Estimates the gas necessary to complete a transaction without submitting it to the network
235
- * @link https://eips.ethereum.org/EIPS/eip-1474
236
- * @example
237
- * provider.request({
238
- * method: 'eth_estimateGas',
239
- * params: [{ from: '0x...', to: '0x...', value: '0x...' }]
240
- * })
241
- * // => '0x5208'
242
- * */
243
- method: 'eth_estimateGas'
244
- params: [parameters: TransactionRequest, block?: BlockNumber | BlockTag]
245
- }): Promise<Quantity>
246
- request(args: {
247
- /**
248
- * @description Returns a collection of historical gas information
249
- * @link https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md
250
- * @example
251
- * provider.request({
252
- * method: 'eth_feeHistory',
253
- * params: ['4', 'latest', ['25', '75']]
254
- * })
255
- * // => {
256
- * // oldestBlock: '0x1',
257
- * // baseFeePerGas: ['0x1', '0x2', '0x3', '0x4'],
258
- * // gasUsedRatio: ['0x1', '0x2', '0x3', '0x4'],
259
- * // reward: [['0x1', '0x2'], ['0x3', '0x4'], ['0x5', '0x6'], ['0x7', '0x8']]
260
- * // }
261
- * */
262
- method: 'eth_feeHistory'
263
- params: [
142
+ export type PublicRpcSchema = [
143
+ /**
144
+ * @description Returns the version of the current client
145
+ *
146
+ * @example
147
+ * provider.request({ method: 'web3_clientVersion' })
148
+ * // => 'MetaMask/v1.0.0'
149
+ */
150
+ {
151
+ Method: 'web3_clientVersion'
152
+ Parameters?: never
153
+ ReturnType: string
154
+ },
155
+ /**
156
+ * @description Hashes data using the Keccak-256 algorithm
157
+ *
158
+ * @example
159
+ * provider.request({ method: 'web3_sha3', params: ['0x68656c6c6f20776f726c64'] })
160
+ * // => '0xc94770007dda54cF92009BFF0dE90c06F603a09f'
161
+ */
162
+ {
163
+ Method: 'web3_sha3'
164
+ Parameters: [data: Hash]
165
+ ReturnType: string
166
+ },
167
+ /**
168
+ * @description Determines if this client is listening for new network connections
169
+ *
170
+ * @example
171
+ * provider.request({ method: 'net_listening' })
172
+ * // => true
173
+ */
174
+ {
175
+ Method: 'net_listening'
176
+ Parameters?: never
177
+ ReturnType: boolean
178
+ },
179
+ /**
180
+ * @description Returns the number of peers currently connected to this client
181
+ *
182
+ * @example
183
+ * provider.request({ method: 'net_peerCount' })
184
+ * // => '0x1'
185
+ */
186
+ {
187
+ Method: 'net_peerCount'
188
+ Parameters?: never
189
+ ReturnType: Quantity
190
+ },
191
+ /**
192
+ * @description Returns the chain ID associated with the current network
193
+ *
194
+ * @example
195
+ * provider.request({ method: 'net_version' })
196
+ * // => '1'
197
+ */
198
+ {
199
+ Method: 'net_version'
200
+ Parameters?: never
201
+ ReturnType: Quantity
202
+ },
203
+ /**
204
+ * @description Returns the number of the most recent block seen by this client
205
+ *
206
+ * @example
207
+ * provider.request({ method: 'eth_blockNumber' })
208
+ * // => '0x1b4'
209
+ */
210
+ {
211
+ Method: 'eth_blockNumber'
212
+ Parameters?: never
213
+ ReturnType: Quantity
214
+ },
215
+ /**
216
+ * @description Executes a new message call immediately without submitting a transaction to the network
217
+ *
218
+ * @example
219
+ * provider.request({ method: 'eth_call', params: [{ to: '0x...', data: '0x...' }] })
220
+ * // => '0x...'
221
+ */
222
+ {
223
+ Method: 'eth_call'
224
+ Parameters:
225
+ | [transaction: Partial<TransactionRequest>]
226
+ | [
227
+ transaction: Partial<TransactionRequest>,
228
+ block: BlockNumber | BlockTag | BlockIdentifier,
229
+ ]
230
+ ReturnType: Hex
231
+ },
232
+ /**
233
+ * @description Returns the chain ID associated with the current network
234
+ * @example
235
+ * provider.request({ method: 'eth_chainId' })
236
+ * // => '1'
237
+ */
238
+ {
239
+ Method: 'eth_chainId'
240
+ Parameters?: never
241
+ ReturnType: Quantity
242
+ },
243
+ /**
244
+ * @description Returns the client coinbase address.
245
+ * @example
246
+ * provider.request({ method: 'eth_coinbase' })
247
+ * // => '0x...'
248
+ */
249
+ {
250
+ Method: 'eth_coinbase'
251
+ Parameters?: never
252
+ ReturnType: Address
253
+ },
254
+ /**
255
+ * @description Estimates the gas necessary to complete a transaction without submitting it to the network
256
+ *
257
+ * @example
258
+ * provider.request({
259
+ * method: 'eth_estimateGas',
260
+ * params: [{ from: '0x...', to: '0x...', value: '0x...' }]
261
+ * })
262
+ * // => '0x5208'
263
+ */
264
+ {
265
+ Method: 'eth_estimateGas'
266
+ Parameters:
267
+ | [transaction: TransactionRequest]
268
+ | [transaction: TransactionRequest, block: BlockNumber | BlockTag]
269
+ ReturnType: Quantity
270
+ },
271
+ /**
272
+ * @description Returns a collection of historical gas information
273
+ *
274
+ * @example
275
+ * provider.request({
276
+ * method: 'eth_feeHistory',
277
+ * params: ['4', 'latest', ['25', '75']]
278
+ * })
279
+ * // => {
280
+ * // oldestBlock: '0x1',
281
+ * // baseFeePerGas: ['0x1', '0x2', '0x3', '0x4'],
282
+ * // gasUsedRatio: ['0x1', '0x2', '0x3', '0x4'],
283
+ * // reward: [['0x1', '0x2'], ['0x3', '0x4'], ['0x5', '0x6'], ['0x7', '0x8']]
284
+ * // }
285
+ * */
286
+ {
287
+ Method: 'eth_feeHistory'
288
+ Parameters: [
264
289
  /** Number of blocks in the requested range. Between 1 and 1024 blocks can be requested in a single query. Less than requested may be returned if not all blocks are available. */
265
290
  blockCount: Quantity,
266
291
  /** Highest number block of the requested range. */
@@ -268,137 +293,153 @@ export type PublicRequests = {
268
293
  /** A monotonically increasing list of percentile values to sample from each block's effective priority fees per gas in ascending order, weighted by gas used. */
269
294
  rewardPercentiles: number[] | undefined,
270
295
  ]
271
- }): Promise<FeeHistory>
272
- request(args: {
273
- /**
274
- * @description Returns the current price of gas expressed in wei
275
- * @link https://eips.ethereum.org/EIPS/eip-1474
276
- * @example
277
- * provider.request({ method: 'eth_gasPrice' })
278
- * // => '0x09184e72a000'
279
- * */
280
- method: 'eth_gasPrice'
281
- params?: never
282
- }): Promise<Quantity>
283
- request(args: {
284
- /**
285
- * @description Returns the balance of an address in wei
286
- * @link https://eips.ethereum.org/EIPS/eip-1474
287
- * @example
288
- * provider.request({ method: 'eth_getBalance', params: ['0x...', 'latest'] })
289
- * // => '0x12a05...'
290
- * */
291
- method: 'eth_getBalance'
292
- params: [address: Address, block: BlockNumber | BlockTag | BlockIdentifier]
293
- }): Promise<Quantity>
294
- request(args: {
295
- /**
296
- * @description Returns information about a block specified by hash
297
- * @link https://eips.ethereum.org/EIPS/eip-1474
298
- * @example
299
- * provider.request({ method: 'eth_getBlockByHash', params: ['0x...', true] })
300
- * // => {
301
- * // number: '0x1b4',
302
- * // hash: '0x...',
303
- * // parentHash: '0x...',
304
- * // ...
305
- * // }
306
- * */
307
- method: 'eth_getBlockByHash'
308
- params: [
296
+ ReturnType: FeeHistory
297
+ },
298
+ /**
299
+ * @description Returns the current price of gas expressed in wei
300
+ *
301
+ * @example
302
+ * provider.request({ method: 'eth_gasPrice' })
303
+ * // => '0x09184e72a000'
304
+ */
305
+ {
306
+ Method: 'eth_gasPrice'
307
+ Parameters?: never
308
+ ReturnType: Quantity
309
+ },
310
+ /**
311
+ * @description Returns the balance of an address in wei
312
+ *
313
+ * @example
314
+ * provider.request({ method: 'eth_getBalance', params: ['0x...', 'latest'] })
315
+ * // => '0x12a05...'
316
+ */
317
+ {
318
+ Method: 'eth_getBalance'
319
+ Parameters: [
320
+ address: Address,
321
+ block: BlockNumber | BlockTag | BlockIdentifier,
322
+ ]
323
+ ReturnType: Quantity
324
+ },
325
+ /**
326
+ * @description Returns information about a block specified by hash
327
+ * @link https://eips.ethereum.org/EIPS/eip-1474
328
+ * @example
329
+ * provider.request({ method: 'eth_getBlockByHash', params: ['0x...', true] })
330
+ * // => {
331
+ * // number: '0x1b4',
332
+ * // hash: '0x...',
333
+ * // parentHash: '0x...',
334
+ * // ...
335
+ * // }
336
+ */
337
+ {
338
+ Method: 'eth_getBlockByHash'
339
+ Parameters: [
309
340
  /** hash of a block */
310
341
  hash: Hash,
311
342
  /** true will pull full transaction objects, false will pull transaction hashes */
312
343
  includeTransactionObjects: boolean,
313
344
  ]
314
- }): Promise<Block | null>
315
- request(args: {
316
- /**
317
- * @description Returns information about a block specified by number
318
- * @link https://eips.ethereum.org/EIPS/eip-1474
319
- * @example
320
- * provider.request({ method: 'eth_getBlockByNumber', params: ['0x1b4', true] })
321
- * // => {
322
- * // number: '0x1b4',
323
- * // hash: '0x...',
324
- * // parentHash: '0x...',
325
- * // ...
326
- * // }
327
- * */
328
- method: 'eth_getBlockByNumber'
329
- params: [
345
+ ReturnType: Block | null
346
+ },
347
+ /**
348
+ * @description Returns information about a block specified by number
349
+ * @link https://eips.ethereum.org/EIPS/eip-1474
350
+ * @example
351
+ * provider.request({ method: 'eth_getBlockByNumber', params: ['0x1b4', true] })
352
+ * // => {
353
+ * // number: '0x1b4',
354
+ * // hash: '0x...',
355
+ * // parentHash: '0x...',
356
+ * // ...
357
+ * // }
358
+ */
359
+ {
360
+ Method: 'eth_getBlockByNumber'
361
+ Parameters: [
330
362
  /** block number, or one of "latest", "safe", "finalized", "earliest" or "pending" */
331
363
  block: BlockNumber | BlockTag,
332
364
  /** true will pull full transaction objects, false will pull transaction hashes */
333
365
  includeTransactionObjects: boolean,
334
366
  ]
335
- }): Promise<Block | null>
336
- request(args: {
337
- /**
338
- * @description Returns the number of transactions in a block specified by block hash
339
- * @link https://eips.ethereum.org/EIPS/eip-1474
340
- * @example
341
- * provider.request({ method: 'eth_getBlockTransactionCountByHash', params: ['0x...'] })
342
- * // => '0x1'
343
- * */
344
- method: 'eth_getBlockTransactionCountByHash'
345
- params: [hash: Hash]
346
- }): Promise<Quantity>
347
- request(args: {
348
- /**
349
- * @description Returns the number of transactions in a block specified by block number
350
- * @link https://eips.ethereum.org/EIPS/eip-1474
351
- * @example
352
- * provider.request({ method: 'eth_getBlockTransactionCountByNumber', params: ['0x1b4'] })
353
- * // => '0x1'
354
- * */
355
- method: 'eth_getBlockTransactionCountByNumber'
356
- params: [block: BlockNumber | BlockTag]
357
- }): Promise<Quantity>
358
- request(args: {
359
- /**
360
- * @description Returns the contract code stored at a given address
361
- * @link https://eips.ethereum.org/EIPS/eip-1474
362
- * @example
363
- * provider.request({ method: 'eth_getCode', params: ['0x...', 'latest'] })
364
- * // => '0x...'
365
- * */
366
- method: 'eth_getCode'
367
- params: [address: Address, block: BlockNumber | BlockTag | BlockIdentifier]
368
- }): Promise<Hex>
369
- request(args: {
370
- /**
371
- * @description Returns a list of all logs based on filter ID since the last log retrieval
372
- * @link https://eips.ethereum.org/EIPS/eip-1474
373
- * @example
374
- * provider.request({ method: 'eth_getFilterChanges', params: ['0x...'] })
375
- * // => [{ ... }, { ... }]
376
- * */
377
- method: 'eth_getFilterChanges'
378
- params: [filterId: Quantity]
379
- }): Promise<Log[] | Hex[]>
380
- request(args: {
381
- /**
382
- * @description Returns a list of all logs based on filter ID
383
- * @link https://eips.ethereum.org/EIPS/eip-1474
384
- * @example
385
- * provider.request({ method: 'eth_getFilterLogs', params: ['0x...'] })
386
- * // => [{ ... }, { ... }]
387
- * */
388
- method: 'eth_getFilterLogs'
389
- params: [filterId: Quantity]
390
- }): Promise<Log[]>
391
- request(args: {
392
- /**
393
- * @description Returns a list of all logs based on a filter object
394
- * @link https://eips.ethereum.org/EIPS/eip-1474
395
- * @example
396
- * provider.request({ method: 'eth_getLogs', params: [{ fromBlock: '0x...', toBlock: '0x...', address: '0x...', topics: ['0x...'] }] })
397
- * // => [{ ... }, { ... }]
398
- * */
399
- method: 'eth_getLogs'
400
- params: [
401
- parameters: {
367
+ ReturnType: Block | null
368
+ },
369
+ /**
370
+ * @description Returns the number of transactions in a block specified by block hash
371
+ * @link https://eips.ethereum.org/EIPS/eip-1474
372
+ * @example
373
+ * provider.request({ method: 'eth_getBlockTransactionCountByHash', params: ['0x...'] })
374
+ * // => '0x1'
375
+ */
376
+ {
377
+ Method: 'eth_getBlockTransactionCountByHash'
378
+ Parameters: [hash: Hash]
379
+ ReturnType: Quantity
380
+ },
381
+ /**
382
+ * @description Returns the number of transactions in a block specified by block number
383
+ * @link https://eips.ethereum.org/EIPS/eip-1474
384
+ * @example
385
+ * provider.request({ method: 'eth_getBlockTransactionCountByNumber', params: ['0x1b4'] })
386
+ * // => '0x1'
387
+ */
388
+ {
389
+ Method: 'eth_getBlockTransactionCountByNumber'
390
+ Parameters: [block: BlockNumber | BlockTag]
391
+ ReturnType: Quantity
392
+ },
393
+ /**
394
+ * @description Returns the contract code stored at a given address
395
+ * @link https://eips.ethereum.org/EIPS/eip-1474
396
+ * @example
397
+ * provider.request({ method: 'eth_getCode', params: ['0x...', 'latest'] })
398
+ * // => '0x...'
399
+ */
400
+ {
401
+ Method: 'eth_getCode'
402
+ Parameters: [
403
+ address: Address,
404
+ block: BlockNumber | BlockTag | BlockIdentifier,
405
+ ]
406
+ ReturnType: Hex
407
+ },
408
+ /**
409
+ * @description Returns a list of all logs based on filter ID since the last log retrieval
410
+ * @link https://eips.ethereum.org/EIPS/eip-1474
411
+ * @example
412
+ * provider.request({ method: 'eth_getFilterChanges', params: ['0x...'] })
413
+ * // => [{ ... }, { ... }]
414
+ */
415
+ {
416
+ Method: 'eth_getFilterChanges'
417
+ Parameters: [filterId: Quantity]
418
+ ReturnType: Log[] | Hex[]
419
+ },
420
+ /**
421
+ * @description Returns a list of all logs based on filter ID
422
+ * @link https://eips.ethereum.org/EIPS/eip-1474
423
+ * @example
424
+ * provider.request({ method: 'eth_getFilterLogs', params: ['0x...'] })
425
+ * // => [{ ... }, { ... }]
426
+ */
427
+ {
428
+ Method: 'eth_getFilterLogs'
429
+ Parameters: [filterId: Quantity]
430
+ ReturnType: Log[]
431
+ },
432
+ /**
433
+ * @description Returns a list of all logs based on a filter object
434
+ * @link https://eips.ethereum.org/EIPS/eip-1474
435
+ * @example
436
+ * provider.request({ method: 'eth_getLogs', params: [{ fromBlock: '0x...', toBlock: '0x...', address: '0x...', topics: ['0x...'] }] })
437
+ * // => [{ ... }, { ... }]
438
+ */
439
+ {
440
+ Method: 'eth_getLogs'
441
+ Parameters: [
442
+ {
402
443
  address?: Address | Address[]
403
444
  topics?: LogTopic[]
404
445
  } & (
@@ -414,142 +455,157 @@ export type PublicRequests = {
414
455
  }
415
456
  ),
416
457
  ]
417
- }): Promise<Log[]>
418
- request(args: {
419
- /**
420
- * @description Returns the value from a storage position at an address
421
- * @link https://eips.ethereum.org/EIPS/eip-1474
422
- * @example
423
- * provider.request({ method: 'eth_getStorageAt', params: ['0x...', '0x...', 'latest'] })
424
- * // => '0x...'
425
- * */
426
- method: 'eth_getStorageAt'
427
- params: [
458
+ ReturnType: Log[]
459
+ },
460
+ /**
461
+ * @description Returns the value from a storage position at an address
462
+ * @link https://eips.ethereum.org/EIPS/eip-1474
463
+ * @example
464
+ * provider.request({ method: 'eth_getStorageAt', params: ['0x...', '0x...', 'latest'] })
465
+ * // => '0x...'
466
+ */
467
+ {
468
+ Method: 'eth_getStorageAt'
469
+ Parameters: [
428
470
  address: Address,
429
471
  index: Quantity,
430
472
  block: BlockNumber | BlockTag | BlockIdentifier,
431
473
  ]
432
- }): Promise<Hex>
433
- request(args: {
434
- /**
435
- * @description Returns information about a transaction specified by block hash and transaction index
436
- * @link https://eips.ethereum.org/EIPS/eip-1474
437
- * @example
438
- * provider.request({ method: 'eth_getTransactionByBlockHashAndIndex', params: ['0x...', '0x...'] })
439
- * // => { ... }
440
- * */
441
- method: 'eth_getTransactionByBlockHashAndIndex'
442
- params: [hash: Hash, index: Quantity]
443
- }): Promise<Transaction | null>
444
- request(args: {
445
- /**
446
- * @description Returns information about a transaction specified by block number and transaction index
447
- * @link https://eips.ethereum.org/EIPS/eip-1474
448
- * @example
449
- * provider.request({ method: 'eth_getTransactionByBlockNumberAndIndex', params: ['0x...', '0x...'] })
450
- * // => { ... }
451
- * */
452
- method: 'eth_getTransactionByBlockNumberAndIndex'
453
- params: [block: BlockNumber | BlockTag, index: Quantity]
454
- }): Promise<Transaction | null>
455
- request(args: {
456
- /**
457
- * @description Returns information about a transaction specified by hash
458
- * @link https://eips.ethereum.org/EIPS/eip-1474
459
- * @example
460
- * provider.request({ method: 'eth_getTransactionByHash', params: ['0x...'] })
461
- * // => { ... }
462
- * */
463
- method: 'eth_getTransactionByHash'
464
- params: [hash: Hash]
465
- }): Promise<Transaction | null>
466
- request(args: {
467
- /**
468
- * @description Returns the number of transactions sent from an address
469
- * @link https://eips.ethereum.org/EIPS/eip-1474
470
- * @example
471
- * provider.request({ method: 'eth_getTransactionCount', params: ['0x...', 'latest'] })
472
- * // => '0x1'
473
- * */
474
- method: 'eth_getTransactionCount'
475
- params: [address: Address, block: BlockNumber | BlockTag | BlockIdentifier]
476
- }): Promise<Quantity>
477
- request(args: {
478
- /**
479
- * @description Returns the receipt of a transaction specified by hash
480
- * @link https://eips.ethereum.org/EIPS/eip-1474
481
- * @example
482
- * provider.request({ method: 'eth_getTransactionReceipt', params: ['0x...'] })
483
- * // => { ... }
484
- * */
485
- method: 'eth_getTransactionReceipt'
486
- params: [hash: Hash]
487
- }): Promise<TransactionReceipt | null>
488
- request(args: {
489
- /**
490
- * @description Returns information about an uncle specified by block hash and uncle index position
491
- * @link https://eips.ethereum.org/EIPS/eip-1474
492
- * @example
493
- * provider.request({ method: 'eth_getUncleByBlockHashAndIndex', params: ['0x...', '0x...'] })
494
- * // => { ... }
495
- * */
496
- method: 'eth_getUncleByBlockHashAndIndex'
497
- params: [hash: Hash, index: Quantity]
498
- }): Promise<Uncle | null>
499
- request(args: {
500
- /**
501
- * @description Returns information about an uncle specified by block number and uncle index position
502
- * @link https://eips.ethereum.org/EIPS/eip-1474
503
- * @example
504
- * provider.request({ method: 'eth_getUncleByBlockNumberAndIndex', params: ['0x...', '0x...'] })
505
- * // => { ... }
506
- * */
507
- method: 'eth_getUncleByBlockNumberAndIndex'
508
- params: [block: BlockNumber | BlockTag, index: Quantity]
509
- }): Promise<Uncle | null>
510
- request(args: {
511
- /**
512
- * @description Returns the number of uncles in a block specified by block hash
513
- * @link https://eips.ethereum.org/EIPS/eip-1474
514
- * @example
515
- * provider.request({ method: 'eth_getUncleCountByBlockHash', params: ['0x...'] })
516
- * // => '0x1'
517
- * */
518
- method: 'eth_getUncleCountByBlockHash'
519
- params: [hash: Hash]
520
- }): Promise<Quantity>
521
- request(args: {
522
- /**
523
- * @description Returns the number of uncles in a block specified by block number
524
- * @link https://eips.ethereum.org/EIPS/eip-1474
525
- * @example
526
- * provider.request({ method: 'eth_getUncleCountByBlockNumber', params: ['0x...'] })
527
- * // => '0x1'
528
- * */
529
- method: 'eth_getUncleCountByBlockNumber'
530
- params: [block: BlockNumber | BlockTag]
531
- }): Promise<Quantity>
532
- request(args: {
533
- /**
534
- * @description Creates a filter to listen for new blocks that can be used with `eth_getFilterChanges`
535
- * @link https://eips.ethereum.org/EIPS/eip-1474
536
- * @example
537
- * provider.request({ method: 'eth_newBlockFilter' })
538
- * // => '0x1'
539
- * */
540
- method: 'eth_newBlockFilter'
541
- params?: never
542
- }): Promise<Quantity>
543
- request(args: {
544
- /**
545
- * @description Creates a filter to listen for specific state changes that can then be used with `eth_getFilterChanges`
546
- * @link https://eips.ethereum.org/EIPS/eip-1474
547
- * @example
548
- * provider.request({ method: 'eth_newFilter', params: [{ fromBlock: '0x...', toBlock: '0x...', address: '0x...', topics: ['0x...'] }] })
549
- * // => '0x1'
550
- * */
551
- method: 'eth_newFilter'
552
- params: [
474
+ ReturnType: Hex
475
+ },
476
+ /**
477
+ * @description Returns information about a transaction specified by block hash and transaction index
478
+ * @link https://eips.ethereum.org/EIPS/eip-1474
479
+ * @example
480
+ * provider.request({ method: 'eth_getTransactionByBlockHashAndIndex', params: ['0x...', '0x...'] })
481
+ * // => { ... }
482
+ */
483
+ {
484
+ Method: 'eth_getTransactionByBlockHashAndIndex'
485
+ Parameters: [hash: Hash, index: Quantity]
486
+ ReturnType: Transaction | null
487
+ },
488
+ /**
489
+ * @description Returns information about a transaction specified by block number and transaction index
490
+ * @link https://eips.ethereum.org/EIPS/eip-1474
491
+ * @example
492
+ * provider.request({ method: 'eth_getTransactionByBlockNumberAndIndex', params: ['0x...', '0x...'] })
493
+ * // => { ... }
494
+ */
495
+ {
496
+ Method: 'eth_getTransactionByBlockNumberAndIndex'
497
+ Parameters: [block: BlockNumber | BlockTag, index: Quantity]
498
+ ReturnType: Transaction | null
499
+ },
500
+ /**
501
+ * @description Returns information about a transaction specified by hash
502
+ * @link https://eips.ethereum.org/EIPS/eip-1474
503
+ * @example
504
+ * provider.request({ method: 'eth_getTransactionByHash', params: ['0x...'] })
505
+ * // => { ... }
506
+ */
507
+ {
508
+ Method: 'eth_getTransactionByHash'
509
+ Parameters: [hash: Hash]
510
+ ReturnType: Transaction | null
511
+ },
512
+ /**
513
+ * @description Returns the number of transactions sent from an address
514
+ * @link https://eips.ethereum.org/EIPS/eip-1474
515
+ * @example
516
+ * provider.request({ method: 'eth_getTransactionCount', params: ['0x...', 'latest'] })
517
+ * // => '0x1'
518
+ */
519
+ {
520
+ Method: 'eth_getTransactionCount'
521
+ Parameters: [
522
+ address: Address,
523
+ block: BlockNumber | BlockTag | BlockIdentifier,
524
+ ]
525
+ ReturnType: Quantity
526
+ },
527
+ /**
528
+ * @description Returns the receipt of a transaction specified by hash
529
+ * @link https://eips.ethereum.org/EIPS/eip-1474
530
+ * @example
531
+ * provider.request({ method: 'eth_getTransactionReceipt', params: ['0x...'] })
532
+ * // => { ... }
533
+ */
534
+ {
535
+ Method: 'eth_getTransactionReceipt'
536
+ Parameters: [hash: Hash]
537
+ ReturnType: TransactionReceipt | null
538
+ },
539
+ /**
540
+ * @description Returns information about an uncle specified by block hash and uncle index position
541
+ * @link https://eips.ethereum.org/EIPS/eip-1474
542
+ * @example
543
+ * provider.request({ method: 'eth_getUncleByBlockHashAndIndex', params: ['0x...', '0x...'] })
544
+ * // => { ... }
545
+ */
546
+ {
547
+ Method: 'eth_getUncleByBlockHashAndIndex'
548
+ Parameters: [hash: Hash, index: Quantity]
549
+ ReturnType: Uncle | null
550
+ },
551
+ /**
552
+ * @description Returns information about an uncle specified by block number and uncle index position
553
+ * @link https://eips.ethereum.org/EIPS/eip-1474
554
+ * @example
555
+ * provider.request({ method: 'eth_getUncleByBlockNumberAndIndex', params: ['0x...', '0x...'] })
556
+ * // => { ... }
557
+ */
558
+ {
559
+ Method: 'eth_getUncleByBlockNumberAndIndex'
560
+ Parameters: [block: BlockNumber | BlockTag, index: Quantity]
561
+ ReturnType: Uncle | null
562
+ },
563
+ /**
564
+ * @description Returns the number of uncles in a block specified by block hash
565
+ * @link https://eips.ethereum.org/EIPS/eip-1474
566
+ * @example
567
+ * provider.request({ method: 'eth_getUncleCountByBlockHash', params: ['0x...'] })
568
+ * // => '0x1'
569
+ */
570
+ {
571
+ Method: 'eth_getUncleCountByBlockHash'
572
+ Parameters: [hash: Hash]
573
+ ReturnType: Quantity
574
+ },
575
+ /**
576
+ * @description Returns the number of uncles in a block specified by block number
577
+ * @link https://eips.ethereum.org/EIPS/eip-1474
578
+ * @example
579
+ * provider.request({ method: 'eth_getUncleCountByBlockNumber', params: ['0x...'] })
580
+ * // => '0x1'
581
+ */
582
+ {
583
+ Method: 'eth_getUncleCountByBlockNumber'
584
+ Parameters: [block: BlockNumber | BlockTag]
585
+ ReturnType: Quantity
586
+ },
587
+ /**
588
+ * @description Creates a filter to listen for new blocks that can be used with `eth_getFilterChanges`
589
+ * @link https://eips.ethereum.org/EIPS/eip-1474
590
+ * @example
591
+ * provider.request({ method: 'eth_newBlockFilter' })
592
+ * // => '0x1'
593
+ */
594
+ {
595
+ Method: 'eth_newBlockFilter'
596
+ Parameters?: never
597
+ ReturnType: Quantity
598
+ },
599
+ /**
600
+ * @description Creates a filter to listen for specific state changes that can then be used with `eth_getFilterChanges`
601
+ * @link https://eips.ethereum.org/EIPS/eip-1474
602
+ * @example
603
+ * provider.request({ method: 'eth_newFilter', params: [{ fromBlock: '0x...', toBlock: '0x...', address: '0x...', topics: ['0x...'] }] })
604
+ * // => '0x1'
605
+ */
606
+ {
607
+ Method: 'eth_newFilter'
608
+ Parameters: [
553
609
  filter: {
554
610
  fromBlock?: BlockNumber | BlockTag
555
611
  toBlock?: BlockNumber | BlockTag
@@ -557,204 +613,222 @@ export type PublicRequests = {
557
613
  topics?: LogTopic[]
558
614
  },
559
615
  ]
560
- }): Promise<Quantity>
561
- request(args: {
562
- /**
563
- * @description Creates a filter to listen for new pending transactions that can be used with `eth_getFilterChanges`
564
- * @link https://eips.ethereum.org/EIPS/eip-1474
565
- * @example
566
- * provider.request({ method: 'eth_newPendingTransactionFilter' })
567
- * // => '0x1'
568
- * */
569
- method: 'eth_newPendingTransactionFilter'
570
- params?: never
571
- }): Promise<Quantity>
572
- request(args: {
573
- /**
574
- * @description Returns the current Ethereum protocol version
575
- * @link https://eips.ethereum.org/EIPS/eip-1474
576
- * @example
577
- * provider.request({ method: 'eth_protocolVersion' })
578
- * // => '54'
579
- * */
580
- method: 'eth_protocolVersion'
581
- params?: never
582
- }): Promise<string>
583
- request(args: {
584
- /**
585
- * @description Sends and already-signed transaction to the network
586
- * @link https://eips.ethereum.org/EIPS/eip-1474
587
- * @example
588
- * provider.request({ method: 'eth_sendRawTransaction', params: ['0x...'] })
589
- * // => '0x...'
590
- * */
591
- method: 'eth_sendRawTransaction'
592
- params: [signedTransaction: Hex]
593
- }): Promise<Hex>
594
- request(args: {
595
- /**
596
- * @description Destroys a filter based on filter ID
597
- * @link https://eips.ethereum.org/EIPS/eip-1474
598
- * @example
599
- * provider.request({ method: 'eth_uninstallFilter', params: ['0x1'] })
600
- * // => true
601
- * */
602
- method: 'eth_uninstallFilter'
603
- params: [
604
- /** ID of the filter to destroy */
605
- filterId: Quantity,
606
- ]
607
- }): Promise<boolean>
608
- }
616
+ ReturnType: Quantity
617
+ },
618
+ /**
619
+ * @description Creates a filter to listen for new pending transactions that can be used with `eth_getFilterChanges`
620
+ * @link https://eips.ethereum.org/EIPS/eip-1474
621
+ * @example
622
+ * provider.request({ method: 'eth_newPendingTransactionFilter' })
623
+ * // => '0x1'
624
+ */
625
+ {
626
+ Method: 'eth_newPendingTransactionFilter'
627
+ Parameters?: never
628
+ ReturnType: Quantity
629
+ },
630
+ /**
631
+ * @description Returns the current Ethereum protocol version
632
+ * @link https://eips.ethereum.org/EIPS/eip-1474
633
+ * @example
634
+ * provider.request({ method: 'eth_protocolVersion' })
635
+ * // => '54'
636
+ */
637
+ {
638
+ Method: 'eth_protocolVersion'
639
+ Parameters?: never
640
+ ReturnType: string
641
+ },
642
+ /**
643
+ * @description Sends and already-signed transaction to the network
644
+ * @link https://eips.ethereum.org/EIPS/eip-1474
645
+ * @example
646
+ * provider.request({ method: 'eth_sendRawTransaction', params: ['0x...'] })
647
+ * // => '0x...'
648
+ */
649
+ {
650
+ Method: 'eth_sendRawTransaction'
651
+ Parameters: [signedTransaction: Hex]
652
+ ReturnType: Hash
653
+ },
654
+ /**
655
+ * @description Destroys a filter based on filter ID
656
+ * @link https://eips.ethereum.org/EIPS/eip-1474
657
+ * @example
658
+ * provider.request({ method: 'eth_uninstallFilter', params: ['0x1'] })
659
+ * // => true
660
+ */
661
+ {
662
+ Method: 'eth_uninstallFilter'
663
+ Parameters: [filterId: Quantity]
664
+ ReturnType: boolean
665
+ },
666
+ ]
609
667
 
610
- export type TestRequests<Name extends string> = {
611
- request(args: {
612
- /**
613
- * @description Add information about compiled contracts
614
- * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_addcompilationresult
615
- */
616
- method: `${Name}_addCompilationResult`
617
- params: any[]
618
- }): Promise<any>
619
- request(args: {
620
- /**
621
- * @description Remove a transaction from the mempool
622
- * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_droptransaction
623
- */
624
- method: `${Name}_dropTransaction`
625
- params: [hash: Hash]
626
- }): Promise<void>
627
- request(args: {
628
- /**
629
- * @description Turn on call traces for transactions that are returned to the user when they execute a transaction (instead of just txhash/receipt).
630
- */
631
- method: `${Name}_enableTraces`
632
- params?: never
633
- }): Promise<void>
634
- request(args: {
635
- /**
636
- * @description Impersonate an account or contract address.
637
- * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_impersonateaccount
638
- */
639
- method: `${Name}_impersonateAccount`
640
- params: [address: Address]
641
- }): Promise<void>
642
- request(args: {
643
- /**
644
- * @description Returns true if automatic mining is enabled, and false otherwise. See [Mining Modes](https://hardhat.org/hardhat-network/explanation/mining-modes) to learn more.
645
- * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_getautomine
646
- */
647
- method: `${Name}_getAutomine`
648
- }): Promise<boolean>
649
- request(args: {
650
- /**
651
- * @description Advance the block number of the network by a certain number of blocks
652
- * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_mine
653
- */
654
- method: `${Name}_mine`
655
- params: [
668
+ export type TestRpcSchema<TMode extends string> = [
669
+ /**
670
+ * @description Add information about compiled contracts
671
+ * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_addcompilationresult
672
+ */
673
+ {
674
+ Method: `${TMode}_addCompilationResult`
675
+ Parameters: any[]
676
+ ReturnType: any
677
+ },
678
+ /**
679
+ * @description Remove a transaction from the mempool
680
+ * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_droptransaction
681
+ */
682
+ {
683
+ Method: `${TMode}_dropTransaction`
684
+ Parameters: [hash: Hash]
685
+ ReturnType: void
686
+ },
687
+ /**
688
+ * @description Turn on call traces for transactions that are returned to the user when they execute a transaction (instead of just txhash/receipt).
689
+ */
690
+ {
691
+ Method: `${TMode}_enableTraces`
692
+ Parameters?: never
693
+ ReturnType: void
694
+ },
695
+ /**
696
+ * @description Impersonate an account or contract address.
697
+ * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_impersonateaccount
698
+ */
699
+ {
700
+ Method: `${TMode}_impersonateAccount`
701
+ Parameters: [address: Address]
702
+ ReturnType: void
703
+ },
704
+ /**
705
+ * @description Returns true if automatic mining is enabled, and false otherwise. See [Mining Modes](https://hardhat.org/hardhat-network/explanation/mining-modes) to learn more.
706
+ * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_getautomine
707
+ */
708
+ {
709
+ Method: `${TMode}_getAutomine`
710
+ Parameters?: never
711
+ ReturnType: boolean
712
+ },
713
+ /**
714
+ * @description Advance the block number of the network by a certain number of blocks
715
+ * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_mine
716
+ */
717
+ {
718
+ Method: `${TMode}_mine`
719
+ Parameters: [
656
720
  /** Number of blocks to mine. */
657
721
  count: Hex,
658
722
  /** Interval between each block in seconds. */
659
723
  interval: Hex | undefined,
660
724
  ]
661
- }): Promise<void>
662
- request(args: {
663
- /**
664
- * @description Resets the fork.
665
- * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_reset
666
- */
667
- method: `${Name}_reset`
668
- params: any[]
669
- }): Promise<void>
670
- request(args: {
671
- /**
672
- * @description Modifies the balance of an account.
673
- * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_setbalance
674
- */
675
- method: `${Name}_setBalance`
676
- params: [
725
+ ReturnType: void
726
+ },
727
+ /**
728
+ * @description Resets the fork.
729
+ * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_reset
730
+ */
731
+ {
732
+ Method: `${TMode}_reset`
733
+ Parameters: any[]
734
+ ReturnType: void
735
+ },
736
+ /**
737
+ * @description Modifies the balance of an account.
738
+ * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_setbalance
739
+ */
740
+ {
741
+ Method: `${TMode}_setBalance`
742
+ Parameters: [
677
743
  /** The address of the target account. */
678
744
  address: Address,
679
745
  /** Amount to send in wei. */
680
- value: Quantity,
746
+ balance: Quantity,
681
747
  ]
682
- }): Promise<void>
683
- request(args: {
684
- /**
685
- * @description Modifies the bytecode stored at an account's address.
686
- * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_setcode
687
- */
688
- method: `${Name}_setCode`
689
- params: [
748
+ ReturnType: void
749
+ },
750
+ /**
751
+ * @description Modifies the bytecode stored at an account's address.
752
+ * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_setcode
753
+ */
754
+ {
755
+ Method: `${TMode}_setCode`
756
+ Parameters: [
690
757
  /** The address of the contract. */
691
758
  address: Address,
692
759
  /** Data bytecode. */
693
760
  data: string,
694
761
  ]
695
- }): Promise<void>
696
- request(args: {
697
- /**
698
- * @description Sets the coinbase address to be used in new blocks.
699
- * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_setcoinbase
700
- */
701
- method: `${Name}_setCoinbase`
702
- params: [
762
+ ReturnType: void
763
+ },
764
+ /**
765
+ * @description Sets the coinbase address to be used in new blocks.
766
+ * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_setcoinbase
767
+ */
768
+ {
769
+ Method: `${TMode}_setCoinbase`
770
+ Parameters: [
703
771
  /** The address to set as the coinbase address. */
704
772
  address: Address,
705
773
  ]
706
- }): Promise<void>
707
- request(args: {
708
- /**
709
- * @description Enable or disable logging on the test node network.
710
- * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_setcoinbase
711
- */
712
- method: `${Name}_setLoggingEnabled`
713
- params: [enabled: boolean]
714
- }): Promise<void>
715
- request(args: {
716
- /**
717
- * @description Change the minimum gas price accepted by the network (in wei).
718
- * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_setmingasprice
719
- */
720
- method: `${Name}_setMinGasPrice`
721
- params: [gasPrice: Quantity]
722
- }): Promise<void>
723
- request(args: {
724
- /**
725
- * @description Sets the base fee of the next block.
726
- * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_setnextblockbasefeepergas
727
- */
728
- method: `${Name}_setNextBlockBaseFeePerGas`
729
- params: [baseFeePerGas: Quantity]
730
- }): Promise<void>
731
- request(args: {
732
- /**
733
- * @description Modifies an account's nonce by overwriting it.
734
- * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_setnonce
735
- */
736
- method: `${Name}_setNonce`
737
- params: [
774
+ ReturnType: void
775
+ },
776
+ /**
777
+ * @description Enable or disable logging on the test node network.
778
+ * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_setcoinbase
779
+ */
780
+ {
781
+ Method: `${TMode}_setLoggingEnabled`
782
+ Parameters: [enabled: boolean]
783
+ ReturnType: void
784
+ },
785
+ /**
786
+ * @description Change the minimum gas price accepted by the network (in wei).
787
+ * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_setmingasprice
788
+ */
789
+ {
790
+ Method: `${TMode}_setMinGasPrice`
791
+ Parameters: [gasPrice: Quantity]
792
+ ReturnType: void
793
+ },
794
+ /**
795
+ * @description Sets the base fee of the next block.
796
+ * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_setnextblockbasefeepergas
797
+ */
798
+ {
799
+ Method: `${TMode}_setNextBlockBaseFeePerGas`
800
+ Parameters: [baseFeePerGas: Quantity]
801
+ ReturnType: void
802
+ },
803
+ /**
804
+ * @description Modifies an account's nonce by overwriting it.
805
+ * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_setnonce
806
+ */
807
+ {
808
+ Method: `${TMode}_setNonce`
809
+ Parameters: [
738
810
  /** The account address. */
739
811
  address: Address,
740
812
  /** The new nonce. */
741
813
  nonce: Quantity,
742
814
  ]
743
- }): Promise<void>
744
- request(args: {
745
- /**
746
- * @description Sets the backend RPC URL.
747
- */
748
- method: `${Name}_setRpcUrl`
749
- params: [url: string]
750
- }): Promise<void>
751
- request(args: {
752
- /**
753
- * @description Writes a single position of an account's storage.
754
- * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_setstorageat
755
- */
756
- method: `${Name}_setStorageAt`
757
- params: [
815
+ ReturnType: void
816
+ },
817
+ /**
818
+ * @description Sets the backend RPC URL.
819
+ */
820
+ {
821
+ Method: `${TMode}_setRpcUrl`
822
+ Parameters: [url: string]
823
+ ReturnType: void
824
+ },
825
+ /**
826
+ * @description Writes a single position of an account's storage.
827
+ * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_setstorageat
828
+ */
829
+ {
830
+ Method: `${TMode}_setStorageAt`
831
+ Parameters: [
758
832
  /** The account address. */
759
833
  address: Address,
760
834
  /** The storage position index. */
@@ -762,302 +836,482 @@ export type TestRequests<Name extends string> = {
762
836
  /** The storage value. */
763
837
  value: Quantity,
764
838
  ]
765
- }): Promise<void>
766
- request(args: {
767
- /**
768
- * @description Use this method to stop impersonating an account after having previously used impersonateAccount.
769
- * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_stopimpersonatingaccount
770
- */
771
- method: `${Name}_stopImpersonatingAccount`
772
- params: [
839
+ ReturnType: void
840
+ },
841
+ /**
842
+ * @description Use this method to stop impersonating an account after having previously used impersonateAccount.
843
+ * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_stopimpersonatingaccount
844
+ */
845
+ {
846
+ Method: `${TMode}_stopImpersonatingAccount`
847
+ Parameters: [
773
848
  /** The address to stop impersonating. */
774
849
  address: Address,
775
850
  ]
776
- }): Promise<void>
777
- request(args: {
778
- /**
779
- * @description Jump forward in time by the given amount of time, in seconds.
780
- * @link https://github.com/trufflesuite/ganache/blob/ef1858d5d6f27e4baeb75cccd57fb3dc77a45ae8/src/chains/ethereum/ethereum/RPC-METHODS.md#evm_increasetime
781
- */
782
- method: 'evm_increaseTime'
783
- params: [seconds: Quantity]
784
- }): Promise<Quantity>
785
- request(args: {
786
- /**
787
- * @description Enables or disables, based on the single boolean argument, the automatic mining of new blocks with each new transaction submitted to the network.
788
- * @link https://hardhat.org/hardhat-network/docs/reference#evm_setautomine
789
- */
790
- method: 'evm_setAutomine'
791
- params: [boolean]
792
- }): Promise<void>
793
- request(args: {
794
- /**
795
- * @description Sets the block's gas limit.
796
- * @link https://hardhat.org/hardhat-network/docs/reference#evm_setblockgaslimit
797
- */
798
- method: 'evm_setBlockGasLimit'
799
- params: [gasLimit: Quantity]
800
- }): Promise<void>
801
- request(args: {
802
- /**
803
- * @description Similar to `evm_increaseTime` but sets a block timestamp `interval`.
804
- * The timestamp of the next block will be computed as `lastBlock_timestamp` + `interval`
805
- */
806
- method: `${Name}_setBlockTimestampInterval`
807
- params: [seconds: number]
808
- }): Promise<void>
809
- request(args: {
810
- /**
811
- * @description Removes `setBlockTimestampInterval` if it exists
812
- */
813
- method: `${Name}_removeBlockTimestampInterval`
814
- }): Promise<void>
815
- request(args: {
816
- /**
817
- * @description Enables (with a numeric argument greater than 0) or disables (with a numeric argument equal to 0), the automatic mining of blocks at a regular interval of milliseconds, each of which will include all pending transactions.
818
- * @link https://hardhat.org/hardhat-network/docs/reference#evm_setintervalmining
819
- */
820
- method: 'evm_setIntervalMining'
821
- params: [number]
822
- }): Promise<void>
823
- request(args: {
824
- /**
825
- * @description Set the timestamp of the next block.
826
- * @link https://hardhat.org/hardhat-network/docs/reference#evm_setnextblocktimestamp
827
- */
828
- method: 'evm_setNextBlockTimestamp'
829
- params: [Quantity]
830
- }): Promise<void>
831
- request(args: {
832
- /**
833
- * @description Snapshot the state of the blockchain at the current block. Takes no parameters. Returns the id of the snapshot that was created.
834
- * @link https://hardhat.org/hardhat-network/docs/reference#evm_snapshot
835
- */
836
- method: 'evm_snapshot'
837
- params?: never
838
- }): Promise<Quantity>
839
- request(args: {
840
- /**
841
- * @description Revert the state of the blockchain to a previous snapshot. Takes a single parameter, which is the snapshot id to revert to.
842
- */
843
- method: 'evm_revert'
844
- params?: [id: Quantity]
845
- }): Promise<void>
846
- request(args: {
847
- /**
848
- * @link https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-content
849
- */
850
- method: 'txpool_content'
851
- params?: never
852
- }): Promise<{
853
- pending: Record<Address, Record<string, Transaction>>
854
- queued: Record<Address, Record<string, Transaction>>
855
- }>
856
- request(args: {
857
- /**
858
- * @link https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-inspect
859
- */
860
- method: 'txpool_inspect'
861
- params?: never
862
- }): Promise<{
863
- pending: Record<Address, Record<string, string>>
864
- queued: Record<Address, Record<string, string>>
865
- }>
866
- request(args: {
867
- /**
868
- * @link https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-inspect
869
- */
870
- method: 'txpool_status'
871
- params?: never
872
- }): Promise<{
873
- pending: Quantity
874
- queued: Quantity
875
- }>
876
- request(args: {
877
- /**
878
- * @description Creates, signs, and sends a new transaction to the network regardless of the signature.
879
- * @link https://eips.ethereum.org/EIPS/eip-1474
880
- * @example
881
- * provider.request({ method: 'eth_sendTransaction', params: [{ from: '0x...', to: '0x...', value: '0x...' }] })
882
- * // => '0x...'
883
- * */
884
- method: 'eth_sendUnsignedTransaction'
885
- params: [request: TransactionRequest]
886
- }): Promise<Hash>
887
- }
851
+ ReturnType: void
852
+ },
853
+ /**
854
+ * @description Jump forward in time by the given amount of time, in seconds.
855
+ * @link https://github.com/trufflesuite/ganache/blob/ef1858d5d6f27e4baeb75cccd57fb3dc77a45ae8/src/chains/ethereum/ethereum/RPC-METHODS.md#evm_increasetime
856
+ */
857
+ {
858
+ Method: `${TMode}_increaseTime`
859
+ Parameters: [seconds: number]
860
+ ReturnType: Quantity
861
+ },
862
+ /**
863
+ * @description Modifies the balance of an account.
864
+ * @link https://ganache.dev/#evm_setAccountBalance
865
+ */
866
+ {
867
+ Method: `evm_setAccountBalance`
868
+ Parameters: [
869
+ /** The address of the target account. */
870
+ address: Address,
871
+ /** Amount to send in wei. */
872
+ value: Quantity,
873
+ ]
874
+ ReturnType: void
875
+ },
876
+ /**
877
+ * @description Enables or disables, based on the single boolean argument, the automatic mining of new blocks with each new transaction submitted to the network.
878
+ * @link https://hardhat.org/hardhat-network/docs/reference#evm_setautomine
879
+ */
880
+ {
881
+ Method: `evm_setAutomine`
882
+ Parameters: [boolean]
883
+ ReturnType: void
884
+ },
885
+ /**
886
+ * @description Sets the block's gas limit.
887
+ * @link https://hardhat.org/hardhat-network/docs/reference#evm_setblockgaslimit
888
+ */
889
+ {
890
+ Method: 'evm_setBlockGasLimit'
891
+ Parameters: [gasLimit: Quantity]
892
+ ReturnType: void
893
+ },
894
+ /**
895
+ * @description Jump forward in time by the given amount of time, in seconds.
896
+ * @link https://github.com/trufflesuite/ganache/blob/ef1858d5d6f27e4baeb75cccd57fb3dc77a45ae8/src/chains/ethereum/ethereum/RPC-METHODS.md#evm_increasetime
897
+ */
898
+ {
899
+ Method: `evm_increaseTime`
900
+ Parameters: [seconds: Quantity]
901
+ ReturnType: Quantity
902
+ },
903
+ /**
904
+ * @description Similar to `evm_increaseTime` but sets a block timestamp `interval`.
905
+ * The timestamp of the next block will be computed as `lastBlock_timestamp` + `interval`
906
+ */
907
+ {
908
+ Method: `${TMode}_setBlockTimestampInterval`
909
+ Parameters: [seconds: number]
910
+ ReturnType: void
911
+ },
912
+ /**
913
+ * @description Removes `setBlockTimestampInterval` if it exists
914
+ */
915
+ {
916
+ Method: `${TMode}_removeBlockTimestampInterval`
917
+ Parameters?: never
918
+ ReturnType: void
919
+ },
920
+ /**
921
+ * @description Enables (with a numeric argument greater than 0) or disables (with a numeric argument equal to 0), the automatic mining of blocks at a regular interval of milliseconds, each of which will include all pending transactions.
922
+ * @link https://hardhat.org/hardhat-network/docs/reference#evm_setintervalmining
923
+ */
924
+ {
925
+ Method: 'evm_setIntervalMining'
926
+ Parameters: [number]
927
+ ReturnType: void
928
+ },
929
+ /**
930
+ * @description Set the timestamp of the next block.
931
+ * @link https://hardhat.org/hardhat-network/docs/reference#evm_setnextblocktimestamp
932
+ */
933
+ {
934
+ Method: 'evm_setNextBlockTimestamp'
935
+ Parameters: [Quantity]
936
+ ReturnType: void
937
+ },
938
+ /**
939
+ * @description Snapshot the state of the blockchain at the current block. Takes no parameters. Returns the id of the snapshot that was created.
940
+ * @link https://hardhat.org/hardhat-network/docs/reference#evm_snapshot
941
+ */
942
+ {
943
+ Method: 'evm_snapshot'
944
+ Parameters?: never
945
+ ReturnType: Quantity
946
+ },
947
+ /**
948
+ * @description Revert the state of the blockchain to a previous snapshot. Takes a single parameter, which is the snapshot id to revert to.
949
+ */
950
+ {
951
+ Method: 'evm_revert'
952
+ Parameters?: [id: Quantity]
953
+ ReturnType: void
954
+ },
955
+ /**
956
+ * @description Enables the automatic mining of new blocks with each new transaction submitted to the network.
957
+ * @link https://ganache.dev/#miner_start
958
+ */
959
+ {
960
+ Method: 'miner_start'
961
+ Parameters?: never
962
+ ReturnType: void
963
+ },
964
+ /**
965
+ * @description Disables the automatic mining of new blocks with each new transaction submitted to the network.
966
+ * @link https://ganache.dev/#miner_stop
967
+ */
968
+ {
969
+ Method: 'miner_stop'
970
+ Parameters?: never
971
+ ReturnType: void
972
+ },
973
+ /**
974
+ * @link https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-content
975
+ */
976
+ {
977
+ Method: 'txpool_content'
978
+ Parameters?: never
979
+ ReturnType: {
980
+ pending: Record<Address, Record<string, Transaction>>
981
+ queued: Record<Address, Record<string, Transaction>>
982
+ }
983
+ },
984
+ /**
985
+ * @link https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-inspect
986
+ */
987
+ {
988
+ Method: 'txpool_inspect'
989
+ Parameters?: never
990
+ ReturnType: {
991
+ pending: Record<Address, Record<string, string>>
992
+ queued: Record<Address, Record<string, string>>
993
+ }
994
+ },
995
+ /**
996
+ * @link https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-inspect
997
+ */
998
+ {
999
+ Method: 'txpool_status'
1000
+ Parameters?: never
1001
+ ReturnType: {
1002
+ pending: Quantity
1003
+ queued: Quantity
1004
+ }
1005
+ },
1006
+ /**
1007
+ * @description Returns whether the client is actively mining new blocks.
1008
+ * @link https://eips.ethereum.org/EIPS/eip-1474
1009
+ * @example
1010
+ * provider.request({ method: 'eth_mining' })
1011
+ * // => true
1012
+ */
1013
+ {
1014
+ Method: 'eth_mining'
1015
+ Parameters?: never
1016
+ ReturnType: boolean
1017
+ },
1018
+ /**
1019
+ * @description Advance the block number of the network by a certain number of blocks.
1020
+ * @link https://ganache.dev/#evm_mine
1021
+ */
1022
+ {
1023
+ Method: 'evm_mine'
1024
+ Parameters?: [
1025
+ {
1026
+ /** Number of blocks to mine. */
1027
+ blocks: Hex
1028
+ },
1029
+ ]
1030
+ ReturnType: void
1031
+ },
1032
+ /**
1033
+ * @description Creates, signs, and sends a new transaction to the network regardless of the signature.
1034
+ * @link https://eips.ethereum.org/EIPS/eip-1474
1035
+ * @example
1036
+ * provider.request({ method: 'eth_sendTransaction', params: [{ from: '0x...', to: '0x...', value: '0x...' }] })
1037
+ * // => '0x...'
1038
+ */
1039
+ {
1040
+ Method: 'eth_sendUnsignedTransaction'
1041
+ Parameters: [transaction: TransactionRequest]
1042
+ ReturnType: Hash
1043
+ },
1044
+ ]
888
1045
 
889
- export type SignableRequests = {
890
- request(args: {
891
- /**
892
- * @description Creates, signs, and sends a new transaction to the network
893
- * @link https://eips.ethereum.org/EIPS/eip-1474
894
- * @example
895
- * provider.request({ method: 'eth_sendTransaction', params: [{ from: '0x...', to: '0x...', value: '0x...' }] })
896
- * // => '0x...'
897
- * */
898
- method: 'eth_sendTransaction'
899
- params: [request: TransactionRequest]
900
- }): Promise<Hash>
901
- request(args: {
902
- /**
903
- * @description Calculates an Ethereum-specific signature in the form of `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`
904
- * @link https://eips.ethereum.org/EIPS/eip-1474
905
- * @example
906
- * provider.request({ method: 'eth_sign', params: ['0x...', '0x...'] })
907
- * // => '0x...'
908
- * */
909
- method: 'eth_sign'
910
- params: [
1046
+ export type WalletRpcSchema = [
1047
+ /**
1048
+ * @description Returns a list of addresses owned by this client
1049
+ * @link https://eips.ethereum.org/EIPS/eip-1474
1050
+ * @example
1051
+ * provider.request({ method: 'eth_accounts' })
1052
+ * // => ['0x0fB69...']
1053
+ */
1054
+ {
1055
+ Method: 'eth_accounts'
1056
+ Parameters?: never
1057
+ ReturnType: Address[]
1058
+ },
1059
+ /**
1060
+ * @description Returns the current chain ID associated with the wallet.
1061
+ * @example
1062
+ * provider.request({ method: 'eth_chainId' })
1063
+ * // => '1'
1064
+ */
1065
+ {
1066
+ Method: 'eth_chainId'
1067
+ Parameters?: never
1068
+ ReturnType: Quantity
1069
+ },
1070
+ /**
1071
+ * @description Estimates the gas necessary to complete a transaction without submitting it to the network
1072
+ *
1073
+ * @example
1074
+ * provider.request({
1075
+ * method: 'eth_estimateGas',
1076
+ * params: [{ from: '0x...', to: '0x...', value: '0x...' }]
1077
+ * })
1078
+ * // => '0x5208'
1079
+ */
1080
+ {
1081
+ Method: 'eth_estimateGas'
1082
+ Parameters:
1083
+ | [transaction: TransactionRequest]
1084
+ | [transaction: TransactionRequest, block: BlockNumber | BlockTag]
1085
+ ReturnType: Quantity
1086
+ },
1087
+ /**
1088
+ * @description Requests that the user provides an Ethereum address to be identified by. Typically causes a browser extension popup to appear.
1089
+ * @link https://eips.ethereum.org/EIPS/eip-1102
1090
+ * @example
1091
+ * provider.request({ method: 'eth_requestAccounts' }] })
1092
+ * // => ['0x...', '0x...']
1093
+ */
1094
+ {
1095
+ Method: 'eth_requestAccounts'
1096
+ Parameters?: never
1097
+ ReturnType: Address[]
1098
+ },
1099
+ /**
1100
+ * @description Creates, signs, and sends a new transaction to the network
1101
+ * @link https://eips.ethereum.org/EIPS/eip-1474
1102
+ * @example
1103
+ * provider.request({ method: 'eth_sendTransaction', params: [{ from: '0x...', to: '0x...', value: '0x...' }] })
1104
+ * // => '0x...'
1105
+ */
1106
+ {
1107
+ Method: 'eth_sendTransaction'
1108
+ Parameters: [transaction: TransactionRequest]
1109
+ ReturnType: Hash
1110
+ },
1111
+ /**
1112
+ * @description Sends and already-signed transaction to the network
1113
+ * @link https://eips.ethereum.org/EIPS/eip-1474
1114
+ * @example
1115
+ * provider.request({ method: 'eth_sendRawTransaction', params: ['0x...'] })
1116
+ * // => '0x...'
1117
+ */
1118
+ {
1119
+ Method: 'eth_sendRawTransaction'
1120
+ Parameters: [signedTransaction: Hex]
1121
+ ReturnType: Hash
1122
+ },
1123
+ /**
1124
+ * @description Calculates an Ethereum-specific signature in the form of `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`
1125
+ * @link https://eips.ethereum.org/EIPS/eip-1474
1126
+ * @example
1127
+ * provider.request({ method: 'eth_sign', params: ['0x...', '0x...'] })
1128
+ * // => '0x...'
1129
+ */
1130
+ {
1131
+ Method: 'eth_sign'
1132
+ Parameters: [
911
1133
  /** Address to use for signing */
912
1134
  address: Address,
913
1135
  /** Data to sign */
914
1136
  data: Hex,
915
1137
  ]
916
- }): Promise<Hex>
917
- request(args: {
918
- /**
919
- * @description Signs a transaction that can be submitted to the network at a later time using with `eth_sendRawTransaction`
920
- * @link https://eips.ethereum.org/EIPS/eip-1474
921
- * @example
922
- * provider.request({ method: 'eth_signTransaction', params: [{ from: '0x...', to: '0x...', value: '0x...' }] })
923
- * // => '0x...'
924
- * */
925
- method: 'eth_signTransaction'
926
- params: [request: TransactionRequest]
927
- }): Promise<Hex>
928
- request(args: {
929
- /**
930
- * @description Calculates an Ethereum-specific signature in the form of `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`
931
- * @link https://eips.ethereum.org/EIPS/eip-1474
932
- * @example
933
- * provider.request({ method: 'eth_signTypedData_v4', params: [{ from: '0x...', data: [{ type: 'string', name: 'message', value: 'hello world' }] }] })
934
- * // => '0x...'
935
- * */
936
- method: 'eth_signTypedData_v4'
937
- params: [
1138
+ ReturnType: Hex
1139
+ },
1140
+ /**
1141
+ * @description Signs a transaction that can be submitted to the network at a later time using with `eth_sendRawTransaction`
1142
+ * @link https://eips.ethereum.org/EIPS/eip-1474
1143
+ * @example
1144
+ * provider.request({ method: 'eth_signTransaction', params: [{ from: '0x...', to: '0x...', value: '0x...' }] })
1145
+ * // => '0x...'
1146
+ */
1147
+ {
1148
+ Method: 'eth_signTransaction'
1149
+ Parameters: [request: TransactionRequest]
1150
+ ReturnType: Hex
1151
+ },
1152
+ /**
1153
+ * @description Calculates an Ethereum-specific signature in the form of `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`
1154
+ * @link https://eips.ethereum.org/EIPS/eip-1474
1155
+ * @example
1156
+ * provider.request({ method: 'eth_signTypedData_v4', params: [{ from: '0x...', data: [{ type: 'string', name: 'message', value: 'hello world' }] }] })
1157
+ * // => '0x...'
1158
+ */
1159
+ {
1160
+ Method: 'eth_signTypedData_v4'
1161
+ Parameters: [
938
1162
  /** Address to use for signing */
939
1163
  address: Address,
940
1164
  /** Message to sign containing type information, a domain separator, and data */
941
1165
  message: string,
942
1166
  ]
943
- }): Promise<Hex>
944
- request(args: {
945
- /**
946
- * @description Returns information about the status of this client’s network synchronization
947
- * @link https://eips.ethereum.org/EIPS/eip-1474
948
- * @example
949
- * provider.request({ method: 'eth_syncing' })
950
- * // => { startingBlock: '0x...', currentBlock: '0x...', highestBlock: '0x...' }
951
- * */
952
- method: 'eth_syncing'
953
- params?: never
954
- }): Promise<NetworkSync | false>
955
- request(args: {
956
- /**
957
- * @description Calculates an Ethereum-specific signature in the form of `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`
958
- * @link https://eips.ethereum.org/EIPS/eip-1474
959
- * @example
960
- * provider.request({ method: 'personal_sign', params: ['0x...', '0x...'] })
961
- * // => '0x...'
962
- * */
963
- method: 'personal_sign'
964
- params: [
1167
+ ReturnType: Hex
1168
+ },
1169
+ /**
1170
+ * @description Returns information about the status of this client’s network synchronization
1171
+ * @link https://eips.ethereum.org/EIPS/eip-1474
1172
+ * @example
1173
+ * provider.request({ method: 'eth_syncing' })
1174
+ * // => { startingBlock: '0x...', currentBlock: '0x...', highestBlock: '0x...' }
1175
+ */
1176
+ {
1177
+ Method: 'eth_syncing'
1178
+ Parameters?: never
1179
+ ReturnType: NetworkSync | false
1180
+ },
1181
+ /**
1182
+ * @description Calculates an Ethereum-specific signature in the form of `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`
1183
+ * @link https://eips.ethereum.org/EIPS/eip-1474
1184
+ * @example
1185
+ * provider.request({ method: 'personal_sign', params: ['0x...', '0x...'] })
1186
+ * // => '0x...'
1187
+ */
1188
+ {
1189
+ Method: 'personal_sign'
1190
+ Parameters: [
965
1191
  /** Data to sign */
966
1192
  data: Hex,
967
1193
  /** Address to use for signing */
968
1194
  address: Address,
969
1195
  ]
970
- }): Promise<Hex>
971
- }
972
-
973
- export type WalletRequests = {
974
- request(args: {
975
- /**
976
- * @description Returns a list of addresses owned by this client
977
- * @link https://eips.ethereum.org/EIPS/eip-1474
978
- * @example
979
- * provider.request({ method: 'eth_accounts' })
980
- * // => ['0x0fB69...']
981
- * */
982
- method: 'eth_accounts'
983
- params?: never
984
- }): Promise<Address[]>
985
- request(args: {
986
- /**
987
- * @description Returns the current chain ID associated with the wallet.
988
- * @example
989
- * provider.request({ method: 'eth_chainId' })
990
- * // => '1'
991
- */
992
- method: 'eth_chainId'
993
- params?: never
994
- }): Promise<Quantity>
995
- request(args: {
996
- /**
997
- * @description Requests that the user provides an Ethereum address to be identified by. Typically causes a browser extension popup to appear.
998
- * @link https://eips.ethereum.org/EIPS/eip-1102
999
- * @example
1000
- * provider.request({ method: 'eth_requestAccounts' })
1001
- * // => ['0x...', '0x...']
1002
- * */
1003
- method: 'eth_requestAccounts'
1004
- params?: never
1005
- }): Promise<Address[]>
1006
- request(args: {
1007
- /**
1008
- * @description Requests the given permissions from the user.
1009
- * @link https://eips.ethereum.org/EIPS/eip-2255
1010
- * @example
1011
- * provider.request({ method: 'wallet_requestPermissions', params: [{ eth_accounts: {} }] })
1012
- * // => { ... }
1013
- * */
1014
- method: 'wallet_requestPermissions'
1015
- params: [permissions: { eth_accounts: Record<string, any> }]
1016
- }): Promise<WalletPermission[]>
1017
- request(args: {
1018
- /**
1019
- * @description Gets the wallets current permissions.
1020
- * @link https://eips.ethereum.org/EIPS/eip-2255
1021
- * @example
1022
- * provider.request({ method: 'wallet_getPermissions' })
1023
- * // => { ... }
1024
- * */
1025
- method: 'wallet_getPermissions'
1026
- params?: never
1027
- }): Promise<WalletPermission[]>
1028
- request(args: {
1029
- /**
1030
- * @description Add an Ethereum chain to the wallet.
1031
- * @link https://eips.ethereum.org/EIPS/eip-3085
1032
- * @example
1033
- * provider.request({ method: 'wallet_addEthereumChain', params: [{ chainId: 1, rpcUrl: 'https://mainnet.infura.io/v3/...' }] })
1034
- * // => { ... }
1035
- */
1036
- method: 'wallet_addEthereumChain'
1037
- params: [chain: Chain]
1038
- }): Promise<null>
1039
- request(args: {
1040
- /**
1041
- * @description Switch the wallet to the given Ethereum chain.
1042
- * @link https://eips.ethereum.org/EIPS/eip-3326
1043
- * @example
1044
- * provider.request({ method: 'wallet_switchEthereumChain', params: [{ chainId: '0xf00' }] })
1045
- * // => { ... }
1046
- * */
1047
- method: 'wallet_switchEthereumChain'
1048
- params: [chain: { chainId: string }]
1049
- }): Promise<null>
1196
+ ReturnType: Hex
1197
+ },
1198
+ /**
1199
+ * @description Add an Ethereum chain to the wallet.
1200
+ * @link https://eips.ethereum.org/EIPS/eip-3085
1201
+ * @example
1202
+ * provider.request({ method: 'wallet_addEthereumChain', params: [{ chainId: 1, rpcUrl: 'https://mainnet.infura.io/v3/...' }] })
1203
+ * // => { ... }
1204
+ */
1205
+ {
1206
+ Method: 'wallet_addEthereumChain'
1207
+ Parameters: [chain: AddEthereumChainParameter]
1208
+ ReturnType: null
1209
+ },
1210
+ /**
1211
+ * @description Gets the wallets current permissions.
1212
+ * @link https://eips.ethereum.org/EIPS/eip-2255
1213
+ * @example
1214
+ * provider.request({ method: 'wallet_getPermissions' })
1215
+ * // => { ... }
1216
+ */
1217
+ {
1218
+ Method: 'wallet_getPermissions'
1219
+ Parameters?: never
1220
+ ReturnType: WalletPermission[]
1221
+ },
1222
+ /**
1223
+ * @description Requests the given permissions from the user.
1224
+ * @link https://eips.ethereum.org/EIPS/eip-2255
1225
+ * @example
1226
+ * provider.request({ method: 'wallet_requestPermissions', params: [{ eth_accounts: {} }] })
1227
+ * // => { ... }
1228
+ */
1229
+ {
1230
+ Method: 'wallet_requestPermissions'
1231
+ Parameters: [permissions: { eth_accounts: Record<string, any> }]
1232
+ ReturnType: WalletPermission[]
1233
+ },
1234
+ /**
1235
+ * @description Switch the wallet to the given Ethereum chain.
1236
+ * @link https://eips.ethereum.org/EIPS/eip-3326
1237
+ * @example
1238
+ * provider.request({ method: 'wallet_switchEthereumChain', params: [{ chainId: '0xf00' }] })
1239
+ * // => { ... }
1240
+ */
1241
+ {
1242
+ Method: 'wallet_switchEthereumChain'
1243
+ Parameters: [chain: { chainId: string }]
1244
+ ReturnType: null
1245
+ },
1050
1246
  /**
1051
1247
  * @description Requests that the user tracks the token in their wallet. Returns a boolean indicating if the token was successfully added.
1052
1248
  * @link https://eips.ethereum.org/EIPS/eip-747
1053
1249
  * @example
1054
1250
  * provider.request({ method: 'wallet_watchAsset' }] })
1055
1251
  * // => true
1056
- * */
1057
- request(args: {
1058
- method: 'wallet_watchAsset'
1059
- params: WatchAssetParams
1060
- }): Promise<boolean>
1061
- }
1252
+ */
1253
+ {
1254
+ Method: 'wallet_watchAsset'
1255
+ Parameters: WatchAssetParams
1256
+ ReturnType: boolean
1257
+ },
1258
+ ]
1259
+
1260
+ ///////////////////////////////////////////////////////////////////////////
1261
+ // Utils
1262
+
1263
+ export type RpcSchema = readonly {
1264
+ Method: string
1265
+ Parameters?: unknown
1266
+ ReturnType: unknown
1267
+ }[]
1268
+
1269
+ export type RpcSchemaOverride = Omit<RpcSchema[number], 'Method'>
1270
+
1271
+ export type EIP1193Parameters<
1272
+ TRpcSchema extends RpcSchema | undefined = undefined,
1273
+ > = TRpcSchema extends RpcSchema
1274
+ ? {
1275
+ [K in keyof TRpcSchema]: Prettify<
1276
+ {
1277
+ method: TRpcSchema[K] extends TRpcSchema[number]
1278
+ ? TRpcSchema[K]['Method']
1279
+ : never
1280
+ } & (TRpcSchema[K] extends TRpcSchema[number]
1281
+ ? TRpcSchema[K]['Parameters'] extends undefined
1282
+ ? { params?: never }
1283
+ : { params: TRpcSchema[K]['Parameters'] }
1284
+ : never)
1285
+ >
1286
+ }[number]
1287
+ : {
1288
+ method: string
1289
+ params?: unknown
1290
+ }
1291
+
1292
+ type DerivedRpcSchema<
1293
+ TRpcSchema extends RpcSchema | undefined,
1294
+ TRpcSchemaOverride extends RpcSchemaOverride | undefined,
1295
+ > = TRpcSchemaOverride extends RpcSchemaOverride
1296
+ ? [TRpcSchemaOverride & { Method: string }]
1297
+ : TRpcSchema
1062
1298
 
1063
- export type Requests = PublicRequests & SignableRequests & WalletRequests
1299
+ export type EIP1193RequestFn<
1300
+ TRpcSchema extends RpcSchema | undefined = undefined,
1301
+ > = <
1302
+ TRpcSchemaOverride extends RpcSchemaOverride | undefined = undefined,
1303
+ TParameters extends EIP1193Parameters<
1304
+ DerivedRpcSchema<TRpcSchema, TRpcSchemaOverride>
1305
+ > = EIP1193Parameters<DerivedRpcSchema<TRpcSchema, TRpcSchemaOverride>>,
1306
+ _ReturnType = DerivedRpcSchema<
1307
+ TRpcSchema,
1308
+ TRpcSchemaOverride
1309
+ > extends RpcSchema
1310
+ ? Extract<
1311
+ DerivedRpcSchema<TRpcSchema, TRpcSchemaOverride>[number],
1312
+ { Method: TParameters['method'] }
1313
+ >['ReturnType']
1314
+ : unknown,
1315
+ >(
1316
+ args: TParameters,
1317
+ ) => Promise<_ReturnType>