hardhat 3.0.5 → 3.0.7

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 (114) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.d.ts.map +1 -1
  3. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js +1 -2
  4. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js.map +1 -1
  5. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.d.ts +1 -0
  6. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.d.ts.map +1 -1
  7. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js +9 -2
  8. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js.map +1 -1
  9. package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/hre.d.ts.map +1 -1
  10. package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/hre.js +13 -5
  11. package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/hre.js.map +1 -1
  12. package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/network.js +1 -1
  13. package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/network.js.map +1 -1
  14. package/dist/src/internal/builtin-plugins/network-manager/network-manager.d.ts +4 -3
  15. package/dist/src/internal/builtin-plugins/network-manager/network-manager.d.ts.map +1 -1
  16. package/dist/src/internal/builtin-plugins/network-manager/network-manager.js +79 -37
  17. package/dist/src/internal/builtin-plugins/network-manager/network-manager.js.map +1 -1
  18. package/dist/src/internal/builtin-plugins/network-manager/type-validation.js +2 -2
  19. package/dist/src/internal/builtin-plugins/network-manager/type-validation.js.map +1 -1
  20. package/dist/src/internal/builtin-plugins/node/artifacts/build-info-watcher.d.ts +25 -0
  21. package/dist/src/internal/builtin-plugins/node/artifacts/build-info-watcher.d.ts.map +1 -0
  22. package/dist/src/internal/builtin-plugins/node/artifacts/build-info-watcher.js +56 -0
  23. package/dist/src/internal/builtin-plugins/node/artifacts/build-info-watcher.js.map +1 -0
  24. package/dist/src/internal/builtin-plugins/node/helpers.d.ts +12 -0
  25. package/dist/src/internal/builtin-plugins/node/helpers.d.ts.map +1 -1
  26. package/dist/src/internal/builtin-plugins/node/helpers.js +32 -0
  27. package/dist/src/internal/builtin-plugins/node/helpers.js.map +1 -1
  28. package/dist/src/internal/builtin-plugins/node/json-rpc/server.d.ts +3 -10
  29. package/dist/src/internal/builtin-plugins/node/json-rpc/server.d.ts.map +1 -1
  30. package/dist/src/internal/builtin-plugins/node/json-rpc/server.js +1 -1
  31. package/dist/src/internal/builtin-plugins/node/json-rpc/server.js.map +1 -1
  32. package/dist/src/internal/builtin-plugins/node/task-action.d.ts.map +1 -1
  33. package/dist/src/internal/builtin-plugins/node/task-action.js +14 -4
  34. package/dist/src/internal/builtin-plugins/node/task-action.js.map +1 -1
  35. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts +13 -5
  36. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts.map +1 -1
  37. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js +126 -58
  38. package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.map +1 -1
  39. package/dist/src/internal/builtin-plugins/solidity/build-system/cache.d.ts +1 -1
  40. package/dist/src/internal/builtin-plugins/solidity/build-system/cache.d.ts.map +1 -1
  41. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.d.ts.map +1 -1
  42. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js +14 -6
  43. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js.map +1 -1
  44. package/dist/src/internal/builtin-plugins/solidity/index.d.ts.map +1 -1
  45. package/dist/src/internal/builtin-plugins/solidity/index.js +8 -0
  46. package/dist/src/internal/builtin-plugins/solidity/index.js.map +1 -1
  47. package/dist/src/internal/builtin-plugins/solidity/tasks/build.d.ts +4 -2
  48. package/dist/src/internal/builtin-plugins/solidity/tasks/build.d.ts.map +1 -1
  49. package/dist/src/internal/builtin-plugins/solidity/tasks/build.js +37 -10
  50. package/dist/src/internal/builtin-plugins/solidity/tasks/build.js.map +1 -1
  51. package/dist/src/internal/builtin-plugins/solidity-test/config.d.ts +4 -2
  52. package/dist/src/internal/builtin-plugins/solidity-test/config.d.ts.map +1 -1
  53. package/dist/src/internal/builtin-plugins/solidity-test/config.js +24 -4
  54. package/dist/src/internal/builtin-plugins/solidity-test/config.js.map +1 -1
  55. package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts +3 -1
  56. package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts.map +1 -1
  57. package/dist/src/internal/builtin-plugins/solidity-test/helpers.js +26 -3
  58. package/dist/src/internal/builtin-plugins/solidity-test/helpers.js.map +1 -1
  59. package/dist/src/internal/builtin-plugins/solidity-test/hook-handlers/config.d.ts.map +1 -1
  60. package/dist/src/internal/builtin-plugins/solidity-test/hook-handlers/config.js +1 -1
  61. package/dist/src/internal/builtin-plugins/solidity-test/hook-handlers/config.js.map +1 -1
  62. package/dist/src/internal/builtin-plugins/solidity-test/task-action.d.ts.map +1 -1
  63. package/dist/src/internal/builtin-plugins/solidity-test/task-action.js +26 -43
  64. package/dist/src/internal/builtin-plugins/solidity-test/task-action.js.map +1 -1
  65. package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts +17 -7
  66. package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts.map +1 -1
  67. package/dist/src/internal/core/hre.d.ts +29 -1
  68. package/dist/src/internal/core/hre.d.ts.map +1 -1
  69. package/dist/src/internal/core/hre.js +57 -20
  70. package/dist/src/internal/core/hre.js.map +1 -1
  71. package/dist/src/internal/core/plugins/resolve-plugin-list.js +40 -3
  72. package/dist/src/internal/core/plugins/resolve-plugin-list.js.map +1 -1
  73. package/dist/src/internal/utils/package.d.ts +1 -0
  74. package/dist/src/internal/utils/package.d.ts.map +1 -1
  75. package/dist/src/internal/utils/package.js +17 -1
  76. package/dist/src/internal/utils/package.js.map +1 -1
  77. package/dist/src/types/hre.d.ts +4 -0
  78. package/dist/src/types/hre.d.ts.map +1 -1
  79. package/dist/src/types/network.d.ts +40 -0
  80. package/dist/src/types/network.d.ts.map +1 -1
  81. package/dist/src/types/plugins.d.ts +8 -0
  82. package/dist/src/types/plugins.d.ts.map +1 -1
  83. package/dist/src/types/solidity/build-system.d.ts +23 -8
  84. package/dist/src/types/solidity/build-system.d.ts.map +1 -1
  85. package/package.json +5 -4
  86. package/src/internal/builtin-plugins/coverage/hook-handlers/solidity.ts +2 -3
  87. package/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts +20 -1
  88. package/src/internal/builtin-plugins/network-manager/hook-handlers/hre.ts +36 -18
  89. package/src/internal/builtin-plugins/network-manager/hook-handlers/network.ts +1 -1
  90. package/src/internal/builtin-plugins/network-manager/network-manager.ts +137 -60
  91. package/src/internal/builtin-plugins/network-manager/type-validation.ts +2 -2
  92. package/src/internal/builtin-plugins/node/artifacts/build-info-watcher.ts +82 -0
  93. package/src/internal/builtin-plugins/node/helpers.ts +64 -0
  94. package/src/internal/builtin-plugins/node/json-rpc/server.ts +3 -10
  95. package/src/internal/builtin-plugins/node/task-action.ts +31 -5
  96. package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +203 -98
  97. package/src/internal/builtin-plugins/solidity/build-system/cache.ts +1 -1
  98. package/src/internal/builtin-plugins/solidity/hook-handlers/hre.ts +22 -5
  99. package/src/internal/builtin-plugins/solidity/index.ts +8 -0
  100. package/src/internal/builtin-plugins/solidity/tasks/build.ts +59 -16
  101. package/src/internal/builtin-plugins/solidity-test/config.ts +46 -3
  102. package/src/internal/builtin-plugins/solidity-test/helpers.ts +44 -4
  103. package/src/internal/builtin-plugins/solidity-test/hook-handlers/config.ts +5 -1
  104. package/src/internal/builtin-plugins/solidity-test/task-action.ts +39 -54
  105. package/src/internal/builtin-plugins/solidity-test/type-extensions.ts +23 -9
  106. package/src/internal/core/hre.ts +102 -32
  107. package/src/internal/core/plugins/resolve-plugin-list.ts +57 -3
  108. package/src/internal/utils/package.ts +31 -1
  109. package/src/types/hre.ts +4 -0
  110. package/src/types/network.ts +45 -0
  111. package/src/types/plugins.ts +5 -0
  112. package/src/types/solidity/build-system.ts +23 -7
  113. package/templates/hardhat-3/01-node-test-runner-viem/package.json +3 -3
  114. package/templates/hardhat-3/02-mocha-ethers/package.json +4 -4
@@ -12,7 +12,11 @@ import type {
12
12
  GlobalOptions,
13
13
  GlobalOptionDefinitions,
14
14
  } from "../../types/global-options.js";
15
- import type { HookContext, HookManager } from "../../types/hooks.js";
15
+ import type {
16
+ HardhatUserConfigValidationError,
17
+ HookContext,
18
+ HookManager,
19
+ } from "../../types/hooks.js";
16
20
  import type { HardhatRuntimeEnvironment } from "../../types/hre.js";
17
21
  import type { NetworkManager } from "../../types/network.js";
18
22
  import type { HardhatPlugin } from "../../types/plugins.js";
@@ -25,6 +29,8 @@ import { HardhatError } from "@nomicfoundation/hardhat-errors";
25
29
  import { findClosestPackageRoot } from "@nomicfoundation/hardhat-utils/package";
26
30
  import { resolveFromRoot } from "@nomicfoundation/hardhat-utils/path";
27
31
 
32
+ import { getEdrVersion, getHardhatVersion } from "../utils/package.js";
33
+
28
34
  import { validateUserConfig } from "./config-validation.js";
29
35
  import { resolveConfigurationVariable } from "./configuration-variables.js";
30
36
  import {
@@ -62,26 +68,31 @@ export class HardhatRuntimeEnvironmentImplementation
62
68
  unsafeOptions?.resolvedPlugins ??
63
69
  (await resolvePluginList(resolvedProjectRoot, inputUserConfig.plugins));
64
70
 
71
+ const [hardhatVersion, edrVersion] = await Promise.all([
72
+ getHardhatVersion(),
73
+ getEdrVersion(),
74
+ ]);
75
+
76
+ const versions = {
77
+ hardhat: hardhatVersion,
78
+ edr: edrVersion,
79
+ };
65
80
  const hooks = new HookManagerImplementation(
66
81
  resolvedProjectRoot,
67
82
  resolvedPlugins,
68
83
  );
69
84
 
70
- // extend user config:
71
- const extendedUserConfig = await runUserConfigExtensions(
72
- hooks,
85
+ const configResolutionResult = await resolveUserConfigToHardhatConfig(
73
86
  inputUserConfig,
74
- );
75
-
76
- // validate config
77
- const userConfigValidationErrors = await validateUserConfig(
78
87
  hooks,
79
- extendedUserConfig,
88
+ resolvedProjectRoot,
89
+ userProvidedGlobalOptions.config,
90
+ resolvedPlugins,
80
91
  );
81
92
 
82
- if (userConfigValidationErrors.length > 0) {
93
+ if (!configResolutionResult.success) {
83
94
  throw new HardhatError(HardhatError.ERRORS.CORE.GENERAL.INVALID_CONFIG, {
84
- errors: `\t${userConfigValidationErrors
95
+ errors: `\t${configResolutionResult.userConfigValidationErrors
85
96
  .map(
86
97
  (error) =>
87
98
  `* Config error in config.${error.path.join(".")}: ${error.message}`,
@@ -90,26 +101,7 @@ export class HardhatRuntimeEnvironmentImplementation
90
101
  });
91
102
  }
92
103
 
93
- // Resolve config
94
-
95
- const resolvedConfig = await resolveUserConfig(
96
- resolvedProjectRoot,
97
- userProvidedGlobalOptions.config,
98
- hooks,
99
- resolvedPlugins,
100
- extendedUserConfig,
101
- );
102
-
103
- // We override the plugins and the project root, as we want to prevent
104
- // the plugins from changing them
105
- const config: HardhatConfig = {
106
- ...resolvedConfig,
107
- paths: {
108
- ...resolvedConfig.paths,
109
- root: resolvedProjectRoot,
110
- },
111
- plugins: resolvedPlugins,
112
- };
104
+ const { config, extendedUserConfig } = configResolutionResult;
113
105
 
114
106
  const globalOptionDefinitions =
115
107
  unsafeOptions?.globalOptionDefinitions ??
@@ -122,7 +114,6 @@ export class HardhatRuntimeEnvironmentImplementation
122
114
 
123
115
  // Set the HookContext in the hook manager so that non-config hooks can
124
116
  // use it
125
-
126
117
  const interruptions = new UserInterruptionManagerImplementation(hooks);
127
118
 
128
119
  const hre = new HardhatRuntimeEnvironmentImplementation(
@@ -131,6 +122,7 @@ export class HardhatRuntimeEnvironmentImplementation
131
122
  hooks,
132
123
  interruptions,
133
124
  globalOptions,
125
+ versions,
134
126
  globalOptionDefinitions,
135
127
  );
136
128
 
@@ -160,6 +152,10 @@ export class HardhatRuntimeEnvironmentImplementation
160
152
  public readonly hooks: HookManager,
161
153
  public readonly interruptions: UserInterruptionManager,
162
154
  public readonly globalOptions: GlobalOptions,
155
+ public readonly versions: {
156
+ readonly hardhat: string;
157
+ readonly edr: string;
158
+ },
163
159
  globalOptionDefinitions: GlobalOptionDefinitions,
164
160
  ) {
165
161
  this.tasks = new TaskManagerImplementation(this, globalOptionDefinitions);
@@ -180,6 +176,80 @@ export async function resolveProjectRoot(
180
176
  return findClosestPackageRoot(absolutePathWithinProject ?? process.cwd());
181
177
  }
182
178
 
179
+ /**
180
+ * Runs the provided Hardhat user config through the resolution process,
181
+ * invoking relevant plugin hooks (both internal and external) to extend
182
+ * and transform the config into a full HardhatConfig.
183
+ *
184
+ * @param hooks - The HookManager used to run config extension and validation
185
+ * hooks.
186
+ * @param inputUserConfig - The initial user provided Hardhat config object.
187
+ * @param resolvedProjectRoot - The project root path.
188
+ * @param userProvidedConfigPath - The user provided Hardhat config file path.
189
+ * @param resolvedPlugins - The list of plugins, we do not want the plugins
190
+ * overwriting them so we re-add them to the final HardhatConfig.
191
+ * @returns Either an object containing the resolved HardhatConfig and the
192
+ * extended version of the user config, or a list of validation errors.
193
+ */
194
+ export async function resolveUserConfigToHardhatConfig(
195
+ inputUserConfig: HardhatUserConfig,
196
+ hooks: HookManager,
197
+ resolvedProjectRoot: string,
198
+ userProvidedConfigPath: string | undefined,
199
+ resolvedPlugins: HardhatPlugin[],
200
+ ): Promise<
201
+ | {
202
+ success: true;
203
+ config: HardhatConfig;
204
+ extendedUserConfig: HardhatUserConfig;
205
+ }
206
+ | {
207
+ success: false;
208
+ userConfigValidationErrors: HardhatUserConfigValidationError[];
209
+ }
210
+ > {
211
+ // extend user config:
212
+ const extendedUserConfig = await runUserConfigExtensions(
213
+ hooks,
214
+ inputUserConfig,
215
+ );
216
+
217
+ // validate config
218
+ const userConfigValidationErrors = await validateUserConfig(
219
+ hooks,
220
+ extendedUserConfig,
221
+ );
222
+
223
+ if (userConfigValidationErrors.length > 0) {
224
+ return {
225
+ success: false,
226
+ userConfigValidationErrors,
227
+ };
228
+ }
229
+
230
+ // Resolve config
231
+ const resolvedConfig = await resolveUserConfig(
232
+ resolvedProjectRoot,
233
+ userProvidedConfigPath,
234
+ hooks,
235
+ resolvedPlugins,
236
+ extendedUserConfig,
237
+ );
238
+
239
+ // We override the plugins and the project root, as we want to prevent
240
+ // the plugins from changing them
241
+ const config: HardhatConfig = {
242
+ ...resolvedConfig,
243
+ paths: {
244
+ ...resolvedConfig.paths,
245
+ root: resolvedProjectRoot,
246
+ },
247
+ plugins: resolvedPlugins,
248
+ };
249
+
250
+ return { success: true, config, extendedUserConfig };
251
+ }
252
+
183
253
  async function runUserConfigExtensions(
184
254
  hooks: HookManager,
185
255
  config: HardhatUserConfig,
@@ -28,7 +28,7 @@ async function reverseTopologicalSort(
28
28
  plugins: HardhatPlugin[],
29
29
  ): Promise<HardhatPlugin[]> {
30
30
  const visitedPlugins: Map<string, HardhatPlugin> = new Map();
31
- const result: HardhatPlugin[] = [];
31
+ const resolvedPlugins: HardhatPlugin[] = [];
32
32
 
33
33
  async function dfs(plugin: HardhatPlugin) {
34
34
  const visited = visitedPlugins.get(plugin.id);
@@ -69,12 +69,66 @@ async function reverseTopologicalSort(
69
69
  }
70
70
  }
71
71
 
72
- result.push(plugin);
72
+ resolvedPlugins.push(plugin);
73
73
  }
74
74
 
75
75
  for (const plugin of plugins) {
76
76
  await dfs(plugin);
77
77
  }
78
78
 
79
- return result;
79
+ // Resolve conditional dependencies iteratively
80
+ let lastResolvedCount = -1;
81
+
82
+ while (resolvedPlugins.length !== lastResolvedCount) {
83
+ lastResolvedCount = resolvedPlugins.length;
84
+
85
+ for (const plugin of resolvedPlugins) {
86
+ if (plugin.conditionalDependencies === undefined) {
87
+ continue;
88
+ }
89
+
90
+ for (const conditionalDependency of plugin.conditionalDependencies) {
91
+ // Check all condition plugins are installed
92
+ let conditionModules;
93
+ try {
94
+ conditionModules = await Promise.all(
95
+ conditionalDependency.condition(),
96
+ );
97
+ } catch (_error) {
98
+ continue;
99
+ }
100
+
101
+ // Check all condition plugins are loaded
102
+ if (
103
+ conditionModules.some(
104
+ (conditionPlugin) =>
105
+ !resolvedPlugins.includes(conditionPlugin.default),
106
+ )
107
+ ) {
108
+ continue;
109
+ }
110
+
111
+ // Load the conditional dependency
112
+ let pluginModule;
113
+ try {
114
+ pluginModule = await conditionalDependency.plugin();
115
+ } catch (error) {
116
+ ensureError(error);
117
+ await detectPluginNpmDependencyProblems(projectRoot, plugin);
118
+
119
+ throw new HardhatError(
120
+ HardhatError.ERRORS.CORE.PLUGINS.PLUGIN_DEPENDENCY_FAILED_LOAD,
121
+ {
122
+ pluginId: plugin.id,
123
+ },
124
+ error,
125
+ );
126
+ }
127
+
128
+ await dfs(pluginModule.default);
129
+ }
130
+ }
131
+ }
132
+
133
+ return resolvedPlugins;
80
134
  }
@@ -1,9 +1,16 @@
1
1
  import type { PackageJson } from "@nomicfoundation/hardhat-utils/package";
2
2
 
3
- import { readClosestPackageJson } from "@nomicfoundation/hardhat-utils/package";
3
+ import { readFile } from "node:fs/promises";
4
+
5
+ import {
6
+ findClosestPackageRoot,
7
+ findDependencyPackageJson,
8
+ readClosestPackageJson,
9
+ } from "@nomicfoundation/hardhat-utils/package";
4
10
 
5
11
  let cachedHardhatVersion: string | undefined;
6
12
  let cachedLatestHardhatVersion: string | undefined;
13
+ let cachedEdrVersion: string | undefined;
7
14
 
8
15
  export async function getHardhatVersion(): Promise<string> {
9
16
  if (cachedHardhatVersion !== undefined) {
@@ -19,6 +26,29 @@ export async function getHardhatVersion(): Promise<string> {
19
26
  return packageJson.version;
20
27
  }
21
28
 
29
+ export async function getEdrVersion(): Promise<string> {
30
+ if (cachedEdrVersion !== undefined) {
31
+ return cachedEdrVersion;
32
+ }
33
+
34
+ const hardhatRoot = await findClosestPackageRoot(import.meta.url);
35
+
36
+ const edrPackageJsonPath = await findDependencyPackageJson(
37
+ hardhatRoot,
38
+ "@nomicfoundation/edr",
39
+ );
40
+
41
+ if (edrPackageJsonPath === undefined) {
42
+ return "";
43
+ }
44
+
45
+ const rawPackageJson = await readFile(edrPackageJsonPath, "utf-8");
46
+ const edrPackageJson: PackageJson = JSON.parse(rawPackageJson);
47
+ cachedEdrVersion = edrPackageJson.version;
48
+
49
+ return cachedEdrVersion;
50
+ }
51
+
22
52
  export async function getLatestHardhatVersion(): Promise<string> {
23
53
  const { getRequest } = await import("@nomicfoundation/hardhat-utils/request");
24
54
 
package/src/types/hre.ts CHANGED
@@ -11,6 +11,10 @@ export interface HardhatRuntimeEnvironment {
11
11
  readonly userConfig: HardhatUserConfig;
12
12
  readonly globalOptions: GlobalOptions;
13
13
  readonly interruptions: UserInterruptionManager;
14
+ readonly versions: {
15
+ readonly hardhat: string;
16
+ readonly edr: string;
17
+ };
14
18
  // These fields are defined using module agumentation despite being part of
15
19
  // Hardhat's core:
16
20
  // readonly hooks: HookManager;
@@ -52,6 +52,21 @@ export interface NetworkManager {
52
52
  connect<ChainTypeT extends ChainType | string = DefaultChainType>(
53
53
  networkOrParams?: NetworkConnectionParams<ChainTypeT> | string,
54
54
  ): Promise<NetworkConnection<ChainTypeT>>;
55
+
56
+ /**
57
+ * Spawns an Ethereum JSON-RPC server listening on HTTP and Websocket.
58
+ *
59
+ * @param networkOrParams The network name or connection parameters.
60
+ * @param hostname Hostname to bind the server to. Defaults to localhost or 0.0.0.0 on docker.
61
+ * @param port Port to listen on. Defaults to a random available port.
62
+ *
63
+ * @return A `JsonRpcServer` instance that can be started with {@link JsonRpcServer.listen}.
64
+ */
65
+ createServer(
66
+ networkOrParams?: NetworkConnectionParams | string,
67
+ hostname?: string,
68
+ port?: number,
69
+ ): Promise<JsonRpcServer>;
55
70
  }
56
71
 
57
72
  export interface NetworkConnection<
@@ -65,3 +80,33 @@ export interface NetworkConnection<
65
80
 
66
81
  close(): Promise<void>;
67
82
  }
83
+
84
+ /**
85
+ * An Ethereum JSON-RPC server that accepts connections via HTTP and websocket.
86
+ */
87
+ export interface JsonRpcServer {
88
+ /**
89
+ * Starts the Ethereum JSON-RPC server.
90
+ *
91
+ * @returns returns the address and port the server is listening on.
92
+ */
93
+ listen(): Promise<{ address: string; port: number }>;
94
+
95
+ /**
96
+ * Closes the Ethereum JSON-RPC server.
97
+ *
98
+ * @returns A promise that resolves once shutdown is finished.
99
+ */
100
+ close(): Promise<void>;
101
+
102
+ /**
103
+ * Resolves once the Ethereum JSON-RPC server has been
104
+ * closed, including its underlying HTTP and Websocket sockets.
105
+ *
106
+ * Useful for awaiting a shutdown that was initiated elsewhere.
107
+ *
108
+ * @returns A promise that resolves once the server and
109
+ * its sockets have been closed.
110
+ */
111
+ afterClosed(): Promise<void>;
112
+ }
@@ -39,6 +39,11 @@ export interface HardhatPlugin {
39
39
  */
40
40
  dependencies?: () => Array<Promise<{ default: HardhatPlugin }>>;
41
41
 
42
+ conditionalDependencies?: Array<{
43
+ condition: () => Array<Promise<{ default: HardhatPlugin }>>;
44
+ plugin: () => Promise<{ default: HardhatPlugin }>;
45
+ }>;
46
+
42
47
  /**
43
48
  * An object with the different hook handlers that this plugin defines.
44
49
  *
@@ -38,18 +38,18 @@ export interface BuildOptions {
38
38
  concurrency?: number;
39
39
 
40
40
  /**
41
- * An array of remappings provided by the user.
41
+ * If `true`, the build process doesn't print any output.
42
42
  */
43
- userProvidedRemappings?: string[];
43
+ quiet?: boolean;
44
44
 
45
45
  /**
46
- * If `true`, the build process doesn't print any output.
46
+ * Whether to compile contracts or tests. Defaults to contracts
47
47
  */
48
- quiet?: boolean;
48
+ scope?: BuildScope;
49
49
  }
50
50
 
51
51
  /**
52
- * The options of the `getBuildInfos` method.
52
+ * The options of the `getCompilationJobs` method.
53
53
  *
54
54
  * Note that this option object includes a `quiet` property, as this process
55
55
  * may require downloading compilers, and potentially printing some output.
@@ -196,7 +196,12 @@ export interface SolidityBuildSystem {
196
196
  *
197
197
  * @returns An array of root file paths.
198
198
  */
199
- getRootFilePaths(): Promise<string[]>;
199
+ getRootFilePaths(options?: { scope?: BuildScope }): Promise<string[]>;
200
+
201
+ /**
202
+ * Given the filesystem path for a source file, returns the build scope
203
+ */
204
+ getScope(fsPath: string): Promise<BuildScope>;
200
205
 
201
206
  /**
202
207
  * Builds the provided files, generating their compilation artifacts.
@@ -272,6 +277,7 @@ export interface SolidityBuildSystem {
272
277
  emitArtifacts(
273
278
  compilationJob: CompilationJob,
274
279
  compilerOutput: CompilerOutput,
280
+ options?: { scope?: BuildScope },
275
281
  ): Promise<EmitArtifactsResult>;
276
282
 
277
283
  /**
@@ -287,7 +293,10 @@ export interface SolidityBuildSystem {
287
293
 
288
294
  * @param rootFilePaths All the root files of the project.
289
295
  */
290
- cleanupArtifacts(rootFilePaths: string[]): Promise<void>;
296
+ cleanupArtifacts(
297
+ rootFilePaths: string[],
298
+ options?: { scope?: BuildScope },
299
+ ): Promise<void>;
291
300
 
292
301
  /**
293
302
  * Compiles a build info, returning the output of the compilation, verbatim,
@@ -301,4 +310,11 @@ export interface SolidityBuildSystem {
301
310
  buildInfo: SolidityBuildInfo,
302
311
  options?: CompileBuildInfoOptions,
303
312
  ): Promise<CompilerOutput>;
313
+
314
+ /**
315
+ * Gets the artifacts directory for a given target (contracts/tests)
316
+ */
317
+ getArtifactsDirectory(scope: BuildScope): Promise<string>;
304
318
  }
319
+
320
+ export type BuildScope = "contracts" | "tests";
@@ -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.0.0",
8
+ "hardhat": "workspace:^3.0.7",
9
9
  "@nomicfoundation/hardhat-toolbox-viem": "workspace:^5.0.0",
10
10
  "@nomicfoundation/hardhat-ignition": "workspace:^3.0.0",
11
11
  "@types/node": "^22.8.5",
@@ -16,11 +16,11 @@
16
16
  "peerDependencies": {
17
17
  "@nomicfoundation/hardhat-ignition-viem": "workspace:^3.0.0",
18
18
  "@nomicfoundation/hardhat-keystore": "workspace:^3.0.0",
19
- "@nomicfoundation/hardhat-network-helpers": "workspace:^3.0.0",
19
+ "@nomicfoundation/hardhat-network-helpers": "workspace:^3.0.1",
20
20
  "@nomicfoundation/hardhat-node-test-runner": "workspace:^3.0.0",
21
21
  "@nomicfoundation/hardhat-viem": "workspace:^3.0.0",
22
22
  "@nomicfoundation/hardhat-viem-assertions": "workspace:^3.0.0",
23
- "@nomicfoundation/hardhat-verify": "workspace:^3.0.0",
23
+ "@nomicfoundation/hardhat-verify": "workspace:^3.0.3",
24
24
  "@nomicfoundation/ignition-core": "workspace:^3.0.0"
25
25
  }
26
26
  }
@@ -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.0.0",
8
+ "hardhat": "workspace:^3.0.7",
9
9
  "@nomicfoundation/hardhat-toolbox-mocha-ethers": "workspace:^3.0.0",
10
10
  "@nomicfoundation/hardhat-ignition": "workspace:^3.0.0",
11
11
  "@types/chai": "^4.2.0",
@@ -19,15 +19,15 @@
19
19
  "typescript": "~5.8.0"
20
20
  },
21
21
  "peerDependencies": {
22
- "@nomicfoundation/hardhat-ethers": "workspace:^4.0.0",
22
+ "@nomicfoundation/hardhat-ethers": "workspace:^4.0.2",
23
23
  "@nomicfoundation/hardhat-ethers-chai-matchers": "workspace:^3.0.0",
24
24
  "@nomicfoundation/hardhat-ignition": "workspace:^3.0.0",
25
25
  "@nomicfoundation/hardhat-ignition-ethers": "workspace:^3.0.0",
26
26
  "@nomicfoundation/hardhat-keystore": "workspace:^3.0.0",
27
27
  "@nomicfoundation/hardhat-mocha": "workspace:^3.0.0",
28
- "@nomicfoundation/hardhat-network-helpers": "workspace:^3.0.0",
28
+ "@nomicfoundation/hardhat-network-helpers": "workspace:^3.0.1",
29
29
  "@nomicfoundation/hardhat-typechain": "workspace:^3.0.0",
30
- "@nomicfoundation/hardhat-verify": "workspace:^3.0.0",
30
+ "@nomicfoundation/hardhat-verify": "workspace:^3.0.3",
31
31
  "@nomicfoundation/ignition-core": "workspace:^3.0.0"
32
32
  }
33
33
  }