hardhat 3.4.0 → 3.4.1

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 (197) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.js +1 -1
  3. package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.js.map +1 -1
  4. package/dist/src/internal/builtin-plugins/artifacts/hook-handlers/hre.d.ts.map +1 -1
  5. package/dist/src/internal/builtin-plugins/artifacts/hook-handlers/hre.js +10 -10
  6. package/dist/src/internal/builtin-plugins/artifacts/hook-handlers/hre.js.map +1 -1
  7. package/dist/src/internal/builtin-plugins/clean/index.js +1 -1
  8. package/dist/src/internal/builtin-plugins/clean/index.js.map +1 -1
  9. package/dist/src/internal/builtin-plugins/console/index.js +1 -1
  10. package/dist/src/internal/builtin-plugins/console/index.js.map +1 -1
  11. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js +2 -2
  12. package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js.map +1 -1
  13. package/dist/src/internal/builtin-plugins/flatten/index.js +1 -1
  14. package/dist/src/internal/builtin-plugins/flatten/index.js.map +1 -1
  15. package/dist/src/internal/builtin-plugins/gas-analytics/index.d.ts.map +1 -1
  16. package/dist/src/internal/builtin-plugins/gas-analytics/index.js +2 -2
  17. package/dist/src/internal/builtin-plugins/gas-analytics/index.js.map +1 -1
  18. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js +4 -4
  19. package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js.map +1 -1
  20. package/dist/src/internal/builtin-plugins/network-manager/edr/genesis-state.js +1 -1
  21. package/dist/src/internal/builtin-plugins/network-manager/edr/genesis-state.js.map +1 -1
  22. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js +1 -1
  23. package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js.map +1 -1
  24. package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/hre.js +4 -4
  25. package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/hre.js.map +1 -1
  26. package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/network.js +2 -2
  27. package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/network.js.map +1 -1
  28. package/dist/src/internal/builtin-plugins/network-manager/http-provider.d.ts.map +1 -1
  29. package/dist/src/internal/builtin-plugins/network-manager/http-provider.js +2 -2
  30. package/dist/src/internal/builtin-plugins/network-manager/http-provider.js.map +1 -1
  31. package/dist/src/internal/builtin-plugins/network-manager/network-manager.d.ts.map +1 -1
  32. package/dist/src/internal/builtin-plugins/network-manager/network-manager.js +7 -7
  33. package/dist/src/internal/builtin-plugins/network-manager/network-manager.js.map +1 -1
  34. package/dist/src/internal/builtin-plugins/node/helpers.js +1 -1
  35. package/dist/src/internal/builtin-plugins/node/helpers.js.map +1 -1
  36. package/dist/src/internal/builtin-plugins/node/index.js +1 -1
  37. package/dist/src/internal/builtin-plugins/node/index.js.map +1 -1
  38. package/dist/src/internal/builtin-plugins/run/index.js +1 -1
  39. package/dist/src/internal/builtin-plugins/run/index.js.map +1 -1
  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 +13 -10
  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/compilation-job.js +1 -1
  44. package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job.js.map +1 -1
  45. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.js +4 -4
  46. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.js.map +1 -1
  47. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/index.js +2 -2
  48. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/index.js.map +1 -1
  49. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-runner.js +1 -1
  50. package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-runner.js.map +1 -1
  51. package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph-building.js +1 -1
  52. package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph-building.js.map +1 -1
  53. package/dist/src/internal/builtin-plugins/solidity/build-system/read-source-file.js +1 -1
  54. package/dist/src/internal/builtin-plugins/solidity/build-system/read-source-file.js.map +1 -1
  55. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.js +10 -10
  56. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.js.map +1 -1
  57. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.js +1 -1
  58. package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.js.map +1 -1
  59. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/config.js +1 -1
  60. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/config.js.map +1 -1
  61. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.d.ts.map +1 -1
  62. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js +10 -10
  63. package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js.map +1 -1
  64. package/dist/src/internal/builtin-plugins/solidity/index.js +1 -1
  65. package/dist/src/internal/builtin-plugins/solidity/index.js.map +1 -1
  66. package/dist/src/internal/builtin-plugins/solidity/solidity-hooks.js +1 -1
  67. package/dist/src/internal/builtin-plugins/solidity/solidity-hooks.js.map +1 -1
  68. package/dist/src/internal/builtin-plugins/solidity/tasks/build.js +4 -4
  69. package/dist/src/internal/builtin-plugins/solidity/tasks/build.js.map +1 -1
  70. package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.js +2 -2
  71. package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.js.map +1 -1
  72. package/dist/src/internal/builtin-plugins/solidity-test/hook-handlers/config.js +1 -1
  73. package/dist/src/internal/builtin-plugins/solidity-test/hook-handlers/config.js.map +1 -1
  74. package/dist/src/internal/builtin-plugins/solidity-test/hook-handlers/test.js +1 -1
  75. package/dist/src/internal/builtin-plugins/solidity-test/hook-handlers/test.js.map +1 -1
  76. package/dist/src/internal/builtin-plugins/solidity-test/index.js +1 -1
  77. package/dist/src/internal/builtin-plugins/solidity-test/index.js.map +1 -1
  78. package/dist/src/internal/builtin-plugins/solidity-test/reporter.js +1 -1
  79. package/dist/src/internal/builtin-plugins/solidity-test/reporter.js.map +1 -1
  80. package/dist/src/internal/builtin-plugins/telemetry/index.js +1 -1
  81. package/dist/src/internal/builtin-plugins/telemetry/index.js.map +1 -1
  82. package/dist/src/internal/builtin-plugins/test/hook-handlers/config.js +1 -1
  83. package/dist/src/internal/builtin-plugins/test/hook-handlers/config.js.map +1 -1
  84. package/dist/src/internal/builtin-plugins/test/index.js +1 -1
  85. package/dist/src/internal/builtin-plugins/test/index.js.map +1 -1
  86. package/dist/src/internal/cli/init/init.js +1 -1
  87. package/dist/src/internal/cli/init/init.js.map +1 -1
  88. package/dist/src/internal/cli/main.d.ts.map +1 -1
  89. package/dist/src/internal/cli/main.js +4 -2
  90. package/dist/src/internal/cli/main.js.map +1 -1
  91. package/dist/src/internal/cli/node-version.d.ts.map +1 -1
  92. package/dist/src/internal/cli/node-version.js +3 -0
  93. package/dist/src/internal/cli/node-version.js.map +1 -1
  94. package/dist/src/internal/cli/telemetry/analytics/analytics.js +2 -2
  95. package/dist/src/internal/cli/telemetry/analytics/analytics.js.map +1 -1
  96. package/dist/src/internal/cli/telemetry/error-reporter/global-error-handlers.d.ts +6 -0
  97. package/dist/src/internal/cli/telemetry/error-reporter/global-error-handlers.d.ts.map +1 -0
  98. package/dist/src/internal/cli/telemetry/error-reporter/global-error-handlers.js +47 -0
  99. package/dist/src/internal/cli/telemetry/error-reporter/global-error-handlers.js.map +1 -0
  100. package/dist/src/internal/cli/telemetry/error-reporter/reporter.d.ts +27 -0
  101. package/dist/src/internal/cli/telemetry/error-reporter/reporter.d.ts.map +1 -0
  102. package/dist/src/internal/cli/telemetry/error-reporter/reporter.js +40 -0
  103. package/dist/src/internal/cli/telemetry/error-reporter/reporter.js.map +1 -0
  104. package/dist/src/internal/cli/telemetry/sentry/anonymizer.js +1 -1
  105. package/dist/src/internal/cli/telemetry/sentry/anonymizer.js.map +1 -1
  106. package/dist/src/internal/cli/telemetry/sentry/init.d.ts +0 -8
  107. package/dist/src/internal/cli/telemetry/sentry/init.d.ts.map +1 -1
  108. package/dist/src/internal/cli/telemetry/sentry/init.js +1 -37
  109. package/dist/src/internal/cli/telemetry/sentry/init.js.map +1 -1
  110. package/dist/src/internal/cli/telemetry/sentry/reporter.d.ts +8 -2
  111. package/dist/src/internal/cli/telemetry/sentry/reporter.d.ts.map +1 -1
  112. package/dist/src/internal/cli/telemetry/sentry/reporter.js +18 -12
  113. package/dist/src/internal/cli/telemetry/sentry/reporter.js.map +1 -1
  114. package/dist/src/internal/cli/telemetry/sentry/transport.js +1 -1
  115. package/dist/src/internal/cli/telemetry/sentry/transport.js.map +1 -1
  116. package/dist/src/internal/cli/telemetry/telemetry-permissions.js +1 -1
  117. package/dist/src/internal/cli/telemetry/telemetry-permissions.js.map +1 -1
  118. package/dist/src/internal/config-loading.js +3 -3
  119. package/dist/src/internal/config-loading.js.map +1 -1
  120. package/dist/src/internal/core/configuration-variables.d.ts.map +1 -1
  121. package/dist/src/internal/core/configuration-variables.js +1 -1
  122. package/dist/src/internal/core/configuration-variables.js.map +1 -1
  123. package/dist/src/internal/core/hook-manager.js +3 -3
  124. package/dist/src/internal/core/hook-manager.js.map +1 -1
  125. package/dist/src/internal/core/hre.d.ts.map +1 -1
  126. package/dist/src/internal/core/hre.js +3 -3
  127. package/dist/src/internal/core/hre.js.map +1 -1
  128. package/dist/src/internal/core/plugins/resolve-plugin-list.js +1 -1
  129. package/dist/src/internal/core/plugins/resolve-plugin-list.js.map +1 -1
  130. package/dist/src/internal/core/tasks/resolved-task.js +4 -4
  131. package/dist/src/internal/core/tasks/resolved-task.js.map +1 -1
  132. package/dist/src/internal/core/user-interruptions.js +9 -9
  133. package/dist/src/internal/core/user-interruptions.js.map +1 -1
  134. package/dist/src/internal/hre-initialization.js +1 -1
  135. package/dist/src/internal/hre-initialization.js.map +1 -1
  136. package/package.json +4 -4
  137. package/src/internal/builtin-plugins/artifacts/artifact-manager.ts +1 -1
  138. package/src/internal/builtin-plugins/artifacts/hook-handlers/hre.ts +16 -10
  139. package/src/internal/builtin-plugins/clean/index.ts +1 -1
  140. package/src/internal/builtin-plugins/console/index.ts +1 -1
  141. package/src/internal/builtin-plugins/coverage/hook-handlers/solidity.ts +2 -2
  142. package/src/internal/builtin-plugins/flatten/index.ts +1 -1
  143. package/src/internal/builtin-plugins/gas-analytics/index.ts +4 -2
  144. package/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts +4 -4
  145. package/src/internal/builtin-plugins/network-manager/edr/genesis-state.ts +1 -1
  146. package/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.ts +1 -1
  147. package/src/internal/builtin-plugins/network-manager/hook-handlers/hre.ts +4 -4
  148. package/src/internal/builtin-plugins/network-manager/hook-handlers/network.ts +2 -2
  149. package/src/internal/builtin-plugins/network-manager/http-provider.ts +6 -2
  150. package/src/internal/builtin-plugins/network-manager/network-manager.ts +11 -7
  151. package/src/internal/builtin-plugins/node/helpers.ts +1 -1
  152. package/src/internal/builtin-plugins/node/index.ts +1 -1
  153. package/src/internal/builtin-plugins/run/index.ts +1 -1
  154. package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +21 -12
  155. package/src/internal/builtin-plugins/solidity/build-system/compilation-job.ts +1 -1
  156. package/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts +4 -4
  157. package/src/internal/builtin-plugins/solidity/build-system/compiler/index.ts +2 -2
  158. package/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-runner.ts +1 -1
  159. package/src/internal/builtin-plugins/solidity/build-system/dependency-graph-building.ts +1 -1
  160. package/src/internal/builtin-plugins/solidity/build-system/read-source-file.ts +2 -2
  161. package/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.ts +11 -11
  162. package/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.ts +1 -1
  163. package/src/internal/builtin-plugins/solidity/hook-handlers/config.ts +1 -1
  164. package/src/internal/builtin-plugins/solidity/hook-handlers/hre.ts +14 -10
  165. package/src/internal/builtin-plugins/solidity/index.ts +1 -1
  166. package/src/internal/builtin-plugins/solidity/solidity-hooks.ts +1 -1
  167. package/src/internal/builtin-plugins/solidity/tasks/build.ts +4 -4
  168. package/src/internal/builtin-plugins/solidity-test/edr-artifacts.ts +2 -2
  169. package/src/internal/builtin-plugins/solidity-test/hook-handlers/config.ts +1 -1
  170. package/src/internal/builtin-plugins/solidity-test/hook-handlers/test.ts +1 -1
  171. package/src/internal/builtin-plugins/solidity-test/index.ts +1 -1
  172. package/src/internal/builtin-plugins/solidity-test/reporter.ts +1 -1
  173. package/src/internal/builtin-plugins/telemetry/index.ts +1 -1
  174. package/src/internal/builtin-plugins/test/hook-handlers/config.ts +1 -1
  175. package/src/internal/builtin-plugins/test/index.ts +1 -1
  176. package/src/internal/cli/init/init.ts +1 -1
  177. package/src/internal/cli/main.ts +5 -3
  178. package/src/internal/cli/node-version.ts +3 -0
  179. package/src/internal/cli/telemetry/analytics/analytics.ts +2 -2
  180. package/src/internal/cli/telemetry/error-reporter/global-error-handlers.ts +64 -0
  181. package/src/internal/cli/telemetry/error-reporter/reporter.ts +49 -0
  182. package/src/internal/cli/telemetry/sentry/anonymizer.ts +1 -1
  183. package/src/internal/cli/telemetry/sentry/init.ts +2 -62
  184. package/src/internal/cli/telemetry/sentry/reporter.ts +27 -15
  185. package/src/internal/cli/telemetry/sentry/transport.ts +1 -1
  186. package/src/internal/cli/telemetry/telemetry-permissions.ts +1 -1
  187. package/src/internal/config-loading.ts +3 -3
  188. package/src/internal/core/configuration-variables.ts +19 -18
  189. package/src/internal/core/hook-manager.ts +3 -3
  190. package/src/internal/core/hre.ts +5 -3
  191. package/src/internal/core/plugins/resolve-plugin-list.ts +1 -1
  192. package/src/internal/core/tasks/resolved-task.ts +4 -4
  193. package/src/internal/core/user-interruptions.ts +9 -9
  194. package/src/internal/hre-initialization.ts +1 -1
  195. package/templates/hardhat-3/01-node-test-runner-viem/package.json +10 -10
  196. package/templates/hardhat-3/02-mocha-ethers/package.json +13 -13
  197. package/templates/hardhat-3/03-minimal/package.json +1 -1
@@ -6,11 +6,11 @@ export function readSourceFileFactory(
6
6
  hooks: HookManager,
7
7
  ): (absPath: string) => Promise<string> {
8
8
  return async (factoryAbsPath: string) => {
9
- return hooks.runHandlerChain(
9
+ return await hooks.runHandlerChain(
10
10
  "solidity",
11
11
  "readSourceFile",
12
12
  [factoryAbsPath],
13
- async (_context, absPath) => readUtf8File(absPath),
13
+ async (_context, absPath) => await readUtf8File(absPath),
14
14
  );
15
15
  };
16
16
  }
@@ -133,8 +133,8 @@ export class ResolverImplementation implements Resolver {
133
133
  public async resolveProjectFile(
134
134
  absoluteFilePath: string,
135
135
  ): Promise<Result<ProjectResolvedFile, ProjectRootResolutionError>> {
136
- return this.#mutex.exclusiveRun(async () => {
137
- return this.#resolveProjectFile(absoluteFilePath);
136
+ return await this.#mutex.exclusiveRun(async () => {
137
+ return await this.#resolveProjectFile(absoluteFilePath);
138
138
  });
139
139
  }
140
140
 
@@ -146,8 +146,8 @@ export class ResolverImplementation implements Resolver {
146
146
  NpmRootResolutionError
147
147
  >
148
148
  > {
149
- return this.#mutex.exclusiveRun(async () => {
150
- return this.#resolveNpmDependencyFileAsRoot(npmModule);
149
+ return await this.#mutex.exclusiveRun(async () => {
150
+ return await this.#resolveNpmDependencyFileAsRoot(npmModule);
151
151
  });
152
152
  }
153
153
 
@@ -160,8 +160,8 @@ export class ResolverImplementation implements Resolver {
160
160
  ImportResolutionError
161
161
  >
162
162
  > {
163
- return this.#mutex.exclusiveRun(async () =>
164
- this.#resolveImport(from, importPath),
163
+ return await this.#mutex.exclusiveRun(
164
+ async () => await this.#resolveImport(from, importPath),
165
165
  );
166
166
  }
167
167
 
@@ -495,7 +495,7 @@ export class ResolverImplementation implements Resolver {
495
495
  };
496
496
  }
497
497
 
498
- return this.#resolveRelativeImport({
498
+ return await this.#resolveRelativeImport({
499
499
  from,
500
500
  importPath,
501
501
  directImport,
@@ -504,7 +504,7 @@ export class ResolverImplementation implements Resolver {
504
504
  if (bestUserRemapping !== undefined) {
505
505
  // If the import isn't relative, and there's a user remapping, we
506
506
  // prioritize that.
507
- return this.#resolveUserRemappedImport({
507
+ return await this.#resolveUserRemappedImport({
508
508
  from,
509
509
  importPath,
510
510
  directImport,
@@ -576,7 +576,7 @@ export class ResolverImplementation implements Resolver {
576
576
 
577
577
  const relativeFsPath = sourceNamePathToFsPath(relativeSourceNamePath);
578
578
 
579
- return this.#commonImportResolution({
579
+ return await this.#commonImportResolution({
580
580
  from,
581
581
  importPath,
582
582
  npmPackage: from.package,
@@ -639,7 +639,7 @@ export class ResolverImplementation implements Resolver {
639
639
 
640
640
  const relativeFsPath = sourceNamePathToFsPath(relativeSourceNamePath);
641
641
 
642
- return this.#commonImportResolution({
642
+ return await this.#commonImportResolution({
643
643
  from,
644
644
  importPath,
645
645
  npmPackage: targetNpmPackage,
@@ -796,7 +796,7 @@ export class ResolverImplementation implements Resolver {
796
796
  const relativePath = resolvedSubpath ?? subpath;
797
797
  const relativeFsPathWithinPackage = sourceNamePathToFsPath(relativePath);
798
798
 
799
- return this.#commonImportResolution({
799
+ return await this.#commonImportResolution({
800
800
  from,
801
801
  importPath,
802
802
  npmPackage: dependency,
@@ -457,7 +457,7 @@ export class RemappedNpmPackagesGraphImplementation
457
457
  npmPackage.version,
458
458
  npmPackage.rootFsPath,
459
459
  async (_packageName, _packageVersion, packagePath) =>
460
- this.#defaultReadPackageRemappings(packagePath),
460
+ await this.#defaultReadPackageRemappings(packagePath),
461
461
  );
462
462
 
463
463
  return this.#parseAndDeduplicateRemappings(npmPackage, allRemappings);
@@ -20,7 +20,7 @@ export default async (): Promise<Partial<ConfigHooks>> => {
20
20
  resolveConfigurationVariable,
21
21
  );
22
22
 
23
- return resolveSolidityUserConfig(userConfig, resolvedConfig);
23
+ return await resolveSolidityUserConfig(userConfig, resolvedConfig);
24
24
  },
25
25
  validateResolvedConfig: async (resolvedConfig) =>
26
26
  validateSolidityConfig(resolvedConfig),
@@ -38,12 +38,12 @@ class LazySolidityBuildSystem implements SolidityBuildSystem {
38
38
  options: { scope?: BuildScope } = {},
39
39
  ): Promise<string[]> {
40
40
  const buildSystem = await this.#getBuildSystem();
41
- return buildSystem.getRootFilePaths(options);
41
+ return await buildSystem.getRootFilePaths(options);
42
42
  }
43
43
 
44
44
  public async getScope(fsPath: string): Promise<BuildScope> {
45
45
  const buildSystem = await this.#getBuildSystem();
46
- return buildSystem.getScope(fsPath);
46
+ return await buildSystem.getScope(fsPath);
47
47
  }
48
48
 
49
49
  public isSuccessfulBuildResult(
@@ -59,7 +59,7 @@ class LazySolidityBuildSystem implements SolidityBuildSystem {
59
59
  options?: BuildOptions,
60
60
  ): Promise<CompilationJobCreationError | Map<string, FileBuildResult>> {
61
61
  const buildSystem = await this.#getBuildSystem();
62
- return buildSystem.build(rootFiles, options);
62
+ return await buildSystem.build(rootFiles, options);
63
63
  }
64
64
 
65
65
  public async getCompilationJobs(
@@ -67,7 +67,7 @@ class LazySolidityBuildSystem implements SolidityBuildSystem {
67
67
  options?: GetCompilationJobsOptions,
68
68
  ): Promise<CompilationJobCreationError | GetCompilationJobsResult> {
69
69
  const buildSystem = await this.#getBuildSystem();
70
- return buildSystem.getCompilationJobs(rootFiles, options);
70
+ return await buildSystem.getCompilationJobs(rootFiles, options);
71
71
  }
72
72
 
73
73
  public async runCompilationJob(
@@ -75,7 +75,7 @@ class LazySolidityBuildSystem implements SolidityBuildSystem {
75
75
  options?: RunCompilationJobOptions,
76
76
  ): Promise<RunCompilationJobResult> {
77
77
  const buildSystem = await this.#getBuildSystem();
78
- return buildSystem.runCompilationJob(compilationJob, options);
78
+ return await buildSystem.runCompilationJob(compilationJob, options);
79
79
  }
80
80
 
81
81
  public async remapCompilerError(
@@ -84,7 +84,7 @@ class LazySolidityBuildSystem implements SolidityBuildSystem {
84
84
  shouldShortenPaths?: boolean,
85
85
  ): Promise<CompilerOutputError> {
86
86
  const buildSystem = await this.#getBuildSystem();
87
- return buildSystem.remapCompilerError(
87
+ return await buildSystem.remapCompilerError(
88
88
  compilationJob,
89
89
  error,
90
90
  shouldShortenPaths,
@@ -97,7 +97,11 @@ class LazySolidityBuildSystem implements SolidityBuildSystem {
97
97
  options: { scope?: BuildScope } = {},
98
98
  ): Promise<EmitArtifactsResult> {
99
99
  const buildSystem = await this.#getBuildSystem();
100
- return buildSystem.emitArtifacts(compilationJob, compilerOutput, options);
100
+ return await buildSystem.emitArtifacts(
101
+ compilationJob,
102
+ compilerOutput,
103
+ options,
104
+ );
101
105
  }
102
106
 
103
107
  public async cleanupArtifacts(
@@ -105,7 +109,7 @@ class LazySolidityBuildSystem implements SolidityBuildSystem {
105
109
  options: { scope?: BuildScope } = {},
106
110
  ): Promise<void> {
107
111
  const buildSystem = await this.#getBuildSystem();
108
- return buildSystem.cleanupArtifacts(rootFilePaths, options);
112
+ return await buildSystem.cleanupArtifacts(rootFilePaths, options);
109
113
  }
110
114
 
111
115
  public async compileBuildInfo(
@@ -113,12 +117,12 @@ class LazySolidityBuildSystem implements SolidityBuildSystem {
113
117
  options?: CompileBuildInfoOptions,
114
118
  ): Promise<CompilerOutput> {
115
119
  const buildSystem = await this.#getBuildSystem();
116
- return buildSystem.compileBuildInfo(buildInfo, options);
120
+ return await buildSystem.compileBuildInfo(buildInfo, options);
117
121
  }
118
122
 
119
123
  public async getArtifactsDirectory(scope: BuildScope): Promise<string> {
120
124
  const buildSystem = await this.#getBuildSystem();
121
- return buildSystem.getArtifactsDirectory(scope);
125
+ return await buildSystem.getArtifactsDirectory(scope);
122
126
  }
123
127
 
124
128
  async #getBuildSystem(): Promise<SolidityBuildSystem> {
@@ -32,7 +32,7 @@ const buildTask = task("build", "Build project")
32
32
  name: "noContracts",
33
33
  description: "Skip solidity contracts compilation",
34
34
  })
35
- .setAction(async () => import("./tasks/build.js"))
35
+ .setAction(async () => await import("./tasks/build.js"))
36
36
  .build();
37
37
 
38
38
  const hardhatPlugin: HardhatPlugin = {
@@ -46,7 +46,7 @@ export async function getSolcCompilerForConfig(
46
46
  compilerConfig: SolidityCompilerConfig,
47
47
  buildProfilePreferWasm: boolean,
48
48
  ): Promise<Compiler> {
49
- return getCompiler(compilerConfig.version, {
49
+ return await getCompiler(compilerConfig.version, {
50
50
  preferWasm: resolvePreferWasm(compilerConfig, buildProfilePreferWasm),
51
51
  compilerPath: compilerConfig.path,
52
52
  });
@@ -119,7 +119,7 @@ const buildAction: NewTaskActionFunction<BuildActionArguments> = async (
119
119
  return { contractRootPaths, testRootPaths };
120
120
  }
121
121
 
122
- return runSolidityBuild({
122
+ return await runSolidityBuild({
123
123
  buildProfile,
124
124
  files,
125
125
  force: args.force,
@@ -208,7 +208,7 @@ async function runSolidityBuild({
208
208
  return { contractRootPaths, testRootPaths };
209
209
  }
210
210
 
211
- return partitionRootPathsByScope(solidity, builtRootPaths);
211
+ return await partitionRootPathsByScope(solidity, builtRootPaths);
212
212
  }
213
213
 
214
214
  /**
@@ -237,7 +237,7 @@ async function getRootsToBuild({
237
237
  isFullBuild: boolean;
238
238
  }> {
239
239
  if (isUnifiedModeOrScope === true) {
240
- return getRootsToBuildInUnifiedMode({
240
+ return await getRootsToBuildInUnifiedMode({
241
241
  files,
242
242
  noContracts,
243
243
  noTests,
@@ -245,7 +245,7 @@ async function getRootsToBuild({
245
245
  });
246
246
  }
247
247
 
248
- return getRootsToBuildForScope({
248
+ return await getRootsToBuildForScope({
249
249
  files,
250
250
  scope: isUnifiedModeOrScope,
251
251
  solidity,
@@ -31,7 +31,7 @@ export async function getBuildInfosAndOutputs(
31
31
  ): Promise<BuildInfoAndOutput[]> {
32
32
  const buildInfoIds = await artifactManager.getAllBuildInfoIds();
33
33
 
34
- return Promise.all(
34
+ return await Promise.all(
35
35
  Array.from(buildInfoIds).map(async (buildInfoId) => {
36
36
  const buildInfoPath = await artifactManager.getBuildInfoPath(buildInfoId);
37
37
  const buildInfoOutputPath =
@@ -76,7 +76,7 @@ export async function buildEdrArtifactsWithMetadata(
76
76
 
77
77
  const artifacts = await Promise.all(
78
78
  Array.from(fullyQualifiedNames).map(async (fullyQualifiedName) => {
79
- return artifactManager.readArtifact(fullyQualifiedName);
79
+ return await artifactManager.readArtifact(fullyQualifiedName);
80
80
  }),
81
81
  );
82
82
 
@@ -19,7 +19,7 @@ export default async (): Promise<Partial<ConfigHooks>> => {
19
19
  resolveConfigurationVariable,
20
20
  );
21
21
 
22
- return resolveSolidityTestUserConfig(
22
+ return await resolveSolidityTestUserConfig(
23
23
  userConfig,
24
24
  resolvedConfig,
25
25
  resolveConfigurationVariable,
@@ -15,7 +15,7 @@ export default async (): Promise<Partial<TestHooks>> => {
15
15
  return "solidity";
16
16
  }
17
17
 
18
- return next(context, filePath);
18
+ return await next(context, filePath);
19
19
  },
20
20
  };
21
21
 
@@ -42,7 +42,7 @@ const hardhatPlugin: HardhatPlugin = {
42
42
  defaultValue: 0,
43
43
  hidden: true,
44
44
  })
45
- .setAction(async () => import("./task-action.js"))
45
+ .setAction(async () => await import("./task-action.js"))
46
46
  .build(),
47
47
  ],
48
48
  dependencies: () => [
@@ -9,7 +9,7 @@ import type { TestResult } from "@nomicfoundation/edr";
9
9
  import { bytesToHexString } from "@nomicfoundation/hardhat-utils/hex";
10
10
  import chalk from "chalk";
11
11
 
12
- import { sendErrorTelemetry } from "../../cli/telemetry/sentry/reporter.js";
12
+ import { sendErrorTelemetry } from "../../cli/telemetry/error-reporter/reporter.js";
13
13
  import { SolidityTestStackTraceGenerationError } from "../network-manager/edr/stack-traces/stack-trace-generation-errors.js";
14
14
  import { encodeStackTraceEntry } from "../network-manager/edr/stack-traces/stack-trace-solidity-errors.js";
15
15
  import { formatTraces } from "../network-manager/edr/utils/trace-formatters.js";
@@ -14,7 +14,7 @@ const hardhatPlugin: HardhatPlugin = {
14
14
  name: "disable",
15
15
  description: "Disable telemetry",
16
16
  })
17
- .setAction(async () => import("./task-action.js"))
17
+ .setAction(async () => await import("./task-action.js"))
18
18
  .build(),
19
19
  ],
20
20
  npmPackage: "hardhat",
@@ -14,7 +14,7 @@ export default async (): Promise<Partial<ConfigHooks>> => {
14
14
  resolveConfigurationVariable,
15
15
  );
16
16
 
17
- return resolveTestUserConfig(userConfig, resolvedConfig);
17
+ return await resolveTestUserConfig(userConfig, resolvedConfig);
18
18
  },
19
19
  };
20
20
 
@@ -32,7 +32,7 @@ const hardhatPlugin: HardhatPlugin = {
32
32
  name: "noCompile",
33
33
  description: "Do not compile the project before running the tests",
34
34
  })
35
- .setAction(async () => import("./task-action.js"))
35
+ .setAction(async () => await import("./task-action.js"))
36
36
  .build(),
37
37
  ],
38
38
  dependencies: () => [import("../solidity/index.js")],
@@ -31,7 +31,7 @@ import {
31
31
  } from "../../utils/package.js";
32
32
  import { BannerManager } from "../banner-manager.js";
33
33
  import { sendProjectTypeAnalytics } from "../telemetry/analytics/analytics.js";
34
- import { sendErrorTelemetry } from "../telemetry/sentry/reporter.js";
34
+ import { sendErrorTelemetry } from "../telemetry/error-reporter/reporter.js";
35
35
 
36
36
  import {
37
37
  getDevDependenciesInstallationCommand,
@@ -46,11 +46,11 @@ import { printErrorMessages } from "./error-handler.js";
46
46
  import { getGlobalHelpString } from "./help/get-global-help-string.js";
47
47
  import { getHelpString } from "./help/get-help-string.js";
48
48
  import { sendTaskAnalytics } from "./telemetry/analytics/analytics.js";
49
+ import { setupGlobalUnhandledErrorHandlers } from "./telemetry/error-reporter/global-error-handlers.js";
49
50
  import {
50
51
  sendErrorTelemetry,
51
52
  setCliHardhatConfigPath,
52
- setupErrorTelemetryIfEnabled,
53
- } from "./telemetry/sentry/reporter.js";
53
+ } from "./telemetry/error-reporter/reporter.js";
54
54
  import { printVersionMessage } from "./version.js";
55
55
 
56
56
  export interface MainOptions {
@@ -64,7 +64,9 @@ export async function main(
64
64
  rawArguments: string[],
65
65
  options: MainOptions = {},
66
66
  ): Promise<void> {
67
- await setupErrorTelemetryIfEnabled();
67
+ // We set up the global unhandled errors before running any functionality
68
+ setupGlobalUnhandledErrorHandlers();
69
+
68
70
  const print = options.print ?? console.log;
69
71
 
70
72
  const log = debug("hardhat:core:cli:main");
@@ -1,5 +1,8 @@
1
1
  // NOTE: We don't use the `semver` package because it's slow to load, and this
2
2
  // is always run during the initialization of the CLI.
3
+ //
4
+ // NOTE: This file shouldn't import any non-builtin dependency, as it's imported
5
+ // before enabling source maps support. TODO: Change chalk to util.styleText
3
6
 
4
7
  import chalk from "chalk";
5
8
 
@@ -60,7 +60,7 @@ export async function sendTaskAnalytics(taskId: string[]): Promise<boolean> {
60
60
  },
61
61
  };
62
62
 
63
- return sendAnalytics(taskAnalyticsEvent);
63
+ return await sendAnalytics(taskAnalyticsEvent);
64
64
  }
65
65
 
66
66
  export async function sendProjectTypeAnalytics(
@@ -75,7 +75,7 @@ export async function sendProjectTypeAnalytics(
75
75
  },
76
76
  };
77
77
 
78
- return sendAnalytics(initAnalyticsEvent);
78
+ return await sendAnalytics(initAnalyticsEvent);
79
79
  }
80
80
 
81
81
  // Return a boolean for testing purposes to confirm whether analytics were sent based on the consent value and not in CI environments
@@ -0,0 +1,64 @@
1
+ import { isObject } from "@nomicfoundation/hardhat-utils/lang";
2
+ import debug from "debug";
3
+
4
+ import { sendErrorTelemetry } from "./reporter.js";
5
+
6
+ const log = debug("hardhat:core:telemetry:global-error-handlers");
7
+
8
+ function createUnhandledErrorListener(isPromiseRejection: boolean) {
9
+ const description = isPromiseRejection
10
+ ? "Unhandled promise rejection"
11
+ : "Uncaught exception";
12
+
13
+ const mechanismType = isPromiseRejection
14
+ ? "onunhandledrejection"
15
+ : "onuncaughtexception";
16
+
17
+ async function listener(error: Error | unknown) {
18
+ log(description, error);
19
+
20
+ const telemetryError =
21
+ error instanceof Error
22
+ ? error
23
+ : new Error(
24
+ isObject(error) &&
25
+ "message" in error &&
26
+ typeof error.message === "string"
27
+ ? error.message
28
+ : "Unknown error",
29
+ { cause: error },
30
+ );
31
+
32
+ try {
33
+ await sendErrorTelemetry(telemetryError, {
34
+ unhandled: true,
35
+ mechanismType,
36
+ });
37
+ } catch (telemetryErrorReportingError) {
38
+ log(
39
+ "Failed to send telemetry for unhandled error",
40
+ telemetryErrorReportingError,
41
+ );
42
+ }
43
+
44
+ console.error();
45
+ console.error(`${description}:`);
46
+ console.error();
47
+ console.error(error);
48
+
49
+ process.exit(1);
50
+ }
51
+
52
+ return listener;
53
+ }
54
+
55
+ /**
56
+ * Sets up global error handlers that report unhandled errors and promise
57
+ * rejections if authorized by the user.
58
+ */
59
+ export function setupGlobalUnhandledErrorHandlers(): void {
60
+ log("Setting up global unhandled error handlers");
61
+
62
+ process.on("uncaughtException", createUnhandledErrorListener(false));
63
+ process.on("unhandledRejection", createUnhandledErrorListener(true));
64
+ }
@@ -0,0 +1,49 @@
1
+ import type * as SentryReporterT from "../sentry/reporter.js";
2
+
3
+ // Sentry's reporter loads a large number of modules, so we only load it if
4
+ // needed.
5
+ let sentryReporterModule: typeof SentryReporterT | undefined;
6
+
7
+ // We cache the `setCliHardhatConfigPath` to avoid loading the reporter just
8
+ // for this setting. We load it and set the config path if needed.
9
+ let cliHardhatConfigPath: string | undefined;
10
+
11
+ /**
12
+ * Reports an error if telemetry is authorized by the user.
13
+ *
14
+ * While this function is async, it's expected to always complete quickly,
15
+ * delegating the actual reporting to a subprocess.
16
+ *
17
+ * @param error - The error to report.
18
+ * @param hint - Optional metadata describing how the error was captured, used
19
+ * to tag the event in Sentry so unhandled crashes can be distinguished from
20
+ * errors caught and reported by the CLI.
21
+ * @param hint.unhandled - Whether the error reached a global handler without
22
+ * being caught (e.g. an uncaught exception or unhandled promise rejection).
23
+ * Defaults to `false` (i.e. the error was handled).
24
+ * @param hint.mechanismType - The Sentry mechanism type, used as a tag on the
25
+ * event. Common values are `"onuncaughtexception"`, `"onunhandledrejection"`,
26
+ * `"instrument"`, and `"generic"`. Defaults to `"generic"`.
27
+ */
28
+ export async function sendErrorTelemetry(
29
+ error: Error,
30
+ hint?: { unhandled?: boolean; mechanismType?: string },
31
+ ): Promise<void> {
32
+ if (sentryReporterModule === undefined) {
33
+ sentryReporterModule = await import("../sentry/reporter.js");
34
+ }
35
+
36
+ if (cliHardhatConfigPath !== undefined) {
37
+ sentryReporterModule.setCliHardhatConfigPath(cliHardhatConfigPath);
38
+ }
39
+
40
+ await sentryReporterModule.sendErrorTelemetry(error, hint);
41
+ }
42
+
43
+ /**
44
+ * Sets the config path used in the Hardhat CLI. This is used for better
45
+ * anonymization of errors.
46
+ */
47
+ export function setCliHardhatConfigPath(configPath: string): void {
48
+ cliHardhatConfigPath = configPath;
49
+ }
@@ -359,7 +359,7 @@ export class Anonymizer {
359
359
  async #anonymizeFrames(frames: StackFrame[]): Promise<StackFrame[]> {
360
360
  const anonymizedFrames = await Promise.all(
361
361
  frames.map(async (frame) => {
362
- return this.#anonymizeFrame(frame);
362
+ return await this.#anonymizeFrame(frame);
363
363
  }),
364
364
  );
365
365
  return anonymizedFrames;
@@ -1,10 +1,6 @@
1
1
  /* This file is inspired by https://github.com/getsentry/sentry-javascript/blob/9.4.0/packages/node/src/sdk/index.ts */
2
2
 
3
- import type {
4
- Client,
5
- ServerRuntimeClientOptions,
6
- Transport,
7
- } from "@sentry/core";
3
+ import type { ServerRuntimeClientOptions, Transport } from "@sentry/core";
8
4
 
9
5
  import os from "node:os";
10
6
  import path from "node:path";
@@ -18,15 +14,12 @@ import {
18
14
  ServerRuntimeClient,
19
15
  stackParserFromStackParserOptions,
20
16
  } from "@sentry/core";
21
- import debug from "debug";
22
17
 
23
18
  import { GENERIC_SERVER_NAME } from "./constants.js";
24
19
  import { nodeContextIntegration } from "./vendor/integrations/context.js";
25
20
  import { contextLinesIntegration } from "./vendor/integrations/contextlines.js";
26
21
  import { createGetModuleFromFilename } from "./vendor/utils/module.js";
27
22
 
28
- const log = debug("hardhat:core:sentry:init");
29
-
30
23
  interface GlobalCustomSentryReporterOptions {
31
24
  /**
32
25
  * Sentry's DSN
@@ -49,12 +42,6 @@ interface GlobalCustomSentryReporterOptions {
49
42
  * See the transport module for the different options.
50
43
  */
51
44
  transport: Transport;
52
-
53
- /**
54
- * If `true`, the global unhandled rejection and uncaught exception handlers
55
- * will be installed.
56
- */
57
- installGlobalHandlers?: boolean;
58
45
  }
59
46
 
60
47
  /**
@@ -72,12 +59,9 @@ interface GlobalCustomSentryReporterOptions {
72
59
  * The reason that this uses the global instance of sentry (by calling
73
60
  * initAndBind), is that using the client directly doesn't work with the linked
74
61
  * errors integration.
75
- *
76
- * Calling `init` also has an option to set global unhandled rejection and
77
- * uncaught exception handlers.
78
62
  */
79
63
  export function init(options: GlobalCustomSentryReporterOptions): void {
80
- const client = initAndBind<ServerRuntimeClient, ServerRuntimeClientOptions>(
64
+ initAndBind<ServerRuntimeClient, ServerRuntimeClientOptions>(
81
65
  ServerRuntimeClient,
82
66
  {
83
67
  dsn: options.dsn,
@@ -113,48 +97,4 @@ export function init(options: GlobalCustomSentryReporterOptions): void {
113
97
  ),
114
98
  },
115
99
  );
116
-
117
- setupGlobalUnhandledErrorHandlers(client);
118
- }
119
-
120
- function createUnhandledErrorListener(
121
- client: Client,
122
- isPromiseRejection: boolean,
123
- ) {
124
- const description = isPromiseRejection
125
- ? "Unhandled promise rejection"
126
- : "Uncaught exception";
127
-
128
- async function listener(error: Error | unknown) {
129
- log(description, error);
130
-
131
- client.captureException(error, {
132
- captureContext: {
133
- level: "fatal",
134
- },
135
- mechanism: {
136
- handled: false,
137
- type: "onuncaughtexception",
138
- },
139
- });
140
-
141
- await client.flush(100);
142
- await client.close(100);
143
-
144
- console.error();
145
- console.error(`${description}:`);
146
- console.error();
147
- console.error(error);
148
-
149
- process.exit(1);
150
- }
151
-
152
- return listener;
153
- }
154
-
155
- function setupGlobalUnhandledErrorHandlers(client: Client) {
156
- log("Setting up global unhandled error handlers");
157
-
158
- process.on("uncaughtException", createUnhandledErrorListener(client, false));
159
- process.on("unhandledRejection", createUnhandledErrorListener(client, true));
160
100
  }