hardhat 2.12.4 → 2.12.6
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.
- package/builtin-tasks/compile.js +11 -2
- package/builtin-tasks/compile.js.map +1 -1
- package/builtin-tasks/flatten.js +10 -4
- package/builtin-tasks/flatten.js.map +1 -1
- package/builtin-tasks/help.js +2 -4
- package/builtin-tasks/help.js.map +1 -1
- package/builtin-tasks/task-names.d.ts +1 -0
- package/builtin-tasks/task-names.d.ts.map +1 -1
- package/builtin-tasks/task-names.js +3 -2
- package/builtin-tasks/task-names.js.map +1 -1
- package/internal/artifacts.d.ts.map +1 -1
- package/internal/artifacts.js +6 -10
- package/internal/artifacts.js.map +1 -1
- package/internal/cli/cli.js +3 -8
- package/internal/cli/cli.js.map +1 -1
- package/internal/cli/project-creation.d.ts +0 -1
- package/internal/cli/project-creation.d.ts.map +1 -1
- package/internal/cli/project-creation.js +20 -16
- package/internal/cli/project-creation.js.map +1 -1
- package/internal/cli/prompt.d.ts +2 -2
- package/internal/cli/prompt.d.ts.map +1 -1
- package/internal/cli/prompt.js +1 -2
- package/internal/cli/prompt.js.map +1 -1
- package/internal/cli/types.d.ts +1 -0
- package/internal/cli/types.d.ts.map +1 -1
- package/internal/core/config/config-resolution.d.ts.map +1 -1
- package/internal/core/config/config-resolution.js +2 -1
- package/internal/core/config/config-resolution.js.map +1 -1
- package/internal/core/errors-list.d.ts +7 -0
- package/internal/core/errors-list.d.ts.map +1 -1
- package/internal/core/errors-list.js +84 -75
- package/internal/core/errors-list.js.map +1 -1
- package/internal/core/flamegraph.js +10 -10
- package/internal/core/providers/backwards-compatibility.d.ts.map +1 -1
- package/internal/core/providers/backwards-compatibility.js +3 -0
- package/internal/core/providers/backwards-compatibility.js.map +1 -1
- package/internal/core/providers/gas-providers.d.ts +1 -1
- package/internal/core/providers/gas-providers.d.ts.map +1 -1
- package/internal/core/providers/gas-providers.js +1 -1
- package/internal/core/providers/gas-providers.js.map +1 -1
- package/internal/core/providers/http.js +1 -1
- package/internal/core/providers/http.js.map +1 -1
- package/internal/core/runtime-environment.d.ts +1 -0
- package/internal/core/runtime-environment.d.ts.map +1 -1
- package/internal/core/runtime-environment.js +2 -0
- package/internal/core/runtime-environment.js.map +1 -1
- package/internal/hardhat-network/jsonrpc/client.d.ts.map +1 -1
- package/internal/hardhat-network/jsonrpc/client.js +5 -3
- package/internal/hardhat-network/jsonrpc/client.js.map +1 -1
- package/internal/hardhat-network/provider/modules/eth.js +4 -4
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js +4 -2
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js +4 -2
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js +4 -2
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js.map +1 -1
- package/internal/hardhat-network/provider/utils/makeFakeSignature.d.ts +7 -0
- package/internal/hardhat-network/provider/utils/makeFakeSignature.d.ts.map +1 -0
- package/internal/hardhat-network/provider/utils/makeFakeSignature.js +31 -0
- package/internal/hardhat-network/provider/utils/makeFakeSignature.js.map +1 -0
- package/internal/hardhat-network/stack-traces/error-inferrer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/error-inferrer.js +2 -5
- package/internal/hardhat-network/stack-traces/error-inferrer.js.map +1 -1
- package/internal/hardhat-network/stack-traces/solidity-errors.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/solidity-errors.js +2 -1
- package/internal/hardhat-network/stack-traces/solidity-errors.js.map +1 -1
- package/internal/solidity/dependencyGraph.d.ts.map +1 -1
- package/internal/solidity/dependencyGraph.js +2 -0
- package/internal/solidity/dependencyGraph.js.map +1 -1
- package/internal/solidity/resolver.d.ts +4 -3
- package/internal/solidity/resolver.d.ts.map +1 -1
- package/internal/solidity/resolver.js +18 -7
- package/internal/solidity/resolver.js.map +1 -1
- package/internal/util/console.d.ts.map +1 -1
- package/internal/util/console.js +1 -1
- package/internal/util/console.js.map +1 -1
- package/internal/util/download.d.ts +3 -1
- package/internal/util/download.d.ts.map +1 -1
- package/internal/util/download.js +3 -2
- package/internal/util/download.js.map +1 -1
- package/internal/util/packageInfo.d.ts +1 -1
- package/internal/util/packageInfo.d.ts.map +1 -1
- package/internal/util/packageInfo.js +4 -10
- package/internal/util/packageInfo.js.map +1 -1
- package/package.json +3 -3
- package/src/builtin-tasks/compile.ts +18 -5
- package/src/builtin-tasks/flatten.ts +18 -4
- package/src/builtin-tasks/help.ts +15 -16
- package/src/builtin-tasks/task-names.ts +2 -0
- package/src/internal/artifacts.ts +6 -15
- package/src/internal/cli/cli.ts +6 -12
- package/src/internal/cli/project-creation.ts +21 -21
- package/src/internal/cli/prompt.ts +2 -4
- package/src/internal/cli/types.ts +2 -0
- package/src/internal/core/config/config-resolution.ts +4 -3
- package/src/internal/core/errors-list.ts +85 -75
- package/src/internal/core/flamegraph.ts +10 -10
- package/src/internal/core/jsonrpc/types/output/metadata.ts +3 -3
- package/src/internal/core/providers/backwards-compatibility.ts +3 -0
- package/src/internal/core/providers/gas-providers.ts +1 -1
- package/src/internal/core/providers/http.ts +1 -1
- package/src/internal/core/runtime-environment.ts +3 -0
- package/src/internal/hardhat-network/jsonrpc/client.ts +7 -4
- package/src/internal/hardhat-network/provider/modules/eth.ts +4 -4
- package/src/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.ts +5 -2
- package/src/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.ts +5 -2
- package/src/internal/hardhat-network/provider/transactions/FakeSenderTransaction.ts +5 -2
- package/src/internal/hardhat-network/provider/utils/makeFakeSignature.ts +46 -0
- package/src/internal/hardhat-network/stack-traces/compiler-to-model.ts +2 -2
- package/src/internal/hardhat-network/stack-traces/error-inferrer.ts +2 -6
- package/src/internal/hardhat-network/stack-traces/solidity-errors.ts +3 -1
- package/src/internal/solidity/compiler/downloader.ts +1 -1
- package/src/internal/solidity/dependencyGraph.ts +2 -0
- package/src/internal/solidity/resolver.ts +28 -11
- package/src/internal/util/console.ts +4 -2
- package/src/internal/util/download.ts +4 -2
- package/src/internal/util/packageInfo.ts +9 -10
- package/src/types/artifacts.ts +1 -0
- package/src/types/runtime.ts +1 -0
- package/types/artifacts.d.ts +1 -0
- package/types/artifacts.d.ts.map +1 -1
- package/types/runtime.d.ts +1 -0
- package/types/runtime.d.ts.map +1 -1
|
@@ -10,5 +10,5 @@ export interface PackageJson {
|
|
|
10
10
|
export declare function findClosestPackageJson(file: string): string | null;
|
|
11
11
|
export declare function getPackageName(file: string): Promise<string>;
|
|
12
12
|
export declare function getPackageJson(): Promise<PackageJson>;
|
|
13
|
-
export declare function getHardhatVersion(): string
|
|
13
|
+
export declare function getHardhatVersion(): string;
|
|
14
14
|
//# sourceMappingURL=packageInfo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageInfo.d.ts","sourceRoot":"","sources":["../../src/internal/util/packageInfo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"packageInfo.d.ts","sourceRoot":"","sources":["../../src/internal/util/packageInfo.ts"],"names":[],"mappings":"AAMA,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAgB,cAAc,IAAI,MAAM,CAIvC;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAElE;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOlE;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC,CAG3D;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAU1C"}
|
|
@@ -7,6 +7,7 @@ exports.getHardhatVersion = exports.getPackageJson = exports.getPackageName = ex
|
|
|
7
7
|
const find_up_1 = __importDefault(require("find-up"));
|
|
8
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const errors_1 = require("../core/errors");
|
|
10
11
|
function getPackageJsonPath() {
|
|
11
12
|
return findClosestPackageJson(__filename);
|
|
12
13
|
}
|
|
@@ -36,16 +37,9 @@ async function getPackageJson() {
|
|
|
36
37
|
exports.getPackageJson = getPackageJson;
|
|
37
38
|
function getHardhatVersion() {
|
|
38
39
|
const packageJsonPath = findClosestPackageJson(__filename);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
try {
|
|
43
|
-
const packageJson = fs_extra_1.default.readJsonSync(packageJsonPath);
|
|
44
|
-
return packageJson.version;
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
40
|
+
(0, errors_1.assertHardhatInvariant)(packageJsonPath !== null, "There should be a package.json in hardhat-core's root directory");
|
|
41
|
+
const packageJson = fs_extra_1.default.readJsonSync(packageJsonPath);
|
|
42
|
+
return packageJson.version;
|
|
49
43
|
}
|
|
50
44
|
exports.getHardhatVersion = getHardhatVersion;
|
|
51
45
|
//# sourceMappingURL=packageInfo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageInfo.js","sourceRoot":"","sources":["../../src/internal/util/packageInfo.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA6B;AAC7B,wDAA+B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|
"name": "hardhat",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.6",
|
|
4
4
|
"author": "Nomic Labs LLC",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://hardhat.org",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@types/glob": "^7.1.1",
|
|
69
69
|
"@types/keccak": "^3.0.1",
|
|
70
70
|
"@types/lodash": "^4.14.123",
|
|
71
|
-
"@types/mocha": "
|
|
71
|
+
"@types/mocha": ">=9.1.0",
|
|
72
72
|
"@types/node": "^14.0.0",
|
|
73
73
|
"@types/qs": "^6.5.3",
|
|
74
74
|
"@types/resolve": "^1.17.1",
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
"source-map-support": "^0.5.13",
|
|
146
146
|
"stacktrace-parser": "^0.1.10",
|
|
147
147
|
"tsort": "0.0.1",
|
|
148
|
-
"undici": "^5.
|
|
148
|
+
"undici": "^5.14.0",
|
|
149
149
|
"uuid": "^8.3.2",
|
|
150
150
|
"ws": "^7.4.6"
|
|
151
151
|
},
|
|
@@ -73,6 +73,7 @@ import {
|
|
|
73
73
|
TASK_COMPILE_SOLIDITY_RUN_SOLC,
|
|
74
74
|
TASK_COMPILE_SOLIDITY_RUN_SOLCJS,
|
|
75
75
|
TASK_COMPILE_REMOVE_OBSOLETE_ARTIFACTS,
|
|
76
|
+
TASK_COMPILE_TRANSFORM_IMPORT_NAME,
|
|
76
77
|
} from "./task-names";
|
|
77
78
|
import {
|
|
78
79
|
getSolidityFilesCachePath,
|
|
@@ -157,6 +158,18 @@ subtask(TASK_COMPILE_SOLIDITY_READ_FILE)
|
|
|
157
158
|
}
|
|
158
159
|
);
|
|
159
160
|
|
|
161
|
+
/**
|
|
162
|
+
* This task transform the string literal in an import directive.
|
|
163
|
+
* By default it does nothing, but it can be overriden by plugins.
|
|
164
|
+
*/
|
|
165
|
+
subtask(TASK_COMPILE_TRANSFORM_IMPORT_NAME)
|
|
166
|
+
.addParam("importName", undefined, undefined, types.string)
|
|
167
|
+
.setAction(
|
|
168
|
+
async ({ importName }: { importName: string }): Promise<string> => {
|
|
169
|
+
return importName;
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
|
|
160
173
|
/**
|
|
161
174
|
* Receives a list of source names and returns a dependency graph. This task
|
|
162
175
|
* is responsible for both resolving dependencies (like getting files from
|
|
@@ -178,7 +191,9 @@ subtask(TASK_COMPILE_SOLIDITY_GET_DEPENDENCY_GRAPH)
|
|
|
178
191
|
config.paths.root,
|
|
179
192
|
parser,
|
|
180
193
|
(absolutePath: string) =>
|
|
181
|
-
run(TASK_COMPILE_SOLIDITY_READ_FILE, { absolutePath })
|
|
194
|
+
run(TASK_COMPILE_SOLIDITY_READ_FILE, { absolutePath }),
|
|
195
|
+
(importName: string) =>
|
|
196
|
+
run(TASK_COMPILE_TRANSFORM_IMPORT_NAME, { importName })
|
|
182
197
|
);
|
|
183
198
|
|
|
184
199
|
const resolvedFiles = await Promise.all(
|
|
@@ -748,7 +763,7 @@ subtask(TASK_COMPILE_SOLIDITY_LOG_COMPILATION_ERRORS)
|
|
|
748
763
|
}
|
|
749
764
|
}
|
|
750
765
|
|
|
751
|
-
const hasConsoleErrors = output.errors.some(isConsoleLogError);
|
|
766
|
+
const hasConsoleErrors: boolean = output.errors.some(isConsoleLogError);
|
|
752
767
|
if (hasConsoleErrors) {
|
|
753
768
|
console.error(
|
|
754
769
|
chalk.red(
|
|
@@ -1478,9 +1493,7 @@ function needsCompilation(
|
|
|
1478
1493
|
}
|
|
1479
1494
|
|
|
1480
1495
|
function hasCompilationErrors(output: any): boolean {
|
|
1481
|
-
return (
|
|
1482
|
-
output.errors && output.errors.some((x: any) => x.severity === "error")
|
|
1483
|
-
);
|
|
1496
|
+
return output.errors?.some((x: any) => x.severity === "error");
|
|
1484
1497
|
}
|
|
1485
1498
|
|
|
1486
1499
|
/**
|
|
@@ -19,12 +19,23 @@ function getSortedFiles(dependenciesGraph: DependencyGraph) {
|
|
|
19
19
|
const tsort = require("tsort");
|
|
20
20
|
const graph = tsort();
|
|
21
21
|
|
|
22
|
+
// sort the graph entries to make the results deterministic
|
|
23
|
+
const dependencies = dependenciesGraph
|
|
24
|
+
.entries()
|
|
25
|
+
.sort(([a], [b]) => a.sourceName.localeCompare(b.sourceName));
|
|
26
|
+
|
|
22
27
|
const filesMap: ResolvedFilesMap = {};
|
|
23
|
-
const resolvedFiles =
|
|
28
|
+
const resolvedFiles = dependencies.map(([file, _deps]) => file);
|
|
29
|
+
|
|
24
30
|
resolvedFiles.forEach((f) => (filesMap[f.sourceName] = f));
|
|
25
31
|
|
|
26
|
-
for (const [from, deps] of
|
|
27
|
-
|
|
32
|
+
for (const [from, deps] of dependencies) {
|
|
33
|
+
// sort the dependencies to make the results deterministic
|
|
34
|
+
const sortedDeps = [...deps].sort((a, b) =>
|
|
35
|
+
a.sourceName.localeCompare(b.sourceName)
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
for (const to of sortedDeps) {
|
|
28
39
|
graph.add(to.sourceName, from.sourceName);
|
|
29
40
|
}
|
|
30
41
|
}
|
|
@@ -113,7 +124,10 @@ subtask(TASK_FLATTEN_GET_DEPENDENCY_GRAPH)
|
|
|
113
124
|
return dependencyGraph;
|
|
114
125
|
});
|
|
115
126
|
|
|
116
|
-
task(
|
|
127
|
+
task(
|
|
128
|
+
TASK_FLATTEN,
|
|
129
|
+
"Flattens and prints contracts and their dependencies. If no file is passed, all the contracts in the project will be flattened."
|
|
130
|
+
)
|
|
117
131
|
.addOptionalVariadicPositionalParam(
|
|
118
132
|
"files",
|
|
119
133
|
"The files to flatten",
|
|
@@ -2,7 +2,6 @@ import { HelpPrinter } from "../internal/cli/HelpPrinter";
|
|
|
2
2
|
import { HARDHAT_EXECUTABLE_NAME, HARDHAT_NAME } from "../internal/constants";
|
|
3
3
|
import { task } from "../internal/core/config/config-env";
|
|
4
4
|
import { HARDHAT_PARAM_DEFINITIONS } from "../internal/core/params/hardhat-params";
|
|
5
|
-
import { getPackageJson } from "../internal/util/packageInfo";
|
|
6
5
|
|
|
7
6
|
import { TASK_HELP } from "./task-names";
|
|
8
7
|
|
|
@@ -11,21 +10,21 @@ task(TASK_HELP, "Prints this message")
|
|
|
11
10
|
"task",
|
|
12
11
|
"An optional task to print more info about"
|
|
13
12
|
)
|
|
14
|
-
.setAction(
|
|
15
|
-
|
|
13
|
+
.setAction(
|
|
14
|
+
async ({ task: taskName }: { task?: string }, { tasks, version }) => {
|
|
15
|
+
const helpPrinter = new HelpPrinter(
|
|
16
|
+
HARDHAT_NAME,
|
|
17
|
+
HARDHAT_EXECUTABLE_NAME,
|
|
18
|
+
version,
|
|
19
|
+
HARDHAT_PARAM_DEFINITIONS,
|
|
20
|
+
tasks
|
|
21
|
+
);
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
HARDHAT_PARAM_DEFINITIONS,
|
|
22
|
-
tasks
|
|
23
|
-
);
|
|
23
|
+
if (taskName !== undefined) {
|
|
24
|
+
helpPrinter.printTaskHelp(taskName);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
helpPrinter.printTaskHelp(taskName);
|
|
27
|
-
return;
|
|
28
|
+
helpPrinter.printGlobalHelp();
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
helpPrinter.printGlobalHelp();
|
|
31
|
-
});
|
|
30
|
+
);
|
|
@@ -12,6 +12,8 @@ export const TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS =
|
|
|
12
12
|
export const TASK_COMPILE_SOLIDITY_GET_SOURCE_NAMES =
|
|
13
13
|
"compile:solidity:get-source-names";
|
|
14
14
|
export const TASK_COMPILE_SOLIDITY_READ_FILE = "compile:solidity:read-file";
|
|
15
|
+
export const TASK_COMPILE_TRANSFORM_IMPORT_NAME =
|
|
16
|
+
"compile:solidity:transform-import-name";
|
|
15
17
|
export const TASK_COMPILE_SOLIDITY_GET_DEPENDENCY_GRAPH =
|
|
16
18
|
"compile:solidity:get-dependency-graph";
|
|
17
19
|
export const TASK_COMPILE_SOLIDITY_GET_COMPILATION_JOBS =
|
|
@@ -917,31 +917,22 @@ export function getArtifactFromContractOutput(
|
|
|
917
917
|
contractName: string,
|
|
918
918
|
contractOutput: any
|
|
919
919
|
): Artifact {
|
|
920
|
-
const evmBytecode = contractOutput.evm
|
|
921
|
-
let bytecode: string =
|
|
922
|
-
evmBytecode && evmBytecode.object ? evmBytecode.object : "";
|
|
920
|
+
const evmBytecode = contractOutput.evm?.bytecode;
|
|
921
|
+
let bytecode: string = evmBytecode?.object ?? "";
|
|
923
922
|
|
|
924
923
|
if (bytecode.slice(0, 2).toLowerCase() !== "0x") {
|
|
925
924
|
bytecode = `0x${bytecode}`;
|
|
926
925
|
}
|
|
927
926
|
|
|
928
|
-
const evmDeployedBytecode =
|
|
929
|
-
|
|
930
|
-
let deployedBytecode: string =
|
|
931
|
-
evmDeployedBytecode && evmDeployedBytecode.object
|
|
932
|
-
? evmDeployedBytecode.object
|
|
933
|
-
: "";
|
|
927
|
+
const evmDeployedBytecode = contractOutput.evm?.deployedBytecode;
|
|
928
|
+
let deployedBytecode: string = evmDeployedBytecode?.object ?? "";
|
|
934
929
|
|
|
935
930
|
if (deployedBytecode.slice(0, 2).toLowerCase() !== "0x") {
|
|
936
931
|
deployedBytecode = `0x${deployedBytecode}`;
|
|
937
932
|
}
|
|
938
933
|
|
|
939
|
-
const linkReferences =
|
|
940
|
-
|
|
941
|
-
const deployedLinkReferences =
|
|
942
|
-
evmDeployedBytecode && evmDeployedBytecode.linkReferences
|
|
943
|
-
? evmDeployedBytecode.linkReferences
|
|
944
|
-
: {};
|
|
934
|
+
const linkReferences = evmBytecode?.linkReferences ?? {};
|
|
935
|
+
const deployedLinkReferences = evmDeployedBytecode?.linkReferences ?? {};
|
|
945
936
|
|
|
946
937
|
return {
|
|
947
938
|
_format: ARTIFACT_FORMAT_VERSION,
|
package/src/internal/cli/cli.ts
CHANGED
|
@@ -39,7 +39,7 @@ import { saveFlamegraph } from "../core/flamegraph";
|
|
|
39
39
|
import { Analytics } from "./analytics";
|
|
40
40
|
import { ArgumentsParser } from "./ArgumentsParser";
|
|
41
41
|
import { enableEmoji } from "./emoji";
|
|
42
|
-
import { createProject
|
|
42
|
+
import { createProject } from "./project-creation";
|
|
43
43
|
import { confirmHHVSCodeInstallation, confirmTelemetryConsent } from "./prompt";
|
|
44
44
|
import {
|
|
45
45
|
InstallationState,
|
|
@@ -171,7 +171,11 @@ async function main() {
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
if (
|
|
174
|
+
if (
|
|
175
|
+
process.env.HARDHAT_EXPERIMENTAL_ALLOW_NON_LOCAL_INSTALLATION !==
|
|
176
|
+
"true" &&
|
|
177
|
+
!isHardhatInstalledLocallyOrLinked()
|
|
178
|
+
) {
|
|
175
179
|
throw new HardhatError(ERRORS.GENERAL.NON_LOCAL_INSTALLATION);
|
|
176
180
|
}
|
|
177
181
|
|
|
@@ -301,16 +305,6 @@ async function main() {
|
|
|
301
305
|
process.stdout.isTTY === true
|
|
302
306
|
) {
|
|
303
307
|
await suggestInstallingHardhatVscode();
|
|
304
|
-
|
|
305
|
-
// we show the solidity survey message if the tests failed and only
|
|
306
|
-
// 1/3 of the time
|
|
307
|
-
if (
|
|
308
|
-
process.exitCode !== 0 &&
|
|
309
|
-
Math.random() < 0.3333 &&
|
|
310
|
-
process.env.HARDHAT_HIDE_SOLIDITY_SURVEY_MESSAGE !== "true"
|
|
311
|
-
) {
|
|
312
|
-
showSoliditySurveyMessage();
|
|
313
|
-
}
|
|
314
308
|
}
|
|
315
309
|
|
|
316
310
|
log(`Killing Hardhat after successfully running task ${taskName}`);
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
confirmProjectCreation,
|
|
21
21
|
} from "./prompt";
|
|
22
22
|
import { emoji } from "./emoji";
|
|
23
|
-
import { Dependencies } from "./types";
|
|
23
|
+
import { Dependencies, PackageManager } from "./types";
|
|
24
24
|
|
|
25
25
|
enum Action {
|
|
26
26
|
CREATE_JAVASCRIPT_PROJECT_ACTION = "Create a JavaScript project",
|
|
@@ -60,7 +60,7 @@ const TYPESCRIPT_DEPENDENCIES: Dependencies = {};
|
|
|
60
60
|
|
|
61
61
|
const TYPESCRIPT_PEER_DEPENDENCIES: Dependencies = {
|
|
62
62
|
"@types/chai": "^4.2.0",
|
|
63
|
-
"@types/mocha": "
|
|
63
|
+
"@types/mocha": ">=9.1.0",
|
|
64
64
|
"@types/node": ">=12.0.0",
|
|
65
65
|
"ts-node": ">=8.0.0",
|
|
66
66
|
typescript: ">=4.5.0",
|
|
@@ -138,7 +138,7 @@ async function copySampleProject(
|
|
|
138
138
|
"this file already exists",
|
|
139
139
|
"these files already exist"
|
|
140
140
|
)}: ${existingFiles.join(", ")}
|
|
141
|
-
|
|
141
|
+
|
|
142
142
|
Please delete or move them and try again.`;
|
|
143
143
|
console.log(chalk.red(errorMsg));
|
|
144
144
|
process.exit(1);
|
|
@@ -252,20 +252,6 @@ function showStarOnGitHubMessage() {
|
|
|
252
252
|
console.log(chalk.cyan(" https://github.com/NomicFoundation/hardhat"));
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
export function showSoliditySurveyMessage() {
|
|
256
|
-
if (new Date() > new Date("2023-07-01 23:39")) {
|
|
257
|
-
// the survey has finished
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
console.log();
|
|
262
|
-
console.log(
|
|
263
|
-
chalk.cyan(
|
|
264
|
-
"Please take a moment to complete the 2022 Solidity Survey: https://hardhat.org/solidity-survey-2022"
|
|
265
|
-
)
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
255
|
export async function createProject() {
|
|
270
256
|
printAsciiLogo();
|
|
271
257
|
|
|
@@ -301,7 +287,6 @@ export async function createProject() {
|
|
|
301
287
|
|
|
302
288
|
console.log();
|
|
303
289
|
showStarOnGitHubMessage();
|
|
304
|
-
showSoliditySurveyMessage();
|
|
305
290
|
|
|
306
291
|
return;
|
|
307
292
|
}
|
|
@@ -372,7 +357,7 @@ export async function createProject() {
|
|
|
372
357
|
useDefaultPromptResponses ||
|
|
373
358
|
(await confirmRecommendedDepsInstallation(
|
|
374
359
|
dependenciesToInstall,
|
|
375
|
-
await
|
|
360
|
+
await getProjectPackageManager()
|
|
376
361
|
));
|
|
377
362
|
if (shouldInstall) {
|
|
378
363
|
const installed = await installRecommendedDependencies(
|
|
@@ -402,7 +387,6 @@ export async function createProject() {
|
|
|
402
387
|
console.log("See the README.md file for some example tasks you can run");
|
|
403
388
|
console.log();
|
|
404
389
|
showStarOnGitHubMessage();
|
|
405
|
-
showSoliditySurveyMessage();
|
|
406
390
|
}
|
|
407
391
|
|
|
408
392
|
async function canInstallRecommendedDeps() {
|
|
@@ -430,6 +414,16 @@ async function isYarnProject() {
|
|
|
430
414
|
return fsExtra.pathExists("yarn.lock");
|
|
431
415
|
}
|
|
432
416
|
|
|
417
|
+
async function isPnpmProject() {
|
|
418
|
+
return fsExtra.pathExists("pnpm-lock.yaml");
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
async function getProjectPackageManager(): Promise<PackageManager> {
|
|
422
|
+
if (await isYarnProject()) return "yarn";
|
|
423
|
+
if (await isPnpmProject()) return "pnpm";
|
|
424
|
+
return "npm";
|
|
425
|
+
}
|
|
426
|
+
|
|
433
427
|
async function doesNpmAutoInstallPeerDependencies() {
|
|
434
428
|
const { execSync } = require("child_process");
|
|
435
429
|
try {
|
|
@@ -496,6 +490,10 @@ async function getRecommendedDependenciesInstallationCommand(
|
|
|
496
490
|
return ["yarn", "add", "--dev", ...deps];
|
|
497
491
|
}
|
|
498
492
|
|
|
493
|
+
if (await isPnpmProject()) {
|
|
494
|
+
return ["pnpm", "add", "-D", ...deps];
|
|
495
|
+
}
|
|
496
|
+
|
|
499
497
|
return ["npm", "install", "--save-dev", ...deps];
|
|
500
498
|
}
|
|
501
499
|
|
|
@@ -503,7 +501,9 @@ async function getDependencies(
|
|
|
503
501
|
projectType: SampleProjectTypeCreationAction
|
|
504
502
|
): Promise<Dependencies> {
|
|
505
503
|
const shouldInstallPeerDependencies =
|
|
506
|
-
(await isYarnProject()) ||
|
|
504
|
+
(await isYarnProject()) ||
|
|
505
|
+
(await isPnpmProject()) ||
|
|
506
|
+
!(await doesNpmAutoInstallPeerDependencies());
|
|
507
507
|
|
|
508
508
|
const shouldInstallTypescriptDependencies =
|
|
509
509
|
projectType === Action.CREATE_TYPESCRIPT_PROJECT_ACTION;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dependencies } from "./types";
|
|
1
|
+
import { Dependencies, PackageManager } from "./types";
|
|
2
2
|
|
|
3
3
|
function createConfirmationPrompt(name: string, message: string) {
|
|
4
4
|
return {
|
|
@@ -36,7 +36,7 @@ function createConfirmationPrompt(name: string, message: string) {
|
|
|
36
36
|
|
|
37
37
|
export async function confirmRecommendedDepsInstallation(
|
|
38
38
|
depsToInstall: Dependencies,
|
|
39
|
-
|
|
39
|
+
packageManager: PackageManager
|
|
40
40
|
): Promise<boolean> {
|
|
41
41
|
const { default: enquirer } = await import("enquirer");
|
|
42
42
|
|
|
@@ -44,8 +44,6 @@ export async function confirmRecommendedDepsInstallation(
|
|
|
44
44
|
shouldInstallPlugin: boolean;
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
const packageManager = useYarn ? "yarn" : "npm";
|
|
48
|
-
|
|
49
47
|
try {
|
|
50
48
|
responses = await enquirer.prompt<typeof responses>([
|
|
51
49
|
createConfirmationPrompt(
|
|
@@ -408,9 +408,10 @@ function resolveCompiler(compiler: SolcUserConfig): SolcConfig {
|
|
|
408
408
|
}
|
|
409
409
|
|
|
410
410
|
for (const output of outputs) {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
411
|
+
const includesOutput: boolean =
|
|
412
|
+
resolved.settings.outputSelection[file][contract].includes(output);
|
|
413
|
+
|
|
414
|
+
if (!includesOutput) {
|
|
414
415
|
resolved.settings.outputSelection[file][contract].push(output);
|
|
415
416
|
}
|
|
416
417
|
}
|