hardhat 3.4.0 → 3.4.2

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 (275) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/src/cli.js +5 -5
  3. package/dist/src/cli.js.map +1 -1
  4. package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.d.ts.map +1 -1
  5. package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.js +11 -4
  6. package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.js.map +1 -1
  7. package/dist/src/internal/builtin-plugins/artifacts/hook-handlers/hre.d.ts.map +1 -1
  8. package/dist/src/internal/builtin-plugins/artifacts/hook-handlers/hre.js +10 -10
  9. package/dist/src/internal/builtin-plugins/artifacts/hook-handlers/hre.js.map +1 -1
  10. package/dist/src/internal/builtin-plugins/clean/index.js +1 -1
  11. package/dist/src/internal/builtin-plugins/clean/index.js.map +1 -1
  12. package/dist/src/internal/builtin-plugins/console/index.js +1 -1
  13. package/dist/src/internal/builtin-plugins/console/index.js.map +1 -1
  14. package/dist/src/internal/builtin-plugins/coverage/exports.d.ts +1 -1
  15. package/dist/src/internal/builtin-plugins/coverage/exports.d.ts.map +1 -1
  16. package/dist/src/internal/builtin-plugins/coverage/exports.js +1 -1
  17. package/dist/src/internal/builtin-plugins/coverage/exports.js.map +1 -1
  18. package/dist/src/internal/builtin-plugins/coverage/helpers/accessors.d.ts +7 -0
  19. package/dist/src/internal/builtin-plugins/coverage/helpers/accessors.d.ts.map +1 -0
  20. package/dist/src/internal/builtin-plugins/coverage/helpers/accessors.js +24 -0
  21. package/dist/src/internal/builtin-plugins/coverage/helpers/accessors.js.map +1 -0
  22. package/dist/src/internal/builtin-plugins/coverage/helpers/compat.d.ts +4 -0
  23. package/dist/src/internal/builtin-plugins/coverage/helpers/compat.d.ts.map +1 -0
  24. package/dist/src/internal/builtin-plugins/coverage/helpers/compat.js +27 -0
  25. package/dist/src/internal/builtin-plugins/coverage/helpers/compat.js.map +1 -0
  26. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/clean.js +1 -1
  27. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/clean.js.map +1 -1
  28. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/hre.d.ts.map +1 -1
  29. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/hre.js +18 -15
  30. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/hre.js.map +1 -1
  31. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js +3 -3
  32. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js.map +1 -1
  33. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.js +1 -1
  34. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.js.map +1 -1
  35. package/dist/src/internal/builtin-plugins/flatten/index.js +1 -1
  36. package/dist/src/internal/builtin-plugins/flatten/index.js.map +1 -1
  37. package/dist/src/internal/builtin-plugins/gas-analytics/helpers/accessors.d.ts.map +1 -1
  38. package/dist/src/internal/builtin-plugins/gas-analytics/helpers/accessors.js +10 -4
  39. package/dist/src/internal/builtin-plugins/gas-analytics/helpers/accessors.js.map +1 -1
  40. package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.d.ts.map +1 -1
  41. package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.js +18 -14
  42. package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.js.map +1 -1
  43. package/dist/src/internal/builtin-plugins/gas-analytics/index.d.ts.map +1 -1
  44. package/dist/src/internal/builtin-plugins/gas-analytics/index.js +2 -2
  45. package/dist/src/internal/builtin-plugins/gas-analytics/index.js.map +1 -1
  46. package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.d.ts.map +1 -1
  47. package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.js +2 -7
  48. package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.js.map +1 -1
  49. package/dist/src/internal/builtin-plugins/network-manager/config-resolution.js +1 -1
  50. package/dist/src/internal/builtin-plugins/network-manager/config-resolution.js.map +1 -1
  51. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.d.ts +14 -0
  52. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.d.ts.map +1 -0
  53. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.js +40 -0
  54. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.js.map +1 -0
  55. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.d.ts +1 -12
  56. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.d.ts.map +1 -1
  57. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js +3 -42
  58. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js.map +1 -1
  59. package/dist/src/internal/builtin-plugins/network-manager/edr/genesis-state.js +1 -1
  60. package/dist/src/internal/builtin-plugins/network-manager/edr/genesis-state.js.map +1 -1
  61. package/dist/src/internal/builtin-plugins/network-manager/edr/types/hardfork.d.ts.map +1 -1
  62. package/dist/src/internal/builtin-plugins/network-manager/edr/types/hardfork.js +2 -5
  63. package/dist/src/internal/builtin-plugins/network-manager/edr/types/hardfork.js.map +1 -1
  64. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js +2 -2
  65. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js.map +1 -1
  66. package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/hre.js +4 -4
  67. package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/hre.js.map +1 -1
  68. package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/network.js +2 -2
  69. package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/network.js.map +1 -1
  70. package/dist/src/internal/builtin-plugins/network-manager/http-provider.d.ts.map +1 -1
  71. package/dist/src/internal/builtin-plugins/network-manager/http-provider.js +2 -2
  72. package/dist/src/internal/builtin-plugins/network-manager/http-provider.js.map +1 -1
  73. package/dist/src/internal/builtin-plugins/network-manager/network-manager.d.ts.map +1 -1
  74. package/dist/src/internal/builtin-plugins/network-manager/network-manager.js +7 -7
  75. package/dist/src/internal/builtin-plugins/network-manager/network-manager.js.map +1 -1
  76. package/dist/src/internal/builtin-plugins/node/helpers.js +2 -2
  77. package/dist/src/internal/builtin-plugins/node/helpers.js.map +1 -1
  78. package/dist/src/internal/builtin-plugins/node/index.js +1 -1
  79. package/dist/src/internal/builtin-plugins/node/index.js.map +1 -1
  80. package/dist/src/internal/builtin-plugins/run/index.js +1 -1
  81. package/dist/src/internal/builtin-plugins/run/index.js.map +1 -1
  82. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts.map +1 -1
  83. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js +61 -28
  84. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.map +1 -1
  85. package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job.js +1 -1
  86. package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job.js.map +1 -1
  87. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.js +4 -4
  88. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.js.map +1 -1
  89. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/index.js +2 -2
  90. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/index.js.map +1 -1
  91. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-runner.js +1 -1
  92. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-runner.js.map +1 -1
  93. package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph-building.js +1 -1
  94. package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph-building.js.map +1 -1
  95. package/dist/src/internal/builtin-plugins/solidity/build-system/read-source-file.js +1 -1
  96. package/dist/src/internal/builtin-plugins/solidity/build-system/read-source-file.js.map +1 -1
  97. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.js +10 -10
  98. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.js.map +1 -1
  99. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.js +1 -1
  100. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.js.map +1 -1
  101. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/config.js +1 -1
  102. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/config.js.map +1 -1
  103. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.d.ts.map +1 -1
  104. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js +16 -11
  105. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js.map +1 -1
  106. package/dist/src/internal/builtin-plugins/solidity/index.js +1 -1
  107. package/dist/src/internal/builtin-plugins/solidity/index.js.map +1 -1
  108. package/dist/src/internal/builtin-plugins/solidity/solidity-hooks.js +1 -1
  109. package/dist/src/internal/builtin-plugins/solidity/solidity-hooks.js.map +1 -1
  110. package/dist/src/internal/builtin-plugins/solidity/tasks/build.js +4 -4
  111. package/dist/src/internal/builtin-plugins/solidity/tasks/build.js.map +1 -1
  112. package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.js +2 -2
  113. package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.js.map +1 -1
  114. package/dist/src/internal/builtin-plugins/solidity-test/hook-handlers/config.js +1 -1
  115. package/dist/src/internal/builtin-plugins/solidity-test/hook-handlers/config.js.map +1 -1
  116. package/dist/src/internal/builtin-plugins/solidity-test/hook-handlers/test.js +1 -1
  117. package/dist/src/internal/builtin-plugins/solidity-test/hook-handlers/test.js.map +1 -1
  118. package/dist/src/internal/builtin-plugins/solidity-test/index.js +1 -1
  119. package/dist/src/internal/builtin-plugins/solidity-test/index.js.map +1 -1
  120. package/dist/src/internal/builtin-plugins/solidity-test/reporter.js +1 -1
  121. package/dist/src/internal/builtin-plugins/solidity-test/reporter.js.map +1 -1
  122. package/dist/src/internal/builtin-plugins/solidity-test/task-action.js +1 -1
  123. package/dist/src/internal/builtin-plugins/solidity-test/task-action.js.map +1 -1
  124. package/dist/src/internal/builtin-plugins/telemetry/index.js +1 -1
  125. package/dist/src/internal/builtin-plugins/telemetry/index.js.map +1 -1
  126. package/dist/src/internal/builtin-plugins/test/hook-handlers/config.js +1 -1
  127. package/dist/src/internal/builtin-plugins/test/hook-handlers/config.js.map +1 -1
  128. package/dist/src/internal/builtin-plugins/test/index.js +1 -1
  129. package/dist/src/internal/builtin-plugins/test/index.js.map +1 -1
  130. package/dist/src/internal/builtin-plugins/test/task-action.js +1 -1
  131. package/dist/src/internal/builtin-plugins/test/task-action.js.map +1 -1
  132. package/dist/src/internal/cli/init/init.d.ts.map +1 -1
  133. package/dist/src/internal/cli/init/init.js +18 -9
  134. package/dist/src/internal/cli/init/init.js.map +1 -1
  135. package/dist/src/internal/cli/init/template.d.ts.map +1 -1
  136. package/dist/src/internal/cli/init/template.js +5 -14
  137. package/dist/src/internal/cli/init/template.js.map +1 -1
  138. package/dist/src/internal/cli/main.d.ts.map +1 -1
  139. package/dist/src/internal/cli/main.js +4 -2
  140. package/dist/src/internal/cli/main.js.map +1 -1
  141. package/dist/src/internal/cli/node-version.d.ts +1 -1
  142. package/dist/src/internal/cli/node-version.d.ts.map +1 -1
  143. package/dist/src/internal/cli/node-version.js +18 -8
  144. package/dist/src/internal/cli/node-version.js.map +1 -1
  145. package/dist/src/internal/cli/telemetry/analytics/analytics.js +2 -2
  146. package/dist/src/internal/cli/telemetry/analytics/analytics.js.map +1 -1
  147. package/dist/src/internal/cli/telemetry/error-reporter/global-error-handlers.d.ts +6 -0
  148. package/dist/src/internal/cli/telemetry/error-reporter/global-error-handlers.d.ts.map +1 -0
  149. package/dist/src/internal/cli/telemetry/error-reporter/global-error-handlers.js +47 -0
  150. package/dist/src/internal/cli/telemetry/error-reporter/global-error-handlers.js.map +1 -0
  151. package/dist/src/internal/cli/telemetry/error-reporter/reporter.d.ts +27 -0
  152. package/dist/src/internal/cli/telemetry/error-reporter/reporter.d.ts.map +1 -0
  153. package/dist/src/internal/cli/telemetry/error-reporter/reporter.js +40 -0
  154. package/dist/src/internal/cli/telemetry/error-reporter/reporter.js.map +1 -0
  155. package/dist/src/internal/cli/telemetry/sentry/anonymizer.js +1 -1
  156. package/dist/src/internal/cli/telemetry/sentry/anonymizer.js.map +1 -1
  157. package/dist/src/internal/cli/telemetry/sentry/init.d.ts +0 -8
  158. package/dist/src/internal/cli/telemetry/sentry/init.d.ts.map +1 -1
  159. package/dist/src/internal/cli/telemetry/sentry/init.js +1 -37
  160. package/dist/src/internal/cli/telemetry/sentry/init.js.map +1 -1
  161. package/dist/src/internal/cli/telemetry/sentry/reporter.d.ts +8 -2
  162. package/dist/src/internal/cli/telemetry/sentry/reporter.d.ts.map +1 -1
  163. package/dist/src/internal/cli/telemetry/sentry/reporter.js +18 -12
  164. package/dist/src/internal/cli/telemetry/sentry/reporter.js.map +1 -1
  165. package/dist/src/internal/cli/telemetry/sentry/transport.js +1 -1
  166. package/dist/src/internal/cli/telemetry/sentry/transport.js.map +1 -1
  167. package/dist/src/internal/cli/telemetry/telemetry-permissions.js +1 -1
  168. package/dist/src/internal/cli/telemetry/telemetry-permissions.js.map +1 -1
  169. package/dist/src/internal/config-loading.js +3 -3
  170. package/dist/src/internal/config-loading.js.map +1 -1
  171. package/dist/src/internal/core/configuration-variables.d.ts.map +1 -1
  172. package/dist/src/internal/core/configuration-variables.js +1 -1
  173. package/dist/src/internal/core/configuration-variables.js.map +1 -1
  174. package/dist/src/internal/core/hook-manager.d.ts.map +1 -1
  175. package/dist/src/internal/core/hook-manager.js +196 -59
  176. package/dist/src/internal/core/hook-manager.js.map +1 -1
  177. package/dist/src/internal/core/hre.d.ts.map +1 -1
  178. package/dist/src/internal/core/hre.js +5 -5
  179. package/dist/src/internal/core/hre.js.map +1 -1
  180. package/dist/src/internal/core/lazy-user-interruptions.d.ts +11 -0
  181. package/dist/src/internal/core/lazy-user-interruptions.d.ts.map +1 -0
  182. package/dist/src/internal/core/lazy-user-interruptions.js +39 -0
  183. package/dist/src/internal/core/lazy-user-interruptions.js.map +1 -0
  184. package/dist/src/internal/core/plugins/resolve-plugin-list.js +1 -1
  185. package/dist/src/internal/core/plugins/resolve-plugin-list.js.map +1 -1
  186. package/dist/src/internal/core/tasks/resolved-task.js +4 -4
  187. package/dist/src/internal/core/tasks/resolved-task.js.map +1 -1
  188. package/dist/src/internal/core/user-interruptions.js +9 -9
  189. package/dist/src/internal/core/user-interruptions.js.map +1 -1
  190. package/dist/src/internal/hre-initialization.js +1 -1
  191. package/dist/src/internal/hre-initialization.js.map +1 -1
  192. package/package.json +4 -4
  193. package/src/cli.ts +5 -5
  194. package/src/internal/builtin-plugins/artifacts/artifact-manager.ts +13 -6
  195. package/src/internal/builtin-plugins/artifacts/hook-handlers/hre.ts +16 -10
  196. package/src/internal/builtin-plugins/clean/index.ts +1 -1
  197. package/src/internal/builtin-plugins/console/index.ts +1 -1
  198. package/src/internal/builtin-plugins/coverage/exports.ts +1 -1
  199. package/src/internal/builtin-plugins/coverage/helpers/accessors.ts +44 -0
  200. package/src/internal/builtin-plugins/coverage/helpers/compat.ts +37 -0
  201. package/src/internal/builtin-plugins/coverage/hook-handlers/clean.ts +1 -1
  202. package/src/internal/builtin-plugins/coverage/hook-handlers/hre.ts +26 -16
  203. package/src/internal/builtin-plugins/coverage/hook-handlers/solidity.ts +3 -3
  204. package/src/internal/builtin-plugins/coverage/hook-handlers/test.ts +1 -1
  205. package/src/internal/builtin-plugins/flatten/index.ts +1 -1
  206. package/src/internal/builtin-plugins/gas-analytics/helpers/accessors.ts +12 -5
  207. package/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.ts +29 -17
  208. package/src/internal/builtin-plugins/gas-analytics/index.ts +4 -2
  209. package/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.ts +2 -6
  210. package/src/internal/builtin-plugins/network-manager/config-resolution.ts +1 -1
  211. package/src/internal/builtin-plugins/network-manager/edr/edr-constants.ts +61 -0
  212. package/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts +3 -62
  213. package/src/internal/builtin-plugins/network-manager/edr/genesis-state.ts +1 -1
  214. package/src/internal/builtin-plugins/network-manager/edr/types/hardfork.ts +3 -9
  215. package/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.ts +2 -2
  216. package/src/internal/builtin-plugins/network-manager/hook-handlers/hre.ts +4 -4
  217. package/src/internal/builtin-plugins/network-manager/hook-handlers/network.ts +2 -2
  218. package/src/internal/builtin-plugins/network-manager/http-provider.ts +6 -2
  219. package/src/internal/builtin-plugins/network-manager/network-manager.ts +11 -7
  220. package/src/internal/builtin-plugins/node/helpers.ts +2 -2
  221. package/src/internal/builtin-plugins/node/index.ts +1 -1
  222. package/src/internal/builtin-plugins/run/index.ts +1 -1
  223. package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +84 -49
  224. package/src/internal/builtin-plugins/solidity/build-system/compilation-job.ts +1 -1
  225. package/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts +4 -4
  226. package/src/internal/builtin-plugins/solidity/build-system/compiler/index.ts +2 -2
  227. package/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-runner.ts +1 -1
  228. package/src/internal/builtin-plugins/solidity/build-system/dependency-graph-building.ts +1 -1
  229. package/src/internal/builtin-plugins/solidity/build-system/read-source-file.ts +2 -2
  230. package/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.ts +11 -11
  231. package/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.ts +1 -1
  232. package/src/internal/builtin-plugins/solidity/hook-handlers/config.ts +1 -1
  233. package/src/internal/builtin-plugins/solidity/hook-handlers/hre.ts +27 -14
  234. package/src/internal/builtin-plugins/solidity/index.ts +1 -1
  235. package/src/internal/builtin-plugins/solidity/solidity-hooks.ts +1 -1
  236. package/src/internal/builtin-plugins/solidity/tasks/build.ts +4 -4
  237. package/src/internal/builtin-plugins/solidity-test/edr-artifacts.ts +2 -2
  238. package/src/internal/builtin-plugins/solidity-test/hook-handlers/config.ts +1 -1
  239. package/src/internal/builtin-plugins/solidity-test/hook-handlers/test.ts +1 -1
  240. package/src/internal/builtin-plugins/solidity-test/index.ts +1 -1
  241. package/src/internal/builtin-plugins/solidity-test/reporter.ts +1 -1
  242. package/src/internal/builtin-plugins/solidity-test/task-action.ts +1 -1
  243. package/src/internal/builtin-plugins/telemetry/index.ts +1 -1
  244. package/src/internal/builtin-plugins/test/hook-handlers/config.ts +1 -1
  245. package/src/internal/builtin-plugins/test/index.ts +1 -1
  246. package/src/internal/builtin-plugins/test/task-action.ts +1 -1
  247. package/src/internal/cli/init/init.ts +32 -14
  248. package/src/internal/cli/init/template.ts +22 -27
  249. package/src/internal/cli/main.ts +5 -3
  250. package/src/internal/cli/node-version.ts +21 -10
  251. package/src/internal/cli/telemetry/analytics/analytics.ts +2 -2
  252. package/src/internal/cli/telemetry/error-reporter/global-error-handlers.ts +64 -0
  253. package/src/internal/cli/telemetry/error-reporter/reporter.ts +49 -0
  254. package/src/internal/cli/telemetry/sentry/anonymizer.ts +1 -1
  255. package/src/internal/cli/telemetry/sentry/init.ts +2 -62
  256. package/src/internal/cli/telemetry/sentry/reporter.ts +27 -15
  257. package/src/internal/cli/telemetry/sentry/transport.ts +1 -1
  258. package/src/internal/cli/telemetry/telemetry-permissions.ts +1 -1
  259. package/src/internal/config-loading.ts +3 -3
  260. package/src/internal/core/configuration-variables.ts +19 -18
  261. package/src/internal/core/hook-manager.ts +267 -103
  262. package/src/internal/core/hre.ts +7 -5
  263. package/src/internal/core/lazy-user-interruptions.ts +75 -0
  264. package/src/internal/core/plugins/resolve-plugin-list.ts +1 -1
  265. package/src/internal/core/tasks/resolved-task.ts +4 -4
  266. package/src/internal/core/user-interruptions.ts +9 -9
  267. package/src/internal/hre-initialization.ts +1 -1
  268. package/templates/hardhat-3/01-node-test-runner-viem/package.json +10 -10
  269. package/templates/hardhat-3/02-mocha-ethers/package.json +13 -13
  270. package/templates/hardhat-3/03-minimal/package.json +1 -1
  271. package/dist/src/internal/builtin-plugins/coverage/helpers.d.ts +0 -15
  272. package/dist/src/internal/builtin-plugins/coverage/helpers.d.ts.map +0 -1
  273. package/dist/src/internal/builtin-plugins/coverage/helpers.js +0 -35
  274. package/dist/src/internal/builtin-plugins/coverage/helpers.js.map +0 -1
  275. package/src/internal/builtin-plugins/coverage/helpers.ts +0 -63
@@ -23,35 +23,94 @@ export class HookManagerImplementation implements HookManager {
23
23
 
24
24
  readonly #projectRoot: string;
25
25
 
26
- readonly #pluginsInReverseOrder: HardhatPlugin[];
27
-
28
26
  /**
27
+ * The context passed to hook handlers, except to the `config` ones, to break
28
+ * a circular dependency between the config and the hook handler.
29
+ *
29
30
  * Initially `undefined` to be able to run the config hooks during
30
31
  * initialization.
31
32
  */
32
33
  #context: HookContext | undefined;
33
34
 
34
35
  /**
35
- * The initialized handler categories for each plugin.
36
+ * Plugins that provide hook handlers for each category, in reverse order.
37
+ *
38
+ * Precomputed from the plugin list at construction.
39
+ */
40
+ readonly #pluginsByHookCategory: Map<keyof HardhatHooks, HardhatPlugin[]> =
41
+ new Map();
42
+
43
+ /**
44
+ * Cached resolved category objects per hook category in reverse plugin
45
+ * order.
46
+ *
47
+ * Only written by #getStaticHookHandlerCategories, which uses a mutex to
48
+ * ensure that every Hook Category Factory is run once per HookManager
49
+ * instance.
36
50
  */
37
- readonly #staticHookHandlerCategories: Map<
38
- string,
39
- Map<keyof HardhatHooks, Partial<HardhatHooks[keyof HardhatHooks]>>
51
+ readonly #resolvedStaticCategories: Map<
52
+ keyof HardhatHooks,
53
+ Array<Partial<HardhatHooks[keyof HardhatHooks]>>
40
54
  > = new Map();
41
55
 
42
56
  /**
43
57
  * A map of the dynamically registered handler categories.
44
58
  *
45
59
  * Each array is a list of categories, in reverse order of registration.
60
+ *
61
+ * Written by registerHandlers and unregisterHandlers.
46
62
  */
47
63
  readonly #dynamicHookHandlerCategories: Map<
48
64
  keyof HardhatHooks,
49
65
  Array<Partial<HardhatHooks[keyof HardhatHooks]>>
50
66
  > = new Map();
51
67
 
68
+ /**
69
+ * Cached combined (dynamic + static) handlers per (category, hook name) in
70
+ * chained running order.
71
+ *
72
+ * Only written by #getHandlersInChainedRunningOrder, and invalidated
73
+ * per-category on dynamic handlers register/unregister.
74
+ */
75
+ readonly #chainedHandlers: Map<keyof HardhatHooks, Map<string, any[]>> =
76
+ new Map();
77
+
78
+ /**
79
+ * Cached combined handlers per (category, hook name) in sequential running
80
+ * order (reverse of chained).
81
+ *
82
+ * Only written by #getHandlersInSequentialRunningOrder, and invalidated
83
+ * per-category on dynamic handlers register/unregister.
84
+ */
85
+ readonly #sequentialHandlers: Map<keyof HardhatHooks, Map<string, any[]>> =
86
+ new Map();
87
+
52
88
  constructor(projectRoot: string, plugins: HardhatPlugin[]) {
53
89
  this.#projectRoot = projectRoot;
54
- this.#pluginsInReverseOrder = plugins.toReversed();
90
+
91
+ for (const plugin of plugins.toReversed()) {
92
+ if (plugin.hookHandlers === undefined) {
93
+ continue;
94
+ }
95
+
96
+ for (const hookCategoryName of Object.keys(plugin.hookHandlers) as Array<
97
+ keyof HardhatHooks
98
+ >) {
99
+ if (plugin.hookHandlers[hookCategoryName] === undefined) {
100
+ continue;
101
+ }
102
+
103
+ let pluginsForCategory =
104
+ this.#pluginsByHookCategory.get(hookCategoryName);
105
+
106
+ if (pluginsForCategory === undefined) {
107
+ pluginsForCategory = [];
108
+ this.#pluginsByHookCategory.set(hookCategoryName, pluginsForCategory);
109
+ }
110
+
111
+ pluginsForCategory.push(plugin);
112
+ }
113
+ }
55
114
  }
56
115
 
57
116
  public setContext(context: HookContext): void {
@@ -69,6 +128,8 @@ export class HookManagerImplementation implements HookManager {
69
128
  }
70
129
 
71
130
  categories.unshift(hookHandlerCategory);
131
+
132
+ this.#invalidateResolvedHandlersCache(hookCategoryName);
72
133
  }
73
134
 
74
135
  public unregisterHandlers<HookCategoryNameT extends keyof HardhatHooks>(
@@ -84,6 +145,8 @@ export class HookManagerImplementation implements HookManager {
84
145
  hookCategoryName,
85
146
  categories.filter((c) => c !== hookHandlerCategory),
86
147
  );
148
+
149
+ this.#invalidateResolvedHandlersCache(hookCategoryName);
87
150
  }
88
151
 
89
152
  public async runHandlerChain<
@@ -96,10 +159,23 @@ export class HookManagerImplementation implements HookManager {
96
159
  params: InitialChainedHookParams<HookCategoryNameT, HookT>,
97
160
  defaultImplementation: LastParameter<HookT>,
98
161
  ): Promise<Awaited<Return<HardhatHooks[HookCategoryNameT][HookNameT]>>> {
99
- const handlers = await this.#getHandlersInChainedRunningOrder(
100
- hookCategoryName,
101
- hookName,
102
- );
162
+ // Synchronous fast path for already cached handlers. This duplicates
163
+ // the check inside #getHandlersInChainedRunningOrder on purpose:
164
+ // calling that async method introduces a microtask tick even on a
165
+ // cache hit, whereas a direct Map lookup stays on the current tick.
166
+ // That tick matters here because runHandlerChain is on every hook's
167
+ // hot path, and this path pairs with the empty-handlers shortcut
168
+ // below to dispatch straight to defaultImplementation with no awaits.
169
+ const cachedHandlers = this.#chainedHandlers
170
+ .get(hookCategoryName)
171
+ ?.get(hookName as string);
172
+
173
+ const handlers =
174
+ cachedHandlers ??
175
+ (await this.#getHandlersInChainedRunningOrder(
176
+ hookCategoryName,
177
+ hookName,
178
+ ));
103
179
 
104
180
  let handlerParams: Parameters<typeof defaultImplementation>;
105
181
  if (hookCategoryName !== "config") {
@@ -113,6 +189,13 @@ export class HookManagerImplementation implements HookManager {
113
189
  handlerParams = params as any;
114
190
  }
115
191
 
192
+ // Fast path for the common case of no registered handlers: skip building
193
+ // handlerParams and the `next` closure, and call the default implementation
194
+ // directly.
195
+ if (handlers.length === 0) {
196
+ return (await defaultImplementation(...handlerParams)) as any;
197
+ }
198
+
116
199
  const numberOfHandlers = handlers.length;
117
200
  let index = 0;
118
201
  const next = async (...nextParams: typeof handlerParams) => {
@@ -124,7 +207,7 @@ export class HookManagerImplementation implements HookManager {
124
207
  return result;
125
208
  };
126
209
 
127
- return next(...handlerParams);
210
+ return await next(...handlerParams);
128
211
  }
129
212
 
130
213
  public async runSequentialHandlers<
@@ -192,7 +275,7 @@ export class HookManagerImplementation implements HookManager {
192
275
  handlerParams = params;
193
276
  }
194
277
 
195
- return Promise.all(
278
+ return await Promise.all(
196
279
  handlers.map((handler) => (handler as any)(...handlerParams)),
197
280
  );
198
281
  }
@@ -220,14 +303,48 @@ export class HookManagerImplementation implements HookManager {
220
303
  hookCategoryName: HookCategoryNameT,
221
304
  hookName: HookNameT,
222
305
  ): Promise<Array<HardhatHooks[HookCategoryNameT][HookNameT]>> {
223
- const pluginHooks = await this.#getPluginHooks(hookCategoryName, hookName);
306
+ let handlersByName = this.#chainedHandlers.get(hookCategoryName);
307
+ if (handlersByName === undefined) {
308
+ handlersByName = new Map();
309
+ this.#chainedHandlers.set(hookCategoryName, handlersByName);
310
+ }
224
311
 
225
- const dynamicHooks = await this.#getDynamicHooks(
312
+ const cached = handlersByName.get(hookName as string);
313
+ if (cached !== undefined) {
314
+ return cached;
315
+ }
316
+
317
+ const staticCategories =
318
+ await this.#getStaticHookHandlerCategories(hookCategoryName);
319
+
320
+ // IMPORTANT NOTE: Accessing the dynamic hook handlers MUST happen
321
+ // after awaiting the static ones. See
322
+ // #invalidateResolvedHandlersCache for more info.
323
+ const dynamicCategories = this.#dynamicHookHandlerCategories.get(
226
324
  hookCategoryName,
227
- hookName,
228
- );
325
+ ) as Array<Partial<HardhatHooks[HookCategoryNameT]>> | undefined;
326
+
327
+ const handlers: Array<HardhatHooks[HookCategoryNameT][HookNameT]> = [];
229
328
 
230
- return [...dynamicHooks, ...pluginHooks];
329
+ if (dynamicCategories !== undefined) {
330
+ for (const category of dynamicCategories) {
331
+ const handler = category[hookName];
332
+ if (handler !== undefined) {
333
+ handlers.push(handler as HardhatHooks[HookCategoryNameT][HookNameT]);
334
+ }
335
+ }
336
+ }
337
+
338
+ for (const category of staticCategories) {
339
+ const handler = category[hookName];
340
+ if (handler !== undefined) {
341
+ handlers.push(handler as HardhatHooks[HookCategoryNameT][HookNameT]);
342
+ }
343
+ }
344
+
345
+ handlersByName.set(hookName as string, handlers);
346
+
347
+ return handlers;
231
348
  }
232
349
 
233
350
  async #getHandlersInSequentialRunningOrder<
@@ -237,111 +354,158 @@ export class HookManagerImplementation implements HookManager {
237
354
  hookCategoryName: HookCategoryNameT,
238
355
  hookName: HookNameT,
239
356
  ): Promise<Array<HardhatHooks[HookCategoryNameT][HookNameT]>> {
240
- const handlersInChainedOrder = await this.#getHandlersInChainedRunningOrder(
357
+ let handlersByName = this.#sequentialHandlers.get(hookCategoryName);
358
+ if (handlersByName === undefined) {
359
+ handlersByName = new Map();
360
+ this.#sequentialHandlers.set(hookCategoryName, handlersByName);
361
+ }
362
+
363
+ const cached = handlersByName.get(hookName as string);
364
+ if (cached !== undefined) {
365
+ return cached;
366
+ }
367
+
368
+ const chained = await this.#getHandlersInChainedRunningOrder(
241
369
  hookCategoryName,
242
370
  hookName,
243
371
  );
244
372
 
245
- return handlersInChainedOrder.reverse();
373
+ const sequential = chained.toReversed();
374
+
375
+ handlersByName.set(hookName as string, sequential);
376
+
377
+ return sequential;
246
378
  }
247
379
 
248
- async #getDynamicHooks<
380
+ async #getStaticHookHandlerCategories<
249
381
  HookCategoryNameT extends keyof HardhatHooks,
250
- HookNameT extends keyof HardhatHooks[HookCategoryNameT],
251
382
  >(
252
383
  hookCategoryName: HookCategoryNameT,
253
- hookName: HookNameT,
254
- ): Promise<Array<HardhatHooks[HookCategoryNameT][HookNameT]>> {
255
- const categories = this.#dynamicHookHandlerCategories.get(
256
- hookCategoryName,
257
- ) as Array<Partial<HardhatHooks[HookCategoryNameT]>> | undefined;
384
+ ): Promise<Array<Partial<HardhatHooks[HookCategoryNameT]>>> {
385
+ const cached = this.#resolvedStaticCategories.get(hookCategoryName) as
386
+ | Array<Partial<HardhatHooks[HookCategoryNameT]>>
387
+ | undefined;
258
388
 
259
- if (categories === undefined) {
389
+ if (cached !== undefined) {
390
+ return cached;
391
+ }
392
+
393
+ const plugins = this.#pluginsByHookCategory.get(hookCategoryName);
394
+
395
+ // We don't need to get the mutex to resolve this case, as it will always
396
+ // be an empty array, and won't execute any factory.
397
+ if (plugins === undefined) {
398
+ this.#resolvedStaticCategories.set(hookCategoryName, []);
260
399
  return [];
261
400
  }
262
401
 
263
- return categories.flatMap((hookCategory) => {
264
- return (hookCategory[hookName] ?? []) as Array<
265
- HardhatHooks[HookCategoryNameT][HookNameT]
266
- >;
402
+ return await this.#mutex.exclusiveRun(async () => {
403
+ // Re-check under the mutex in case another caller just populated it.
404
+ const recheck = this.#resolvedStaticCategories.get(hookCategoryName) as
405
+ | Array<Partial<HardhatHooks[HookCategoryNameT]>>
406
+ | undefined;
407
+
408
+ if (recheck !== undefined) {
409
+ return recheck;
410
+ }
411
+
412
+ const resolved = await Promise.all(
413
+ plugins.map(
414
+ async (plugin) =>
415
+ await this.#getPluginStaticHookCategory(plugin, hookCategoryName),
416
+ ),
417
+ );
418
+
419
+ this.#resolvedStaticCategories.set(hookCategoryName, resolved);
420
+
421
+ return resolved;
267
422
  });
268
423
  }
269
424
 
270
- async #getPluginHooks<
425
+ /**
426
+ * Returns the hook category object for a plugin that has the hook category
427
+ * defined.
428
+ *
429
+ * @param plugin A plugin that MUST have the given hook category defined.
430
+ * @param hookCategoryName The name of the hook category.
431
+ * @returns The hook category object.
432
+ */
433
+ async #getPluginStaticHookCategory<
271
434
  HookCategoryNameT extends keyof HardhatHooks,
272
- HookNameT extends keyof HardhatHooks[HookCategoryNameT],
273
435
  >(
436
+ plugin: HardhatPlugin,
274
437
  hookCategoryName: HookCategoryNameT,
275
- hookName: HookNameT,
276
- ): Promise<Array<HardhatHooks[HookCategoryNameT][HookNameT]>> {
277
- const categories: Array<
278
- Partial<HardhatHooks[HookCategoryNameT]> | undefined
279
- > = await this.#mutex.exclusiveRun(async () => {
280
- return Promise.all(
281
- this.#pluginsInReverseOrder.map(async (plugin) => {
282
- const existingCategory = this.#staticHookHandlerCategories
283
- .get(plugin.id)
284
- ?.get(hookCategoryName);
285
-
286
- if (existingCategory !== undefined) {
287
- return existingCategory as Partial<HardhatHooks[HookCategoryNameT]>;
288
- }
289
-
290
- const hookHandlerCategoryFactory =
291
- plugin.hookHandlers?.[hookCategoryName];
292
-
293
- if (hookHandlerCategoryFactory === undefined) {
294
- return;
295
- }
296
-
297
- let factory;
298
- try {
299
- factory = (await hookHandlerCategoryFactory()).default;
300
- } catch (error) {
301
- ensureError(error);
302
-
303
- await detectPluginNpmDependencyProblems(
304
- this.#projectRoot,
305
- plugin,
306
- error,
307
- );
308
-
309
- throw error;
310
- }
311
-
312
- assertHardhatInvariant(
313
- typeof factory === "function",
314
- `Plugin ${plugin.id} doesn't export a hook factory for category ${hookCategoryName}`,
315
- );
316
-
317
- const hookCategory = await factory();
318
-
319
- assertHardhatInvariant(
320
- hookCategory !== null && typeof hookCategory === "object",
321
- `Plugin ${plugin.id} doesn't export a valid factory for category ${hookCategoryName}, it didn't return an object`,
322
- );
323
-
324
- if (!this.#staticHookHandlerCategories.has(plugin.id)) {
325
- this.#staticHookHandlerCategories.set(plugin.id, new Map());
326
- }
327
-
328
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Defined right above
329
- this.#staticHookHandlerCategories
330
- .get(plugin.id)!
331
- .set(hookCategoryName, hookCategory);
332
-
333
- return hookCategory;
334
- }),
335
- );
336
- });
438
+ ): Promise<Partial<HardhatHooks[HookCategoryNameT]>> {
439
+ const hookHandlerCategoryFactory = plugin.hookHandlers?.[hookCategoryName];
337
440
 
338
- return categories.flatMap((category) => {
339
- const handler = category?.[hookName];
340
- if (handler === undefined) {
341
- return [];
342
- }
441
+ assertHardhatInvariant(
442
+ hookHandlerCategoryFactory !== undefined,
443
+ "#pluginsByHookCategory only contains plugins with this hook category",
444
+ );
343
445
 
344
- return handler as HardhatHooks[HookCategoryNameT][HookNameT];
345
- });
446
+ let factory;
447
+ try {
448
+ factory = (await hookHandlerCategoryFactory()).default;
449
+ } catch (error) {
450
+ ensureError(error);
451
+
452
+ await detectPluginNpmDependencyProblems(this.#projectRoot, plugin, error);
453
+
454
+ throw error;
455
+ }
456
+
457
+ assertHardhatInvariant(
458
+ typeof factory === "function",
459
+ `Plugin ${plugin.id} doesn't export a hook factory for category ${hookCategoryName}`,
460
+ );
461
+
462
+ const hookCategory = await factory();
463
+
464
+ assertHardhatInvariant(
465
+ hookCategory !== null && typeof hookCategory === "object",
466
+ `Plugin ${plugin.id} doesn't export a valid factory for category ${hookCategoryName}, it didn't return an object`,
467
+ );
468
+
469
+ return hookCategory;
470
+ }
471
+
472
+ #invalidateResolvedHandlersCache<
473
+ HookCategoryNameT extends keyof HardhatHooks,
474
+ >(hookCategoryName: HookCategoryNameT) {
475
+ // Invalidation deletes the outer entry rather than clearing the inner
476
+ // map. This matters under concurrency.
477
+ //
478
+ // A reader of #getHandlersInChainedRunningOrder (or its sequential
479
+ // sibling) captures a reference to the inner map before awaiting the
480
+ // static categories, and writes its computed array back after the
481
+ // await. If invalidation runs during that await, deleting the outer
482
+ // entry leaves the reader's inner map orphaned: its write lands in a
483
+ // map no longer reachable from #chainedHandlers/#sequentialHandlers,
484
+ // so it cannot poison the shared cache. The next reader sees
485
+ // `undefined`, installs a fresh inner map, and rebuilds from the
486
+ // current dynamic state.
487
+ //
488
+ // Two distinct properties make this safe, guaranteed by two different
489
+ // things:
490
+ //
491
+ // 1. The in-flight reader's own return value is correct. This is
492
+ // because #getHandlersInChainedRunningOrder reads
493
+ // #dynamicHookHandlerCategories *after* awaiting the static
494
+ // categories. Any invalidation that happened during the await is
495
+ // visible to the reader when it resumes, so the array it builds
496
+ // reflects the current dynamic state.
497
+ //
498
+ // 2. The shared cache never holds a stale array. This is guaranteed
499
+ // by the orphaning-by-delete described above: a reader that
500
+ // started before the invalidation can only write into an
501
+ // unreachable inner map.
502
+ //
503
+ // Property 1 depends on the ordering of the dynamic handlers read relative
504
+ // to the await. If that read ever moved *before* the await, a reader
505
+ // could build a stale array and return it to its caller — the cache
506
+ // would still be protected by property 2, but the reader's caller
507
+ // would see the stale result.
508
+ this.#chainedHandlers.delete(hookCategoryName);
509
+ this.#sequentialHandlers.delete(hookCategoryName);
346
510
  }
347
511
  }
@@ -40,9 +40,9 @@ import {
40
40
  resolveGlobalOptions,
41
41
  } from "./global-options.js";
42
42
  import { HookManagerImplementation } from "./hook-manager.js";
43
+ import { LazyUserInterruptionManager } from "./lazy-user-interruptions.js";
43
44
  import { resolvePluginList } from "./plugins/resolve-plugin-list.js";
44
45
  import { TaskManagerImplementation } from "./tasks/task-manager.js";
45
- import { UserInterruptionManagerImplementation } from "./user-interruptions.js";
46
46
 
47
47
  export class HardhatRuntimeEnvironmentImplementation
48
48
  implements HardhatRuntimeEnvironment
@@ -134,7 +134,7 @@ export class HardhatRuntimeEnvironmentImplementation
134
134
 
135
135
  // Set the HookContext in the hook manager so that non-config hooks can
136
136
  // use it
137
- const interruptions = new UserInterruptionManagerImplementation(hooks);
137
+ const interruptions = new LazyUserInterruptionManager(hooks);
138
138
 
139
139
  const hre = new HardhatRuntimeEnvironmentImplementation(
140
140
  extendedUserConfig,
@@ -193,7 +193,9 @@ export class HardhatRuntimeEnvironmentImplementation
193
193
  export async function resolveProjectRoot(
194
194
  absolutePathWithinProject: string | undefined,
195
195
  ): Promise<string> {
196
- return findClosestPackageRoot(absolutePathWithinProject ?? process.cwd());
196
+ return await findClosestPackageRoot(
197
+ absolutePathWithinProject ?? process.cwd(),
198
+ );
197
199
  }
198
200
 
199
201
  /**
@@ -292,7 +294,7 @@ async function runUserConfigExtensions(
292
294
  hooks: HookManager,
293
295
  config: HardhatUserConfig,
294
296
  ): Promise<HardhatUserConfig> {
295
- return hooks.runHandlerChain(
297
+ return await hooks.runHandlerChain(
296
298
  "config",
297
299
  "extendUserConfig",
298
300
  [config],
@@ -320,7 +322,7 @@ async function resolveUserConfig(
320
322
  paths: resolvePaths(projectRoot, configPath, config.paths),
321
323
  } as HardhatConfig;
322
324
 
323
- return hooks.runHandlerChain(
325
+ return await hooks.runHandlerChain(
324
326
  "config",
325
327
  "resolveUserConfig",
326
328
  [config, (variable) => resolveConfigurationVariable(hooks, variable)],
@@ -0,0 +1,75 @@
1
+ import type { UserInterruptionManagerImplementation as UserInterruptionManagerImplementationT } from "./user-interruptions.js";
2
+ import type { HookManager } from "../../types/hooks.js";
3
+ import type { UserInterruptionManager } from "../../types/user-interruptions.js";
4
+
5
+ let UserInterruptionManagerImplementation:
6
+ | typeof UserInterruptionManagerImplementationT
7
+ | undefined;
8
+
9
+ export class LazyUserInterruptionManager implements UserInterruptionManager {
10
+ readonly #hooks: HookManager;
11
+
12
+ #userInterruptionManager: UserInterruptionManagerImplementationT | undefined;
13
+
14
+ constructor(hooks: HookManager) {
15
+ this.#hooks = hooks;
16
+ }
17
+
18
+ public async displayMessage(
19
+ interruptor: string,
20
+ message: string,
21
+ ): Promise<void> {
22
+ const userInterruptionManager = await this.#getUserInterruptionManager();
23
+ return await userInterruptionManager.displayMessage(interruptor, message);
24
+ }
25
+
26
+ public async requestInput(
27
+ interruptor: string,
28
+ inputDescription: string,
29
+ ): Promise<string> {
30
+ const userInterruptionManager = await this.#getUserInterruptionManager();
31
+ return await userInterruptionManager.requestInput(
32
+ interruptor,
33
+ inputDescription,
34
+ );
35
+ }
36
+
37
+ public async requestSecretInput(
38
+ interruptor: string,
39
+ inputDescription: string,
40
+ ): Promise<string> {
41
+ const userInterruptionManager = await this.#getUserInterruptionManager();
42
+ return await userInterruptionManager.requestSecretInput(
43
+ interruptor,
44
+ inputDescription,
45
+ );
46
+ }
47
+
48
+ public async uninterrupted<ReturnT>(
49
+ f: () => ReturnT,
50
+ ): Promise<Awaited<ReturnT>> {
51
+ const userInterruptionManager = await this.#getUserInterruptionManager();
52
+ return await userInterruptionManager.uninterrupted(f);
53
+ }
54
+
55
+ async #getUserInterruptionManager(): Promise<UserInterruptionManagerImplementationT> {
56
+ // Note: `await import` must run BEFORE the instance cache check so that
57
+ // concurrent callers share a single microtask-dedupe point — otherwise
58
+ // each suspended caller re-enters the branch and constructs its own
59
+ // impl, so callers end up holding different impl instances and state,
60
+ // which can cause concurrency issues.
61
+ if (UserInterruptionManagerImplementation === undefined) {
62
+ ({ UserInterruptionManagerImplementation } = await import(
63
+ "./user-interruptions.js"
64
+ ));
65
+ }
66
+
67
+ if (this.#userInterruptionManager === undefined) {
68
+ this.#userInterruptionManager = new UserInterruptionManagerImplementation(
69
+ this.#hooks,
70
+ );
71
+ }
72
+
73
+ return this.#userInterruptionManager;
74
+ }
75
+ }
@@ -12,7 +12,7 @@ export async function resolvePluginList(
12
12
  projectRoot: string,
13
13
  userConfigPluginList: HardhatPlugin[] = [],
14
14
  ): Promise<HardhatPlugin[]> {
15
- return reverseTopologicalSort(projectRoot, userConfigPluginList);
15
+ return await reverseTopologicalSort(projectRoot, userConfigPluginList);
16
16
  }
17
17
 
18
18
  /**
@@ -175,22 +175,22 @@ export class ResolvedTask implements Task {
175
175
  if (currentIndex === 0) {
176
176
  /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions --
177
177
  We know that the first action in the array is a NewTaskActionFunction */
178
- return (actionFn as NewTaskActionFunction)(
178
+ return await (actionFn as NewTaskActionFunction)(
179
179
  nextTaskArguments,
180
180
  this.#hre,
181
181
  );
182
182
  }
183
183
 
184
- return actionFn(
184
+ return await actionFn(
185
185
  nextTaskArguments,
186
186
  this.#hre,
187
187
  async (newTaskArguments: TaskArguments) => {
188
- return next(newTaskArguments, currentIndex - 1);
188
+ return await next(newTaskArguments, currentIndex - 1);
189
189
  },
190
190
  );
191
191
  };
192
192
 
193
- return next(validatedTaskArguments);
193
+ return await next(validatedTaskArguments);
194
194
  }
195
195
 
196
196
  /**