hardhat 2.12.5 → 2.12.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.
- package/builtin-tasks/compile.js +10 -1
- package/builtin-tasks/compile.js.map +1 -1
- package/builtin-tasks/flatten.js +1 -1
- 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/cli/cli.js +0 -7
- 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 +19 -15
- 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-loading.d.ts.map +1 -1
- package/internal/core/config/config-loading.js +1 -0
- package/internal/core/config/config-loading.js.map +1 -1
- package/internal/core/config/config-validation.d.ts +2 -0
- package/internal/core/config/config-validation.d.ts.map +1 -1
- package/internal/core/config/config-validation.js +18 -1
- package/internal/core/config/config-validation.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 +9 -0
- package/internal/core/errors-list.js.map +1 -1
- package/internal/core/providers/construction.d.ts.map +1 -1
- package/internal/core/providers/construction.js +25 -5
- package/internal/core/providers/construction.js.map +1 -1
- package/internal/core/providers/http.d.ts +2 -2
- package/internal/core/providers/http.d.ts.map +1 -1
- package/internal/core/providers/http.js +29 -5
- 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/handler.d.ts +1 -0
- package/internal/hardhat-network/jsonrpc/handler.d.ts.map +1 -1
- package/internal/hardhat-network/jsonrpc/handler.js +13 -18
- package/internal/hardhat-network/jsonrpc/handler.js.map +1 -1
- package/internal/hardhat-network/provider/modules/evm.d.ts +2 -1
- package/internal/hardhat-network/provider/modules/evm.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/evm.js +10 -4
- package/internal/hardhat-network/provider/modules/evm.js.map +1 -1
- package/internal/hardhat-network/provider/node-types.d.ts +1 -1
- package/internal/hardhat-network/provider/node-types.d.ts.map +1 -1
- package/internal/hardhat-network/provider/node.d.ts +1 -0
- package/internal/hardhat-network/provider/node.d.ts.map +1 -1
- package/internal/hardhat-network/provider/node.js +6 -4
- package/internal/hardhat-network/provider/node.js.map +1 -1
- package/internal/hardhat-network/provider/provider.d.ts +25 -21
- package/internal/hardhat-network/provider/provider.d.ts.map +1 -1
- package/internal/hardhat-network/provider/provider.js +25 -42
- package/internal/hardhat-network/provider/provider.js.map +1 -1
- 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/provider/utils/putGenesisBlock.d.ts +1 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.js +2 -2
- package/internal/hardhat-network/provider/utils/putGenesisBlock.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/download.d.ts.map +1 -1
- package/internal/util/download.js +13 -10
- 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/internal/util/proxy.d.ts +2 -0
- package/internal/util/proxy.d.ts.map +1 -0
- package/internal/util/proxy.js +19 -0
- package/internal/util/proxy.js.map +1 -0
- package/package.json +3 -4
- package/src/builtin-tasks/compile.ts +16 -1
- package/src/builtin-tasks/flatten.ts +4 -1
- package/src/builtin-tasks/help.ts +15 -16
- package/src/builtin-tasks/task-names.ts +2 -0
- package/src/internal/cli/cli.ts +1 -11
- package/src/internal/cli/project-creation.ts +20 -20
- package/src/internal/cli/prompt.ts +2 -4
- package/src/internal/cli/types.ts +2 -0
- package/src/internal/core/config/config-loading.ts +3 -1
- package/src/internal/core/config/config-validation.ts +20 -0
- package/src/internal/core/errors-list.ts +10 -0
- package/src/internal/core/providers/construction.ts +29 -24
- package/src/internal/core/providers/http.ts +17 -11
- package/src/internal/core/runtime-environment.ts +3 -0
- package/src/internal/hardhat-network/jsonrpc/handler.ts +31 -28
- package/src/internal/hardhat-network/provider/modules/evm.ts +15 -3
- package/src/internal/hardhat-network/provider/node-types.ts +1 -1
- package/src/internal/hardhat-network/provider/node.ts +5 -1
- package/src/internal/hardhat-network/provider/provider.ts +60 -49
- 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/provider/utils/putGenesisBlock.ts +2 -2
- package/src/internal/solidity/resolver.ts +28 -11
- package/src/internal/util/download.ts +13 -12
- package/src/internal/util/packageInfo.ts +9 -10
- package/src/internal/util/proxy.ts +18 -0
- package/src/types/artifacts.ts +1 -0
- package/src/types/config.ts +2 -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/config.d.ts +2 -0
- package/types/config.d.ts.map +1 -1
- package/types/runtime.d.ts +1 -0
- package/types/runtime.d.ts.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.js","sourceRoot":"","sources":["../../src/internal/util/download.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"download.js","sourceRoot":"","sources":["../../src/internal/util/download.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAEA,4CAAoB;AACpB,wDAA+B;AAC/B,gDAAwB;AACxB,gDAAwB;AAExB,+CAAkD;AAClD,mCAAyC;AAEzC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEhC,SAAS,mBAAmB,CAAC,QAAgB;IAC3C,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,cAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEhD,OAAO,cAAI,CAAC,MAAM,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,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAE,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC,CAAC;QACvE,OAAO,kBAAO,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;KACjE;SAAM;QACL,oEAAoE;QACpE,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;KAC5B;IAED,gFAAgF;IAChF,MAAM,IAAI,KAAK,CACb,sBAAsB,GAAG,MACvB,QAAQ,CAAC,UACX,cAAc,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAC3C,CAAC;AACJ,CAAC;AAhDD,4BAgDC"}
|
|
@@ -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;AAC/B,gDAAwB;AAExB,SAAgB,kBAAkB;IAChC,OAAO,sBAAsB,CAAC,UA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C,GAAG,EAAE,MAAM,GAAG,OAAO,CAiBnD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shouldUseProxy = void 0;
|
|
4
|
+
function shouldUseProxy(url) {
|
|
5
|
+
const { hostname } = new URL(url);
|
|
6
|
+
const noProxy = process.env.NO_PROXY;
|
|
7
|
+
if (hostname === "localhost" || hostname === "127.0.0.1" || noProxy === "*") {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
if (noProxy !== undefined && noProxy !== "") {
|
|
11
|
+
const noProxyList = noProxy.split(",");
|
|
12
|
+
if (noProxyList.includes(hostname)) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
exports.shouldUseProxy = shouldUseProxy;
|
|
19
|
+
//# sourceMappingURL=proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/internal/util/proxy.ts"],"names":[],"mappings":";;;AAAA,SAAgB,cAAc,CAAC,GAAW;IACxC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;IAErC,IAAI,QAAQ,KAAK,WAAW,IAAI,QAAQ,KAAK,WAAW,IAAI,OAAO,KAAK,GAAG,EAAE;QAC3E,OAAO,KAAK,CAAC;KACd;IAED,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,EAAE,EAAE;QAC3C,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEvC,IAAI,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAClC,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAjBD,wCAiBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hardhat",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.7",
|
|
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",
|
|
@@ -90,7 +90,6 @@
|
|
|
90
90
|
"ethers": "^5.0.0",
|
|
91
91
|
"mocha": "^10.0.0",
|
|
92
92
|
"prettier": "2.4.1",
|
|
93
|
-
"proxy": "^1.0.2",
|
|
94
93
|
"rimraf": "^3.0.2",
|
|
95
94
|
"sinon": "^9.0.0",
|
|
96
95
|
"time-require": "^0.1.2",
|
|
@@ -145,7 +144,7 @@
|
|
|
145
144
|
"source-map-support": "^0.5.13",
|
|
146
145
|
"stacktrace-parser": "^0.1.10",
|
|
147
146
|
"tsort": "0.0.1",
|
|
148
|
-
"undici": "^5.
|
|
147
|
+
"undici": "^5.14.0",
|
|
149
148
|
"uuid": "^8.3.2",
|
|
150
149
|
"ws": "^7.4.6"
|
|
151
150
|
},
|
|
@@ -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(
|
|
@@ -124,7 +124,10 @@ subtask(TASK_FLATTEN_GET_DEPENDENCY_GRAPH)
|
|
|
124
124
|
return dependencyGraph;
|
|
125
125
|
});
|
|
126
126
|
|
|
127
|
-
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
|
+
)
|
|
128
131
|
.addOptionalVariadicPositionalParam(
|
|
129
132
|
"files",
|
|
130
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 =
|
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,
|
|
@@ -305,16 +305,6 @@ async function main() {
|
|
|
305
305
|
process.stdout.isTTY === true
|
|
306
306
|
) {
|
|
307
307
|
await suggestInstallingHardhatVscode();
|
|
308
|
-
|
|
309
|
-
// we show the solidity survey message if the tests failed and only
|
|
310
|
-
// 1/3 of the time
|
|
311
|
-
if (
|
|
312
|
-
process.exitCode !== 0 &&
|
|
313
|
-
Math.random() < 0.3333 &&
|
|
314
|
-
process.env.HARDHAT_HIDE_SOLIDITY_SURVEY_MESSAGE !== "true"
|
|
315
|
-
) {
|
|
316
|
-
showSoliditySurveyMessage();
|
|
317
|
-
}
|
|
318
308
|
}
|
|
319
309
|
|
|
320
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",
|
|
@@ -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(
|
|
@@ -19,7 +19,7 @@ import { getUserConfigPath } from "../project-structure";
|
|
|
19
19
|
|
|
20
20
|
import { SUPPORTED_SOLIDITY_VERSION_RANGE } from "../../hardhat-network/stack-traces/constants";
|
|
21
21
|
import { resolveConfig } from "./config-resolution";
|
|
22
|
-
import { validateConfig } from "./config-validation";
|
|
22
|
+
import { validateConfig, validateResolvedConfig } from "./config-validation";
|
|
23
23
|
import { DEFAULT_SOLC_VERSION } from "./default-config";
|
|
24
24
|
|
|
25
25
|
const log = debug("hardhat:core:config");
|
|
@@ -108,6 +108,8 @@ export function loadConfigAndTasks(
|
|
|
108
108
|
extender(resolved, frozenUserConfig);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
validateResolvedConfig(resolved);
|
|
112
|
+
|
|
111
113
|
if (showSolidityConfigWarnings) {
|
|
112
114
|
checkUnsupportedSolidityConfig(resolved);
|
|
113
115
|
checkUnsupportedRemappings(resolved);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { HardhatConfig as HardhatConfigT } from "../../../types";
|
|
2
|
+
|
|
1
3
|
import * as t from "io-ts";
|
|
2
4
|
import { Context, getFunctionName, ValidationError } from "io-ts/lib";
|
|
3
5
|
import { Reporter } from "io-ts/lib/Reporter";
|
|
@@ -573,3 +575,21 @@ export function getValidationErrors(config: any): string[] {
|
|
|
573
575
|
const ioTsErrors = DotPathReporter.report(result);
|
|
574
576
|
return [...errors, ...ioTsErrors];
|
|
575
577
|
}
|
|
578
|
+
|
|
579
|
+
export function validateResolvedConfig(resolvedConfig: HardhatConfigT) {
|
|
580
|
+
const solcConfigs = [
|
|
581
|
+
...resolvedConfig.solidity.compilers,
|
|
582
|
+
...Object.values(resolvedConfig.solidity.overrides),
|
|
583
|
+
];
|
|
584
|
+
const runs = solcConfigs
|
|
585
|
+
.filter(({ settings }) => settings?.optimizer?.runs !== undefined)
|
|
586
|
+
.map(({ settings }) => settings?.optimizer?.runs);
|
|
587
|
+
|
|
588
|
+
for (const run of runs) {
|
|
589
|
+
if (run >= 2 ** 32) {
|
|
590
|
+
throw new HardhatError(ERRORS.GENERAL.INVALID_CONFIG, {
|
|
591
|
+
errors: "The number of optimizer runs exceeds the maximum of 2**32 - 1",
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}
|
|
@@ -819,6 +819,16 @@ Try installing the library using npm.`,
|
|
|
819
819
|
Use a relative import instead of referencing the package's name.`,
|
|
820
820
|
shouldBeReported: false,
|
|
821
821
|
},
|
|
822
|
+
IMPORTED_MAPPED_FILE_NOT_FOUND: {
|
|
823
|
+
number: 413,
|
|
824
|
+
message:
|
|
825
|
+
"File %importName% => %imported%, imported from %from%, not found.",
|
|
826
|
+
title: "Imported mapped file not found",
|
|
827
|
+
description: `One of your source files imported a nonexistent or not installed file.
|
|
828
|
+
|
|
829
|
+
Please double check your imports and installed libraries.`,
|
|
830
|
+
shouldBeReported: false,
|
|
831
|
+
},
|
|
822
832
|
},
|
|
823
833
|
SOLC: {
|
|
824
834
|
INVALID_VERSION: {
|
|
@@ -86,31 +86,36 @@ export function createProvider(
|
|
|
86
86
|
require("../../hardhat-network/provider/utils/disk-cache") as typeof DiskCacheT;
|
|
87
87
|
|
|
88
88
|
eip1193Provider = new HardhatNetworkProvider(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
89
|
+
{
|
|
90
|
+
chainId: hardhatNetConfig.chainId,
|
|
91
|
+
networkId: hardhatNetConfig.chainId,
|
|
92
|
+
hardfork: hardhatNetConfig.hardfork,
|
|
93
|
+
blockGasLimit: hardhatNetConfig.blockGasLimit,
|
|
94
|
+
initialBaseFeePerGas: hardhatNetConfig.initialBaseFeePerGas,
|
|
95
|
+
minGasPrice: hardhatNetConfig.minGasPrice,
|
|
96
|
+
throwOnTransactionFailures: hardhatNetConfig.throwOnTransactionFailures,
|
|
97
|
+
throwOnCallFailures: hardhatNetConfig.throwOnCallFailures,
|
|
98
|
+
automine: hardhatNetConfig.mining.auto,
|
|
99
|
+
intervalMining: hardhatNetConfig.mining.interval,
|
|
100
|
+
// This cast is valid because of the config validation and resolution
|
|
101
|
+
mempoolOrder: hardhatNetConfig.mining.mempool.order as MempoolOrder,
|
|
102
|
+
chains: hardhatNetConfig.chains,
|
|
103
|
+
coinbase: hardhatNetConfig.coinbase,
|
|
104
|
+
genesisAccounts: accounts,
|
|
105
|
+
allowUnlimitedContractSize: hardhatNetConfig.allowUnlimitedContractSize,
|
|
106
|
+
allowBlocksWithSameTimestamp:
|
|
107
|
+
hardhatNetConfig.allowBlocksWithSameTimestamp ?? false,
|
|
108
|
+
initialDate:
|
|
109
|
+
hardhatNetConfig.initialDate !== undefined
|
|
110
|
+
? parseDateString(hardhatNetConfig.initialDate)
|
|
111
|
+
: undefined,
|
|
112
|
+
experimentalHardhatNetworkMessageTraceHooks,
|
|
113
|
+
forkConfig,
|
|
114
|
+
forkCachePath:
|
|
115
|
+
paths !== undefined ? getForkCacheDirPath(paths) : undefined,
|
|
116
|
+
},
|
|
103
117
|
new ModulesLogger(hardhatNetConfig.loggingEnabled),
|
|
104
|
-
|
|
105
|
-
artifacts,
|
|
106
|
-
hardhatNetConfig.allowUnlimitedContractSize,
|
|
107
|
-
hardhatNetConfig.initialDate !== undefined
|
|
108
|
-
? parseDateString(hardhatNetConfig.initialDate)
|
|
109
|
-
: undefined,
|
|
110
|
-
experimentalHardhatNetworkMessageTraceHooks,
|
|
111
|
-
forkConfig,
|
|
112
|
-
paths !== undefined ? getForkCacheDirPath(paths) : undefined,
|
|
113
|
-
hardhatNetConfig.coinbase
|
|
118
|
+
artifacts
|
|
114
119
|
);
|
|
115
120
|
} else {
|
|
116
121
|
const HttpProvider = importProvider<
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as Undici from "undici";
|
|
2
2
|
|
|
3
3
|
import { EventEmitter } from "events";
|
|
4
4
|
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import { getHardhatVersion } from "../../util/packageInfo";
|
|
18
18
|
import { HardhatError } from "../errors";
|
|
19
19
|
import { ERRORS } from "../errors-list";
|
|
20
|
+
import { shouldUseProxy } from "../../util/proxy";
|
|
20
21
|
|
|
21
22
|
import { ProviderError } from "./errors";
|
|
22
23
|
|
|
@@ -33,7 +34,7 @@ const hardhatVersion = getHardhatVersion();
|
|
|
33
34
|
|
|
34
35
|
export class HttpProvider extends EventEmitter implements EIP1193Provider {
|
|
35
36
|
private _nextRequestId = 1;
|
|
36
|
-
private _dispatcher: Dispatcher;
|
|
37
|
+
private _dispatcher: Undici.Dispatcher;
|
|
37
38
|
private _path: string;
|
|
38
39
|
private _authHeader: string | undefined;
|
|
39
40
|
|
|
@@ -42,11 +43,11 @@ export class HttpProvider extends EventEmitter implements EIP1193Provider {
|
|
|
42
43
|
private readonly _networkName: string,
|
|
43
44
|
private readonly _extraHeaders: { [name: string]: string } = {},
|
|
44
45
|
private readonly _timeout = 20000,
|
|
45
|
-
client: Dispatcher | undefined = undefined
|
|
46
|
+
client: Undici.Dispatcher | undefined = undefined
|
|
46
47
|
) {
|
|
47
48
|
super();
|
|
48
49
|
|
|
49
|
-
const { Pool } = require("undici") as
|
|
50
|
+
const { Pool, ProxyAgent } = require("undici") as typeof Undici;
|
|
50
51
|
|
|
51
52
|
const url = new URL(this._url);
|
|
52
53
|
this._path = url.pathname;
|
|
@@ -59,6 +60,10 @@ export class HttpProvider extends EventEmitter implements EIP1193Provider {
|
|
|
59
60
|
).toString("base64")}`;
|
|
60
61
|
try {
|
|
61
62
|
this._dispatcher = client ?? new Pool(url.origin);
|
|
63
|
+
|
|
64
|
+
if (process.env.http_proxy !== undefined && shouldUseProxy(url.origin)) {
|
|
65
|
+
this._dispatcher = new ProxyAgent(process.env.http_proxy);
|
|
66
|
+
}
|
|
62
67
|
} catch (e) {
|
|
63
68
|
if (e instanceof TypeError && e.message === "Invalid URL") {
|
|
64
69
|
e.message += ` ${url.origin}`;
|
|
@@ -163,10 +168,13 @@ export class HttpProvider extends EventEmitter implements EIP1193Provider {
|
|
|
163
168
|
request: JsonRpcRequest | JsonRpcRequest[],
|
|
164
169
|
retryNumber = 0
|
|
165
170
|
): Promise<JsonRpcResponse | JsonRpcResponse[]> {
|
|
171
|
+
const { request: sendRequest } = await import("undici");
|
|
172
|
+
const url = new URL(this._url);
|
|
173
|
+
|
|
166
174
|
try {
|
|
167
|
-
const response = await
|
|
175
|
+
const response = await sendRequest(url, {
|
|
176
|
+
dispatcher: this._dispatcher,
|
|
168
177
|
method: "POST",
|
|
169
|
-
path: this._path,
|
|
170
178
|
body: JSON.stringify(request),
|
|
171
179
|
maxRedirections: 10,
|
|
172
180
|
headersTimeout:
|
|
@@ -175,7 +183,7 @@ export class HttpProvider extends EventEmitter implements EIP1193Provider {
|
|
|
175
183
|
: this._timeout,
|
|
176
184
|
headers: {
|
|
177
185
|
"Content-Type": "application/json",
|
|
178
|
-
"User-Agent": `hardhat ${hardhatVersion
|
|
186
|
+
"User-Agent": `hardhat ${hardhatVersion}`,
|
|
179
187
|
Authorization: this._authHeader,
|
|
180
188
|
...this._extraHeaders,
|
|
181
189
|
},
|
|
@@ -194,8 +202,6 @@ export class HttpProvider extends EventEmitter implements EIP1193Provider {
|
|
|
194
202
|
return await this._retry(request, seconds, retryNumber);
|
|
195
203
|
}
|
|
196
204
|
|
|
197
|
-
const url = new URL(this._url);
|
|
198
|
-
|
|
199
205
|
// eslint-disable-next-line @nomiclabs/hardhat-internal-rules/only-hardhat-error
|
|
200
206
|
throw new ProviderError(
|
|
201
207
|
`Too Many Requests error received from ${url.hostname}`,
|
|
@@ -255,12 +261,12 @@ export class HttpProvider extends EventEmitter implements EIP1193Provider {
|
|
|
255
261
|
return true;
|
|
256
262
|
}
|
|
257
263
|
|
|
258
|
-
private _isRateLimitResponse(response: Dispatcher.ResponseData) {
|
|
264
|
+
private _isRateLimitResponse(response: Undici.Dispatcher.ResponseData) {
|
|
259
265
|
return response.statusCode === TOO_MANY_REQUEST_STATUS;
|
|
260
266
|
}
|
|
261
267
|
|
|
262
268
|
private _getRetryAfterSeconds(
|
|
263
|
-
response: Dispatcher.ResponseData
|
|
269
|
+
response: Undici.Dispatcher.ResponseData
|
|
264
270
|
): number | undefined {
|
|
265
271
|
const header = response.headers["retry-after"];
|
|
266
272
|
|
|
@@ -20,6 +20,7 @@ import { Artifacts } from "../artifacts";
|
|
|
20
20
|
import { MessageTrace } from "../hardhat-network/stack-traces/message-trace";
|
|
21
21
|
import { lazyObject } from "../util/lazy";
|
|
22
22
|
|
|
23
|
+
import { getHardhatVersion } from "../util/packageInfo";
|
|
23
24
|
import { analyzeModuleNotFoundError } from "./config/config-loading";
|
|
24
25
|
import { HardhatError } from "./errors";
|
|
25
26
|
import { ERRORS } from "./errors-list";
|
|
@@ -50,6 +51,8 @@ export class Environment implements HardhatRuntimeEnvironment {
|
|
|
50
51
|
|
|
51
52
|
public entryTaskProfile?: TaskProfile;
|
|
52
53
|
|
|
54
|
+
public version: string = getHardhatVersion();
|
|
55
|
+
|
|
53
56
|
/**
|
|
54
57
|
* Initializes the Hardhat Runtime Environment and the given
|
|
55
58
|
* extender functions.
|