hardhat 2.19.1 → 2.19.3

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 (38) hide show
  1. package/builtin-tasks/test.js +2 -2
  2. package/builtin-tasks/test.js.map +1 -1
  3. package/internal/artifacts.d.ts +1 -0
  4. package/internal/artifacts.d.ts.map +1 -1
  5. package/internal/artifacts.js +8 -8
  6. package/internal/artifacts.js.map +1 -1
  7. package/internal/cli/autocomplete.d.ts.map +1 -1
  8. package/internal/cli/autocomplete.js +100 -39
  9. package/internal/cli/autocomplete.js.map +1 -1
  10. package/internal/cli/cli.js +10 -1
  11. package/internal/cli/cli.js.map +1 -1
  12. package/internal/cli/project-creation.d.ts +1 -0
  13. package/internal/cli/project-creation.d.ts.map +1 -1
  14. package/internal/cli/project-creation.js +22 -8
  15. package/internal/cli/project-creation.js.map +1 -1
  16. package/internal/core/project-structure.d.ts.map +1 -1
  17. package/internal/core/project-structure.js +6 -0
  18. package/internal/core/project-structure.js.map +1 -1
  19. package/internal/core/typescript-support.d.ts +2 -0
  20. package/internal/core/typescript-support.d.ts.map +1 -1
  21. package/internal/core/typescript-support.js +12 -4
  22. package/internal/core/typescript-support.js.map +1 -1
  23. package/internal/hardhat-network/stack-traces/constants.d.ts +1 -1
  24. package/internal/hardhat-network/stack-traces/constants.js +1 -1
  25. package/internal/solidity/compiler/solc-info.d.ts.map +1 -1
  26. package/internal/solidity/compiler/solc-info.js +1 -0
  27. package/internal/solidity/compiler/solc-info.js.map +1 -1
  28. package/package.json +1 -1
  29. package/sample-projects/javascript-esm/test/Lock.js +3 -1
  30. package/src/builtin-tasks/test.ts +9 -4
  31. package/src/internal/artifacts.ts +13 -16
  32. package/src/internal/cli/autocomplete.ts +136 -48
  33. package/src/internal/cli/cli.ts +14 -2
  34. package/src/internal/cli/project-creation.ts +27 -9
  35. package/src/internal/core/project-structure.ts +7 -0
  36. package/src/internal/core/typescript-support.ts +12 -4
  37. package/src/internal/hardhat-network/stack-traces/constants.ts +1 -1
  38. package/src/internal/solidity/compiler/solc-info.ts +1 -0
@@ -1,6 +1,5 @@
1
1
  import chalk from "chalk";
2
2
  import fsExtra from "fs-extra";
3
- import os from "os";
4
3
  import path from "path";
5
4
 
6
5
  import { HARDHAT_NAME } from "../constants";
@@ -279,6 +278,11 @@ async function getAction(isEsm: boolean): Promise<Action> {
279
278
  process.env.HARDHAT_CREATE_TYPESCRIPT_PROJECT_WITH_DEFAULTS !== undefined
280
279
  ) {
281
280
  return Action.CREATE_TYPESCRIPT_PROJECT_ACTION;
281
+ } else if (
282
+ process.env.HARDHAT_CREATE_TYPESCRIPT_VIEM_PROJECT_WITH_DEFAULTS !==
283
+ undefined
284
+ ) {
285
+ return Action.CREATE_TYPESCRIPT_VIEM_PROJECT_ACTION;
282
286
  }
283
287
 
284
288
  const { default: enquirer } = await import("enquirer");
@@ -358,6 +362,20 @@ function showStarOnGitHubMessage() {
358
362
  console.log(chalk.cyan(" https://github.com/NomicFoundation/hardhat"));
359
363
  }
360
364
 
365
+ export function showSoliditySurveyMessage() {
366
+ if (new Date() > new Date("2024-01-07 23:39")) {
367
+ // the survey has finished
368
+ return;
369
+ }
370
+
371
+ console.log();
372
+ console.log(
373
+ chalk.cyan(
374
+ "Please take a moment to complete the 2023 Solidity Survey: https://hardhat.org/solidity-survey-2023"
375
+ )
376
+ );
377
+ }
378
+
361
379
  export async function createProject() {
362
380
  printAsciiLogo();
363
381
 
@@ -403,6 +421,7 @@ export async function createProject() {
403
421
 
404
422
  console.log();
405
423
  showStarOnGitHubMessage();
424
+ showSoliditySurveyMessage();
406
425
 
407
426
  return;
408
427
  }
@@ -414,7 +433,9 @@ export async function createProject() {
414
433
 
415
434
  const useDefaultPromptResponses =
416
435
  process.env.HARDHAT_CREATE_JAVASCRIPT_PROJECT_WITH_DEFAULTS !== undefined ||
417
- process.env.HARDHAT_CREATE_TYPESCRIPT_PROJECT_WITH_DEFAULTS !== undefined;
436
+ process.env.HARDHAT_CREATE_TYPESCRIPT_PROJECT_WITH_DEFAULTS !== undefined ||
437
+ process.env.HARDHAT_CREATE_TYPESCRIPT_VIEM_PROJECT_WITH_DEFAULTS !==
438
+ undefined;
418
439
 
419
440
  if (useDefaultPromptResponses) {
420
441
  responses = {
@@ -506,15 +527,11 @@ export async function createProject() {
506
527
  console.log("See the README.md file for some example tasks you can run");
507
528
  console.log();
508
529
  showStarOnGitHubMessage();
530
+ showSoliditySurveyMessage();
509
531
  }
510
532
 
511
533
  async function canInstallRecommendedDeps() {
512
- return (
513
- (await fsExtra.pathExists("package.json")) &&
514
- // TODO: Figure out why this doesn't work on Win
515
- // cf. https://github.com/nomiclabs/hardhat/issues/1698
516
- os.type() !== "Windows_NT"
517
- );
534
+ return fsExtra.pathExists("package.json");
518
535
  }
519
536
 
520
537
  function isInstalled(dep: string) {
@@ -557,7 +574,7 @@ async function installRecommendedDependencies(dependencies: Dependencies) {
557
574
  console.log("");
558
575
 
559
576
  // The reason we don't quote the dependencies here is because they are going
560
- // to be used in child_process.sapwn, which doesn't require escaping string,
577
+ // to be used in child_process.spawn, which doesn't require escaping string,
561
578
  // and can actually fail if you do.
562
579
  const installCmd = await getRecommendedDependenciesInstallationCommand(
563
580
  dependencies,
@@ -576,6 +593,7 @@ async function installDependencies(
576
593
 
577
594
  const childProcess = spawn(packageManager, args, {
578
595
  stdio: "inherit",
596
+ shell: true,
579
597
  });
580
598
 
581
599
  return new Promise((resolve, reject) => {
@@ -10,10 +10,12 @@ import { ERRORS } from "./errors-list";
10
10
  const JS_CONFIG_FILENAME = "hardhat.config.js";
11
11
  const CJS_CONFIG_FILENAME = "hardhat.config.cjs";
12
12
  const TS_CONFIG_FILENAME = "hardhat.config.ts";
13
+ const CTS_CONFIG_FILENAME = "hardhat.config.cts";
13
14
 
14
15
  export function isCwdInsideProject() {
15
16
  return (
16
17
  findUp.sync(TS_CONFIG_FILENAME) !== null ||
18
+ findUp.sync(CTS_CONFIG_FILENAME) !== null ||
17
19
  findUp.sync(CJS_CONFIG_FILENAME) !== null ||
18
20
  findUp.sync(JS_CONFIG_FILENAME) !== null
19
21
  );
@@ -25,6 +27,11 @@ export function getUserConfigPath() {
25
27
  return tsConfigPath;
26
28
  }
27
29
 
30
+ const ctsConfigPath = findUp.sync(CTS_CONFIG_FILENAME);
31
+ if (ctsConfigPath !== null) {
32
+ return ctsConfigPath;
33
+ }
34
+
28
35
  const cjsConfigPath = findUp.sync(CJS_CONFIG_FILENAME);
29
36
  if (cjsConfigPath !== null) {
30
37
  return cjsConfigPath;
@@ -13,14 +13,14 @@ let cachedIsTypescriptSupported: boolean | undefined;
13
13
  */
14
14
  export function willRunWithTypescript(configPath?: string): boolean {
15
15
  const config = resolveConfigPath(configPath);
16
- return isTypescriptFile(config);
16
+ return isNonEsmTypescriptFile(config);
17
17
  }
18
18
 
19
19
  /**
20
20
  * Returns true if an Hardhat is already running with typescript.
21
21
  */
22
22
  export function isRunningWithTypescript(config: HardhatConfig): boolean {
23
- return isTypescriptFile(config.paths.configFile);
23
+ return isNonEsmTypescriptFile(config.paths.configFile);
24
24
  }
25
25
 
26
26
  export function isTypescriptSupported() {
@@ -80,6 +80,14 @@ export function loadTsNode(
80
80
  require(tsNodeRequirement);
81
81
  }
82
82
 
83
- function isTypescriptFile(path: string): boolean {
84
- return path.endsWith(".ts");
83
+ function isNonEsmTypescriptFile(path: string): boolean {
84
+ return /\.(ts|cts)$/i.test(path);
85
+ }
86
+
87
+ export function isTypescriptFile(path: string): boolean {
88
+ return /\.(ts|cts|mts)$/i.test(path);
89
+ }
90
+
91
+ export function isJavascriptFile(path: string): boolean {
92
+ return /\.(js|cjs|mjs)$/i.test(path);
85
93
  }
@@ -1,2 +1,2 @@
1
- export const SUPPORTED_SOLIDITY_VERSION_RANGE = "<=0.8.22";
1
+ export const SUPPORTED_SOLIDITY_VERSION_RANGE = "<=0.8.23";
2
2
  export const FIRST_SOLC_VERSION_SUPPORTED = "0.5.1";
@@ -59,6 +59,7 @@ const defaultEvmTargets: { [key: string]: string } = {
59
59
  "0.8.20": "shanghai",
60
60
  "0.8.21": "shanghai",
61
61
  "0.8.22": "shanghai",
62
+ "0.8.23": "shanghai",
62
63
  };
63
64
 
64
65
  export function getEvmVersionFromSolcVersion(