hardhat 3.5.0 → 3.6.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 (82) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/src/internal/builtin-plugins/flatten/task-action.d.ts.map +1 -1
  3. package/dist/src/internal/builtin-plugins/flatten/task-action.js +23 -7
  4. package/dist/src/internal/builtin-plugins/flatten/task-action.js.map +1 -1
  5. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts +2 -5
  6. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts.map +1 -1
  7. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js +79 -12
  8. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.map +1 -1
  9. package/dist/src/internal/builtin-plugins/solidity/build-system/warning-suppression.d.ts +6 -10
  10. package/dist/src/internal/builtin-plugins/solidity/build-system/warning-suppression.d.ts.map +1 -1
  11. package/dist/src/internal/builtin-plugins/solidity/build-system/warning-suppression.js +54 -43
  12. package/dist/src/internal/builtin-plugins/solidity/build-system/warning-suppression.js.map +1 -1
  13. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.d.ts.map +1 -1
  14. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js +2 -1
  15. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js.map +1 -1
  16. package/dist/src/internal/builtin-plugins/solidity/tasks/build.d.ts.map +1 -1
  17. package/dist/src/internal/builtin-plugins/solidity/tasks/build.js +1 -5
  18. package/dist/src/internal/builtin-plugins/solidity/tasks/build.js.map +1 -1
  19. package/dist/src/internal/builtin-plugins/solidity/type-extensions.d.ts +53 -1
  20. package/dist/src/internal/builtin-plugins/solidity/type-extensions.d.ts.map +1 -1
  21. package/dist/src/internal/cli/error-handler.d.ts +11 -2
  22. package/dist/src/internal/cli/error-handler.d.ts.map +1 -1
  23. package/dist/src/internal/cli/error-handler.js +72 -46
  24. package/dist/src/internal/cli/error-handler.js.map +1 -1
  25. package/dist/src/internal/cli/help/utils.d.ts.map +1 -1
  26. package/dist/src/internal/cli/help/utils.js +3 -2
  27. package/dist/src/internal/cli/help/utils.js.map +1 -1
  28. package/dist/src/internal/cli/init/init.d.ts.map +1 -1
  29. package/dist/src/internal/cli/init/init.js +115 -4
  30. package/dist/src/internal/cli/init/init.js.map +1 -1
  31. package/dist/src/internal/cli/init/package-manager.d.ts +7 -1
  32. package/dist/src/internal/cli/init/package-manager.d.ts.map +1 -1
  33. package/dist/src/internal/cli/init/package-manager.js +14 -2
  34. package/dist/src/internal/cli/init/package-manager.js.map +1 -1
  35. package/dist/src/internal/cli/main.d.ts.map +1 -1
  36. package/dist/src/internal/cli/main.js +4 -2
  37. package/dist/src/internal/cli/main.js.map +1 -1
  38. package/dist/src/internal/cli/telemetry/error-classification/classifier.d.ts +2 -1
  39. package/dist/src/internal/cli/telemetry/error-classification/classifier.d.ts.map +1 -1
  40. package/dist/src/internal/cli/telemetry/error-classification/classifier.js +2 -1
  41. package/dist/src/internal/cli/telemetry/error-classification/classifier.js.map +1 -1
  42. package/dist/src/internal/core/tasks/resolved-task.d.ts.map +1 -1
  43. package/dist/src/internal/core/tasks/resolved-task.js +3 -2
  44. package/dist/src/internal/core/tasks/resolved-task.js.map +1 -1
  45. package/dist/src/internal/core/tasks/utils.d.ts +3 -0
  46. package/dist/src/internal/core/tasks/utils.d.ts.map +1 -1
  47. package/dist/src/internal/core/tasks/utils.js +6 -0
  48. package/dist/src/internal/core/tasks/utils.js.map +1 -1
  49. package/dist/src/internal/core/tasks/validations.js +3 -3
  50. package/dist/src/internal/core/tasks/validations.js.map +1 -1
  51. package/dist/src/internal/using-hardhat2-plugin-errors.d.ts.map +1 -1
  52. package/dist/src/internal/using-hardhat2-plugin-errors.js +8 -11
  53. package/dist/src/internal/using-hardhat2-plugin-errors.js.map +1 -1
  54. package/dist/src/types/solidity/build-system.d.ts +22 -2
  55. package/dist/src/types/solidity/build-system.d.ts.map +1 -1
  56. package/dist/src/types/solidity/build-system.js.map +1 -1
  57. package/package.json +4 -3
  58. package/skills/hardhat/SKILL.md +152 -0
  59. package/skills/hardhat-toolbox-mocha-ethers/SKILL.md +119 -0
  60. package/skills/hardhat-toolbox-viem/SKILL.md +126 -0
  61. package/src/internal/builtin-plugins/flatten/task-action.ts +37 -7
  62. package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +126 -21
  63. package/src/internal/builtin-plugins/solidity/build-system/warning-suppression.ts +81 -59
  64. package/src/internal/builtin-plugins/solidity/hook-handlers/hre.ts +3 -2
  65. package/src/internal/builtin-plugins/solidity/tasks/build.ts +1 -6
  66. package/src/internal/builtin-plugins/solidity/type-extensions.ts +69 -0
  67. package/src/internal/cli/error-handler.ts +103 -72
  68. package/src/internal/cli/help/utils.ts +9 -2
  69. package/src/internal/cli/init/init.ts +141 -0
  70. package/src/internal/cli/init/package-manager.ts +18 -1
  71. package/src/internal/cli/main.ts +5 -3
  72. package/src/internal/cli/telemetry/error-classification/classifier.ts +2 -1
  73. package/src/internal/core/tasks/resolved-task.ts +5 -2
  74. package/src/internal/core/tasks/utils.ts +13 -0
  75. package/src/internal/core/tasks/validations.ts +3 -3
  76. package/src/internal/using-hardhat2-plugin-errors.ts +8 -11
  77. package/src/types/solidity/build-system.ts +24 -5
  78. package/templates/hardhat-3/01-node-test-runner-viem/AGENTS.md +20 -0
  79. package/templates/hardhat-3/01-node-test-runner-viem/package.json +3 -3
  80. package/templates/hardhat-3/02-mocha-ethers/AGENTS.md +20 -0
  81. package/templates/hardhat-3/02-mocha-ethers/package.json +3 -3
  82. package/templates/hardhat-3/03-minimal/package.json +1 -1
@@ -22,7 +22,7 @@ import { ensureError } from "@nomicfoundation/hardhat-utils/error";
22
22
 
23
23
  import { detectPluginNpmDependencyProblems } from "../plugins/detect-plugin-npm-dependency-problems.js";
24
24
 
25
- import { formatTaskId } from "./utils.js";
25
+ import { formatTaskId, isArgumentRequired } from "./utils.js";
26
26
  import { validateTaskArgumentValue } from "./validations.js";
27
27
 
28
28
  export class ResolvedTask implements Task {
@@ -203,7 +203,10 @@ export class ResolvedTask implements Task {
203
203
  argument: PositionalArgumentDefinition,
204
204
  value: ArgumentValue | ArgumentValue[],
205
205
  ) {
206
- if (argument.defaultValue === undefined && value === undefined) {
206
+ if (
207
+ isArgumentRequired(argument.type, argument.defaultValue) &&
208
+ value === undefined
209
+ ) {
207
210
  throw new HardhatError(
208
211
  HardhatError.ERRORS.CORE.TASK_DEFINITIONS.MISSING_VALUE_FOR_TASK_ARGUMENT,
209
212
  {
@@ -1,3 +1,5 @@
1
+ import type { ArgumentType, ArgumentValue } from "../../../types/arguments.js";
2
+
1
3
  export function formatTaskId(taskId: string | string[]): string {
2
4
  if (typeof taskId === "string") {
3
5
  return taskId;
@@ -9,3 +11,14 @@ export function formatTaskId(taskId: string | string[]): string {
9
11
  export function getActorFragment(pluginId: string | undefined): string {
10
12
  return pluginId !== undefined ? `Plugin ${pluginId} is` : "You are";
11
13
  }
14
+
15
+ export function isOptionalArgumentType(type: ArgumentType): boolean {
16
+ return type.endsWith("_WITHOUT_DEFAULT");
17
+ }
18
+
19
+ export function isArgumentRequired(
20
+ type: ArgumentType,
21
+ defaultValue: ArgumentValue | ArgumentValue[] | undefined,
22
+ ): boolean {
23
+ return defaultValue === undefined && !isOptionalArgumentType(type);
24
+ }
@@ -19,7 +19,7 @@ import {
19
19
  validateArgumentValue,
20
20
  } from "../arguments.js";
21
21
 
22
- import { formatTaskId } from "./utils.js";
22
+ import { isArgumentRequired, formatTaskId } from "./utils.js";
23
23
 
24
24
  export function validateId(id: string | string[]): void {
25
25
  if (id.length === 0) {
@@ -133,8 +133,8 @@ export function validatePositionalArgument(
133
133
 
134
134
  if (
135
135
  lastArg !== undefined &&
136
- lastArg.defaultValue !== undefined &&
137
- defaultValue === undefined
136
+ !isArgumentRequired(lastArg.type, lastArg.defaultValue) &&
137
+ isArgumentRequired(type, defaultValue)
138
138
  ) {
139
139
  throw new HardhatError(
140
140
  HardhatError.ERRORS.CORE.TASK_DEFINITIONS.REQUIRED_ARG_AFTER_OPTIONAL,
@@ -13,21 +13,18 @@ export class UsingHardhat2PluginError extends CustomError {
13
13
  if (callerPath !== undefined) {
14
14
  message = `You are trying to use a Hardhat 2 plugin in a Hardhat 3 project.
15
15
 
16
- This file is part of a Hardhat 2 plugin calling an API that was removed in Hardhat 3: ${styleText("bold", callerPath)}
17
-
18
- Please read https://hardhat.org/migrate-from-hardhat2 to learn how to migrate your project to Hardhat 3.
19
- `;
16
+ This file is part of a Hardhat 2 plugin calling an API that was removed in Hardhat 3: ${styleText("bold", callerPath)}`;
20
17
  } else {
21
- message = `You are trying to use a Hardhat 2 plugin in a Hardhat 3 project.
22
-
23
- Check the stack trace below to identify which plugin is causing this.
24
-
25
- Please read https://hardhat.org/migrate-from-hardhat2 to learn how to migrate your project to Hardhat 3.
26
- `;
18
+ message = `You are trying to use a Hardhat 2 plugin in a Hardhat 3 project.`;
27
19
  }
28
20
 
29
21
  super(message);
30
- this.callerRelativePath = callerPath;
22
+ // Use a non-enumerable property so that `console.error(error)` does not
23
+ // print `{ callerRelativePath: '…' }` after the stack trace.
24
+ Object.defineProperty(this, "callerRelativePath", {
25
+ value: callerPath,
26
+ enumerable: false,
27
+ });
31
28
  }
32
29
  }
33
30
 
@@ -52,18 +52,36 @@ export interface BuildOptions {
52
52
  * and produce separate compilation passes.
53
53
  */
54
54
  scope?: BuildScope;
55
+
56
+ /**
57
+ * If `true`, a clean up process is run after a successful build.
58
+ *
59
+ * The clean up deletes all the orphan artifacts that aren't reachable from
60
+ * the provided `rootFilePaths`.
61
+ *
62
+ * When building with `"contracts"` scope, it also updates the top-level
63
+ * `artifacts.d.ts`.
64
+ *
65
+ * Only use this option when the provided `rootFilePaths` represent the
66
+ * entire set of contracts for the scope you are using (i.e. not during
67
+ * partial builds). Otherwise, you'll delete artifacts generated in previous
68
+ * builds, despite their sources still being available.
69
+ */
70
+ cleanupArtifacts?: boolean;
55
71
  }
56
72
 
73
+ /**
74
+ * The resolved BuildOptions used to run a build.
75
+ */
76
+ export type ResolvedBuildOptions = Required<BuildOptions>;
77
+
57
78
  /**
58
79
  * The options of the `getCompilationJobs` method.
59
80
  *
60
81
  * Note that this option object includes a `quiet` property, as this process
61
82
  * may require downloading compilers, and potentially printing some output.
62
83
  */
63
- export type GetCompilationJobsOptions = Omit<
64
- BuildOptions,
65
- "removeUnusedArtifacts"
66
- >;
84
+ export type GetCompilationJobsOptions = Omit<BuildOptions, "cleanupArtifacts">;
67
85
 
68
86
  /**
69
87
  * The options of the `runCompilationJob` method.
@@ -434,11 +452,12 @@ export interface SolidityBuildSystem {
434
452
  * used.
435
453
  *
436
454
  * @param rootFilePaths All the root files of the project.
455
+ * @returns The list of artifact paths that remain after the cleanup.
437
456
  */
438
457
  cleanupArtifacts(
439
458
  rootFilePaths: string[],
440
459
  options?: { scope?: BuildScope },
441
- ): Promise<void>;
460
+ ): Promise<string[]>;
442
461
 
443
462
  /**
444
463
  * Compiles a build info, returning the output of the compilation, verbatim,
@@ -0,0 +1,20 @@
1
+ # Hardhat + viem project
2
+
3
+ ## Project layout
4
+
5
+ ```
6
+ contracts/ Solidity source files (*.sol) and unit tests (*.t.sol)
7
+ test/ TypeScript integration tests and Solidity unit tests (*.sol)
8
+ ignition/ Hardhat Ignition deployment modules
9
+ scripts/ Standalone scripts run with `hardhat run`
10
+ hardhat.config.ts
11
+ ```
12
+
13
+ ## Working in this project
14
+
15
+ When writing or modifying tests, configuring `hardhat.config.ts`, or interacting with the network from TypeScript, invoke the **`hardhat`** skill. It covers Solidity and TypeScript testing, how to choose between them, `forge-std` cheatcodes, the `network.create()` API, `networkHelpers`, and the compile-then-typecheck workflow. The skill itself points to the matching `hardhat-toolbox-*` skill for toolbox-specific guidance (clients, contract interaction, assertions).
16
+
17
+ ## Docs
18
+
19
+ - Hardhat 3 — https://hardhat.org/llms.txt
20
+ - viem — https://viem.sh/llms.txt
@@ -5,7 +5,7 @@
5
5
  "description": "A TypeScript Hardhat project using Node Test Runner and Viem",
6
6
  "type": "module",
7
7
  "devDependencies": {
8
- "hardhat": "workspace:^3.5.0",
8
+ "hardhat": "workspace:^3.6.0",
9
9
  "@nomicfoundation/hardhat-toolbox-viem": "workspace:^5.0.6",
10
10
  "@nomicfoundation/hardhat-ignition": "workspace:^3.1.6",
11
11
  "@types/node": "^22.8.5",
@@ -15,11 +15,11 @@
15
15
  },
16
16
  "peerDependencies": {
17
17
  "@nomicfoundation/hardhat-ignition-viem": "workspace:^3.1.5",
18
- "@nomicfoundation/hardhat-keystore": "workspace:^3.0.10",
18
+ "@nomicfoundation/hardhat-keystore": "workspace:^3.0.11",
19
19
  "@nomicfoundation/hardhat-network-helpers": "workspace:^3.0.9",
20
20
  "@nomicfoundation/hardhat-node-test-runner": "workspace:^3.0.16",
21
21
  "@nomicfoundation/hardhat-viem": "workspace:^3.0.8",
22
- "@nomicfoundation/hardhat-viem-assertions": "workspace:^3.0.12",
22
+ "@nomicfoundation/hardhat-viem-assertions": "workspace:^3.1.0",
23
23
  "@nomicfoundation/hardhat-verify": "workspace:^3.0.18",
24
24
  "@nomicfoundation/ignition-core": "workspace:^3.1.6"
25
25
  }
@@ -0,0 +1,20 @@
1
+ # Hardhat + ethers project
2
+
3
+ ## Project layout
4
+
5
+ ```
6
+ contracts/ Solidity source files (*.sol) and unit tests (*.t.sol)
7
+ test/ TypeScript integration tests and Solidity unit tests (*.sol)
8
+ ignition/ Hardhat Ignition deployment modules
9
+ scripts/ Standalone scripts run with `hardhat run`
10
+ hardhat.config.ts
11
+ ```
12
+
13
+ ## Working in this project
14
+
15
+ When writing or modifying tests, configuring `hardhat.config.ts`, or interacting with the network from TypeScript, invoke the **`hardhat`** skill. It covers Solidity and TypeScript testing, how to choose between them, `forge-std` cheatcodes, the `network.create()` API, `networkHelpers`, and the compile-then-typecheck workflow. The skill itself points to the matching `hardhat-toolbox-*` skill for toolbox-specific guidance (signers, contract interaction, assertions).
16
+
17
+ ## Docs
18
+
19
+ - Hardhat 3 — https://hardhat.org/llms.txt
20
+ - ethers.js — https://docs.ethers.org/v6/
@@ -5,7 +5,7 @@
5
5
  "description": "A TypeScript Hardhat project using Mocha and Ethers.js",
6
6
  "type": "module",
7
7
  "devDependencies": {
8
- "hardhat": "workspace:^3.5.0",
8
+ "hardhat": "workspace:^3.6.0",
9
9
  "@nomicfoundation/hardhat-toolbox-mocha-ethers": "workspace:^3.0.6",
10
10
  "@nomicfoundation/hardhat-ethers": "workspace:^4.0.12",
11
11
  "@nomicfoundation/hardhat-ignition": "workspace:^3.1.6",
@@ -24,10 +24,10 @@
24
24
  "@nomicfoundation/hardhat-ethers-chai-matchers": "workspace:^3.0.9",
25
25
  "@nomicfoundation/hardhat-ignition": "workspace:^3.1.6",
26
26
  "@nomicfoundation/hardhat-ignition-ethers": "workspace:^3.1.5",
27
- "@nomicfoundation/hardhat-keystore": "workspace:^3.0.10",
27
+ "@nomicfoundation/hardhat-keystore": "workspace:^3.0.11",
28
28
  "@nomicfoundation/hardhat-mocha": "workspace:^3.0.20",
29
29
  "@nomicfoundation/hardhat-network-helpers": "workspace:^3.0.9",
30
- "@nomicfoundation/hardhat-typechain": "workspace:^3.0.9",
30
+ "@nomicfoundation/hardhat-typechain": "workspace:^3.1.0",
31
31
  "@nomicfoundation/hardhat-verify": "workspace:^3.0.18",
32
32
  "@nomicfoundation/ignition-core": "workspace:^3.1.6"
33
33
  }
@@ -5,7 +5,7 @@
5
5
  "description": "A minimal Hardhat project",
6
6
  "type": "module",
7
7
  "devDependencies": {
8
- "hardhat": "workspace:^3.5.0",
8
+ "hardhat": "workspace:^3.6.0",
9
9
  "@types/node": "^22.8.5",
10
10
  "typescript": "~6.0.3"
11
11
  }