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