hardhat 3.7.0 → 3.8.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 (109) hide show
  1. package/CHANGELOG.md +43 -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/index.d.ts.map +1 -1
  14. package/dist/src/internal/builtin-plugins/coverage/index.js +3 -2
  15. package/dist/src/internal/builtin-plugins/coverage/index.js.map +1 -1
  16. package/dist/src/internal/builtin-plugins/flatten/index.d.ts.map +1 -1
  17. package/dist/src/internal/builtin-plugins/flatten/index.js +3 -2
  18. package/dist/src/internal/builtin-plugins/flatten/index.js.map +1 -1
  19. package/dist/src/internal/builtin-plugins/gas-analytics/index.d.ts.map +1 -1
  20. package/dist/src/internal/builtin-plugins/gas-analytics/index.js +3 -2
  21. package/dist/src/internal/builtin-plugins/gas-analytics/index.js.map +1 -1
  22. package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.d.ts +1 -0
  23. package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.d.ts.map +1 -1
  24. package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.js +5 -0
  25. package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.js.map +1 -1
  26. package/dist/src/internal/builtin-plugins/network-manager/index.d.ts.map +1 -1
  27. package/dist/src/internal/builtin-plugins/network-manager/index.js +3 -2
  28. package/dist/src/internal/builtin-plugins/network-manager/index.js.map +1 -1
  29. package/dist/src/internal/builtin-plugins/network-manager/provider-errors.d.ts +0 -12
  30. package/dist/src/internal/builtin-plugins/network-manager/provider-errors.d.ts.map +1 -1
  31. package/dist/src/internal/builtin-plugins/network-manager/provider-errors.js +0 -28
  32. package/dist/src/internal/builtin-plugins/network-manager/provider-errors.js.map +1 -1
  33. package/dist/src/internal/builtin-plugins/node/index.d.ts.map +1 -1
  34. package/dist/src/internal/builtin-plugins/node/index.js +3 -2
  35. package/dist/src/internal/builtin-plugins/node/index.js.map +1 -1
  36. package/dist/src/internal/builtin-plugins/run/index.d.ts.map +1 -1
  37. package/dist/src/internal/builtin-plugins/run/index.js +3 -2
  38. package/dist/src/internal/builtin-plugins/run/index.js.map +1 -1
  39. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts +6 -0
  40. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts.map +1 -1
  41. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js +8 -0
  42. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.map +1 -1
  43. package/dist/src/internal/builtin-plugins/solidity/build-system/warning-suppression.d.ts.map +1 -1
  44. package/dist/src/internal/builtin-plugins/solidity/build-system/warning-suppression.js +1 -0
  45. package/dist/src/internal/builtin-plugins/solidity/build-system/warning-suppression.js.map +1 -1
  46. package/dist/src/internal/builtin-plugins/solidity/config.js +7 -1
  47. package/dist/src/internal/builtin-plugins/solidity/config.js.map +1 -1
  48. package/dist/src/internal/builtin-plugins/solidity/index.d.ts.map +1 -1
  49. package/dist/src/internal/builtin-plugins/solidity/index.js +3 -2
  50. package/dist/src/internal/builtin-plugins/solidity/index.js.map +1 -1
  51. package/dist/src/internal/builtin-plugins/solidity/solidity-hooks.d.ts.map +1 -1
  52. package/dist/src/internal/builtin-plugins/solidity/solidity-hooks.js +5 -2
  53. package/dist/src/internal/builtin-plugins/solidity/solidity-hooks.js.map +1 -1
  54. package/dist/src/internal/builtin-plugins/solidity-test/index.d.ts.map +1 -1
  55. package/dist/src/internal/builtin-plugins/solidity-test/index.js +3 -2
  56. package/dist/src/internal/builtin-plugins/solidity-test/index.js.map +1 -1
  57. package/dist/src/internal/builtin-plugins/telemetry/index.d.ts.map +1 -1
  58. package/dist/src/internal/builtin-plugins/telemetry/index.js +3 -2
  59. package/dist/src/internal/builtin-plugins/telemetry/index.js.map +1 -1
  60. package/dist/src/internal/builtin-plugins/test/index.d.ts.map +1 -1
  61. package/dist/src/internal/builtin-plugins/test/index.js +3 -2
  62. package/dist/src/internal/builtin-plugins/test/index.js.map +1 -1
  63. package/dist/src/internal/cli/main.d.ts +1 -0
  64. package/dist/src/internal/cli/main.d.ts.map +1 -1
  65. package/dist/src/internal/cli/main.js +4 -0
  66. package/dist/src/internal/cli/main.js.map +1 -1
  67. package/dist/src/internal/core/plugins/loaded-plugins-registry.d.ts +4 -0
  68. package/dist/src/internal/core/plugins/loaded-plugins-registry.d.ts.map +1 -0
  69. package/dist/src/internal/core/plugins/loaded-plugins-registry.js +8 -0
  70. package/dist/src/internal/core/plugins/loaded-plugins-registry.js.map +1 -0
  71. package/dist/src/internal/core/plugins/unused-plugins-warning.d.ts +3 -0
  72. package/dist/src/internal/core/plugins/unused-plugins-warning.d.ts.map +1 -0
  73. package/dist/src/internal/core/plugins/unused-plugins-warning.js +29 -0
  74. package/dist/src/internal/core/plugins/unused-plugins-warning.js.map +1 -0
  75. package/dist/src/plugins.d.ts +13 -0
  76. package/dist/src/plugins.d.ts.map +1 -1
  77. package/dist/src/plugins.js +16 -0
  78. package/dist/src/plugins.js.map +1 -1
  79. package/package.json +4 -4
  80. package/src/cli.ts +4 -1
  81. package/src/internal/builtin-plugins/artifacts/index.ts +5 -2
  82. package/src/internal/builtin-plugins/clean/index.ts +3 -2
  83. package/src/internal/builtin-plugins/console/index.ts +3 -2
  84. package/src/internal/builtin-plugins/coverage/index.ts +3 -2
  85. package/src/internal/builtin-plugins/flatten/index.ts +3 -2
  86. package/src/internal/builtin-plugins/gas-analytics/index.ts +3 -2
  87. package/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.ts +5 -0
  88. package/src/internal/builtin-plugins/network-manager/index.ts +3 -2
  89. package/src/internal/builtin-plugins/network-manager/provider-errors.ts +0 -34
  90. package/src/internal/builtin-plugins/node/index.ts +3 -2
  91. package/src/internal/builtin-plugins/run/index.ts +3 -2
  92. package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +11 -0
  93. package/src/internal/builtin-plugins/solidity/build-system/warning-suppression.ts +1 -0
  94. package/src/internal/builtin-plugins/solidity/config.ts +7 -1
  95. package/src/internal/builtin-plugins/solidity/index.ts +3 -2
  96. package/src/internal/builtin-plugins/solidity/solidity-hooks.ts +8 -2
  97. package/src/internal/builtin-plugins/solidity-test/index.ts +3 -2
  98. package/src/internal/builtin-plugins/telemetry/index.ts +3 -2
  99. package/src/internal/builtin-plugins/test/index.ts +3 -2
  100. package/src/internal/cli/main.ts +6 -0
  101. package/src/internal/core/plugins/loaded-plugins-registry.ts +11 -0
  102. package/src/internal/core/plugins/unused-plugins-warning.ts +47 -0
  103. package/src/plugins.ts +19 -0
  104. package/templates/hardhat-3/01-node-test-runner-viem/package.json +11 -11
  105. package/templates/hardhat-3/01-node-test-runner-viem/tsconfig.json +2 -1
  106. package/templates/hardhat-3/02-mocha-ethers/package.json +14 -14
  107. package/templates/hardhat-3/02-mocha-ethers/tsconfig.json +2 -1
  108. package/templates/hardhat-3/03-minimal/package.json +1 -1
  109. package/templates/hardhat-3/03-minimal/tsconfig.json +2 -1
@@ -0,0 +1,8 @@
1
+ const loadedPlugins = new Map();
2
+ export function registerLoadedPlugin(plugin) {
3
+ loadedPlugins.set(plugin.id, plugin);
4
+ }
5
+ export function getLoadedPlugins() {
6
+ return loadedPlugins;
7
+ }
8
+ //# sourceMappingURL=loaded-plugins-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loaded-plugins-registry.js","sourceRoot":"","sources":["../../../../../src/internal/core/plugins/loaded-plugins-registry.ts"],"names":[],"mappings":"AAEA,MAAM,aAAa,GAAG,IAAI,GAAG,EAAyB,CAAC;AAEvD,MAAM,UAAU,oBAAoB,CAAC,MAAqB;IACxD,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,aAAa,CAAC;AACvB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { HardhatPlugin } from "../../../types/plugins.js";
2
+ export declare function warnAboutUnusedLoadedPlugins(resolvedPlugins: HardhatPlugin[], printError?: (message: string) => void, loadedPlugins?: Iterable<HardhatPlugin>): void;
3
+ //# sourceMappingURL=unused-plugins-warning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unused-plugins-warning.d.ts","sourceRoot":"","sources":["../../../../../src/internal/core/plugins/unused-plugins-warning.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAM/D,wBAAgB,4BAA4B,CAC1C,eAAe,EAAE,aAAa,EAAE,EAChC,UAAU,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAA0C,EAC3E,aAAa,GAAE,QAAQ,CAAC,aAAa,CAA+B,GACnE,IAAI,CAoCN"}
@@ -0,0 +1,29 @@
1
+ import { styleText } from "node:util";
2
+ import { getLoadedPlugins } from "./loaded-plugins-registry.js";
3
+ export function warnAboutUnusedLoadedPlugins(resolvedPlugins, printError = (message) => console.error(message), loadedPlugins = getLoadedPlugins().values()) {
4
+ const resolvedIds = new Set(resolvedPlugins.map((p) => p.id));
5
+ const unused = [];
6
+ for (const plugin of loadedPlugins) {
7
+ if (!resolvedIds.has(plugin.id)) {
8
+ unused.push(plugin);
9
+ }
10
+ }
11
+ if (unused.length === 0) {
12
+ return;
13
+ }
14
+ const lines = [
15
+ "",
16
+ styleText(["bold", "yellow"], "Warning:") +
17
+ " the following plugins were imported but are not present in the `plugins` array of your config:",
18
+ "",
19
+ ];
20
+ for (const plugin of unused) {
21
+ const name = plugin.npmPackage !== undefined && plugin.npmPackage !== null
22
+ ? `${plugin.npmPackage} (id: ${plugin.id})`
23
+ : plugin.id;
24
+ lines.push(` - ${name}`);
25
+ }
26
+ lines.push("", " Add them to the `plugins` array, or remove the unused plugin import(s) to silence this warning.", "");
27
+ printError(lines.join("\n"));
28
+ }
29
+ //# sourceMappingURL=unused-plugins-warning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unused-plugins-warning.js","sourceRoot":"","sources":["../../../../../src/internal/core/plugins/unused-plugins-warning.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,MAAM,UAAU,4BAA4B,CAC1C,eAAgC,EAChC,aAAwC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAC3E,gBAAyC,gBAAgB,EAAE,CAAC,MAAM,EAAE;IAEpE,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAE9D,MAAM,MAAM,GAAoB,EAAE,CAAC;IACnC,KAAK,MAAM,MAAM,IAAI,aAAa,EAAE,CAAC;QACnC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;YAChC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO;IACT,CAAC;IAED,MAAM,KAAK,GAAa;QACtB,EAAE;QACF,SAAS,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,UAAU,CAAC;YACvC,iGAAiG;QACnG,EAAE;KACH,CAAC;IAEF,KAAK,MAAM,MAAM,IAAI,MAAM,EAAE,CAAC;QAC5B,MAAM,IAAI,GACR,MAAM,CAAC,UAAU,KAAK,SAAS,IAAI,MAAM,CAAC,UAAU,KAAK,IAAI;YAC3D,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,UAAU,MAAM,CAAC,EAAE,GAAG;YAC5C,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;QAChB,KAAK,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,IAAI,CACR,EAAE,EACF,mGAAmG,EACnG,EAAE,CACH,CAAC;IAEF,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/B,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.8.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;
@@ -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: [
@@ -20,6 +21,6 @@ const hardhatPlugin: HardhatPlugin = {
20
21
  test: () => import("./hook-handlers/test.js"),
21
22
  },
22
23
  npmPackage: "hardhat",
23
- };
24
+ });
24
25
 
25
26
  export default hardhatPlugin;
@@ -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;
@@ -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
 
@@ -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;
@@ -31,6 +31,7 @@ const SPECIFIC_FILE_RULES: ReadonlyArray<{
31
31
  const TEST_FILE_WARNING_MESSAGES: readonly string[] = [
32
32
  SPDX_WARNING,
33
33
  PRAGMA_WARNING,
34
+ CONTRACT_SIZE_WARNING,
34
35
  ];
35
36
 
36
37
  // Warnings suppressed only when running with `--coverage`. An entry with no
@@ -613,6 +613,7 @@ function copyFromDefault(
613
613
  return {
614
614
  version: defaultSolidityConfig.version,
615
615
  type: defaultSolidityConfig.type,
616
+ path: defaultSolidityConfig.path,
616
617
  };
617
618
  }
618
619
 
@@ -620,12 +621,17 @@ function copyFromDefault(
620
621
  compilers: defaultSolidityConfig.compilers.map((c) => ({
621
622
  version: c.version,
622
623
  type: c.type,
624
+ path: c.path,
623
625
  })),
624
626
  overrides: Object.fromEntries(
625
627
  Object.entries(defaultSolidityConfig.overrides ?? {}).map(
626
628
  ([userSourceName, override]) => [
627
629
  userSourceName,
628
- { version: override.version, type: override.type },
630
+ {
631
+ version: override.version,
632
+ type: override.type,
633
+ path: override.path,
634
+ },
629
635
  ],
630
636
  ),
631
637
  ),
@@ -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, task } from "../../core/config.js";
5
6
 
@@ -35,7 +36,7 @@ const buildTask = task("build", "Build project")
35
36
  .setAction(async () => await import("./tasks/build.js"))
36
37
  .build();
37
38
 
38
- const hardhatPlugin: HardhatPlugin = {
39
+ const hardhatPlugin: HardhatPlugin = definePlugin({
39
40
  id: "builtin:solidity",
40
41
  dependencies: () => [import("../artifacts/index.js")],
41
42
  hookHandlers: {
@@ -65,6 +66,6 @@ const hardhatPlugin: HardhatPlugin = {
65
66
  }),
66
67
  ],
67
68
  npmPackage: "hardhat",
68
- };
69
+ });
69
70
 
70
71
  export default hardhatPlugin;
@@ -1,7 +1,10 @@
1
1
  import type { SolidityCompilerConfig } from "../../../types/config.js";
2
2
  import type { Compiler } from "../../../types/solidity.js";
3
3
 
4
- import { isSolcSolidityCompilerConfig } from "./build-system/build-system.js";
4
+ import {
5
+ isSolcSolidityCompilerConfig,
6
+ isSolcSolidityCompilerLocalBinary,
7
+ } from "./build-system/build-system.js";
5
8
  import {
6
9
  downloadSolcCompilers,
7
10
  getCompiler,
@@ -16,7 +19,10 @@ export async function downloadSolcCompilersHandler(
16
19
  quiet: boolean,
17
20
  ): Promise<void> {
18
21
  const solcVersions = new Set(
19
- compilerConfigs.filter(isSolcSolidityCompilerConfig).map((c) => c.version),
22
+ compilerConfigs
23
+ .filter(isSolcSolidityCompilerConfig)
24
+ .filter((c) => !isSolcSolidityCompilerLocalBinary(c))
25
+ .map((c) => c.version),
20
26
  );
21
27
 
22
28
  if (solcVersions.size > 0) {
@@ -2,11 +2,12 @@ import type { HardhatPlugin } from "../../../types/plugins.js";
2
2
 
3
3
  import { ArgumentType } from "hardhat/types/arguments";
4
4
 
5
+ import { definePlugin } from "../../../plugins.js";
5
6
  import { task } from "../../core/config.js";
6
7
 
7
8
  export type * from "./type-extensions.js";
8
9
 
9
- const hardhatPlugin: HardhatPlugin = {
10
+ const hardhatPlugin: HardhatPlugin = definePlugin({
10
11
  id: "builtin:solidity-tests",
11
12
  hookHandlers: {
12
13
  config: () => import("./hook-handlers/config.js"),
@@ -51,6 +52,6 @@ const hardhatPlugin: HardhatPlugin = {
51
52
  import("../coverage/index.js"),
52
53
  ],
53
54
  npmPackage: "hardhat",
54
- };
55
+ });
55
56
 
56
57
  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:telemetry",
7
8
  tasks: [
8
9
  task("telemetry", "Display and modify telemetry settings")
@@ -18,6 +19,6 @@ const hardhatPlugin: HardhatPlugin = {
18
19
  .build(),
19
20
  ],
20
21
  npmPackage: "hardhat",
21
- };
22
+ });
22
23
 
23
24
  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 { task } 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:test",
10
11
  hookHandlers: {
11
12
  config: () => import("./hook-handlers/config.js"),
@@ -37,6 +38,6 @@ const hardhatPlugin: HardhatPlugin = {
37
38
  ],
38
39
  dependencies: () => [import("../solidity/index.js")],
39
40
  npmPackage: "hardhat",
40
- };
41
+ });
41
42
 
42
43
  export default hardhatPlugin;
@@ -40,6 +40,7 @@ import { parseArgumentValue } from "../core/arguments.js";
40
40
  import { buildGlobalOptionDefinitions } from "../core/global-options.js";
41
41
  import { resolveProjectRoot } from "../core/hre.js";
42
42
  import { resolvePluginList } from "../core/plugins/resolve-plugin-list.js";
43
+ import { warnAboutUnusedLoadedPlugins } from "../core/plugins/unused-plugins-warning.js";
43
44
  import { isArgumentRequired } from "../core/tasks/utils.js";
44
45
  import { setGlobalHardhatRuntimeEnvironment } from "../global-hre-instance.js";
45
46
  import { createHardhatRuntimeEnvironment } from "../hre-initialization.js";
@@ -60,6 +61,7 @@ export interface MainOptions {
60
61
  registerTsx?: boolean;
61
62
  rethrowErrors?: true;
62
63
  allowNonlocalHardhatInstallation?: true;
64
+ warnAboutUnusedPlugins?: true;
63
65
  }
64
66
 
65
67
  export async function main(
@@ -234,6 +236,10 @@ export async function main(
234
236
  { resolvedPlugins, globalOptionDefinitions },
235
237
  );
236
238
 
239
+ if (options.warnAboutUnusedPlugins) {
240
+ warnAboutUnusedLoadedPlugins(hre.config.plugins);
241
+ }
242
+
237
243
  // This must be the first time we set it, otherwise we let it crash
238
244
  setGlobalHardhatRuntimeEnvironment(hre);
239
245
 
@@ -0,0 +1,11 @@
1
+ import type { HardhatPlugin } from "../../../types/plugins.js";
2
+
3
+ const loadedPlugins = new Map<string, HardhatPlugin>();
4
+
5
+ export function registerLoadedPlugin(plugin: HardhatPlugin): void {
6
+ loadedPlugins.set(plugin.id, plugin);
7
+ }
8
+
9
+ export function getLoadedPlugins(): ReadonlyMap<string, HardhatPlugin> {
10
+ return loadedPlugins;
11
+ }