hardhat 3.4.5 → 3.5.1

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 (248) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/dist/src/config.d.ts +0 -1
  3. package/dist/src/config.d.ts.map +1 -1
  4. package/dist/src/config.js.map +1 -1
  5. package/dist/src/hre.d.ts +0 -1
  6. package/dist/src/hre.d.ts.map +1 -1
  7. package/dist/src/hre.js.map +1 -1
  8. package/dist/src/index.d.ts +0 -1
  9. package/dist/src/index.d.ts.map +1 -1
  10. package/dist/src/index.js.map +1 -1
  11. package/dist/src/internal/builtin-global-options.d.ts.map +1 -1
  12. package/dist/src/internal/builtin-global-options.js +1 -1
  13. package/dist/src/internal/builtin-global-options.js.map +1 -1
  14. package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.d.ts +21 -0
  15. package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.d.ts.map +1 -1
  16. package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.js +49 -1
  17. package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.js.map +1 -1
  18. package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.d.ts +2 -1
  19. package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.d.ts.map +1 -1
  20. package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.js +12 -2
  21. package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.js.map +1 -1
  22. package/dist/src/internal/builtin-plugins/network-manager/config-resolution.d.ts.map +1 -1
  23. package/dist/src/internal/builtin-plugins/network-manager/config-resolution.js +9 -2
  24. package/dist/src/internal/builtin-plugins/network-manager/config-resolution.js.map +1 -1
  25. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.d.ts +1 -0
  26. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.d.ts.map +1 -1
  27. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.js +1 -0
  28. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.js.map +1 -1
  29. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.d.ts.map +1 -1
  30. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js +25 -5
  31. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js.map +1 -1
  32. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.d.ts +16 -0
  33. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.d.ts.map +1 -1
  34. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js +28 -1
  35. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js.map +1 -1
  36. package/dist/src/internal/builtin-plugins/network-manager/network-manager.d.ts.map +1 -1
  37. package/dist/src/internal/builtin-plugins/network-manager/network-manager.js +2 -6
  38. package/dist/src/internal/builtin-plugins/network-manager/network-manager.js.map +1 -1
  39. package/dist/src/internal/builtin-plugins/network-manager/type-extensions/config.d.ts +5 -3
  40. package/dist/src/internal/builtin-plugins/network-manager/type-extensions/config.d.ts.map +1 -1
  41. package/dist/src/internal/builtin-plugins/network-manager/type-validation.d.ts.map +1 -1
  42. package/dist/src/internal/builtin-plugins/network-manager/type-validation.js +3 -1
  43. package/dist/src/internal/builtin-plugins/network-manager/type-validation.js.map +1 -1
  44. package/dist/src/internal/builtin-plugins/network-manager/utils/apply-coverage-network-overrides.d.ts +18 -0
  45. package/dist/src/internal/builtin-plugins/network-manager/utils/apply-coverage-network-overrides.d.ts.map +1 -0
  46. package/dist/src/internal/builtin-plugins/network-manager/utils/apply-coverage-network-overrides.js +27 -0
  47. package/dist/src/internal/builtin-plugins/network-manager/utils/apply-coverage-network-overrides.js.map +1 -0
  48. package/dist/src/internal/builtin-plugins/node/json-rpc/handler.js +6 -5
  49. package/dist/src/internal/builtin-plugins/node/json-rpc/handler.js.map +1 -1
  50. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts +1 -4
  51. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts.map +1 -1
  52. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js +1 -11
  53. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.map +1 -1
  54. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.d.ts.map +1 -1
  55. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.js +1 -1
  56. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.js.map +1 -1
  57. package/dist/src/internal/builtin-plugins/solidity/build-system/warning-suppression.d.ts +6 -10
  58. package/dist/src/internal/builtin-plugins/solidity/build-system/warning-suppression.d.ts.map +1 -1
  59. package/dist/src/internal/builtin-plugins/solidity/build-system/warning-suppression.js +54 -43
  60. package/dist/src/internal/builtin-plugins/solidity/build-system/warning-suppression.js.map +1 -1
  61. package/dist/src/internal/builtin-plugins/solidity/constants.d.ts +10 -0
  62. package/dist/src/internal/builtin-plugins/solidity/constants.d.ts.map +1 -1
  63. package/dist/src/internal/builtin-plugins/solidity/constants.js +10 -0
  64. package/dist/src/internal/builtin-plugins/solidity/constants.js.map +1 -1
  65. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.d.ts.map +1 -1
  66. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js +2 -1
  67. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js.map +1 -1
  68. package/dist/src/internal/builtin-plugins/solidity/index.d.ts.map +1 -1
  69. package/dist/src/internal/builtin-plugins/solidity/index.js +1 -0
  70. package/dist/src/internal/builtin-plugins/solidity/index.js.map +1 -1
  71. package/dist/src/internal/builtin-plugins/solidity/tasks/compile.d.ts +9 -0
  72. package/dist/src/internal/builtin-plugins/solidity/tasks/compile.d.ts.map +1 -0
  73. package/dist/src/internal/builtin-plugins/solidity/tasks/compile.js +10 -0
  74. package/dist/src/internal/builtin-plugins/solidity/tasks/compile.js.map +1 -0
  75. package/dist/src/internal/builtin-plugins/solidity-test/config.d.ts +4 -3
  76. package/dist/src/internal/builtin-plugins/solidity-test/config.d.ts.map +1 -1
  77. package/dist/src/internal/builtin-plugins/solidity-test/config.js +55 -8
  78. package/dist/src/internal/builtin-plugins/solidity-test/config.js.map +1 -1
  79. package/dist/src/internal/builtin-plugins/solidity-test/eip712/ast-walker.d.ts +58 -0
  80. package/dist/src/internal/builtin-plugins/solidity-test/eip712/ast-walker.d.ts.map +1 -0
  81. package/dist/src/internal/builtin-plugins/solidity-test/eip712/ast-walker.js +226 -0
  82. package/dist/src/internal/builtin-plugins/solidity-test/eip712/ast-walker.js.map +1 -0
  83. package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.d.ts +29 -0
  84. package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.d.ts.map +1 -0
  85. package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.js +244 -0
  86. package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.js.map +1 -0
  87. package/dist/src/internal/builtin-plugins/solidity-test/eip712/glob.d.ts +7 -0
  88. package/dist/src/internal/builtin-plugins/solidity-test/eip712/glob.d.ts.map +1 -0
  89. package/dist/src/internal/builtin-plugins/solidity-test/eip712/glob.js +204 -0
  90. package/dist/src/internal/builtin-plugins/solidity-test/eip712/glob.js.map +1 -0
  91. package/dist/src/internal/builtin-plugins/solidity-test/eip712/index.d.ts +21 -0
  92. package/dist/src/internal/builtin-plugins/solidity-test/eip712/index.d.ts.map +1 -0
  93. package/dist/src/internal/builtin-plugins/solidity-test/eip712/index.js +77 -0
  94. package/dist/src/internal/builtin-plugins/solidity-test/eip712/index.js.map +1 -0
  95. package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts +4 -3
  96. package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts.map +1 -1
  97. package/dist/src/internal/builtin-plugins/solidity-test/helpers.js +20 -3
  98. package/dist/src/internal/builtin-plugins/solidity-test/helpers.js.map +1 -1
  99. package/dist/src/internal/builtin-plugins/solidity-test/task-action.d.ts.map +1 -1
  100. package/dist/src/internal/builtin-plugins/solidity-test/task-action.js +5 -1
  101. package/dist/src/internal/builtin-plugins/solidity-test/task-action.js.map +1 -1
  102. package/dist/src/internal/builtin-plugins/solidity-test/test-profiles.d.ts +2 -0
  103. package/dist/src/internal/builtin-plugins/solidity-test/test-profiles.d.ts.map +1 -0
  104. package/dist/src/internal/builtin-plugins/solidity-test/test-profiles.js +2 -0
  105. package/dist/src/internal/builtin-plugins/solidity-test/test-profiles.js.map +1 -0
  106. package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts +91 -32
  107. package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts.map +1 -1
  108. package/dist/src/internal/cli/error-handler.d.ts +11 -2
  109. package/dist/src/internal/cli/error-handler.d.ts.map +1 -1
  110. package/dist/src/internal/cli/error-handler.js +72 -46
  111. package/dist/src/internal/cli/error-handler.js.map +1 -1
  112. package/dist/src/internal/cli/init/init.d.ts +31 -6
  113. package/dist/src/internal/cli/init/init.d.ts.map +1 -1
  114. package/dist/src/internal/cli/init/init.js +126 -13
  115. package/dist/src/internal/cli/init/init.js.map +1 -1
  116. package/dist/src/internal/cli/init/package-manager.d.ts +7 -1
  117. package/dist/src/internal/cli/init/package-manager.d.ts.map +1 -1
  118. package/dist/src/internal/cli/init/package-manager.js +14 -2
  119. package/dist/src/internal/cli/init/package-manager.js.map +1 -1
  120. package/dist/src/internal/cli/main.d.ts.map +1 -1
  121. package/dist/src/internal/cli/main.js +42 -2
  122. package/dist/src/internal/cli/main.js.map +1 -1
  123. package/dist/src/internal/cli/telemetry/error-classification/classifier.d.ts +2 -1
  124. package/dist/src/internal/cli/telemetry/error-classification/classifier.d.ts.map +1 -1
  125. package/dist/src/internal/cli/telemetry/error-classification/classifier.js +2 -1
  126. package/dist/src/internal/cli/telemetry/error-classification/classifier.js.map +1 -1
  127. package/dist/src/internal/using-hardhat2-plugin-errors.d.ts.map +1 -1
  128. package/dist/src/internal/using-hardhat2-plugin-errors.js +8 -11
  129. package/dist/src/internal/using-hardhat2-plugin-errors.js.map +1 -1
  130. package/dist/src/types/arguments.d.ts +1 -0
  131. package/dist/src/types/arguments.d.ts.map +1 -1
  132. package/dist/src/types/arguments.js +1 -0
  133. package/dist/src/types/arguments.js.map +1 -1
  134. package/dist/src/types/artifacts.d.ts +1 -0
  135. package/dist/src/types/artifacts.d.ts.map +1 -1
  136. package/dist/src/types/artifacts.js +1 -1
  137. package/dist/src/types/artifacts.js.map +1 -1
  138. package/dist/src/types/builtin-plugin-type-extensions.d.ts +2 -0
  139. package/dist/src/types/builtin-plugin-type-extensions.d.ts.map +1 -0
  140. package/dist/src/types/builtin-plugin-type-extensions.js +2 -0
  141. package/dist/src/types/builtin-plugin-type-extensions.js.map +1 -0
  142. package/dist/src/types/config.d.ts +1 -0
  143. package/dist/src/types/config.d.ts.map +1 -1
  144. package/dist/src/types/config.js +1 -1
  145. package/dist/src/types/config.js.map +1 -1
  146. package/dist/src/types/global-options.d.ts +1 -0
  147. package/dist/src/types/global-options.d.ts.map +1 -1
  148. package/dist/src/types/global-options.js +1 -1
  149. package/dist/src/types/global-options.js.map +1 -1
  150. package/dist/src/types/hooks.d.ts +1 -0
  151. package/dist/src/types/hooks.d.ts.map +1 -1
  152. package/dist/src/types/hooks.js +1 -1
  153. package/dist/src/types/hooks.js.map +1 -1
  154. package/dist/src/types/hre.d.ts +1 -0
  155. package/dist/src/types/hre.d.ts.map +1 -1
  156. package/dist/src/types/hre.js +1 -1
  157. package/dist/src/types/hre.js.map +1 -1
  158. package/dist/src/types/index.d.ts +1 -0
  159. package/dist/src/types/index.d.ts.map +1 -1
  160. package/dist/src/types/index.js +1 -0
  161. package/dist/src/types/index.js.map +1 -1
  162. package/dist/src/types/network.d.ts +1 -0
  163. package/dist/src/types/network.d.ts.map +1 -1
  164. package/dist/src/types/network.js +1 -1
  165. package/dist/src/types/network.js.map +1 -1
  166. package/dist/src/types/plugins.d.ts +1 -1
  167. package/dist/src/types/plugins.d.ts.map +1 -1
  168. package/dist/src/types/plugins.js +1 -1
  169. package/dist/src/types/plugins.js.map +1 -1
  170. package/dist/src/types/providers.d.ts +1 -0
  171. package/dist/src/types/providers.d.ts.map +1 -1
  172. package/dist/src/types/providers.js +1 -1
  173. package/dist/src/types/providers.js.map +1 -1
  174. package/dist/src/types/solidity.d.ts +1 -0
  175. package/dist/src/types/solidity.d.ts.map +1 -1
  176. package/dist/src/types/solidity.js +1 -0
  177. package/dist/src/types/solidity.js.map +1 -1
  178. package/dist/src/types/tasks.d.ts +1 -0
  179. package/dist/src/types/tasks.d.ts.map +1 -1
  180. package/dist/src/types/tasks.js +1 -0
  181. package/dist/src/types/tasks.js.map +1 -1
  182. package/dist/src/types/test.d.ts +1 -0
  183. package/dist/src/types/test.d.ts.map +1 -1
  184. package/dist/src/types/test.js +1 -1
  185. package/dist/src/types/test.js.map +1 -1
  186. package/dist/src/types/user-interruptions.d.ts +1 -0
  187. package/dist/src/types/user-interruptions.d.ts.map +1 -1
  188. package/dist/src/types/user-interruptions.js +1 -1
  189. package/dist/src/types/user-interruptions.js.map +1 -1
  190. package/package.json +12 -11
  191. package/src/config.ts +0 -2
  192. package/src/hre.ts +0 -3
  193. package/src/index.ts +0 -3
  194. package/src/internal/builtin-global-options.ts +2 -1
  195. package/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.ts +90 -1
  196. package/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.ts +24 -2
  197. package/src/internal/builtin-plugins/network-manager/config-resolution.ts +11 -3
  198. package/src/internal/builtin-plugins/network-manager/edr/edr-constants.ts +2 -0
  199. package/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts +38 -8
  200. package/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.ts +43 -1
  201. package/src/internal/builtin-plugins/network-manager/network-manager.ts +5 -6
  202. package/src/internal/builtin-plugins/network-manager/type-extensions/config.ts +5 -3
  203. package/src/internal/builtin-plugins/network-manager/type-validation.ts +7 -1
  204. package/src/internal/builtin-plugins/network-manager/utils/apply-coverage-network-overrides.ts +32 -0
  205. package/src/internal/builtin-plugins/node/json-rpc/handler.ts +7 -5
  206. package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +2 -15
  207. package/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.ts +1 -2
  208. package/src/internal/builtin-plugins/solidity/build-system/warning-suppression.ts +81 -59
  209. package/src/internal/builtin-plugins/solidity/constants.ts +11 -0
  210. package/src/internal/builtin-plugins/solidity/hook-handlers/hre.ts +2 -1
  211. package/src/internal/builtin-plugins/solidity/index.ts +1 -0
  212. package/src/internal/builtin-plugins/solidity/tasks/compile.ts +12 -0
  213. package/src/internal/builtin-plugins/solidity-test/config.ts +85 -12
  214. package/src/internal/builtin-plugins/solidity-test/eip712/ast-walker.ts +324 -0
  215. package/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.ts +317 -0
  216. package/src/internal/builtin-plugins/solidity-test/eip712/glob.ts +225 -0
  217. package/src/internal/builtin-plugins/solidity-test/eip712/index.ts +120 -0
  218. package/src/internal/builtin-plugins/solidity-test/helpers.ts +28 -4
  219. package/src/internal/builtin-plugins/solidity-test/task-action.ts +12 -1
  220. package/src/internal/builtin-plugins/solidity-test/test-profiles.ts +1 -0
  221. package/src/internal/builtin-plugins/solidity-test/type-extensions.ts +100 -33
  222. package/src/internal/cli/error-handler.ts +103 -72
  223. package/src/internal/cli/init/init.ts +203 -16
  224. package/src/internal/cli/init/package-manager.ts +18 -1
  225. package/src/internal/cli/main.ts +65 -2
  226. package/src/internal/cli/telemetry/error-classification/classifier.ts +2 -1
  227. package/src/internal/using-hardhat2-plugin-errors.ts +8 -11
  228. package/src/types/arguments.ts +2 -0
  229. package/src/types/artifacts.ts +2 -0
  230. package/src/types/builtin-plugin-type-extensions.ts +15 -0
  231. package/src/types/config.ts +2 -0
  232. package/src/types/global-options.ts +2 -0
  233. package/src/types/hooks.ts +2 -0
  234. package/src/types/hre.ts +2 -0
  235. package/src/types/index.ts +2 -0
  236. package/src/types/network.ts +2 -0
  237. package/src/types/plugins.ts +1 -2
  238. package/src/types/providers.ts +2 -0
  239. package/src/types/solidity.ts +2 -0
  240. package/src/types/tasks.ts +2 -0
  241. package/src/types/test.ts +2 -0
  242. package/src/types/user-interruptions.ts +2 -0
  243. package/templates/hardhat-3/01-node-test-runner-viem/package.json +11 -11
  244. package/templates/hardhat-3/01-node-test-runner-viem/tsconfig.json +4 -7
  245. package/templates/hardhat-3/02-mocha-ethers/package.json +13 -13
  246. package/templates/hardhat-3/02-mocha-ethers/tsconfig.json +4 -7
  247. package/templates/hardhat-3/03-minimal/package.json +2 -2
  248. package/templates/hardhat-3/03-minimal/tsconfig.json +4 -7
@@ -1,3 +1,5 @@
1
+ import type * as ClassifierT from "./telemetry/error-classification/classifier.js";
2
+
1
3
  import { styleText } from "node:util";
2
4
 
3
5
  import {
@@ -6,19 +8,24 @@ import {
6
8
  } from "@nomicfoundation/hardhat-errors";
7
9
 
8
10
  import { HARDHAT_NAME, HARDHAT_WEBSITE_URL } from "../constants.js";
9
- import { UsingHardhat2PluginError } from "../using-hardhat2-plugin-errors.js";
11
+
12
+ // The classifier may import many unrelated things top-level to do its job, so
13
+ // we load it lazily.
14
+ let classifierModule: typeof ClassifierT | undefined;
10
15
 
11
16
  /**
12
17
  * The different categories of errors that can be handled by hardhat cli.
13
18
  * Each category has a different way of being formatted and displayed.
14
19
  * To add new categories, add a new entry to this enum and update the
15
- * {@link getErrorWithCategory} and {@link getErrorMessages} functions
16
- * accordingly.
20
+ * {@link getErrorWithCategory} function and the switch inside
21
+ * {@link printErrorMessages} accordingly.
17
22
  */
18
23
  enum ErrorCategory {
19
24
  HARDHAT = "HARDHAT",
20
25
  PLUGIN = "PLUGIN",
21
26
  COMMUNITY_PLUGIN = "COMMUNITY_PLUGIN",
27
+ HH2_TO_HH3_MIGRATION = "HH2_TO_HH3_MIGRATION",
28
+ CJS_TO_ESM_MIGRATION = "CJS_TO_ESM_MIGRATION",
22
29
  OTHER = "OTHER",
23
30
  }
24
31
 
@@ -35,55 +42,91 @@ type ErrorWithCategory =
35
42
  category: ErrorCategory.COMMUNITY_PLUGIN;
36
43
  categorizedError: HardhatPluginError;
37
44
  }
45
+ | {
46
+ category: ErrorCategory.HH2_TO_HH3_MIGRATION;
47
+ categorizedError: Error;
48
+ }
49
+ | {
50
+ category: ErrorCategory.CJS_TO_ESM_MIGRATION;
51
+ categorizedError: Error;
52
+ }
38
53
  | {
39
54
  category: ErrorCategory.OTHER;
40
55
  categorizedError: unknown;
41
56
  };
42
57
 
43
- /**
44
- * The different messages that can be displayed for each category of errors.
45
- * - `formattedErrorMessage`: the main error message that is always displayed.
46
- * - `showMoreInfoMessage`: an optional message that can be displayed to
47
- * provide more information about the error. It is only displayed when stack
48
- * traces are hidden.
49
- * - `postErrorStackTraceMessage` an optional message that can be displayed
50
- * after the stack trace. It is only displayed when stack traces are shown.
51
- */
52
- interface ErrorMessages {
53
- formattedErrorMessage: string;
54
- showMoreInfoMessage?: string;
55
- postErrorStackTraceMessage?: string;
56
- }
57
-
58
58
  /**
59
59
  * Formats and logs error messages based on the category the error belongs to.
60
60
  *
61
+ * For each category, we produce up to three pieces:
62
+ * - `formattedErrorMessage`: the main error message that is always displayed.
63
+ * - `showMoreInfoMessage`: an optional message that points the user at more
64
+ * info. It is only displayed when the stack trace is hidden.
65
+ * - `postErrorStackTraceMessage`: an optional message that is displayed after
66
+ * the stack trace.
67
+ *
61
68
  * @param error the error to handle. Supported categories are defined in
62
69
  * {@link ErrorCategory}.
63
70
  * @param shouldShowStackTraces whether to show stack traces or not. If true,
64
71
  * the stack trace is always shown. If false, the stack trace is only shown for
65
- * errors of category {@link ErrorCategory.OTHER}.
72
+ * errors of category {@link ErrorCategory.OTHER},
73
+ * {@link ErrorCategory.HH2_TO_HH3_MIGRATION}, and
74
+ * {@link ErrorCategory.CJS_TO_ESM_MIGRATION}.
66
75
  * @param print the function used to print the error message, defaults to
67
76
  * `console.error`. Useful for testing to capture error messages.
68
77
  */
69
- export function printErrorMessages(
78
+ export async function printErrorMessages(
70
79
  error: Error,
71
80
  shouldShowStackTraces: boolean = false,
72
81
  print: (message: string | Error) => void = console.error,
73
- ): void {
74
- if (error instanceof UsingHardhat2PluginError) {
75
- printUsingHardhat2Error(error, print);
76
- return;
82
+ ): Promise<void> {
83
+ const { category, categorizedError } = await getErrorWithCategory(error);
84
+
85
+ let formattedErrorMessage: string;
86
+ let showMoreInfoMessage: string | undefined;
87
+ let postErrorStackTraceMessage: string | undefined;
88
+
89
+ switch (category) {
90
+ case ErrorCategory.HARDHAT:
91
+ formattedErrorMessage = `${styleText(["red", "bold"], `Error ${categorizedError.errorCode}:`)} ${categorizedError.formattedMessage}`;
92
+ showMoreInfoMessage = `For more info go to ${HARDHAT_WEBSITE_URL}${categorizedError.errorCode} or run ${HARDHAT_NAME} with --show-stack-traces`;
93
+ break;
94
+ case ErrorCategory.PLUGIN:
95
+ formattedErrorMessage = `${styleText(["red", "bold"], `Error ${categorizedError.errorCode} in plugin ${categorizedError.pluginId}:`)} ${categorizedError.formattedMessage}`;
96
+ showMoreInfoMessage = `For more info go to ${HARDHAT_WEBSITE_URL}${categorizedError.errorCode} or run ${HARDHAT_NAME} with --show-stack-traces`;
97
+ break;
98
+ case ErrorCategory.COMMUNITY_PLUGIN:
99
+ formattedErrorMessage = `${styleText(["red", "bold"], `Error in community plugin ${categorizedError.pluginId}:`)} ${categorizedError.message}`;
100
+ showMoreInfoMessage = `For more info run ${HARDHAT_NAME} with --show-stack-traces`;
101
+ break;
102
+ case ErrorCategory.HH2_TO_HH3_MIGRATION:
103
+ formattedErrorMessage = styleText(
104
+ ["red", "bold"],
105
+ `Hardhat 3 migration error:`,
106
+ );
107
+ postErrorStackTraceMessage = `It looks like you are migrating from Hardhat 2 to Hardhat 3. The following error often shows up during this kind of migration.\nPlease read https://hardhat.org/migrate-from-hardhat2 to learn how to migrate your project to Hardhat 3.`;
108
+ break;
109
+ case ErrorCategory.CJS_TO_ESM_MIGRATION:
110
+ formattedErrorMessage = styleText(
111
+ ["red", "bold"],
112
+ `Hardhat 3 migration error:`,
113
+ );
114
+ postErrorStackTraceMessage = `It looks like you are migrating from CommonJS to ESM. The following error often shows up during this kind of migration.\nPlease read https://hardhat.org/migrate-to-esm to learn how to migrate your project to ESM.`;
115
+ break;
116
+ case ErrorCategory.OTHER:
117
+ formattedErrorMessage = styleText(
118
+ ["red", "bold"],
119
+ `An unexpected error occurred:`,
120
+ );
121
+ postErrorStackTraceMessage = `If you think this is a bug in Hardhat, please report it here: ${HARDHAT_WEBSITE_URL}report-bug`;
122
+ break;
77
123
  }
78
124
 
79
125
  const showStackTraces =
80
126
  shouldShowStackTraces ||
81
- getErrorWithCategory(error).category === ErrorCategory.OTHER;
82
- const {
83
- formattedErrorMessage,
84
- showMoreInfoMessage,
85
- postErrorStackTraceMessage,
86
- } = getErrorMessages(error);
127
+ category === ErrorCategory.OTHER ||
128
+ category === ErrorCategory.HH2_TO_HH3_MIGRATION ||
129
+ category === ErrorCategory.CJS_TO_ESM_MIGRATION;
87
130
 
88
131
  print(formattedErrorMessage);
89
132
 
@@ -100,7 +143,7 @@ export function printErrorMessages(
100
143
  }
101
144
  }
102
145
 
103
- function getErrorWithCategory(error: Error): ErrorWithCategory {
146
+ async function getErrorWithCategory(error: Error): Promise<ErrorWithCategory> {
104
147
  if (HardhatError.isHardhatError(error)) {
105
148
  if (error.pluginId === undefined) {
106
149
  return {
@@ -122,49 +165,37 @@ function getErrorWithCategory(error: Error): ErrorWithCategory {
122
165
  };
123
166
  }
124
167
 
168
+ if (classifierModule === undefined) {
169
+ classifierModule = await import(
170
+ "./telemetry/error-classification/classifier.js"
171
+ );
172
+ }
173
+
174
+ // Pass `ignoreDevelopmentTimeFilter=true` so the migration footer also shows
175
+ // when hardhat is run from inside its own monorepo — the dev-time filter is
176
+ // a telemetry concern (don't report to Sentry), unrelated to display routing.
177
+ const classifierCategory = classifierModule.classifyError(error, true);
178
+ if (
179
+ classifierCategory ===
180
+ classifierModule.ErrorCategory.HH2_TO_HH3_MIGRATION_ERROR
181
+ ) {
182
+ return {
183
+ category: ErrorCategory.HH2_TO_HH3_MIGRATION,
184
+ categorizedError: error,
185
+ };
186
+ }
187
+ if (
188
+ classifierCategory ===
189
+ classifierModule.ErrorCategory.CJS_TO_ESM_MIGRATION_ERROR
190
+ ) {
191
+ return {
192
+ category: ErrorCategory.CJS_TO_ESM_MIGRATION,
193
+ categorizedError: error,
194
+ };
195
+ }
196
+
125
197
  return {
126
198
  category: ErrorCategory.OTHER,
127
199
  categorizedError: error,
128
200
  };
129
201
  }
130
-
131
- function getErrorMessages(error: Error): ErrorMessages {
132
- const { category, categorizedError } = getErrorWithCategory(error);
133
- switch (category) {
134
- case ErrorCategory.HARDHAT:
135
- return {
136
- formattedErrorMessage: `${styleText(["red", "bold"], `Error ${categorizedError.errorCode}:`)} ${categorizedError.formattedMessage}`,
137
- showMoreInfoMessage: `For more info go to ${HARDHAT_WEBSITE_URL}${categorizedError.errorCode} or run ${HARDHAT_NAME} with --show-stack-traces`,
138
- };
139
- case ErrorCategory.PLUGIN:
140
- return {
141
- formattedErrorMessage: `${styleText(["red", "bold"], `Error ${categorizedError.errorCode} in plugin ${categorizedError.pluginId}:`)} ${categorizedError.formattedMessage}`,
142
- showMoreInfoMessage: `For more info go to ${HARDHAT_WEBSITE_URL}${categorizedError.errorCode} or run ${HARDHAT_NAME} with --show-stack-traces`,
143
- };
144
- case ErrorCategory.COMMUNITY_PLUGIN:
145
- return {
146
- formattedErrorMessage: `${styleText(["red", "bold"], `Error in community plugin ${categorizedError.pluginId}:`)} ${categorizedError.message}`,
147
- showMoreInfoMessage: `For more info run ${HARDHAT_NAME} with --show-stack-traces`,
148
- };
149
- case ErrorCategory.OTHER:
150
- return {
151
- formattedErrorMessage: styleText(
152
- ["red", "bold"],
153
- `An unexpected error occurred:`,
154
- ),
155
- postErrorStackTraceMessage: `If you think this is a bug in Hardhat, please report it here: ${HARDHAT_WEBSITE_URL}report-bug`,
156
- };
157
- }
158
- }
159
- function printUsingHardhat2Error(
160
- error: UsingHardhat2PluginError,
161
- print: (message: string | Error) => void = console.error,
162
- ): void {
163
- print(styleText(["red", "bold"], `Hardhat 3 installation error:`));
164
- print("");
165
- if (error.callerRelativePath !== undefined) {
166
- print(error.message);
167
- } else {
168
- print(error.stack);
169
- }
170
- }
@@ -35,6 +35,7 @@ import { sendErrorTelemetry } from "../telemetry/error-reporter/reporter.js";
35
35
  import {
36
36
  getDevDependenciesInstallationCommand,
37
37
  getPackageManager,
38
+ getVersion,
38
39
  installsPeerDependenciesByDefault,
39
40
  } from "./package-manager.js";
40
41
  import {
@@ -49,6 +50,10 @@ import {
49
50
  import { spawn } from "./subprocess.js";
50
51
  import { getTemplates } from "./template.js";
51
52
 
53
+ export interface NonInteractiveInitHardhat3Options {
54
+ template: string;
55
+ }
56
+
52
57
  export interface InitHardhatOptions {
53
58
  hardhatVersion?: "hardhat-2" | "hardhat-3";
54
59
  workspace?: string;
@@ -60,6 +65,61 @@ export interface InitHardhatOptions {
60
65
 
61
66
  const log = createDebug("hardhat:core:cli:init");
62
67
 
68
+ export async function initHardhat3NonInteractive(
69
+ options: NonInteractiveInitHardhat3Options,
70
+ ): Promise<void> {
71
+ const [template, projectTypeAnalyticsPromise] = await getTemplate(
72
+ "hardhat-3",
73
+ options.template,
74
+ true,
75
+ );
76
+
77
+ const workspace = process.cwd();
78
+
79
+ try {
80
+ const configFilePath = await findClosestHardhatConfig(workspace);
81
+
82
+ throw new HardhatError(
83
+ HardhatError.ERRORS.CORE.GENERAL.HARDHAT_PROJECT_ALREADY_CREATED,
84
+ {
85
+ hardhatProjectRootPath: configFilePath,
86
+ },
87
+ );
88
+ } catch (err) {
89
+ if (
90
+ !HardhatError.isHardhatError(
91
+ err,
92
+ HardhatError.ERRORS.CORE.GENERAL.NO_CONFIG_FILE_FOUND,
93
+ )
94
+ ) {
95
+ throw err;
96
+ }
97
+ }
98
+
99
+ await assertNoNonInteractiveClashes(workspace, template);
100
+
101
+ console.log("Initializing project...");
102
+
103
+ await validatePackageJson(workspace, template.packageJson, true);
104
+
105
+ await copyProjectFilesNonInteractive(workspace, template);
106
+
107
+ console.log("Installing dependencies...");
108
+
109
+ await Promise.all([
110
+ installProjectDependencies({
111
+ workspace,
112
+ template,
113
+ install: true,
114
+ update: true,
115
+ formatSuccessMessage: false,
116
+ }),
117
+ projectTypeAnalyticsPromise,
118
+ ]);
119
+
120
+ console.log("Project initialized");
121
+ }
122
+
63
123
  /**
64
124
  * initHardhat implements the project initialization wizard flow.
65
125
  *
@@ -126,7 +186,11 @@ export async function initHardhat(options?: InitHardhatOptions): Promise<void> {
126
186
  // Run them only if the user opts-in to it
127
187
  // Concurrently, await the analytics hit
128
188
  await Promise.all([
129
- installProjectDependencies(workspace, template, options?.install),
189
+ installProjectDependencies({
190
+ workspace,
191
+ template,
192
+ install: options?.install,
193
+ }),
130
194
  projectTypeAnalyticsPromise,
131
195
  ]);
132
196
 
@@ -270,12 +334,17 @@ export async function getWorkspace(workspace?: string): Promise<string> {
270
334
  *
271
335
  * NOTE: This function is exported for testing purposes
272
336
  *
337
+ * @param hardhatVersion The version of Hardhat whose templates should be considered.
273
338
  * @param template The name of the template to use for the project initialization.
339
+ * @param includeAvailableTemplatesInErrors When true, a missing template throws
340
+ * `TEMPLATE_NOT_FOUND_WITH_LIST_OF_OPTIONS` (which lists the available
341
+ * templates) instead of the bare `TEMPLATE_NOT_FOUND`.
274
342
  * @returns A tuple with two elements: the template and a promise with the analytics hit.
275
343
  */
276
344
  export async function getTemplate(
277
345
  hardhatVersion: "hardhat-2" | "hardhat-3",
278
346
  template?: string,
347
+ includeAvailableTemplatesInErrors = false,
279
348
  ): Promise<[Template, Promise<boolean>]> {
280
349
  const templates = await getTemplates(hardhatVersion);
281
350
 
@@ -299,9 +368,38 @@ export async function getTemplate(
299
368
  // we wait for the GA hit before throwing
300
369
  await projectTypeAnalyticsPromise;
301
370
 
302
- throw new HardhatError(HardhatError.ERRORS.CORE.GENERAL.TEMPLATE_NOT_FOUND, {
303
- template,
304
- });
371
+ if (!includeAvailableTemplatesInErrors) {
372
+ throw new HardhatError(
373
+ HardhatError.ERRORS.CORE.GENERAL.TEMPLATE_NOT_FOUND,
374
+ {
375
+ template,
376
+ },
377
+ );
378
+ }
379
+
380
+ const availableTemplates = templates.map((t) => ` - ${t.name}`).join("\n");
381
+ throw new HardhatError(
382
+ HardhatError.ERRORS.CORE.GENERAL.TEMPLATE_NOT_FOUND_WITH_LIST_OF_OPTIONS,
383
+ {
384
+ template,
385
+ availableTemplates,
386
+ },
387
+ );
388
+ }
389
+
390
+ /**
391
+ * Prints the list of available templates for the specified Hardhat version.
392
+ *
393
+ * @param hardhatVersion The version of Hardhat whose templates should be
394
+ * printed.
395
+ */
396
+ export async function printTemplatesList(
397
+ hardhatVersion: "hardhat-2" | "hardhat-3",
398
+ print: (message: string) => void = console.log,
399
+ ): Promise<void> {
400
+ const templates = await getTemplates(hardhatVersion);
401
+ const lines = templates.map((t) => ` - ${t.name}`).join("\n");
402
+ print(`Available templates:\n${lines}`);
305
403
  }
306
404
 
307
405
  /**
@@ -496,23 +594,100 @@ export async function copyProjectFiles(
496
594
  console.log(`✨ ${styleText("cyan", `Template files copied`)} ✨`);
497
595
  }
498
596
 
597
+ // NOTE: This function is exported for testing purposes
598
+ export async function assertNoNonInteractiveClashes(
599
+ workspace: string,
600
+ template: Template,
601
+ ): Promise<void> {
602
+ const clashes: string[] = [];
603
+
604
+ for (const relativeTemplatePath of template.files) {
605
+ const relativeWorkspacePath =
606
+ relativeTemplateToWorkspacePath(relativeTemplatePath);
607
+
608
+ if (
609
+ relativeWorkspacePath === "package.json" ||
610
+ relativeWorkspacePath === "README.md" ||
611
+ path.basename(relativeWorkspacePath) === ".gitignore"
612
+ ) {
613
+ continue;
614
+ }
615
+
616
+ if (await exists(path.join(workspace, relativeWorkspacePath))) {
617
+ clashes.push(relativeWorkspacePath);
618
+ }
619
+ }
620
+
621
+ if (clashes.length === 0) {
622
+ return;
623
+ }
624
+
625
+ throw new HardhatError(
626
+ HardhatError.ERRORS.CORE.GENERAL.NON_INTERACTIVE_INIT_WOULD_OVERWRITE_FILES,
627
+ {
628
+ files: clashes.map((f) => ` - ${f}`).join("\n"),
629
+ },
630
+ );
631
+ }
632
+
633
+ // NOTE: This function is exported for testing purposes
634
+ export async function copyProjectFilesNonInteractive(
635
+ workspace: string,
636
+ template: Template,
637
+ ): Promise<void> {
638
+ for (const relativeTemplatePath of template.files) {
639
+ const relativeWorkspacePath =
640
+ relativeTemplateToWorkspacePath(relativeTemplatePath);
641
+ let absoluteWorkspacePath = path.join(workspace, relativeWorkspacePath);
642
+
643
+ if (path.basename(relativeWorkspacePath) === ".gitignore") {
644
+ if (await exists(absoluteWorkspacePath)) {
645
+ continue;
646
+ }
647
+ } else if (
648
+ relativeWorkspacePath === "README.md" &&
649
+ (await exists(absoluteWorkspacePath))
650
+ ) {
651
+ absoluteWorkspacePath = path.join(workspace, "HARDHAT.md");
652
+ if (await exists(absoluteWorkspacePath)) {
653
+ continue;
654
+ }
655
+ }
656
+
657
+ await ensureDir(path.dirname(absoluteWorkspacePath));
658
+ await copy(
659
+ path.join(template.path, relativeTemplatePath),
660
+ absoluteWorkspacePath,
661
+ );
662
+ }
663
+ }
664
+
499
665
  /**
500
666
  * installProjectDependencies prints the commands to install the project dependencies
501
667
  * and runs them if the install option is true or if the user opts-in to it.
502
668
  *
503
669
  * NOTE: This function is exported for testing purposes
504
670
  *
505
- * @param workspace The path to the workspace to initialize the project in.
506
- * @param template The template to use for the project initialization.
507
- * @param install Whether to install the project dependencies.
508
- * @param update Whether to update the project dependencies.
671
+ * @param options The installation options.
672
+ * @param options.workspace The path to the workspace to initialize the project in.
673
+ * @param options.template The template to use for the project initialization.
674
+ * @param options.install Whether to install the project dependencies.
675
+ * @param options.update Whether to update the project dependencies.
676
+ * @param options.formatSuccessMessage Whether to format the success message or not.
509
677
  */
510
- export async function installProjectDependencies(
511
- workspace: string,
512
- template: Template,
513
- install?: boolean,
514
- update?: boolean,
515
- ): Promise<void> {
678
+ export async function installProjectDependencies({
679
+ workspace,
680
+ template,
681
+ install,
682
+ update,
683
+ formatSuccessMessage = true,
684
+ }: {
685
+ workspace: string;
686
+ template: Template;
687
+ install?: boolean;
688
+ update?: boolean;
689
+ formatSuccessMessage?: boolean;
690
+ }): Promise<void> {
516
691
  const pathToWorkspacePackageJson = path.join(workspace, "package.json");
517
692
 
518
693
  const workspacePkg: PackageJson = await readJsonFile(
@@ -520,6 +695,8 @@ export async function installProjectDependencies(
520
695
  );
521
696
 
522
697
  const packageManager = getPackageManager();
698
+ const packageManagerVersion = await getVersion(workspace, packageManager);
699
+ const packageManagerMajorVersion = packageManagerVersion?.[0];
523
700
 
524
701
  // Find the template dev dependencies that are not already installed
525
702
  const templateDependencies = template.packageJson.devDependencies ?? {};
@@ -556,6 +733,7 @@ export async function installProjectDependencies(
556
733
  const command = getDevDependenciesInstallationCommand(
557
734
  packageManager,
558
735
  dependenciesToInstall,
736
+ packageManagerMajorVersion,
559
737
  );
560
738
  const commandString = command.join(" ");
561
739
 
@@ -587,7 +765,11 @@ export async function installProjectDependencies(
587
765
  );
588
766
  }
589
767
 
590
- console.log(`✨ ${styleText("cyan", `Dependencies installed`)} ✨`);
768
+ if (formatSuccessMessage) {
769
+ console.log(`✨ ${styleText("cyan", `Dependencies installed`)} ✨`);
770
+ } else {
771
+ console.log(`Dependencies installed`);
772
+ }
591
773
  }
592
774
  }
593
775
 
@@ -610,6 +792,7 @@ export async function installProjectDependencies(
610
792
  const command = getDevDependenciesInstallationCommand(
611
793
  packageManager,
612
794
  dependenciesToUpdate,
795
+ packageManagerMajorVersion,
613
796
  );
614
797
  const commandString = command.join(" ");
615
798
 
@@ -640,7 +823,11 @@ export async function installProjectDependencies(
640
823
  );
641
824
  }
642
825
 
643
- console.log(`✨ ${styleText("cyan", `Dependencies updated`)} ✨`);
826
+ if (formatSuccessMessage) {
827
+ console.log(`✨ ${styleText("cyan", `Dependencies updated`)} ✨`);
828
+ } else {
829
+ console.log("Dependencies updated");
830
+ }
644
831
  }
645
832
  }
646
833
  }
@@ -104,11 +104,16 @@ export function getPackageManager(): PackageManager {
104
104
  *
105
105
  * @param packageManager The package manager to use.
106
106
  * @param dependencies The dependencies to install.
107
+ * @param packageManagerMajorVersion The major version of the package manager,
108
+ * if known. Used to opt into version-specific flags (e.g. pnpm 11's
109
+ * `--allow-build=esbuild`, required because `tsx` ships `esbuild` whose
110
+ * postinstall script is otherwise blocked).
107
111
  * @returns The installation command.
108
112
  */
109
113
  export function getDevDependenciesInstallationCommand(
110
114
  packageManager: PackageManager,
111
115
  dependencies: string[],
116
+ packageManagerMajorVersion?: number,
112
117
  ): string[] {
113
118
  const packageManagerToCommand: Record<PackageManager, string[]> = {
114
119
  npm: ["npm", "install", "--save-dev"],
@@ -118,6 +123,18 @@ export function getDevDependenciesInstallationCommand(
118
123
  bun: ["bun", "add", "--dev"],
119
124
  };
120
125
  const command = packageManagerToCommand[packageManager];
126
+
127
+ // NOTE: adding an unnecessary flag doesn't result in an error
128
+ // nor warning, so we don't check if hardhat or tsx are being
129
+ // installed.
130
+ if (
131
+ packageManager === "pnpm" &&
132
+ packageManagerMajorVersion !== undefined &&
133
+ packageManagerMajorVersion >= 11
134
+ ) {
135
+ command.push("--allow-build=esbuild");
136
+ }
137
+
121
138
  // We quote all the dependency identifiers so that they can be run on a shell
122
139
  // without semver symbols interfering with the command
123
140
  command.push(
@@ -205,7 +222,7 @@ export async function installsPeerDependenciesByDefault(
205
222
  }
206
223
  }
207
224
 
208
- async function getVersion(
225
+ export async function getVersion(
209
226
  workspace: string,
210
227
  packageManager: PackageManager,
211
228
  version?: string,
@@ -96,7 +96,70 @@ export async function main(
96
96
  }
97
97
 
98
98
  if (builtinGlobalOptions.init) {
99
- const { initHardhat } = await import("./init/init.js");
99
+ const { initHardhat, initHardhat3NonInteractive, printTemplatesList } =
100
+ await import("./init/init.js");
101
+
102
+ let templateName: string | undefined;
103
+ let listTemplates = false;
104
+
105
+ for (let i = 0; i < cliArguments.length; i++) {
106
+ if (usedCliArguments[i]) {
107
+ continue;
108
+ }
109
+
110
+ if (cliArguments[i] === "--templates") {
111
+ usedCliArguments[i] = true;
112
+ listTemplates = true;
113
+ }
114
+ }
115
+
116
+ for (let i = 0; i < cliArguments.length; i++) {
117
+ if (usedCliArguments[i]) {
118
+ continue;
119
+ }
120
+
121
+ if (cliArguments[i] === "--template") {
122
+ usedCliArguments[i] = true;
123
+
124
+ if (templateName !== undefined) {
125
+ throw new HardhatError(
126
+ HardhatError.ERRORS.CORE.ARGUMENTS.DUPLICATED_NAME,
127
+ { name: "--template" },
128
+ );
129
+ }
130
+
131
+ if (listTemplates) {
132
+ throw new HardhatError(
133
+ HardhatError.ERRORS.CORE.ARGUMENTS.CANNOT_COMBINE_TEMPLATE_AND_TEMPLATES,
134
+ );
135
+ }
136
+
137
+ if (
138
+ usedCliArguments[i + 1] === undefined ||
139
+ usedCliArguments[i + 1] === true ||
140
+ cliArguments[i + 1] === undefined ||
141
+ cliArguments[i + 1].startsWith("-")
142
+ ) {
143
+ throw new HardhatError(
144
+ HardhatError.ERRORS.CORE.ARGUMENTS.MISSING_VALUE_FOR_ARGUMENT,
145
+ { argument: "--template" },
146
+ );
147
+ }
148
+
149
+ templateName = cliArguments[i + 1];
150
+ i++;
151
+ usedCliArguments[i] = true;
152
+ }
153
+ }
154
+
155
+ if (listTemplates) {
156
+ return await printTemplatesList("hardhat-3", print);
157
+ }
158
+
159
+ if (templateName !== undefined) {
160
+ return await initHardhat3NonInteractive({ template: templateName });
161
+ }
162
+
100
163
  return await initHardhat();
101
164
  }
102
165
 
@@ -255,7 +318,7 @@ export async function main(
255
318
  }
256
319
  } catch (error) {
257
320
  ensureError(error);
258
- printErrorMessages(error, builtinGlobalOptions?.showStackTraces);
321
+ await printErrorMessages(error, builtinGlobalOptions?.showStackTraces);
259
322
 
260
323
  try {
261
324
  await sendErrorTelemetry(error);
@@ -70,7 +70,8 @@ import {
70
70
  * @param error The error to classify.
71
71
  * @param ignoreDevelopmentTimeFilter If true, the classifier will ignore the
72
72
  * development-time filter, which is used to exclude errors that happen during
73
- * development of Hardhat itself. This is only meant to be used for testing.
73
+ * development of Hardhat itself. Set this from display-side callers (where the
74
+ * dev-time skip is irrelevant) and from tests.
74
75
  * @returns The error category.
75
76
  */
76
77
  export function classifyError(