hardhat 3.1.9 → 3.1.11

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 (298) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/src/config.d.ts +20 -0
  3. package/dist/src/config.d.ts.map +1 -1
  4. package/dist/src/config.js +31 -0
  5. package/dist/src/config.js.map +1 -1
  6. package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.d.ts +2 -2
  7. package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.d.ts.map +1 -1
  8. package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.js.map +1 -1
  9. package/dist/src/internal/builtin-plugins/artifacts/hook-handlers/hre.d.ts.map +1 -1
  10. package/dist/src/internal/builtin-plugins/artifacts/hook-handlers/hre.js.map +1 -1
  11. package/dist/src/internal/builtin-plugins/coverage/coverage-manager.d.ts.map +1 -1
  12. package/dist/src/internal/builtin-plugins/coverage/coverage-manager.js +33 -21
  13. package/dist/src/internal/builtin-plugins/coverage/coverage-manager.js.map +1 -1
  14. package/dist/src/internal/builtin-plugins/coverage/helpers.d.ts +3 -5
  15. package/dist/src/internal/builtin-plugins/coverage/helpers.d.ts.map +1 -1
  16. package/dist/src/internal/builtin-plugins/coverage/helpers.js +7 -19
  17. package/dist/src/internal/builtin-plugins/coverage/helpers.js.map +1 -1
  18. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.d.ts +7 -0
  19. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.d.ts.map +1 -0
  20. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.js +42 -0
  21. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.js.map +1 -0
  22. package/dist/src/internal/builtin-plugins/coverage/index.d.ts.map +1 -1
  23. package/dist/src/internal/builtin-plugins/coverage/index.js +1 -0
  24. package/dist/src/internal/builtin-plugins/coverage/index.js.map +1 -1
  25. package/dist/src/internal/builtin-plugins/flatten/task-action.d.ts.map +1 -1
  26. package/dist/src/internal/builtin-plugins/flatten/task-action.js +1 -1
  27. package/dist/src/internal/builtin-plugins/flatten/task-action.js.map +1 -1
  28. package/dist/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.js +2 -2
  29. package/dist/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.js.map +1 -1
  30. package/dist/src/internal/builtin-plugins/gas-analytics/helpers.d.ts +3 -5
  31. package/dist/src/internal/builtin-plugins/gas-analytics/helpers.d.ts.map +1 -1
  32. package/dist/src/internal/builtin-plugins/gas-analytics/helpers.js +7 -19
  33. package/dist/src/internal/builtin-plugins/gas-analytics/helpers.js.map +1 -1
  34. package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.d.ts +7 -0
  35. package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.d.ts.map +1 -0
  36. package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.js +42 -0
  37. package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.js.map +1 -0
  38. package/dist/src/internal/builtin-plugins/gas-analytics/index.d.ts.map +1 -1
  39. package/dist/src/internal/builtin-plugins/gas-analytics/index.js +1 -0
  40. package/dist/src/internal/builtin-plugins/gas-analytics/index.js.map +1 -1
  41. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.d.ts.map +1 -1
  42. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js +17 -20
  43. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js.map +1 -1
  44. package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-generation-errors.d.ts +1 -1
  45. package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-generation-errors.d.ts.map +1 -1
  46. package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-generation-errors.js +2 -2
  47. package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-generation-errors.js.map +1 -1
  48. package/dist/src/internal/builtin-plugins/network-manager/edr/type-validation.d.ts +0 -2
  49. package/dist/src/internal/builtin-plugins/network-manager/edr/type-validation.d.ts.map +1 -1
  50. package/dist/src/internal/builtin-plugins/network-manager/edr/type-validation.js +0 -6
  51. package/dist/src/internal/builtin-plugins/network-manager/edr/type-validation.js.map +1 -1
  52. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.d.ts +1 -3
  53. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.d.ts.map +1 -1
  54. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js +0 -49
  55. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js.map +1 -1
  56. package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/config.d.ts.map +1 -1
  57. package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/config.js +58 -20
  58. package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/config.js.map +1 -1
  59. package/dist/src/internal/builtin-plugins/network-manager/type-validation.d.ts.map +1 -1
  60. package/dist/src/internal/builtin-plugins/network-manager/type-validation.js +8 -0
  61. package/dist/src/internal/builtin-plugins/network-manager/type-validation.js.map +1 -1
  62. package/dist/src/internal/builtin-plugins/node/task-action.d.ts.map +1 -1
  63. package/dist/src/internal/builtin-plugins/node/task-action.js +1 -2
  64. package/dist/src/internal/builtin-plugins/node/task-action.js.map +1 -1
  65. package/dist/src/internal/builtin-plugins/solidity/build-results.d.ts +2 -2
  66. package/dist/src/internal/builtin-plugins/solidity/build-results.d.ts.map +1 -1
  67. package/dist/src/internal/builtin-plugins/solidity/build-results.js +2 -2
  68. package/dist/src/internal/builtin-plugins/solidity/build-results.js.map +1 -1
  69. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts +1 -0
  70. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts.map +1 -1
  71. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js +14 -6
  72. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.map +1 -1
  73. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.js +1 -1
  74. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.js.map +1 -1
  75. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.d.ts +0 -3
  76. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.d.ts.map +1 -1
  77. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.js +3 -5
  78. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.js.map +1 -1
  79. package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph-building.d.ts +2 -1
  80. package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph-building.d.ts.map +1 -1
  81. package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph-building.js +4 -2
  82. package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph-building.js.map +1 -1
  83. package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph.d.ts +1 -1
  84. package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph.js +1 -1
  85. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.d.ts +5 -2
  86. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.d.ts.map +1 -1
  87. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.js +8 -2
  88. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.js.map +1 -1
  89. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/error-messages.d.ts.map +1 -1
  90. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/error-messages.js +19 -5
  91. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/error-messages.js.map +1 -1
  92. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.d.ts +21 -2
  93. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.d.ts.map +1 -1
  94. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.js +84 -25
  95. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.js.map +1 -1
  96. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/types.d.ts +3 -12
  97. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/types.d.ts.map +1 -1
  98. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/types.js.map +1 -1
  99. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/utils.d.ts +1 -1
  100. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/utils.d.ts.map +1 -1
  101. package/dist/src/internal/builtin-plugins/solidity/build-system/solc-config-selection.d.ts +8 -6
  102. package/dist/src/internal/builtin-plugins/solidity/build-system/solc-config-selection.d.ts.map +1 -1
  103. package/dist/src/internal/builtin-plugins/solidity/build-system/solc-config-selection.js +103 -27
  104. package/dist/src/internal/builtin-plugins/solidity/build-system/solc-config-selection.js.map +1 -1
  105. package/dist/src/internal/builtin-plugins/solidity/config.js +2 -2
  106. package/dist/src/internal/builtin-plugins/solidity/config.js.map +1 -1
  107. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.d.ts.map +1 -1
  108. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js +5 -0
  109. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js.map +1 -1
  110. package/dist/src/internal/builtin-plugins/solidity/tasks/build.js +1 -1
  111. package/dist/src/internal/builtin-plugins/solidity/tasks/build.js.map +1 -1
  112. package/dist/src/internal/builtin-plugins/solidity/type-extensions.d.ts +22 -0
  113. package/dist/src/internal/builtin-plugins/solidity/type-extensions.d.ts.map +1 -1
  114. package/dist/src/internal/builtin-plugins/solidity-test/config.d.ts.map +1 -1
  115. package/dist/src/internal/builtin-plugins/solidity-test/config.js +1 -0
  116. package/dist/src/internal/builtin-plugins/solidity-test/config.js.map +1 -1
  117. package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.d.ts +1 -1
  118. package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.d.ts.map +1 -1
  119. package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.js +1 -1
  120. package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.js.map +1 -1
  121. package/dist/src/internal/builtin-plugins/solidity-test/runner.d.ts +1 -1
  122. package/dist/src/internal/builtin-plugins/solidity-test/runner.js +1 -1
  123. package/dist/src/internal/builtin-plugins/solidity-test/task-action.d.ts.map +1 -1
  124. package/dist/src/internal/builtin-plugins/solidity-test/task-action.js +16 -27
  125. package/dist/src/internal/builtin-plugins/solidity-test/task-action.js.map +1 -1
  126. package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts +1 -0
  127. package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts.map +1 -1
  128. package/dist/src/internal/builtin-plugins/telemetry/task-action.d.ts.map +1 -1
  129. package/dist/src/internal/builtin-plugins/telemetry/task-action.js +3 -2
  130. package/dist/src/internal/builtin-plugins/telemetry/task-action.js.map +1 -1
  131. package/dist/src/internal/builtin-plugins/test/task-action.d.ts.map +1 -1
  132. package/dist/src/internal/builtin-plugins/test/task-action.js +40 -13
  133. package/dist/src/internal/builtin-plugins/test/task-action.js.map +1 -1
  134. package/dist/src/internal/builtin-plugins/test/type-extensions.d.ts +27 -0
  135. package/dist/src/internal/builtin-plugins/test/type-extensions.d.ts.map +1 -1
  136. package/dist/src/internal/cli/banner-manager.d.ts +26 -0
  137. package/dist/src/internal/cli/banner-manager.d.ts.map +1 -0
  138. package/dist/src/internal/cli/banner-manager.js +146 -0
  139. package/dist/src/internal/cli/banner-manager.js.map +1 -0
  140. package/dist/src/internal/cli/error-handler.d.ts.map +1 -1
  141. package/dist/src/internal/cli/error-handler.js +15 -0
  142. package/dist/src/internal/cli/error-handler.js.map +1 -1
  143. package/dist/src/internal/cli/init/init.d.ts.map +1 -1
  144. package/dist/src/internal/cli/init/init.js +8 -0
  145. package/dist/src/internal/cli/init/init.js.map +1 -1
  146. package/dist/src/internal/cli/main.d.ts.map +1 -1
  147. package/dist/src/internal/cli/main.js +18 -1
  148. package/dist/src/internal/cli/main.js.map +1 -1
  149. package/dist/src/internal/cli/telemetry/analytics/subprocess.js +2 -0
  150. package/dist/src/internal/cli/telemetry/analytics/subprocess.js.map +1 -1
  151. package/dist/src/internal/cli/telemetry/sentry/anonymize-paths.js +1 -1
  152. package/dist/src/internal/cli/telemetry/sentry/reporter.d.ts.map +1 -1
  153. package/dist/src/internal/cli/telemetry/sentry/reporter.js +4 -0
  154. package/dist/src/internal/cli/telemetry/sentry/reporter.js.map +1 -1
  155. package/dist/src/internal/cli/telemetry/sentry/vendor/integrations/contextlines.d.ts +1 -1
  156. package/dist/src/internal/cli/telemetry/sentry/vendor/integrations/contextlines.d.ts.map +1 -1
  157. package/dist/src/internal/cli/telemetry/sentry/vendor/integrations/contextlines.js +47 -38
  158. package/dist/src/internal/cli/telemetry/sentry/vendor/integrations/contextlines.js.map +1 -1
  159. package/dist/src/internal/core/config-validation.d.ts +3 -3
  160. package/dist/src/internal/core/config-validation.d.ts.map +1 -1
  161. package/dist/src/internal/core/config-validation.js +48 -18
  162. package/dist/src/internal/core/config-validation.js.map +1 -1
  163. package/dist/src/internal/core/tasks/builders.d.ts +26 -16
  164. package/dist/src/internal/core/tasks/builders.d.ts.map +1 -1
  165. package/dist/src/internal/core/tasks/builders.js +65 -6
  166. package/dist/src/internal/core/tasks/builders.js.map +1 -1
  167. package/dist/src/internal/core/tasks/resolved-task.d.ts +2 -2
  168. package/dist/src/internal/core/tasks/resolved-task.d.ts.map +1 -1
  169. package/dist/src/internal/core/tasks/resolved-task.js +23 -9
  170. package/dist/src/internal/core/tasks/resolved-task.js.map +1 -1
  171. package/dist/src/internal/core/tasks/task-manager.d.ts.map +1 -1
  172. package/dist/src/internal/core/tasks/task-manager.js +14 -6
  173. package/dist/src/internal/core/tasks/task-manager.js.map +1 -1
  174. package/dist/src/internal/core/tasks/validations.d.ts +2 -0
  175. package/dist/src/internal/core/tasks/validations.d.ts.map +1 -1
  176. package/dist/src/internal/core/tasks/validations.js +11 -0
  177. package/dist/src/internal/core/tasks/validations.js.map +1 -1
  178. package/dist/src/internal/core/user-interruptions.js +1 -1
  179. package/dist/src/internal/deprecated-module-imported-from-hardhat2-plugin.d.ts +2 -0
  180. package/dist/src/internal/deprecated-module-imported-from-hardhat2-plugin.d.ts.map +1 -0
  181. package/dist/src/internal/deprecated-module-imported-from-hardhat2-plugin.js +12 -0
  182. package/dist/src/internal/deprecated-module-imported-from-hardhat2-plugin.js.map +1 -0
  183. package/dist/src/internal/using-hardhat2-plugin-errors.d.ts +35 -0
  184. package/dist/src/internal/using-hardhat2-plugin-errors.d.ts.map +1 -0
  185. package/dist/src/internal/using-hardhat2-plugin-errors.js +98 -0
  186. package/dist/src/internal/using-hardhat2-plugin-errors.js.map +1 -0
  187. package/dist/src/plugins.d.ts +8 -0
  188. package/dist/src/plugins.d.ts.map +1 -1
  189. package/dist/src/plugins.js +13 -0
  190. package/dist/src/plugins.js.map +1 -1
  191. package/dist/src/types/artifacts.d.ts +32 -3
  192. package/dist/src/types/artifacts.d.ts.map +1 -1
  193. package/dist/src/types/index.d.ts +15 -0
  194. package/dist/src/types/index.d.ts.map +1 -0
  195. package/dist/src/types/index.js +15 -0
  196. package/dist/src/types/index.js.map +1 -0
  197. package/dist/src/types/network.d.ts +1 -1
  198. package/dist/src/types/plugins.d.ts +2 -2
  199. package/dist/src/types/solidity/build-system.d.ts +56 -10
  200. package/dist/src/types/solidity/build-system.d.ts.map +1 -1
  201. package/dist/src/types/solidity/build-system.js +26 -2
  202. package/dist/src/types/solidity/build-system.js.map +1 -1
  203. package/dist/src/types/solidity/errors.d.ts +18 -0
  204. package/dist/src/types/solidity/errors.d.ts.map +1 -1
  205. package/dist/src/types/solidity/errors.js.map +1 -1
  206. package/dist/src/types/solidity/resolved-file.d.ts +2 -2
  207. package/dist/src/types/tasks.d.ts +103 -34
  208. package/dist/src/types/tasks.d.ts.map +1 -1
  209. package/dist/src/types/tasks.js.map +1 -1
  210. package/dist/src/types/test.d.ts +11 -0
  211. package/dist/src/types/test.d.ts.map +1 -1
  212. package/dist/src/types/utils.d.ts +16 -0
  213. package/dist/src/types/utils.d.ts.map +1 -1
  214. package/dist/src/utils/result.d.ts +33 -0
  215. package/dist/src/utils/result.d.ts.map +1 -0
  216. package/dist/src/utils/result.js +43 -0
  217. package/dist/src/utils/result.js.map +1 -0
  218. package/package.json +12 -7
  219. package/src/config.ts +37 -0
  220. package/src/internal/builtin-plugins/artifacts/artifact-manager.ts +4 -1
  221. package/src/internal/builtin-plugins/artifacts/hook-handlers/hre.ts +4 -1
  222. package/src/internal/builtin-plugins/coverage/coverage-manager.ts +57 -50
  223. package/src/internal/builtin-plugins/coverage/helpers.ts +11 -29
  224. package/src/internal/builtin-plugins/coverage/hook-handlers/test.ts +68 -0
  225. package/src/internal/builtin-plugins/coverage/index.ts +1 -0
  226. package/src/internal/builtin-plugins/flatten/task-action.ts +1 -0
  227. package/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.ts +4 -4
  228. package/src/internal/builtin-plugins/gas-analytics/helpers.ts +11 -29
  229. package/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.ts +68 -0
  230. package/src/internal/builtin-plugins/gas-analytics/index.ts +1 -0
  231. package/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts +21 -28
  232. package/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-generation-errors.ts +5 -2
  233. package/src/internal/builtin-plugins/network-manager/edr/type-validation.ts +0 -13
  234. package/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.ts +0 -64
  235. package/src/internal/builtin-plugins/network-manager/hook-handlers/config.ts +65 -21
  236. package/src/internal/builtin-plugins/network-manager/type-validation.ts +9 -0
  237. package/src/internal/builtin-plugins/node/task-action.ts +2 -2
  238. package/src/internal/builtin-plugins/solidity/build-results.ts +3 -1
  239. package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +16 -5
  240. package/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.ts +1 -1
  241. package/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts +7 -6
  242. package/src/internal/builtin-plugins/solidity/build-system/dependency-graph-building.ts +23 -1
  243. package/src/internal/builtin-plugins/solidity/build-system/dependency-graph.ts +1 -1
  244. package/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.ts +17 -3
  245. package/src/internal/builtin-plugins/solidity/build-system/resolver/error-messages.ts +19 -5
  246. package/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.ts +139 -35
  247. package/src/internal/builtin-plugins/solidity/build-system/resolver/types.ts +3 -9
  248. package/src/internal/builtin-plugins/solidity/build-system/resolver/utils.ts +1 -1
  249. package/src/internal/builtin-plugins/solidity/build-system/solc-config-selection.ts +125 -28
  250. package/src/internal/builtin-plugins/solidity/config.ts +2 -2
  251. package/src/internal/builtin-plugins/solidity/hook-handlers/hre.ts +8 -0
  252. package/src/internal/builtin-plugins/solidity/tasks/build.ts +1 -1
  253. package/src/internal/builtin-plugins/solidity/type-extensions.ts +28 -0
  254. package/src/internal/builtin-plugins/solidity-test/config.ts +1 -0
  255. package/src/internal/builtin-plugins/solidity-test/edr-artifacts.ts +2 -2
  256. package/src/internal/builtin-plugins/solidity-test/runner.ts +1 -1
  257. package/src/internal/builtin-plugins/solidity-test/task-action.ts +36 -38
  258. package/src/internal/builtin-plugins/solidity-test/type-extensions.ts +1 -0
  259. package/src/internal/builtin-plugins/telemetry/task-action.ts +4 -2
  260. package/src/internal/builtin-plugins/test/task-action.ts +71 -25
  261. package/src/internal/builtin-plugins/test/type-extensions.ts +42 -0
  262. package/src/internal/cli/banner-manager.ts +234 -0
  263. package/src/internal/cli/error-handler.ts +18 -0
  264. package/src/internal/cli/init/init.ts +8 -0
  265. package/src/internal/cli/main.ts +19 -1
  266. package/src/internal/cli/telemetry/analytics/subprocess.ts +2 -0
  267. package/src/internal/cli/telemetry/sentry/anonymize-paths.ts +1 -1
  268. package/src/internal/cli/telemetry/sentry/reporter.ts +5 -0
  269. package/src/internal/cli/telemetry/sentry/vendor/integrations/contextlines.ts +98 -50
  270. package/src/internal/core/config-validation.ts +67 -18
  271. package/src/internal/core/tasks/builders.ts +174 -30
  272. package/src/internal/core/tasks/resolved-task.ts +31 -13
  273. package/src/internal/core/tasks/task-manager.ts +23 -5
  274. package/src/internal/core/tasks/validations.ts +40 -0
  275. package/src/internal/core/user-interruptions.ts +1 -1
  276. package/src/internal/deprecated-module-imported-from-hardhat2-plugin.ts +12 -0
  277. package/src/internal/using-hardhat2-plugin-errors.ts +108 -0
  278. package/src/plugins.ts +16 -0
  279. package/src/types/artifacts.ts +40 -3
  280. package/src/types/hre.ts +1 -1
  281. package/src/types/index.ts +14 -0
  282. package/src/types/network.ts +1 -1
  283. package/src/types/plugins.ts +2 -2
  284. package/src/types/solidity/build-system.ts +75 -14
  285. package/src/types/solidity/errors.ts +22 -0
  286. package/src/types/solidity/resolved-file.ts +2 -2
  287. package/src/types/tasks.ts +143 -36
  288. package/src/types/test.ts +12 -0
  289. package/src/types/utils.ts +14 -0
  290. package/src/utils/result.ts +57 -0
  291. package/templates/hardhat-3/01-node-test-runner-viem/package.json +11 -11
  292. package/templates/hardhat-3/02-mocha-ethers/package.json +16 -16
  293. package/templates/hardhat-3/03-minimal/package.json +1 -1
  294. package/dist/src/internal/builtin-plugins/network-manager/edr/types/output.d.ts +0 -19
  295. package/dist/src/internal/builtin-plugins/network-manager/edr/types/output.d.ts.map +0 -1
  296. package/dist/src/internal/builtin-plugins/network-manager/edr/types/output.js +0 -2
  297. package/dist/src/internal/builtin-plugins/network-manager/edr/types/output.js.map +0 -1
  298. package/src/internal/builtin-plugins/network-manager/edr/types/output.ts +0 -19
@@ -8,7 +8,7 @@ import type { TableItem } from "@nomicfoundation/hardhat-utils/format";
8
8
 
9
9
  import path from "node:path";
10
10
 
11
- import { divider, formatTable } from "@nomicfoundation/hardhat-utils/format";
11
+ import { formatTable } from "@nomicfoundation/hardhat-utils/format";
12
12
  import {
13
13
  ensureDir,
14
14
  getAllFilesMatching,
@@ -433,55 +433,60 @@ export class CoverageManagerImplementation implements CoverageManager {
433
433
 
434
434
  const rows: TableItem[] = [];
435
435
 
436
- rows.push([chalk.bold("Coverage Report")]);
437
- rows.push(divider);
436
+ rows.push({
437
+ type: "title",
438
+ text: chalk.bold("Coverage Report"),
439
+ });
438
440
 
439
- rows.push(
440
- ["File Path", "Line %", "Statement %", "Uncovered Lines"].map((s) =>
441
- chalk.yellow(s),
441
+ rows.push({
442
+ type: "section-header",
443
+ text: chalk.bold("File Coverage"),
444
+ });
445
+
446
+ rows.push({
447
+ type: "header",
448
+ cells: ["File Path", "Line %", "Statement %", "Uncovered Lines"].map(
449
+ (s) => chalk.yellow(s),
442
450
  ),
443
- );
451
+ });
444
452
 
445
- const bodyRows = Object.entries(report).map(
446
- ([
447
- relativePath,
448
- {
449
- executedStatementsCount,
450
- unexecutedStatementsCount,
451
- lineExecutionCounts,
452
- executedLinesCount,
453
- unexecutedLines,
454
- },
455
- ]) => {
456
- const lineCoverage =
457
- lineExecutionCounts.size === 0
458
- ? 0
459
- : (executedLinesCount * 100.0) / lineExecutionCounts.size;
460
- const statementCoverage =
461
- executedStatementsCount === 0
462
- ? 0
463
- : (executedStatementsCount * 100.0) /
464
- (executedStatementsCount + unexecutedStatementsCount);
465
-
466
- totalExecutedLines += executedLinesCount;
467
- totalExecutableLines += lineExecutionCounts.size;
468
-
469
- totalExecutedStatements += executedStatementsCount;
470
- totalExecutableStatements +=
471
- executedStatementsCount + unexecutedStatementsCount;
472
-
473
- const row: string[] = [
453
+ for (const [
454
+ relativePath,
455
+ {
456
+ executedStatementsCount,
457
+ unexecutedStatementsCount,
458
+ lineExecutionCounts,
459
+ executedLinesCount,
460
+ unexecutedLines,
461
+ },
462
+ ] of Object.entries(report)) {
463
+ const lineCoverage =
464
+ lineExecutionCounts.size === 0
465
+ ? 0
466
+ : (executedLinesCount * 100.0) / lineExecutionCounts.size;
467
+ const statementCoverage =
468
+ executedStatementsCount === 0
469
+ ? 0
470
+ : (executedStatementsCount * 100.0) /
471
+ (executedStatementsCount + unexecutedStatementsCount);
472
+
473
+ totalExecutedLines += executedLinesCount;
474
+ totalExecutableLines += lineExecutionCounts.size;
475
+
476
+ totalExecutedStatements += executedStatementsCount;
477
+ totalExecutableStatements +=
478
+ executedStatementsCount + unexecutedStatementsCount;
479
+
480
+ rows.push({
481
+ type: "row",
482
+ cells: [
474
483
  this.formatRelativePath(relativePath),
475
484
  this.formatCoverage(lineCoverage),
476
485
  this.formatCoverage(statementCoverage),
477
486
  this.formatLines(unexecutedLines),
478
- ];
479
-
480
- return row;
481
- },
482
- );
483
-
484
- rows.push(...bodyRows);
487
+ ],
488
+ });
489
+ }
485
490
 
486
491
  const totalLineCoverage =
487
492
  totalExecutableLines === 0
@@ -492,13 +497,15 @@ export class CoverageManagerImplementation implements CoverageManager {
492
497
  ? 0
493
498
  : (totalExecutedStatements * 100.0) / totalExecutableStatements;
494
499
 
495
- rows.push(divider);
496
- rows.push([
497
- chalk.yellow("Total"),
498
- this.formatCoverage(totalLineCoverage),
499
- this.formatCoverage(totalStatementCoverage),
500
- "",
501
- ]);
500
+ rows.push({
501
+ type: "header",
502
+ cells: [
503
+ chalk.yellow("Total"),
504
+ this.formatCoverage(totalLineCoverage),
505
+ this.formatCoverage(totalStatementCoverage),
506
+ "",
507
+ ],
508
+ });
502
509
 
503
510
  return formatTable(rows);
504
511
  }
@@ -1,50 +1,32 @@
1
1
  import path from "node:path";
2
2
 
3
- import { assertHardhatInvariant } from "@nomicfoundation/hardhat-errors";
4
-
5
- import { HardhatRuntimeEnvironmentImplementation } from "../../core/hre.js";
3
+ import {
4
+ testRunDone,
5
+ testRunStart,
6
+ testWorkerDone,
7
+ } from "./hook-handlers/test.js";
6
8
 
7
9
  export function getCoveragePath(rootPath: string): string {
8
10
  return path.join(rootPath, "coverage");
9
11
  }
10
12
 
11
13
  /**
12
- * NOTE: The following helpers interact with the global HRE instance only;
13
- * This is OK because:
14
- * - They are intended for the internal use only. They are exposed via the
15
- * internal public API only.
16
- * - We know the HRE has been initialized by the time they are used.
14
+ * The following helpers are kept for backward compatibility with older versions
15
+ * of test runner plugins (hardhat-mocha, hardhat-node-test-runner) that import
16
+ * from "hardhat/internal/coverage".
17
17
  */
18
18
 
19
19
  export async function markTestRunStart(id: string): Promise<void> {
20
20
  const { default: hre } = await import("../../../index.js");
21
- if (hre.globalOptions.coverage === true) {
22
- assertHardhatInvariant(
23
- hre instanceof HardhatRuntimeEnvironmentImplementation,
24
- "Expected HRE to be an instance of HardhatRuntimeEnvironmentImplementation",
25
- );
26
- await hre._coverage.clearData(id);
27
- }
21
+ await testRunStart(hre, id);
28
22
  }
29
23
 
30
24
  export async function markTestWorkerDone(id: string): Promise<void> {
31
25
  const { default: hre } = await import("../../../index.js");
32
- if (hre.globalOptions.coverage === true) {
33
- assertHardhatInvariant(
34
- hre instanceof HardhatRuntimeEnvironmentImplementation,
35
- "Expected HRE to be an instance of HardhatRuntimeEnvironmentImplementation",
36
- );
37
- await hre._coverage.saveData(id);
38
- }
26
+ await testWorkerDone(hre, id);
39
27
  }
40
28
 
41
29
  export async function markTestRunDone(id: string): Promise<void> {
42
30
  const { default: hre } = await import("../../../index.js");
43
- if (hre.globalOptions.coverage === true) {
44
- assertHardhatInvariant(
45
- hre instanceof HardhatRuntimeEnvironmentImplementation,
46
- "Expected HRE to be an instance of HardhatRuntimeEnvironmentImplementation",
47
- );
48
- await hre._coverage.report(id);
49
- }
31
+ await testRunDone(hre, id);
50
32
  }
@@ -0,0 +1,68 @@
1
+ import type { HookContext, TestHooks } from "../../../../types/hooks.js";
2
+
3
+ import { assertHardhatInvariant } from "@nomicfoundation/hardhat-errors";
4
+ import { isObject } from "@nomicfoundation/hardhat-utils/lang";
5
+
6
+ import { CoverageManagerImplementation } from "../coverage-manager.js";
7
+
8
+ export default async (): Promise<Partial<TestHooks>> => ({
9
+ onTestRunStart: async (context, id, next) => {
10
+ await next(context, id);
11
+ await testRunStart(context, id);
12
+ },
13
+
14
+ onTestWorkerDone: async (context, id, next) => {
15
+ await next(context, id);
16
+ await testWorkerDone(context, id);
17
+ },
18
+
19
+ onTestRunDone: async (context, id, next) => {
20
+ await next(context, id);
21
+ await testRunDone(context, id);
22
+ },
23
+ });
24
+
25
+ export async function testRunStart(
26
+ context: HookContext,
27
+ id: string,
28
+ ): Promise<void> {
29
+ if (context.globalOptions.coverage === true) {
30
+ assertHardhatInvariant(
31
+ "_coverage" in context &&
32
+ isObject(context._coverage) &&
33
+ context._coverage instanceof CoverageManagerImplementation,
34
+ "Expected HookContext#_coverage to be an instance of CoverageManagerImplementation",
35
+ );
36
+ await context._coverage.clearData(id);
37
+ }
38
+ }
39
+
40
+ export async function testWorkerDone(
41
+ context: HookContext,
42
+ id: string,
43
+ ): Promise<void> {
44
+ if (context.globalOptions.coverage === true) {
45
+ assertHardhatInvariant(
46
+ "_coverage" in context &&
47
+ isObject(context._coverage) &&
48
+ context._coverage instanceof CoverageManagerImplementation,
49
+ "Expected HookContext#_coverage to be an instance of CoverageManagerImplementation",
50
+ );
51
+ await context._coverage.saveData(id);
52
+ }
53
+ }
54
+
55
+ export async function testRunDone(
56
+ context: HookContext,
57
+ id: string,
58
+ ): Promise<void> {
59
+ if (context.globalOptions.coverage === true) {
60
+ assertHardhatInvariant(
61
+ "_coverage" in context &&
62
+ isObject(context._coverage) &&
63
+ context._coverage instanceof CoverageManagerImplementation,
64
+ "Expected HookContext#_coverage to be an instance of CoverageManagerImplementation",
65
+ );
66
+ await context._coverage.report(id);
67
+ }
68
+ }
@@ -17,6 +17,7 @@ const hardhatPlugin: HardhatPlugin = {
17
17
  clean: () => import("./hook-handlers/clean.js"),
18
18
  hre: () => import("./hook-handlers/hre.js"),
19
19
  solidity: () => import("./hook-handlers/solidity.js"),
20
+ test: () => import("./hook-handlers/test.js"),
20
21
  },
21
22
  npmPackage: "hardhat",
22
23
  };
@@ -64,6 +64,7 @@ const flattenAction: NewTaskActionFunction<FlattenActionArguments> = async (
64
64
  rootPaths.toSorted(), // We sort them to have a deterministic order
65
65
  config.paths.root,
66
66
  readSourceFileFactory(hooks),
67
+ hooks,
67
68
  );
68
69
 
69
70
  let flattened = "";
@@ -1,10 +1,10 @@
1
1
  import type { GasAnalyticsManager, GasMeasurement } from "./types.js";
2
- import type { TableItemV2 } from "@nomicfoundation/hardhat-utils/format";
2
+ import type { TableItem } from "@nomicfoundation/hardhat-utils/format";
3
3
 
4
4
  import crypto from "node:crypto";
5
5
  import path from "node:path";
6
6
 
7
- import { formatTableV2 } from "@nomicfoundation/hardhat-utils/format";
7
+ import { formatTable } from "@nomicfoundation/hardhat-utils/format";
8
8
  import {
9
9
  ensureDir,
10
10
  getAllFilesMatching,
@@ -209,7 +209,7 @@ export class GasAnalyticsManagerImplementation implements GasAnalyticsManager {
209
209
  public _generateGasStatsReport(
210
210
  gasStatsByContract: GasStatsByContract,
211
211
  ): string {
212
- const rows: TableItemV2[] = [];
212
+ const rows: TableItem[] = [];
213
213
 
214
214
  if (gasStatsByContract.size > 0) {
215
215
  rows.push({ type: "title", text: chalk.bold("Gas Usage Statistics") });
@@ -279,7 +279,7 @@ export class GasAnalyticsManagerImplementation implements GasAnalyticsManager {
279
279
  }
280
280
  }
281
281
 
282
- return formatTableV2(rows);
282
+ return formatTable(rows);
283
283
  }
284
284
  }
285
285
 
@@ -1,44 +1,26 @@
1
- import { assertHardhatInvariant } from "@nomicfoundation/hardhat-errors";
2
-
3
- import { HardhatRuntimeEnvironmentImplementation } from "../../core/hre.js";
1
+ import {
2
+ testRunDone,
3
+ testRunStart,
4
+ testWorkerDone,
5
+ } from "./hook-handlers/test.js";
4
6
 
5
7
  /**
6
- * NOTE: The following helpers interact with the global HRE instance only;
7
- * This is OK because:
8
- * - They are intended for the internal use only. They are exposed via the
9
- * internal public API only.
10
- * - We know the HRE has been initialized by the time they are used.
8
+ * The following helpers are kept for backward compatibility with older versions
9
+ * of test runner plugins (hardhat-mocha, hardhat-node-test-runner) that import
10
+ * from "hardhat/internal/gas-analytics".
11
11
  */
12
12
 
13
13
  export async function markTestRunStart(id: string): Promise<void> {
14
14
  const { default: hre } = await import("../../../index.js");
15
- if (hre.globalOptions.gasStats === true) {
16
- assertHardhatInvariant(
17
- hre instanceof HardhatRuntimeEnvironmentImplementation,
18
- "Expected HRE to be an instance of HardhatRuntimeEnvironmentImplementation",
19
- );
20
- await hre._gasAnalytics.clearGasMeasurements(id);
21
- }
15
+ await testRunStart(hre, id);
22
16
  }
23
17
 
24
18
  export async function markTestWorkerDone(id: string): Promise<void> {
25
19
  const { default: hre } = await import("../../../index.js");
26
- if (hre.globalOptions.gasStats === true) {
27
- assertHardhatInvariant(
28
- hre instanceof HardhatRuntimeEnvironmentImplementation,
29
- "Expected HRE to be an instance of HardhatRuntimeEnvironmentImplementation",
30
- );
31
- await hre._gasAnalytics.saveGasMeasurements(id);
32
- }
20
+ await testWorkerDone(hre, id);
33
21
  }
34
22
 
35
23
  export async function markTestRunDone(id: string): Promise<void> {
36
24
  const { default: hre } = await import("../../../index.js");
37
- if (hre.globalOptions.gasStats === true) {
38
- assertHardhatInvariant(
39
- hre instanceof HardhatRuntimeEnvironmentImplementation,
40
- "Expected HRE to be an instance of HardhatRuntimeEnvironmentImplementation",
41
- );
42
- await hre._gasAnalytics.reportGasStats(id);
43
- }
25
+ await testRunDone(hre, id);
44
26
  }
@@ -0,0 +1,68 @@
1
+ import type { HookContext, TestHooks } from "../../../../types/hooks.js";
2
+
3
+ import { assertHardhatInvariant } from "@nomicfoundation/hardhat-errors";
4
+ import { isObject } from "@nomicfoundation/hardhat-utils/lang";
5
+
6
+ import { GasAnalyticsManagerImplementation } from "../gas-analytics-manager.js";
7
+
8
+ export default async (): Promise<Partial<TestHooks>> => ({
9
+ onTestRunStart: async (context, id, next) => {
10
+ await next(context, id);
11
+ await testRunStart(context, id);
12
+ },
13
+
14
+ onTestWorkerDone: async (context, id, next) => {
15
+ await next(context, id);
16
+ await testWorkerDone(context, id);
17
+ },
18
+
19
+ onTestRunDone: async (context, id, next) => {
20
+ await next(context, id);
21
+ await testRunDone(context, id);
22
+ },
23
+ });
24
+
25
+ export async function testRunStart(
26
+ context: HookContext,
27
+ id: string,
28
+ ): Promise<void> {
29
+ if (context.globalOptions.gasStats === true) {
30
+ assertHardhatInvariant(
31
+ "_gasAnalytics" in context &&
32
+ isObject(context._gasAnalytics) &&
33
+ context._gasAnalytics instanceof GasAnalyticsManagerImplementation,
34
+ "Expected HookContext#_gasAnalytics to be an instance of GasAnalyticsManagerImplementation",
35
+ );
36
+ await context._gasAnalytics.clearGasMeasurements(id);
37
+ }
38
+ }
39
+
40
+ export async function testWorkerDone(
41
+ context: HookContext,
42
+ id: string,
43
+ ): Promise<void> {
44
+ if (context.globalOptions.gasStats === true) {
45
+ assertHardhatInvariant(
46
+ "_gasAnalytics" in context &&
47
+ isObject(context._gasAnalytics) &&
48
+ context._gasAnalytics instanceof GasAnalyticsManagerImplementation,
49
+ "Expected HookContext#_gasAnalytics to be an instance of GasAnalyticsManagerImplementation",
50
+ );
51
+ await context._gasAnalytics.saveGasMeasurements(id);
52
+ }
53
+ }
54
+
55
+ export async function testRunDone(
56
+ context: HookContext,
57
+ id: string,
58
+ ): Promise<void> {
59
+ if (context.globalOptions.gasStats === true) {
60
+ assertHardhatInvariant(
61
+ "_gasAnalytics" in context &&
62
+ isObject(context._gasAnalytics) &&
63
+ context._gasAnalytics instanceof GasAnalyticsManagerImplementation,
64
+ "Expected HookContext#_gasAnalytics to be an instance of GasAnalyticsManagerImplementation",
65
+ );
66
+ await context._gasAnalytics.reportGasStats(id);
67
+ }
68
+ }
@@ -16,6 +16,7 @@ const hardhatPlugin: HardhatPlugin = {
16
16
  ],
17
17
  hookHandlers: {
18
18
  hre: () => import("./hook-handlers/hre.js"),
19
+ test: () => import("./hook-handlers/test.js"),
19
20
  },
20
21
  npmPackage: "hardhat",
21
22
  };
@@ -1,4 +1,3 @@
1
- import type { SolidityStackTrace } from "./stack-traces/solidity-stack-trace.js";
2
1
  import type { CoverageConfig } from "./types/coverage.js";
3
2
  import type { LoggerConfig } from "./types/logger.js";
4
3
  import type {
@@ -63,14 +62,10 @@ import {
63
62
 
64
63
  import { EdrProviderStackTraceGenerationError } from "./stack-traces/stack-trace-generation-errors.js";
65
64
  import { createSolidityErrorWithStackTrace } from "./stack-traces/stack-trace-solidity-errors.js";
66
- import {
67
- isDebugTraceResult,
68
- isEdrProviderErrorData,
69
- } from "./type-validation.js";
65
+ import { isEdrProviderErrorData } from "./type-validation.js";
70
66
  import { clientVersion } from "./utils/client-version.js";
71
67
  import { ConsoleLogger } from "./utils/console-logger.js";
72
68
  import {
73
- edrRpcDebugTraceToHardhat,
74
69
  hardhatMiningIntervalToEdrMiningInterval,
75
70
  hardhatMempoolOrderToEdrMineOrdering,
76
71
  hardhatHardforkToEdrSpecId,
@@ -289,15 +284,6 @@ export class EdrProvider extends BaseProvider {
289
284
  "Invalid client version response",
290
285
  );
291
286
  return clientVersion(jsonRpcResponse.result);
292
- } else if (
293
- jsonRpcRequest.method === "debug_traceTransaction" ||
294
- jsonRpcRequest.method === "debug_traceCall"
295
- ) {
296
- assertHardhatInvariant(
297
- isDebugTraceResult(jsonRpcResponse.result),
298
- "Invalid debug trace response",
299
- );
300
- return edrRpcDebugTraceToHardhat(jsonRpcResponse.result);
301
287
  } else {
302
288
  return jsonRpcResponse.result;
303
289
  }
@@ -339,18 +325,9 @@ export class EdrProvider extends BaseProvider {
339
325
  const responseError = jsonRpcResponse.error;
340
326
  let error;
341
327
 
342
- let stackTrace: SolidityStackTrace | null = null;
343
- try {
344
- stackTrace = edrResponse.stackTrace();
345
- } catch (e) {
346
- if (e instanceof Error) {
347
- await sendErrorTelemetry(new EdrProviderStackTraceGenerationError(e));
348
- }
349
-
350
- log("Failed to get stack trace: %O", e);
351
- }
328
+ const stackTrace = edrResponse.stackTrace();
352
329
 
353
- if (stackTrace !== null) {
330
+ if (stackTrace?.kind === "StackTrace") {
354
331
  // If we have a stack trace, we know that the json rpc response data
355
332
  // is an object with the data and transactionHash fields
356
333
  assertHardhatInvariant(
@@ -360,11 +337,27 @@ export class EdrProvider extends BaseProvider {
360
337
 
361
338
  error = createSolidityErrorWithStackTrace(
362
339
  responseError.message,
363
- stackTrace,
340
+ stackTrace.entries,
364
341
  responseError.data.data,
365
342
  responseError.data.transactionHash,
366
343
  );
367
344
  } else {
345
+ if (stackTrace !== null) {
346
+ if (stackTrace.kind === "UnexpectedError") {
347
+ await sendErrorTelemetry(
348
+ new EdrProviderStackTraceGenerationError(stackTrace.errorMessage),
349
+ );
350
+ log(`Failed to get stack trace: ${stackTrace.errorMessage}`);
351
+ } else {
352
+ const errHeuristicFailed =
353
+ "Heuristic failed to generate stack trace";
354
+ await sendErrorTelemetry(
355
+ new EdrProviderStackTraceGenerationError(errHeuristicFailed),
356
+ );
357
+ log(`Failed to get stack trace: ${errHeuristicFailed}`);
358
+ }
359
+ }
360
+
368
361
  error =
369
362
  responseError.code === InvalidArgumentsError.CODE
370
363
  ? new InvalidArgumentsError(responseError.message)
@@ -373,7 +366,7 @@ export class EdrProvider extends BaseProvider {
373
366
  }
374
367
 
375
368
  /* eslint-disable-next-line no-restricted-syntax -- we may throw
376
- non-Hardaht errors inside of an EthereumProvider */
369
+ non-Hardhat errors inside of an EthereumProvider */
377
370
  throw error;
378
371
  }
379
372
 
@@ -3,8 +3,11 @@ import { CustomError } from "@nomicfoundation/hardhat-utils/error";
3
3
  abstract class StackTraceGenerationError extends CustomError {}
4
4
 
5
5
  export class EdrProviderStackTraceGenerationError extends StackTraceGenerationError {
6
- constructor(error: Error) {
7
- super("Failed to generate stack trace for the EDR provider", error);
6
+ constructor(message: string) {
7
+ super(
8
+ "Failed to generate stack trace for the EDR provider",
9
+ new Error(message),
10
+ );
8
11
  }
9
12
  }
10
13
 
@@ -1,18 +1,5 @@
1
- import type { DebugTraceResult } from "@nomicfoundation/edr";
2
-
3
1
  import { isObject } from "@nomicfoundation/hardhat-utils/lang";
4
2
 
5
- export function isDebugTraceResult(
6
- result: unknown,
7
- ): result is DebugTraceResult {
8
- return (
9
- isObject(result) &&
10
- "pass" in result &&
11
- "gasUsed" in result &&
12
- "structLogs" in result
13
- );
14
- }
15
-
16
3
  interface EdrProviderErrorData {
17
4
  data: string;
18
5
  transactionHash?: string;
@@ -9,10 +9,8 @@ import type {
9
9
  } from "../../../../../types/config.js";
10
10
  import type { ChainType } from "../../../../../types/network.js";
11
11
  import type { GasMeasurement } from "../../../gas-analytics/types.js";
12
- import type { RpcDebugTraceOutput, RpcStructLog } from "../types/output.js";
13
12
  import type {
14
13
  IntervalRange,
15
- DebugTraceResult,
16
14
  ChainOverride,
17
15
  ForkConfig,
18
16
  GasReport,
@@ -51,7 +49,6 @@ import {
51
49
  HOLOCENE,
52
50
  ISTHMUS,
53
51
  } from "@nomicfoundation/edr";
54
- import { getUnprefixedHexString } from "@nomicfoundation/hardhat-utils/hex";
55
52
 
56
53
  import {
57
54
  GENERIC_CHAIN_TYPE,
@@ -274,67 +271,6 @@ export function hardhatMempoolOrderToEdrMineOrdering(
274
271
  }
275
272
  }
276
273
 
277
- // TODO: EDR should handle this conversion. This is a temporary solution.
278
- export function edrRpcDebugTraceToHardhat(
279
- debugTraceResult: DebugTraceResult,
280
- ): RpcDebugTraceOutput {
281
- const structLogs = debugTraceResult.structLogs.map((log) => {
282
- const result: RpcStructLog = {
283
- depth: Number(log.depth),
284
- gas: Number(log.gas),
285
- gasCost: Number(log.gasCost),
286
- op: log.opName,
287
- pc: Number(log.pc),
288
- };
289
-
290
- if (log.memory !== undefined) {
291
- result.memory = log.memory;
292
- }
293
-
294
- if (log.stack !== undefined) {
295
- // Remove 0x prefix which is required by EIP-3155, but not expected by Hardhat.
296
- result.stack = log.stack.map(getUnprefixedHexString);
297
- }
298
-
299
- if (log.storage !== undefined) {
300
- result.storage = Object.fromEntries(
301
- Object.entries(log.storage).map(([key, value]) => [
302
- getUnprefixedHexString(key),
303
- getUnprefixedHexString(value),
304
- ]),
305
- );
306
- }
307
-
308
- if (log.error !== undefined) {
309
- result.error = {
310
- message: log.error,
311
- };
312
- }
313
-
314
- return result;
315
- });
316
-
317
- // REVM trace adds initial STOP that Hardhat doesn't expect
318
- // TODO: double check with EDR team that this is still the case
319
- if (structLogs.length > 0 && structLogs[0].op === "STOP") {
320
- structLogs.shift();
321
- }
322
-
323
- /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions --
324
- debugTraceResult.output is a string, but it's typed as Buffer in Edr */
325
- let returnValue = (debugTraceResult.output as unknown as string) ?? "0x";
326
- if (returnValue === "0x") {
327
- returnValue = "";
328
- }
329
-
330
- return {
331
- failed: !debugTraceResult.pass,
332
- gas: Number(debugTraceResult.gasUsed),
333
- returnValue,
334
- structLogs,
335
- };
336
- }
337
-
338
274
  export async function hardhatAccountsToEdrOwnedAccounts(
339
275
  accounts: EdrNetworkAccountsConfig,
340
276
  ): Promise<Array<{ secretKey: string; balance: bigint }>> {