hardhat 3.7.0 → 3.9.0

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 (155) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/dist/src/cli.js +4 -1
  3. package/dist/src/cli.js.map +1 -1
  4. package/dist/src/internal/builtin-plugins/artifacts/index.d.ts.map +1 -1
  5. package/dist/src/internal/builtin-plugins/artifacts/index.js +3 -2
  6. package/dist/src/internal/builtin-plugins/artifacts/index.js.map +1 -1
  7. package/dist/src/internal/builtin-plugins/clean/index.d.ts.map +1 -1
  8. package/dist/src/internal/builtin-plugins/clean/index.js +3 -2
  9. package/dist/src/internal/builtin-plugins/clean/index.js.map +1 -1
  10. package/dist/src/internal/builtin-plugins/console/index.d.ts.map +1 -1
  11. package/dist/src/internal/builtin-plugins/console/index.js +3 -2
  12. package/dist/src/internal/builtin-plugins/console/index.js.map +1 -1
  13. package/dist/src/internal/builtin-plugins/coverage/config.d.ts +6 -0
  14. package/dist/src/internal/builtin-plugins/coverage/config.d.ts.map +1 -0
  15. package/dist/src/internal/builtin-plugins/coverage/config.js +18 -0
  16. package/dist/src/internal/builtin-plugins/coverage/config.js.map +1 -0
  17. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/config.d.ts +4 -0
  18. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/config.d.ts.map +1 -0
  19. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/config.js +15 -0
  20. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/config.js.map +1 -0
  21. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.d.ts.map +1 -1
  22. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js +10 -1
  23. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js.map +1 -1
  24. package/dist/src/internal/builtin-plugins/coverage/index.d.ts.map +1 -1
  25. package/dist/src/internal/builtin-plugins/coverage/index.js +4 -2
  26. package/dist/src/internal/builtin-plugins/coverage/index.js.map +1 -1
  27. package/dist/src/internal/builtin-plugins/coverage/type-extensions.d.ts +20 -0
  28. package/dist/src/internal/builtin-plugins/coverage/type-extensions.d.ts.map +1 -1
  29. package/dist/src/internal/builtin-plugins/flatten/index.d.ts.map +1 -1
  30. package/dist/src/internal/builtin-plugins/flatten/index.js +3 -2
  31. package/dist/src/internal/builtin-plugins/flatten/index.js.map +1 -1
  32. package/dist/src/internal/builtin-plugins/gas-analytics/index.d.ts.map +1 -1
  33. package/dist/src/internal/builtin-plugins/gas-analytics/index.js +3 -2
  34. package/dist/src/internal/builtin-plugins/gas-analytics/index.js.map +1 -1
  35. package/dist/src/internal/builtin-plugins/network-manager/edr/genesis-state.d.ts +2 -1
  36. package/dist/src/internal/builtin-plugins/network-manager/edr/genesis-state.d.ts.map +1 -1
  37. package/dist/src/internal/builtin-plugins/network-manager/edr/genesis-state.js +13 -10
  38. package/dist/src/internal/builtin-plugins/network-manager/edr/genesis-state.js.map +1 -1
  39. package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.d.ts +1 -0
  40. package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.d.ts.map +1 -1
  41. package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.js +5 -0
  42. package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.js.map +1 -1
  43. package/dist/src/internal/builtin-plugins/network-manager/index.d.ts.map +1 -1
  44. package/dist/src/internal/builtin-plugins/network-manager/index.js +3 -2
  45. package/dist/src/internal/builtin-plugins/network-manager/index.js.map +1 -1
  46. package/dist/src/internal/builtin-plugins/network-manager/provider-errors.d.ts +0 -12
  47. package/dist/src/internal/builtin-plugins/network-manager/provider-errors.d.ts.map +1 -1
  48. package/dist/src/internal/builtin-plugins/network-manager/provider-errors.js +0 -28
  49. package/dist/src/internal/builtin-plugins/network-manager/provider-errors.js.map +1 -1
  50. package/dist/src/internal/builtin-plugins/network-manager/type-validation.d.ts.map +1 -1
  51. package/dist/src/internal/builtin-plugins/network-manager/type-validation.js +10 -1
  52. package/dist/src/internal/builtin-plugins/network-manager/type-validation.js.map +1 -1
  53. package/dist/src/internal/builtin-plugins/node/index.d.ts.map +1 -1
  54. package/dist/src/internal/builtin-plugins/node/index.js +3 -2
  55. package/dist/src/internal/builtin-plugins/node/index.js.map +1 -1
  56. package/dist/src/internal/builtin-plugins/run/index.d.ts.map +1 -1
  57. package/dist/src/internal/builtin-plugins/run/index.js +3 -2
  58. package/dist/src/internal/builtin-plugins/run/index.js.map +1 -1
  59. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts +6 -0
  60. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts.map +1 -1
  61. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js +8 -0
  62. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.map +1 -1
  63. package/dist/src/internal/builtin-plugins/solidity/build-system/warning-suppression.d.ts.map +1 -1
  64. package/dist/src/internal/builtin-plugins/solidity/build-system/warning-suppression.js +4 -0
  65. package/dist/src/internal/builtin-plugins/solidity/build-system/warning-suppression.js.map +1 -1
  66. package/dist/src/internal/builtin-plugins/solidity/config.js +7 -1
  67. package/dist/src/internal/builtin-plugins/solidity/config.js.map +1 -1
  68. package/dist/src/internal/builtin-plugins/solidity/index.d.ts.map +1 -1
  69. package/dist/src/internal/builtin-plugins/solidity/index.js +3 -2
  70. package/dist/src/internal/builtin-plugins/solidity/index.js.map +1 -1
  71. package/dist/src/internal/builtin-plugins/solidity/solidity-hooks.d.ts.map +1 -1
  72. package/dist/src/internal/builtin-plugins/solidity/solidity-hooks.js +5 -2
  73. package/dist/src/internal/builtin-plugins/solidity/solidity-hooks.js.map +1 -1
  74. package/dist/src/internal/builtin-plugins/solidity/source-names.d.ts +12 -0
  75. package/dist/src/internal/builtin-plugins/solidity/source-names.d.ts.map +1 -0
  76. package/dist/src/internal/builtin-plugins/solidity/source-names.js +18 -0
  77. package/dist/src/internal/builtin-plugins/solidity/source-names.js.map +1 -0
  78. package/dist/src/internal/builtin-plugins/solidity-test/eip712/index.d.ts.map +1 -1
  79. package/dist/src/internal/builtin-plugins/solidity-test/eip712/index.js +7 -12
  80. package/dist/src/internal/builtin-plugins/solidity-test/eip712/index.js.map +1 -1
  81. package/dist/src/internal/builtin-plugins/solidity-test/index.d.ts.map +1 -1
  82. package/dist/src/internal/builtin-plugins/solidity-test/index.js +3 -2
  83. package/dist/src/internal/builtin-plugins/solidity-test/index.js.map +1 -1
  84. package/dist/src/internal/builtin-plugins/telemetry/index.d.ts.map +1 -1
  85. package/dist/src/internal/builtin-plugins/telemetry/index.js +3 -2
  86. package/dist/src/internal/builtin-plugins/telemetry/index.js.map +1 -1
  87. package/dist/src/internal/builtin-plugins/test/index.d.ts.map +1 -1
  88. package/dist/src/internal/builtin-plugins/test/index.js +3 -2
  89. package/dist/src/internal/builtin-plugins/test/index.js.map +1 -1
  90. package/dist/src/internal/cli/main.d.ts +1 -0
  91. package/dist/src/internal/cli/main.d.ts.map +1 -1
  92. package/dist/src/internal/cli/main.js +4 -0
  93. package/dist/src/internal/cli/main.js.map +1 -1
  94. package/dist/src/internal/core/plugins/loaded-plugins-registry.d.ts +4 -0
  95. package/dist/src/internal/core/plugins/loaded-plugins-registry.d.ts.map +1 -0
  96. package/dist/src/internal/core/plugins/loaded-plugins-registry.js +8 -0
  97. package/dist/src/internal/core/plugins/loaded-plugins-registry.js.map +1 -0
  98. package/dist/src/internal/core/plugins/unused-plugins-warning.d.ts +3 -0
  99. package/dist/src/internal/core/plugins/unused-plugins-warning.d.ts.map +1 -0
  100. package/dist/src/internal/core/plugins/unused-plugins-warning.js +29 -0
  101. package/dist/src/internal/core/plugins/unused-plugins-warning.js.map +1 -0
  102. package/dist/src/internal/edr/context.d.ts.map +1 -1
  103. package/dist/src/internal/edr/context.js +25 -7
  104. package/dist/src/internal/edr/context.js.map +1 -1
  105. package/dist/src/internal/{builtin-plugins/solidity-test/eip712 → utils}/glob.d.ts +4 -0
  106. package/dist/src/internal/utils/glob.d.ts.map +1 -0
  107. package/dist/src/internal/{builtin-plugins/solidity-test/eip712 → utils}/glob.js +3 -3
  108. package/dist/src/internal/utils/glob.js.map +1 -0
  109. package/dist/src/plugins.d.ts +13 -0
  110. package/dist/src/plugins.d.ts.map +1 -1
  111. package/dist/src/plugins.js +16 -0
  112. package/dist/src/plugins.js.map +1 -1
  113. package/package.json +4 -4
  114. package/src/cli.ts +4 -1
  115. package/src/internal/builtin-plugins/artifacts/index.ts +5 -2
  116. package/src/internal/builtin-plugins/clean/index.ts +3 -2
  117. package/src/internal/builtin-plugins/console/index.ts +3 -2
  118. package/src/internal/builtin-plugins/coverage/config.ts +28 -0
  119. package/src/internal/builtin-plugins/coverage/hook-handlers/config.ts +30 -0
  120. package/src/internal/builtin-plugins/coverage/hook-handlers/solidity.ts +15 -2
  121. package/src/internal/builtin-plugins/coverage/index.ts +4 -2
  122. package/src/internal/builtin-plugins/coverage/type-extensions.ts +24 -0
  123. package/src/internal/builtin-plugins/flatten/index.ts +3 -2
  124. package/src/internal/builtin-plugins/gas-analytics/index.ts +3 -2
  125. package/src/internal/builtin-plugins/network-manager/edr/genesis-state.ts +22 -14
  126. package/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.ts +5 -0
  127. package/src/internal/builtin-plugins/network-manager/index.ts +3 -2
  128. package/src/internal/builtin-plugins/network-manager/provider-errors.ts +0 -34
  129. package/src/internal/builtin-plugins/network-manager/type-validation.ts +14 -1
  130. package/src/internal/builtin-plugins/node/index.ts +3 -2
  131. package/src/internal/builtin-plugins/run/index.ts +3 -2
  132. package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +11 -0
  133. package/src/internal/builtin-plugins/solidity/build-system/warning-suppression.ts +4 -0
  134. package/src/internal/builtin-plugins/solidity/config.ts +7 -1
  135. package/src/internal/builtin-plugins/solidity/index.ts +3 -2
  136. package/src/internal/builtin-plugins/solidity/solidity-hooks.ts +8 -2
  137. package/src/internal/builtin-plugins/solidity/source-names.ts +19 -0
  138. package/src/internal/builtin-plugins/solidity-test/eip712/index.ts +8 -16
  139. package/src/internal/builtin-plugins/solidity-test/index.ts +3 -2
  140. package/src/internal/builtin-plugins/telemetry/index.ts +3 -2
  141. package/src/internal/builtin-plugins/test/index.ts +3 -2
  142. package/src/internal/cli/main.ts +6 -0
  143. package/src/internal/core/plugins/loaded-plugins-registry.ts +11 -0
  144. package/src/internal/core/plugins/unused-plugins-warning.ts +47 -0
  145. package/src/internal/edr/context.ts +39 -23
  146. package/src/internal/{builtin-plugins/solidity-test/eip712 → utils}/glob.ts +3 -3
  147. package/src/plugins.ts +19 -0
  148. package/templates/hardhat-3/01-node-test-runner-viem/package.json +11 -11
  149. package/templates/hardhat-3/01-node-test-runner-viem/tsconfig.json +2 -1
  150. package/templates/hardhat-3/02-mocha-ethers/package.json +14 -14
  151. package/templates/hardhat-3/02-mocha-ethers/tsconfig.json +2 -1
  152. package/templates/hardhat-3/03-minimal/package.json +1 -1
  153. package/templates/hardhat-3/03-minimal/tsconfig.json +2 -1
  154. package/dist/src/internal/builtin-plugins/solidity-test/eip712/glob.d.ts.map +0 -1
  155. package/dist/src/internal/builtin-plugins/solidity-test/eip712/glob.js.map +0 -1
@@ -9,10 +9,10 @@ export function isPathSelected(path, include, exclude) {
9
9
  if (include.length === 0) {
10
10
  return false;
11
11
  }
12
- if (!matchesAny(path, include)) {
12
+ if (!matchesAnyGlob(path, include)) {
13
13
  return false;
14
14
  }
15
- if (exclude.length > 0 && matchesAny(path, exclude)) {
15
+ if (exclude.length > 0 && matchesAnyGlob(path, exclude)) {
16
16
  return false;
17
17
  }
18
18
  return true;
@@ -20,7 +20,7 @@ export function isPathSelected(path, include, exclude) {
20
20
  /**
21
21
  * Returns true if `value` matches at least one of the given glob patterns.
22
22
  */
23
- function matchesAny(value, patterns) {
23
+ export function matchesAnyGlob(value, patterns) {
24
24
  for (const pattern of patterns) {
25
25
  if (getCompiledGlob(pattern).test(value)) {
26
26
  return true;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../../src/internal/utils/glob.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAkB,CAAC;AAEpD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,IAAY,EACZ,OAAiB,EACjB,OAAiB;IAEjB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;QACxD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,QAAkB;IAC9D,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACzC,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,OAAe;IACnC,OAAO,IAAI,MAAM,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,aAAa,CAAC,OAAe;IACpC,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;QAC1B,MAAM,CAA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SAAS,EAAE,CAAC;QAC3B,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;QACjC,iBAAiB,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,4 +1,17 @@
1
1
  export { HardhatPluginError } from "@nomicfoundation/hardhat-errors";
2
+ import type { HardhatPlugin } from "./types/plugins.js";
3
+ /**
4
+ * Defines a Hardhat plugin.
5
+ *
6
+ * Plugin authors should use this helper as the default export of their
7
+ * plugin's `index` module. It registers the plugin's `id` in a process-wide
8
+ * registry of loaded plugins, which the Hardhat CLI uses to detect plugins
9
+ * that are imported but not included in the user's `plugins` array.
10
+ *
11
+ * @param plugin The plugin definition.
12
+ * @returns The same plugin definition, unchanged.
13
+ */
14
+ export declare function definePlugin(plugin: HardhatPlugin): HardhatPlugin;
2
15
  /**
3
16
  * @deprecated This function is part of the Hardhat 2 plugin API.
4
17
  */
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../src/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAIrE;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,KAAK,EAAE,GAAG,GAAG,GAAG,CAE/C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,KAAK,EAAE,GAAG,GAAG,GAAG,CAE7C"}
1
+ {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../src/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKxD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAGjE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,KAAK,EAAE,GAAG,GAAG,GAAG,CAE/C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,KAAK,EAAE,GAAG,GAAG,GAAG,CAE7C"}
@@ -1,5 +1,21 @@
1
1
  export { HardhatPluginError } from "@nomicfoundation/hardhat-errors";
2
+ import { registerLoadedPlugin } from "./internal/core/plugins/loaded-plugins-registry.js";
2
3
  import { throwUsingHardhat2PluginError } from "./internal/using-hardhat2-plugin-errors.js";
4
+ /**
5
+ * Defines a Hardhat plugin.
6
+ *
7
+ * Plugin authors should use this helper as the default export of their
8
+ * plugin's `index` module. It registers the plugin's `id` in a process-wide
9
+ * registry of loaded plugins, which the Hardhat CLI uses to detect plugins
10
+ * that are imported but not included in the user's `plugins` array.
11
+ *
12
+ * @param plugin The plugin definition.
13
+ * @returns The same plugin definition, unchanged.
14
+ */
15
+ export function definePlugin(plugin) {
16
+ registerLoadedPlugin(plugin);
17
+ return plugin;
18
+ }
3
19
  /**
4
20
  * @deprecated This function is part of the Hardhat 2 plugin API.
5
21
  */
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../src/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,EAAE,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAE3F;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,GAAG,KAAU;IACxC,6BAA6B,EAAE,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,GAAG,KAAU;IACtC,6BAA6B,EAAE,CAAC;AAClC,CAAC"}
1
+ {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../src/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAIrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAC;AAC1F,OAAO,EAAE,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAE3F;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,MAAqB;IAChD,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,GAAG,KAAU;IACxC,6BAA6B,EAAE,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,GAAG,KAAU;IACtC,6BAA6B,EAAE,CAAC;AAClC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hardhat",
3
- "version": "3.7.0",
3
+ "version": "3.9.0",
4
4
  "description": "Hardhat is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.",
5
5
  "homepage": "https://hardhat.org",
6
6
  "repository": {
@@ -63,7 +63,7 @@
63
63
  "README.md"
64
64
  ],
65
65
  "devDependencies": {
66
- "@nomicfoundation/hardhat-node-test-reporter": "^3.0.7",
66
+ "@nomicfoundation/hardhat-node-test-reporter": "^3.1.0",
67
67
  "@types/adm-zip": "^0.5.5",
68
68
  "@types/node": "^22.0.0",
69
69
  "@types/semver": "^7.5.8",
@@ -77,8 +77,8 @@
77
77
  "@nomicfoundation/hardhat-test-utils": "^2.0.3"
78
78
  },
79
79
  "dependencies": {
80
- "@nomicfoundation/edr": "0.12.0-next.33",
81
- "@nomicfoundation/hardhat-errors": "^3.0.14",
80
+ "@nomicfoundation/edr": "0.12.0",
81
+ "@nomicfoundation/hardhat-errors": "^3.0.15",
82
82
  "@nomicfoundation/hardhat-utils": "^4.1.3",
83
83
  "@nomicfoundation/hardhat-vendored": "^3.0.4",
84
84
  "@nomicfoundation/hardhat-zod-utils": "^3.0.5",
package/src/cli.ts CHANGED
@@ -24,4 +24,7 @@ function isTsxRequired(): boolean {
24
24
  }
25
25
 
26
26
  // eslint-disable-next-line no-restricted-syntax -- We do want TLA here
27
- await main(process.argv.slice(2), { registerTsx: isTsxRequired() });
27
+ await main(process.argv.slice(2), {
28
+ registerTsx: isTsxRequired(),
29
+ warnAboutUnusedPlugins: true,
30
+ });
@@ -1,12 +1,15 @@
1
1
  import type { HardhatPlugin } from "../../../types/plugins.js";
2
+
3
+ import { definePlugin } from "../../../plugins.js";
4
+
2
5
  export type * from "./type-extensions.js";
3
6
 
4
- const hardhatPlugin: HardhatPlugin = {
7
+ const hardhatPlugin: HardhatPlugin = definePlugin({
5
8
  id: "builtin:artifacts",
6
9
  hookHandlers: {
7
10
  hre: () => import("./hook-handlers/hre.js"),
8
11
  },
9
12
  npmPackage: "hardhat",
10
- };
13
+ });
11
14
 
12
15
  export default hardhatPlugin;
@@ -1,10 +1,11 @@
1
1
  import type { HardhatPlugin } from "../../../types/plugins.js";
2
2
 
3
+ import { definePlugin } from "../../../plugins.js";
3
4
  import { task } from "../../core/config.js";
4
5
 
5
6
  export type * from "./type-extensions.js";
6
7
 
7
- const hardhatPlugin: HardhatPlugin = {
8
+ const hardhatPlugin: HardhatPlugin = definePlugin({
8
9
  id: "builtin:clean",
9
10
  tasks: [
10
11
  task("clean", "Clear the cache and delete all artifacts")
@@ -16,6 +17,6 @@ const hardhatPlugin: HardhatPlugin = {
16
17
  .build(),
17
18
  ],
18
19
  npmPackage: "hardhat",
19
- };
20
+ });
20
21
 
21
22
  export default hardhatPlugin;
@@ -1,8 +1,9 @@
1
1
  import type { HardhatPlugin } from "../../../types/plugins.js";
2
2
 
3
+ import { definePlugin } from "../../../plugins.js";
3
4
  import { task } from "../../core/config.js";
4
5
 
5
- const hardhatPlugin: HardhatPlugin = {
6
+ const hardhatPlugin: HardhatPlugin = definePlugin({
6
7
  id: "builtin:console",
7
8
  tasks: [
8
9
  task("console", "Open a hardhat console")
@@ -25,6 +26,6 @@ const hardhatPlugin: HardhatPlugin = {
25
26
  ],
26
27
  dependencies: () => [import("../solidity/index.js")],
27
28
  npmPackage: "hardhat",
28
- };
29
+ });
29
30
 
30
31
  export default hardhatPlugin;
@@ -0,0 +1,28 @@
1
+ import type { HardhatUserConfig } from "../../../config.js";
2
+ import type { CoverageConfig } from "../../../types/config.js";
3
+ import type { HardhatUserConfigValidationError } from "../../../types/hooks.js";
4
+
5
+ import { validateUserConfigZodType } from "@nomicfoundation/hardhat-zod-utils";
6
+ import { z } from "zod";
7
+
8
+ const userConfigType = z.object({
9
+ coverage: z
10
+ .object({
11
+ skipFiles: z.array(z.string()).optional(),
12
+ })
13
+ .optional(),
14
+ });
15
+
16
+ export function validateCoverageUserConfig(
17
+ userConfig: unknown,
18
+ ): HardhatUserConfigValidationError[] {
19
+ return validateUserConfigZodType(userConfig, userConfigType);
20
+ }
21
+
22
+ export function resolveCoverageConfig(
23
+ userConfig: HardhatUserConfig,
24
+ ): CoverageConfig {
25
+ return {
26
+ skipFiles: userConfig.coverage?.skipFiles ?? [],
27
+ };
28
+ }
@@ -0,0 +1,30 @@
1
+ import type { ConfigHooks } from "../../../../types/hooks.js";
2
+
3
+ import {
4
+ resolveCoverageConfig,
5
+ validateCoverageUserConfig,
6
+ } from "../config.js";
7
+
8
+ export default async (): Promise<Partial<ConfigHooks>> => {
9
+ const handlers: Partial<ConfigHooks> = {
10
+ validateUserConfig: async (userConfig) =>
11
+ validateCoverageUserConfig(userConfig),
12
+ resolveUserConfig: async (
13
+ userConfig,
14
+ resolveConfigurationVariable,
15
+ next,
16
+ ) => {
17
+ const resolvedConfig = await next(
18
+ userConfig,
19
+ resolveConfigurationVariable,
20
+ );
21
+
22
+ return {
23
+ ...resolvedConfig,
24
+ coverage: resolveCoverageConfig(userConfig),
25
+ };
26
+ },
27
+ };
28
+
29
+ return handlers;
30
+ };
@@ -8,6 +8,8 @@ import { HardhatError } from "@nomicfoundation/hardhat-errors";
8
8
  import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
9
9
  import { ensureError } from "@nomicfoundation/hardhat-utils/error";
10
10
 
11
+ import { matchesAnyGlob } from "../../../utils/glob.js";
12
+ import { toUserSourceName } from "../../solidity/source-names.js";
11
13
  import { getCoverageManager } from "../helpers/accessors.js";
12
14
  import { instrumentSolidityFileForCompilationJob } from "../instrumentation.js";
13
15
 
@@ -22,12 +24,23 @@ export default async (): Promise<Partial<SolidityHooks>> => ({
22
24
  solcVersion,
23
25
  next,
24
26
  ) => {
27
+ // This hook runs on every project file of every build. Coverage is the
28
+ // only reason to preprocess them, so when it is off we pass the file
29
+ // through untouched and keep the common path free of the work below.
30
+ if (!context.globalOptions.coverage) {
31
+ return await next(context, sourceName, fsPath, fileContent, solcVersion);
32
+ }
33
+
25
34
  // NOTE: We do not want to instrument the test project files as we don't
26
35
  // want to report coverage for them.
27
-
28
36
  const isTestSource = (await context.solidity.getScope(fsPath)) === "tests";
29
37
 
30
- if (context.globalOptions.coverage && !isTestSource) {
38
+ const isSkipped = matchesAnyGlob(
39
+ toUserSourceName(sourceName),
40
+ context.config.coverage.skipFiles,
41
+ );
42
+
43
+ if (!isTestSource && !isSkipped) {
31
44
  try {
32
45
  const { source, metadata } = instrumentSolidityFileForCompilationJob({
33
46
  compilationJobSolcVersion: solcVersion,
@@ -1,10 +1,11 @@
1
1
  import type { HardhatPlugin } from "../../../types/plugins.js";
2
2
 
3
+ import { definePlugin } from "../../../plugins.js";
3
4
  import { globalFlag } from "../../core/config.js";
4
5
 
5
6
  export type * from "./type-extensions.js";
6
7
 
7
- const hardhatPlugin: HardhatPlugin = {
8
+ const hardhatPlugin: HardhatPlugin = definePlugin({
8
9
  id: "builtin:coverage",
9
10
  tasks: [],
10
11
  globalOptions: [
@@ -15,11 +16,12 @@ const hardhatPlugin: HardhatPlugin = {
15
16
  ],
16
17
  hookHandlers: {
17
18
  clean: () => import("./hook-handlers/clean.js"),
19
+ config: () => import("./hook-handlers/config.js"),
18
20
  hre: () => import("./hook-handlers/hre.js"),
19
21
  solidity: () => import("./hook-handlers/solidity.js"),
20
22
  test: () => import("./hook-handlers/test.js"),
21
23
  },
22
24
  npmPackage: "hardhat",
23
- };
25
+ });
24
26
 
25
27
  export default hardhatPlugin;
@@ -3,3 +3,27 @@ declare module "../../../types/global-options.js" {
3
3
  coverage: boolean;
4
4
  }
5
5
  }
6
+
7
+ declare module "../../../types/config.js" {
8
+ export interface CoverageUserConfig {
9
+ /**
10
+ * Globs of Solidity source files to exclude from coverage instrumentation.
11
+ * A project file whose project-relative source name matches any of these
12
+ * globs is not instrumented during a `--coverage` run, and so does not
13
+ * appear in coverage reports.
14
+ */
15
+ skipFiles?: string[];
16
+ }
17
+
18
+ export interface HardhatUserConfig {
19
+ coverage?: CoverageUserConfig;
20
+ }
21
+
22
+ export interface CoverageConfig {
23
+ skipFiles: string[];
24
+ }
25
+
26
+ export interface HardhatConfig {
27
+ coverage: CoverageConfig;
28
+ }
29
+ }
@@ -1,9 +1,10 @@
1
1
  import type { HardhatPlugin } from "../../../types/plugins.js";
2
2
 
3
+ import { definePlugin } from "../../../plugins.js";
3
4
  import { ArgumentType } from "../../../types/arguments.js";
4
5
  import { task } from "../../core/config.js";
5
6
 
6
- const hardhatPlugin: HardhatPlugin = {
7
+ const hardhatPlugin: HardhatPlugin = definePlugin({
7
8
  id: "builtin:flatten",
8
9
  tasks: [
9
10
  task("flatten")
@@ -17,6 +18,6 @@ const hardhatPlugin: HardhatPlugin = {
17
18
  .setAction(async () => await import("./task-action.js"))
18
19
  .build(),
19
20
  ],
20
- };
21
+ });
21
22
 
22
23
  export default hardhatPlugin;
@@ -1,11 +1,12 @@
1
1
  import type { HardhatPlugin } from "../../../types/plugins.js";
2
2
 
3
+ import { definePlugin } from "../../../plugins.js";
3
4
  import { ArgumentType } from "../../../types/arguments.js";
4
5
  import { globalFlag, globalOption, overrideTask } from "../../core/config.js";
5
6
 
6
7
  export type * from "./type-extensions.js";
7
8
 
8
- const hardhatPlugin: HardhatPlugin = {
9
+ const hardhatPlugin: HardhatPlugin = definePlugin({
9
10
  id: "builtin:gas-analytics",
10
11
  tasks: [
11
12
  overrideTask("test")
@@ -63,6 +64,6 @@ const hardhatPlugin: HardhatPlugin = {
63
64
  import("../solidity-test/index.js"),
64
65
  ],
65
66
  npmPackage: "hardhat",
66
- };
67
+ });
67
68
 
68
69
  export default hardhatPlugin;
@@ -12,6 +12,7 @@ import {
12
12
  opHardforkFromString,
13
13
  type AccountOverride,
14
14
  } from "@nomicfoundation/edr";
15
+ import { bytesToHexString } from "@nomicfoundation/hardhat-utils/hex";
15
16
  import { AsyncMutex } from "@nomicfoundation/hardhat-utils/synchronization";
16
17
  import { hexToBytes } from "ethereum-cryptography/utils";
17
18
 
@@ -50,7 +51,7 @@ const genesisStateAndAccountsCache: WeakMap<
50
51
  Map<
51
52
  string,
52
53
  {
53
- genesisState: Map<Uint8Array, AccountOverride>;
54
+ genesisState: Map<string, AccountOverride>;
54
55
  ownedAccounts: Array<{ secretKey: string; balance: bigint }>;
55
56
  }
56
57
  >
@@ -66,7 +67,7 @@ export async function getGenesisStateAndOwnedAccounts(
66
67
  chainType: ChainType,
67
68
  specId: string,
68
69
  ): Promise<{
69
- genesisState: Map<Uint8Array, AccountOverride>;
70
+ genesisState: Map<string, AccountOverride>;
70
71
  ownedAccounts: Array<{ secretKey: string; balance: bigint }>;
71
72
  }> {
72
73
  const cached = genesisStateAndAccountsCache
@@ -131,7 +132,7 @@ async function createGenesisStateAndOwnedAccounts(
131
132
  chainType: ChainType,
132
133
  specId: string,
133
134
  ): Promise<{
134
- genesisState: Map<Uint8Array, AccountOverride>;
135
+ genesisState: Map<string, AccountOverride>;
135
136
  ownedAccounts: Array<{ secretKey: string; balance: bigint }>;
136
137
  }> {
137
138
  if (microEthSignerAddress === undefined) {
@@ -142,7 +143,7 @@ async function createGenesisStateAndOwnedAccounts(
142
143
 
143
144
  const ownedAccounts = await hardhatAccountsToEdrOwnedAccounts(accountsConfig);
144
145
 
145
- const genesisState: Map<Uint8Array, AccountOverride> = new Map(
146
+ const genesisState: Map<string, AccountOverride> = new Map(
146
147
  ownedAccounts.map(({ secretKey, balance }) => {
147
148
  const address = hexToBytes(addr.fromPrivateKey(secretKey));
148
149
  const accountOverride: AccountOverride = {
@@ -151,7 +152,7 @@ async function createGenesisStateAndOwnedAccounts(
151
152
  code: new Uint8Array(), // Empty account code, removing potential delegation code when forking
152
153
  };
153
154
 
154
- return [address, accountOverride];
155
+ return [bytesToHexString(address), accountOverride];
155
156
  }),
156
157
  );
157
158
 
@@ -162,18 +163,25 @@ async function createGenesisStateAndOwnedAccounts(
162
163
  ? opGenesisState(opHardforkFromString(specId))
163
164
  : l1GenesisState(l1HardforkFromString(specId));
164
165
 
166
+ mergeGenesisState(genesisState, chainGenesisState);
167
+
168
+ return { genesisState, ownedAccounts };
169
+ }
170
+
171
+ export function mergeGenesisState(
172
+ genesisState: Map<string, AccountOverride>,
173
+ chainGenesisState: readonly AccountOverride[],
174
+ ): void {
165
175
  for (const account of chainGenesisState) {
166
- const existingOverride = genesisState.get(account.address);
176
+ const addressKey = bytesToHexString(account.address);
177
+ const existingOverride = genesisState.get(addressKey);
167
178
  if (existingOverride !== undefined) {
168
179
  // Favor the genesis state specified by the user
169
- account.balance = account.balance ?? existingOverride.balance;
170
- account.nonce = account.nonce ?? existingOverride.nonce;
171
- account.code = account.code ?? existingOverride.code;
172
- account.storage = account.storage ?? existingOverride.storage;
173
- } else {
174
- genesisState.set(account.address, account);
180
+ account.balance = existingOverride.balance ?? account.balance;
181
+ account.nonce = existingOverride.nonce ?? account.nonce;
182
+ account.code = existingOverride.code ?? account.code;
183
+ account.storage = existingOverride.storage ?? account.storage;
175
184
  }
185
+ genesisState.set(addressKey, account);
176
186
  }
177
-
178
- return { genesisState, ownedAccounts };
179
187
  }
@@ -319,6 +319,7 @@ function getMessageFromLastStackTraceEntry(
319
319
  **/
320
320
  export class SolidityError extends Error {
321
321
  public readonly code: number = REVERT_ERROR_CODE;
322
+ public readonly solidityStack: string;
322
323
 
323
324
  constructor(
324
325
  message: string,
@@ -328,6 +329,10 @@ export class SolidityError extends Error {
328
329
  ) {
329
330
  super(message);
330
331
  this.name = "SolidityError";
332
+ this.solidityStack =
333
+ stackTrace.length !== 0
334
+ ? stackTrace.map(encodeStackTraceEntry).reverse().join("\n")
335
+ : "Internal error when encoding SolidityError";
331
336
 
332
337
  Object.defineProperty(this, Symbol.for("nodejs.util.inspect.custom"), {
333
338
  value: () =>
@@ -1,5 +1,6 @@
1
1
  import type { HardhatPlugin } from "../../../types/plugins.js";
2
2
 
3
+ import { definePlugin } from "../../../plugins.js";
3
4
  import { ArgumentType } from "../../../types/arguments.js";
4
5
  import { globalOption } from "../../core/config.js";
5
6
 
@@ -8,7 +9,7 @@ export type * from "./type-extensions/global-options.js";
8
9
  export type * from "./type-extensions/hooks.js";
9
10
  export type * from "./type-extensions/hre.js";
10
11
 
11
- const hardhatPlugin: HardhatPlugin = {
12
+ const hardhatPlugin: HardhatPlugin = definePlugin({
12
13
  id: "builtin:network-manager",
13
14
  hookHandlers: {
14
15
  config: () => import("./hook-handlers/config.js"),
@@ -25,6 +26,6 @@ const hardhatPlugin: HardhatPlugin = {
25
26
  ],
26
27
  npmPackage: "hardhat",
27
28
  dependencies: () => [import("../artifacts/index.js")],
28
- };
29
+ });
29
30
 
30
31
  export default hardhatPlugin;
@@ -15,13 +15,7 @@ const IS_PROVIDER_ERROR_PROPERTY_NAME = "_isProviderError";
15
15
  // -32603 Internal error Internal JSON-RPC error standard
16
16
  // -32700 Parse error Invalid JSON standard
17
17
  //
18
- // -32003 Transaction rejected Transaction creation failed non-standard
19
- // -32004 Method not supported Method is not implemented non-standard
20
18
  // -32005 Limit exceeded Request exceeds defined limit non-standard
21
- //
22
- // -32999 Invalid response The server returned a JSON-RPC hardhat-specific
23
- // response, but the result is not
24
- // in the expected format
25
19
  export class ProviderError extends CustomError implements ProviderRpcError {
26
20
  public code: number;
27
21
  public data?: unknown;
@@ -76,7 +70,6 @@ export class InvalidRequestError extends ProviderError {
76
70
  }
77
71
  }
78
72
 
79
- // TODO: not used, should we remove it?
80
73
  export class MethodNotFoundError extends ProviderError {
81
74
  public static readonly CODE = -32601;
82
75
 
@@ -101,33 +94,6 @@ export class InternalError extends ProviderError {
101
94
  }
102
95
  }
103
96
 
104
- // TODO: not used, should we remove it?
105
- export class TransactionExecutionError extends ProviderError {
106
- public static readonly CODE = -32003;
107
-
108
- constructor(message: string = "Transaction rejected", parent?: Error) {
109
- super(message, TransactionExecutionError.CODE, parent);
110
- }
111
- }
112
-
113
- // TODO: not used, should we remove it?
114
- export class MethodNotSupportedError extends ProviderError {
115
- public static readonly CODE = -32004;
116
-
117
- constructor(message: string = "Method not supported", parent?: Error) {
118
- super(message, MethodNotSupportedError.CODE, parent);
119
- }
120
- }
121
-
122
- // TODO: not used, should we remove it?
123
- export class InvalidResponseError extends ProviderError {
124
- public static readonly CODE = -32999;
125
-
126
- constructor(message: string = "Invalid response", parent?: Error) {
127
- super(message, InvalidResponseError.CODE, parent);
128
- }
129
- }
130
-
131
97
  export class UnknownError extends ProviderError {
132
98
  public static readonly CODE = -1;
133
99
 
@@ -322,7 +322,20 @@ const edrNetworkUserConfigSchema = z.object({
322
322
  hardfork: z.optional(z.string()),
323
323
  initialBaseFeePerGas: z.optional(gasUnitUserConfigSchema),
324
324
  initialDate: z.optional(
325
- unionType([z.string(), z.instanceof(Date)], "Expected a string or a Date"),
325
+ unionType(
326
+ [z.string(), z.instanceof(Date)],
327
+ "Expected a string or a Date",
328
+ ).refine(
329
+ (val) => {
330
+ if (typeof val === "string") return !Number.isNaN(Date.parse(val));
331
+ if (val instanceof Date) return !Number.isNaN(val.getTime());
332
+ // already union of string/Date, all types are exhausted
333
+ return true;
334
+ },
335
+ {
336
+ message: "initialDate must be a parseable date string or a valid Date",
337
+ },
338
+ ),
326
339
  ),
327
340
  loggingEnabled: z.optional(z.boolean()),
328
341
  minGasPrice: z.optional(gasUnitUserConfigSchema),
@@ -1,9 +1,10 @@
1
1
  import type { HardhatPlugin } from "../../../types/plugins.js";
2
2
 
3
+ import { definePlugin } from "../../../plugins.js";
3
4
  import { ArgumentType } from "../../../types/arguments.js";
4
5
  import { task } from "../../core/config.js";
5
6
 
6
- const hardhatPlugin: HardhatPlugin = {
7
+ const hardhatPlugin: HardhatPlugin = definePlugin({
7
8
  id: "builtin:node",
8
9
  tasks: [
9
10
  task("node", "Start a JSON-RPC server on top of Hardhat Network")
@@ -50,6 +51,6 @@ const hardhatPlugin: HardhatPlugin = {
50
51
  .build(),
51
52
  ],
52
53
  dependencies: () => [import("../network-manager/index.js")],
53
- };
54
+ });
54
55
 
55
56
  export default hardhatPlugin;
@@ -1,8 +1,9 @@
1
1
  import type { HardhatPlugin } from "../../../types/plugins.js";
2
2
 
3
+ import { definePlugin } from "../../../plugins.js";
3
4
  import { task } from "../../core/config.js";
4
5
 
5
- const hardhatPlugin: HardhatPlugin = {
6
+ const hardhatPlugin: HardhatPlugin = definePlugin({
6
7
  id: "builtin:run",
7
8
  tasks: [
8
9
  task("run", "Run a user-defined script after compiling the project")
@@ -19,6 +20,6 @@ const hardhatPlugin: HardhatPlugin = {
19
20
  ],
20
21
  dependencies: () => [import("../solidity/index.js")],
21
22
  npmPackage: "hardhat",
22
- };
23
+ });
23
24
 
24
25
  export default hardhatPlugin;
@@ -96,6 +96,17 @@ export function isSolcSolidityCompilerConfig(
96
96
  return config.type === undefined || config.type === "solc";
97
97
  }
98
98
 
99
+ /**
100
+ * Returns true if the given compiler config defines a custom path to a solc
101
+ * compiler (native binary or WASM bundle). Such a compiler is user-provided and
102
+ * does not need to be downloaded.
103
+ */
104
+ export function isSolcSolidityCompilerLocalBinary(
105
+ config: SolidityCompilerConfig,
106
+ ): boolean {
107
+ return isSolcSolidityCompilerConfig(config) && config.path !== undefined;
108
+ }
109
+
99
110
  interface CompilationResult {
100
111
  compilationJob: CompilationJob;
101
112
  compilerOutput: CompilerOutput;