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
@@ -7,13 +7,13 @@ import type {
7
7
  ResolvedUserRemapping,
8
8
  UnresolvedNpmUserRemapping,
9
9
  RemappedNpmPackagesGraphJson,
10
- Result,
11
10
  } from "./types.js";
12
11
  import type {
13
12
  ResolvedFile,
14
13
  ResolvedNpmPackage,
15
14
  UserRemappingError,
16
15
  } from "../../../../../types/solidity.js";
16
+ import type { Result } from "../../../../../types/utils.js";
17
17
 
18
18
  import path from "node:path";
19
19
 
@@ -37,6 +37,43 @@ import { UserRemappingType } from "./types.js";
37
37
 
38
38
  const HARDHAT_PROJECT_INPUT_SOURCE_NAME_ROOT = "project";
39
39
 
40
+ /**
41
+ * Returns a normalized version of the path if it refers to a node_modules in
42
+ * the root directory (i.e. node_modules/...), or a `node_modules` directory
43
+ * in a parent directory (i.e. ../../node_modules/...).
44
+ *
45
+ * Otherwise returns `undefined`.
46
+ *
47
+ * @param pathToNormalize The path to normalize.
48
+ * @returns The normalized path (node_modules/...), or `undefined`.
49
+ */
50
+ export function getNormalizeNodeModulesPath(
51
+ pathToNormalize: string,
52
+ ): string | undefined {
53
+ if (pathToNormalize.startsWith("node_modules/")) {
54
+ return pathToNormalize;
55
+ }
56
+
57
+ const normalized = path.posix.normalize(pathToNormalize);
58
+
59
+ if (!/^(?:\.\.\/)*node_modules\//.test(normalized)) {
60
+ return undefined;
61
+ }
62
+
63
+ return normalized.substring(normalized.indexOf("node_modules/"));
64
+ }
65
+
66
+ export type RemappingsReaderFunction = (
67
+ packageName: string,
68
+ packageVersion: string,
69
+ packagePath: string,
70
+ defaultBehavior: (
71
+ name: string,
72
+ version: string,
73
+ path: string,
74
+ ) => Promise<Array<{ remappings: string[]; source: string }>>,
75
+ ) => Promise<Array<{ remappings: string[]; source: string }>>;
76
+
40
77
  export function isResolvedUserRemapping(
41
78
  remapping: Remapping | ResolvedUserRemapping,
42
79
  ): remapping is ResolvedUserRemapping {
@@ -55,6 +92,11 @@ export class RemappedNpmPackagesGraphImplementation
55
92
  */
56
93
  readonly #hardhatProjectPackage: ResolvedNpmPackage;
57
94
 
95
+ /**
96
+ * The remappings reader function to use when reading package remappings.
97
+ */
98
+ readonly #remappingsReader: RemappingsReaderFunction;
99
+
58
100
  /**
59
101
  * This is a map of all the npm packages. Every package that has been
60
102
  * loaded by this class, is present in this map.
@@ -104,6 +146,12 @@ export class RemappedNpmPackagesGraphImplementation
104
146
 
105
147
  public static async create(
106
148
  projectRootPath: string,
149
+ remappingsReader: RemappingsReaderFunction = (
150
+ packageName,
151
+ packageVersion,
152
+ packagePath,
153
+ defaultBehavior,
154
+ ) => defaultBehavior(packageName, packageVersion, packagePath),
107
155
  ): Promise<RemappedNpmPackagesGraphImplementation> {
108
156
  const projectPackageJson = await readJsonFile<PackageJson>(
109
157
  path.join(projectRootPath, "package.json"),
@@ -117,11 +165,18 @@ export class RemappedNpmPackagesGraphImplementation
117
165
  inputSourceNameRoot: HARDHAT_PROJECT_INPUT_SOURCE_NAME_ROOT,
118
166
  };
119
167
 
120
- return new RemappedNpmPackagesGraphImplementation(resolvedNpmPackage);
168
+ return new RemappedNpmPackagesGraphImplementation(
169
+ resolvedNpmPackage,
170
+ remappingsReader,
171
+ );
121
172
  }
122
173
 
123
- private constructor(hardhatProjectPackage: ResolvedNpmPackage) {
174
+ private constructor(
175
+ hardhatProjectPackage: ResolvedNpmPackage,
176
+ remappingsReader: RemappingsReaderFunction,
177
+ ) {
124
178
  this.#hardhatProjectPackage = hardhatProjectPackage;
179
+ this.#remappingsReader = remappingsReader;
125
180
  this.#insertNewPackage(hardhatProjectPackage);
126
181
  }
127
182
 
@@ -397,41 +452,88 @@ export class RemappedNpmPackagesGraphImplementation
397
452
  UserRemappingError[]
398
453
  >
399
454
  > {
400
- const remappingsTxtFiles = await getAllFilesMatching(
455
+ const allRemappings = await this.#remappingsReader(
456
+ npmPackage.name,
457
+ npmPackage.version,
401
458
  npmPackage.rootFsPath,
402
- (f) => path.basename(f) === "remappings.txt",
403
- (f) => !f.endsWith("node_modules"),
459
+ async (_packageName, _packageVersion, packagePath) =>
460
+ this.#defaultReadPackageRemappings(packagePath),
404
461
  );
405
462
 
406
- const remappings = [];
407
- const errors = [];
463
+ return this.#parseAndDeduplicateRemappings(npmPackage, allRemappings);
464
+ }
408
465
 
409
- for (const remappingsTxtFsPath of remappingsTxtFiles) {
410
- const packageRemappingsTxtContents =
411
- await readUtf8File(remappingsTxtFsPath);
466
+ /**
467
+ * The default behavior of reading all the remappings.txt files in a package.
468
+ * @param packagePath The fs path to the root of the package.
469
+ * @returns An array with one entry per remappings.txt file, with the
470
+ * contents of the file and the fs path to the file.
471
+ */
472
+ async #defaultReadPackageRemappings(
473
+ packagePath: string,
474
+ ): Promise<Array<{ remappings: string[]; source: string }>> {
475
+ const remappingsTxtFiles = await getAllFilesMatching(
476
+ packagePath,
477
+ (f) => path.basename(f) === "remappings.txt",
478
+ (f) => !f.endsWith("node_modules"),
479
+ );
412
480
 
413
- const rawUserRemappings = packageRemappingsTxtContents
481
+ const results: Array<{ remappings: string[]; source: string }> = [];
482
+ for (const file of remappingsTxtFiles) {
483
+ const contents = await readUtf8File(file);
484
+ const lines = contents
414
485
  .split("\n")
415
486
  .map((line) => line.trim())
416
- .filter((line) => line !== "")
417
- .filter((line) => !line.startsWith("#"));
487
+ .filter((line) => line !== "" && !line.startsWith("#"));
488
+ results.push({ remappings: lines, source: file });
489
+ }
418
490
 
419
- for (const userRemapping of rawUserRemappings) {
420
- const result = await this.#parseUserRemapping(
491
+ return results;
492
+ }
493
+
494
+ /**
495
+ * Parses and deduplicates by "context:prefix" all the remappings from the
496
+ * package.
497
+ *
498
+ * @param npmPackage The npm package.
499
+ * @param allRemappings An array with all the remappings.txt files in the
500
+ * package and their content.
501
+ * @returns A result with the parsed and deduplicated remappings, or an error
502
+ * if there was a problem parsing any of them.
503
+ */
504
+ #parseAndDeduplicateRemappings(
505
+ npmPackage: ResolvedNpmPackage,
506
+ allRemappings: Array<{ remappings: string[]; source: string }>,
507
+ ): Result<
508
+ Array<LocalUserRemapping | UnresolvedNpmUserRemapping>,
509
+ UserRemappingError[]
510
+ > {
511
+ const remappings: Array<LocalUserRemapping | UnresolvedNpmUserRemapping> =
512
+ [];
513
+ const errors: UserRemappingError[] = [];
514
+ const seen = new Set<string>(); // Track by "context:prefix"
515
+
516
+ for (const { remappings: remappingStrings, source } of allRemappings) {
517
+ for (const remappingString of remappingStrings) {
518
+ const result = this.#parseUserRemapping(
421
519
  npmPackage,
422
- remappingsTxtFsPath,
423
- userRemapping,
520
+ source,
521
+ remappingString,
424
522
  );
425
523
 
426
524
  if (!result.success) {
427
525
  errors.push(result.error);
428
- } else {
429
- // If parsing returned `undefined`, it means that it should be
430
- // ignored.
431
- if (result.value === undefined) {
432
- continue;
433
- }
526
+ continue;
527
+ }
434
528
 
529
+ if (result.value === undefined) {
530
+ continue;
531
+ }
532
+
533
+ // Deduplicate by (context + prefix) - first occurrence wins
534
+ const key = `${result.value.context}:${result.value.prefix}`;
535
+ if (!seen.has(key)) {
536
+ seen.add(key);
435
537
  remappings.push(result.value);
436
538
  }
437
539
  }
@@ -454,15 +556,13 @@ export class RemappedNpmPackagesGraphImplementation
454
556
  * @returns The parsed user remapping, or undefined if it should be ignored.
455
557
  * If the parsing and validation fails, an error is returned.
456
558
  */
457
- async #parseUserRemapping(
559
+ #parseUserRemapping(
458
560
  npmPackage: ResolvedNpmPackage,
459
561
  sourceOfTheRemapping: string,
460
562
  remappingString: string,
461
- ): Promise<
462
- Result<
463
- LocalUserRemapping | UnresolvedNpmUserRemapping | undefined,
464
- UserRemappingError
465
- >
563
+ ): Result<
564
+ LocalUserRemapping | UnresolvedNpmUserRemapping | undefined,
565
+ UserRemappingError
466
566
  > {
467
567
  // We first parse the remapping string and validate that it doesn't have
468
568
  // a context starting with `npm/`, and that the prefix and targets end in /.
@@ -485,7 +585,7 @@ export class RemappedNpmPackagesGraphImplementation
485
585
  const prefix = remapping.prefix.endsWith("/")
486
586
  ? remapping.prefix
487
587
  : remapping.prefix + "/";
488
- const target = remapping.target.endsWith("/")
588
+ let target = remapping.target.endsWith("/")
489
589
  ? remapping.target
490
590
  : remapping.target + "/";
491
591
 
@@ -494,12 +594,13 @@ export class RemappedNpmPackagesGraphImplementation
494
594
  path.dirname(sourceOfTheRemapping),
495
595
  );
496
596
 
497
- // If the remapping's target starts with `node_modules/`, we treat
498
- // it as trying to load an npm dependency, otherwise we treat it as a local
597
+ // If the remapping's target starts with `node_modules/`, we treat it as
598
+ // trying to load an npm dependency, otherwise we treat it as a local
499
599
  // remapping.
600
+ const normalizedNodeModulesTarget = getNormalizeNodeModulesPath(target);
500
601
 
501
602
  // Local remapping case
502
- if (!target.startsWith("node_modules/")) {
603
+ if (normalizedNodeModulesTarget === undefined) {
503
604
  return {
504
605
  success: true,
505
606
  value: {
@@ -519,6 +620,9 @@ export class RemappedNpmPackagesGraphImplementation
519
620
  source: sourceOfTheRemapping,
520
621
  },
521
622
  };
623
+ } else {
624
+ // We update the target to the normalized version
625
+ target = normalizedNodeModulesTarget;
522
626
  }
523
627
 
524
628
  // If we are here the remapping is a npm remapping.
@@ -526,7 +630,7 @@ export class RemappedNpmPackagesGraphImplementation
526
630
  const targetWithoutNodeModules = target.substring("node_modules/".length);
527
631
 
528
632
  // If after doing that the prefix and target are the same, we skip it
529
- // so that it doesn't even go unnecesarly go through a user remapping.
633
+ // so that it doesn't even go unnecessarily go through a user remapping.
530
634
  if (prefix === targetWithoutNodeModules) {
531
635
  return { success: true, value: undefined };
532
636
  }
@@ -10,13 +10,7 @@ import type {
10
10
  ResolvedFile,
11
11
  ResolvedNpmPackage,
12
12
  } from "../../../../../types/solidity/resolved-file.js";
13
-
14
- /**
15
- * A result that can either have a value or an error.
16
- */
17
- export type Result<ValueT, ErrorT> =
18
- | { readonly success: true; readonly value: ValueT }
19
- | { readonly success: false; readonly error: ErrorT };
13
+ import type { Result } from "../../../../../types/utils.js";
20
14
 
21
15
  /**
22
16
  * A solc remapping.
@@ -96,7 +90,7 @@ export type InstallationName = string;
96
90
 
97
91
  /**
98
92
  * This interface represents a graph of all the npm packages that the Hardhat
99
- * project uses, including the Hardhat projecct itself, and their remappings.
93
+ * project uses, including the Hardhat project itself, and their remappings.
100
94
  *
101
95
  * This class guarantees that there's a single instance of any npm package per
102
96
  * each version. That means that, even if you have multiple installations of
@@ -109,7 +103,7 @@ export type InstallationName = string;
109
103
  * than expected, because:
110
104
  * - Processing a remapping may require loading a new npm package, and this
111
105
  * interface ensures its uniqueness.
112
- * - Loading an npm package requires processing its remappigns.
106
+ * - Loading an npm package requires processing its remappings.
113
107
  * - Selecting the best user remapping for an import can require processing it
114
108
  * and loading its npm package.
115
109
  *
@@ -1,5 +1,5 @@
1
- import type { Result } from "./types.js";
2
1
  import type { ResolvedNpmPackage } from "../../../../../types/solidity.js";
2
+ import type { Result } from "../../../../../types/utils.js";
3
3
 
4
4
  import { assertHardhatInvariant } from "@nomicfoundation/hardhat-errors";
5
5
  import { ensureError } from "@nomicfoundation/hardhat-utils/error";
@@ -18,19 +18,17 @@ export class SolcConfigSelector {
18
18
 
19
19
  /**
20
20
  * Creates a new SolcConfigSelector that can be used to select the best solc
21
- * configuration for subgraphs of the given dependency graph.
21
+ * configuration for single-root subgraphs to create their respective
22
+ * individual compilation jobs.
22
23
  *
23
- * All the queries are done in the context of the given dependency graph, and
24
- * using the same build profile.
24
+ * All the queries use the same build profile.
25
25
  *
26
26
  * @param buildProfileName The name of the build profile to use.
27
27
  * @param buildProfile The build profile config.
28
- * @param _dependencyGraph The entire dependency graph of the project.
29
28
  */
30
29
  constructor(
31
30
  buildProfileName: string,
32
31
  buildProfile: SolidityBuildProfileConfig,
33
- _dependencyGraph: DependencyGraph,
34
32
  ) {
35
33
  this.#buildProfileName = buildProfileName;
36
34
  this.#buildProfile = buildProfile;
@@ -46,7 +44,7 @@ export class SolcConfigSelector {
46
44
  */
47
45
  public selectBestSolcConfigForSingleRootGraph(
48
46
  subgraph: DependencyGraph,
49
- ): SolcConfig | CompilationJobCreationError {
47
+ ): { success: true; config: SolcConfig } | CompilationJobCreationError {
50
48
  const roots = subgraph.getRoots();
51
49
 
52
50
  assertHardhatInvariant(
@@ -56,11 +54,11 @@ export class SolcConfigSelector {
56
54
 
57
55
  const [userSourceName, root] = [...roots.entries()][0];
58
56
 
59
- const allVersionPragamas = [...subgraph.getAllFiles()]
57
+ const allVersionPragmas = [...subgraph.getAllFiles()]
60
58
  .map(({ content }) => content.versionPragmas)
61
59
  .flat(1);
62
60
 
63
- const versionRange = Array.from(new Set(allVersionPragamas)).join(" ");
61
+ const versionRange = Array.from(new Set(allVersionPragmas)).join(" ");
64
62
 
65
63
  const overriddenCompiler = this.#buildProfile.overrides[userSourceName];
66
64
 
@@ -75,7 +73,7 @@ export class SolcConfigSelector {
75
73
  );
76
74
  }
77
75
 
78
- return overriddenCompiler;
76
+ return { success: true, config: overriddenCompiler };
79
77
  }
80
78
 
81
79
  // if there's no override, we find a compiler that matches the version range
@@ -100,9 +98,21 @@ export class SolcConfigSelector {
100
98
  `Matching config not found for version '${matchingVersion.toString()}'`,
101
99
  );
102
100
 
103
- return matchingConfig;
101
+ return { success: true, config: matchingConfig };
104
102
  }
105
103
 
104
+ /**
105
+ * Returns a description of why we couldn't get a compiler configuration for
106
+ * the given root file and dependency subgraph.
107
+ *
108
+ * @param root The root file that created the single-root dependency subgraph
109
+ * @param dependencyGraph The dependency subgraph we couldn't get a compiler
110
+ * configuration for
111
+ * @param compilerVersions The compiler versions that are configured for the
112
+ * selected build profile. For overridden roots, it's a single one.
113
+ * @param overridden True if the root has an overridden config.
114
+ * @returns The error why we couldn't get a compiler configuration.
115
+ */
106
116
  #getCompilationJobCreationError(
107
117
  root: ResolvedFile,
108
118
  dependencyGraph: DependencyGraph,
@@ -110,27 +120,70 @@ export class SolcConfigSelector {
110
120
  overridden: boolean,
111
121
  ): CompilationJobCreationError {
112
122
  const rootVersionRange = root.content.versionPragmas.join(" ");
113
- if (maxSatisfying(compilerVersions, rootVersionRange) === null) {
114
- let reason: CompilationJobCreationErrorReason;
115
- let formattedReason: string;
116
- if (overridden) {
117
- reason =
118
- CompilationJobCreationErrorReason.INCOMPATIBLE_OVERRIDDEN_SOLC_VERSION;
119
- formattedReason = `An override with incompatible solc version was found for this file.`;
120
- } else {
121
- reason =
122
- CompilationJobCreationErrorReason.NO_COMPATIBLE_SOLC_VERSION_WITH_ROOT;
123
- formattedReason = `No solc version enabled in this profile is compatible with this file.`;
123
+
124
+ // This logic is pretty different depending if we are dealing with a config
125
+ // override or not. If we are, we have a single compiler option, so things
126
+ // are simpler.
127
+
128
+ if (overridden) {
129
+ // The root may not be compatible with the override version
130
+ if (maxSatisfying(compilerVersions, rootVersionRange) === null) {
131
+ return {
132
+ success: false,
133
+ reason:
134
+ CompilationJobCreationErrorReason.INCOMPATIBLE_OVERRIDDEN_SOLC_VERSION,
135
+ rootFilePath: root.fsPath,
136
+ buildProfile: this.#buildProfileName,
137
+ formattedReason: `An override with incompatible solc version was found for this file.`,
138
+ };
124
139
  }
125
140
 
141
+ // A transitive dependency can have a pragma that's incompatible with
142
+ // the overridden version.
143
+ for (const transitiveDependency of this.#getTransitiveDependencies(
144
+ root,
145
+ dependencyGraph,
146
+ )) {
147
+ const depOwnRange =
148
+ transitiveDependency.dependency.content.versionPragmas.join(" ");
149
+
150
+ if (maxSatisfying(compilerVersions, depOwnRange) === null) {
151
+ return {
152
+ success: false,
153
+ reason:
154
+ CompilationJobCreationErrorReason.OVERRIDDEN_SOLC_VERSION_INCOMPATIBLE_WITH_DEPENDENCY,
155
+ rootFilePath: root.fsPath,
156
+ buildProfile: this.#buildProfileName,
157
+ incompatibleImportPath: transitiveDependency.fsPath,
158
+ formattedReason: `The compiler version override is incompatible with a dependency of this file:\n * ${shortenPath(root.fsPath)}\n * ${transitiveDependency.fsPath.map((s) => shortenPath(s)).join("\n * ")}`,
159
+ };
160
+ }
161
+ }
162
+
163
+ // There's no other case. If the root and all the dependencies are
164
+ // compatible, and we still can choose a version, we have a bug.
165
+ /* c8 ignore next 5 */
166
+ assertHardhatInvariant(
167
+ false,
168
+ "Trying to get the error for an overridden solidity file that has no compatible config, but failed to detect it, as the root and all the dependencies are compatible with the overridden compiler config.",
169
+ );
170
+ }
171
+
172
+ // Non-overridden case: we first check if the root is compatible with any
173
+ // configured compiler
174
+ if (maxSatisfying(compilerVersions, rootVersionRange) === null) {
126
175
  return {
127
- reason,
176
+ success: false,
177
+ reason:
178
+ CompilationJobCreationErrorReason.NO_COMPATIBLE_SOLC_VERSION_WITH_ROOT,
128
179
  rootFilePath: root.fsPath,
129
180
  buildProfile: this.#buildProfileName,
130
- formattedReason,
181
+ formattedReason: `No solc version enabled in this profile is compatible with this file.`,
131
182
  };
132
183
  }
133
184
 
185
+ // We check all the transitive dependencies of the root to try to return
186
+ // the most specific error that we can.
134
187
  for (const transitiveDependency of this.#getTransitiveDependencies(
135
188
  root,
136
189
  dependencyGraph,
@@ -140,21 +193,59 @@ export class SolcConfigSelector {
140
193
  .map((pragmas) => pragmas.join(" "))
141
194
  .join(" ");
142
195
 
196
+ const depOwnRange =
197
+ transitiveDependency.dependency.content.versionPragmas.join(" ");
198
+
199
+ // A transitive dependency can have a pragma that's incompatible with
200
+ // all the configured compilers
201
+ if (maxSatisfying(compilerVersions, depOwnRange) === null) {
202
+ return {
203
+ success: false,
204
+ reason:
205
+ CompilationJobCreationErrorReason.NO_COMPATIBLE_SOLC_VERSION_WITH_DEPENDENCY,
206
+ rootFilePath: root.fsPath,
207
+ buildProfile: this.#buildProfileName,
208
+ incompatibleImportPath: transitiveDependency.fsPath,
209
+ formattedReason: `No solc version enabled in this profile is compatible with a dependency of this file:\n * ${shortenPath(root.fsPath)}\n * ${transitiveDependency.fsPath.map((s) => shortenPath(s)).join("\n * ")}`,
210
+ };
211
+ }
212
+
213
+ // The root and the version ranges to get to this transitive dependency
214
+ // may be contradictory, so no version ever can satisfy them.
143
215
  if (!intersects(rootVersionRange, transitiveDependencyVersionRange)) {
144
216
  return {
217
+ success: false,
145
218
  reason: CompilationJobCreationErrorReason.IMPORT_OF_INCOMPATIBLE_FILE,
146
219
  rootFilePath: root.fsPath,
147
220
  buildProfile: this.#buildProfileName,
148
221
  incompatibleImportPath: transitiveDependency.fsPath,
149
- formattedReason: `Following these imports leads to an incompatible solc version pragma that no version can satisfy:
150
- * ${shortenPath(root.fsPath)}
151
- * ${transitiveDependency.fsPath.map((s) => shortenPath(s)).join("\n * ")}
152
- `,
222
+ formattedReason: `Following these imports leads to an incompatible solc version pragma that no version can satisfy:\n * ${shortenPath(root.fsPath)}\n * ${transitiveDependency.fsPath.map((s) => shortenPath(s)).join("\n * ")}`,
223
+ };
224
+ }
225
+
226
+ // The root and the version ranges to get to this transitive dependency
227
+ // may not be compatible with any configured compiler.
228
+ const combinedRange = `${rootVersionRange} ${transitiveDependencyVersionRange}`;
229
+ if (maxSatisfying(compilerVersions, combinedRange) === null) {
230
+ return {
231
+ success: false,
232
+ reason:
233
+ CompilationJobCreationErrorReason.NO_COMPATIBLE_SOLC_VERSION_FOR_TRANSITIVE_IMPORT_PATH,
234
+ rootFilePath: root.fsPath,
235
+ buildProfile: this.#buildProfileName,
236
+ incompatibleImportPath: transitiveDependency.fsPath,
237
+ formattedReason: `No solc version enabled in this profile is compatible with this file and this import path:\n * ${shortenPath(root.fsPath)}\n * ${transitiveDependency.fsPath.map((s) => shortenPath(s)).join("\n * ")}`,
153
238
  };
154
239
  }
155
240
  }
156
241
 
242
+ // This is a generic case that can happen when the incompatibilities exist
243
+ // but we can't detect them with the above algorithm. For example, if a
244
+ // root imports two compatible dependencies that are incompatible with each
245
+ // other. We could try and improve this error message, but it's
246
+ // computationally expensive and hard to express to the users.
157
247
  return {
248
+ success: false,
158
249
  reason:
159
250
  CompilationJobCreationErrorReason.NO_COMPATIBLE_SOLC_VERSION_FOUND,
160
251
  rootFilePath: root.fsPath,
@@ -163,6 +254,12 @@ export class SolcConfigSelector {
163
254
  };
164
255
  }
165
256
 
257
+ /**
258
+ * Returns a generator of all the transitive dependencies of a root file. For each
259
+ * dependency, it yields the sequence of fsPaths from the root to that dependency,
260
+ * along with the corresponding version pragma paths for each file in the import chain.
261
+ * The paths don't include the root itself.
262
+ */
166
263
  *#getTransitiveDependencies(
167
264
  root: ResolvedFile,
168
265
  dependencyGraph: DependencyGraph,
@@ -179,7 +276,7 @@ export class SolcConfigSelector {
179
276
  continue;
180
277
  }
181
278
 
182
- visited.add(file);
279
+ visited = new Set([...visited, file]);
183
280
 
184
281
  yield {
185
282
  fsPath: [file.fsPath],
@@ -124,7 +124,7 @@ const buildProfilesSolidityUserConfigType = commonSolidityUserConfigType.extend(
124
124
  },
125
125
  );
126
126
 
127
- const soldityUserConfigType = conditionalUnionType(
127
+ const solidityUserConfigType = conditionalUnionType(
128
128
  [
129
129
  [(data) => typeof data === "string", z.string()],
130
130
  [(data) => Array.isArray(data), z.array(z.string()).nonempty()],
@@ -159,7 +159,7 @@ const userConfigType = z.object({
159
159
  ).optional(),
160
160
  })
161
161
  .optional(),
162
- solidity: soldityUserConfigType.optional(),
162
+ solidity: solidityUserConfigType.optional(),
163
163
  });
164
164
 
165
165
  export function validateSolidityUserConfig(
@@ -46,6 +46,14 @@ class LazySolidityBuildSystem implements SolidityBuildSystem {
46
46
  return buildSystem.getScope(fsPath);
47
47
  }
48
48
 
49
+ public isSuccessfulBuildResult(
50
+ buildResult: CompilationJobCreationError | Map<string, FileBuildResult>,
51
+ ): buildResult is Map<string, FileBuildResult> {
52
+ // Note: This duplicates the logic of the actual implementation because it's
53
+ // a synchronous method, so we can't import the implementation.
54
+ return buildResult instanceof Map;
55
+ }
56
+
49
57
  public async build(
50
58
  rootFiles: string[],
51
59
  options?: BuildOptions,
@@ -110,7 +110,7 @@ async function buildForScope(
110
110
  scope,
111
111
  });
112
112
 
113
- throwIfSolidityBuildFailed(results);
113
+ throwIfSolidityBuildFailed(solidity, results);
114
114
 
115
115
  // If we recompiled the entire project we cleanup the artifacts
116
116
  if (isFullCompilation) {
@@ -242,5 +242,33 @@ declare module "../../../types/hooks.js" {
242
242
  nextSolcConfig: SolcConfig,
243
243
  ) => Promise<CompilerOutput>,
244
244
  ): Promise<CompilerOutput>;
245
+
246
+ /**
247
+ * Provide a handler for this hook to supply remappings for npm packages.
248
+ *
249
+ * This hook is called when the resolver needs to read remappings for a package.
250
+ * Handlers can provide remappings from alternative sources (e.g., foundry.toml)
251
+ * in addition to the default remappings.txt files.
252
+ *
253
+ * @param context The hook context.
254
+ * @param packageName The name of the npm package.
255
+ * @param packageVersion The version of the npm package.
256
+ * @param packagePath The absolute filesystem path to the package root.
257
+ * @param next A function to get remappings from other sources (including default behavior).
258
+ * @returns An array of remapping sources, each containing an array of remapping strings
259
+ * and the source path they came from.
260
+ */
261
+ readNpmPackageRemappings: (
262
+ context: HookContext,
263
+ packageName: string,
264
+ packageVersion: string,
265
+ packagePath: string,
266
+ next: (
267
+ nextContext: HookContext,
268
+ nextPackageName: string,
269
+ nextPackageVersion: string,
270
+ nextPackagePath: string,
271
+ ) => Promise<Array<{ remappings: string[]; source: string }>>,
272
+ ) => Promise<Array<{ remappings: string[]; source: string }>>;
245
273
  }
246
274
  }
@@ -44,6 +44,7 @@ const solidityTestUserConfigType = z.object({
44
44
  coinbase: z.string().startsWith("0x").optional(),
45
45
  blockTimestamp: z.bigint().optional(),
46
46
  prevRandao: z.bigint().optional(),
47
+ gasLimit: z.bigint().optional(),
47
48
  blockGasLimit: z.bigint().or(z.literal(false)).optional(),
48
49
  fuzz: z
49
50
  .object({
@@ -60,7 +60,7 @@ export async function getBuildInfos(
60
60
  */
61
61
  export async function getEdrArtifacts(
62
62
  artifactManager: ArtifactManager,
63
- ): Promise<Array<{ edrAtifact: EdrArtifact; userSourceName: string }>> {
63
+ ): Promise<Array<{ edrArtifact: EdrArtifact; userSourceName: string }>> {
64
64
  const fullyQualifiedNames = await artifactManager.getAllFullyQualifiedNames();
65
65
 
66
66
  const artifacts = await Promise.all(
@@ -140,7 +140,7 @@ export async function getEdrArtifacts(
140
140
  // from an artifact id between the `run` call and the events emitted by the
141
141
  // test runner.
142
142
  return {
143
- edrAtifact: {
143
+ edrArtifact: {
144
144
  id,
145
145
  contract,
146
146
  },