Skip to content

Commit 6a3b5ea

Browse files
address PR comments
1 parent 66533d5 commit 6a3b5ea

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

packages/hardhat-core/src/builtin-tasks/compile.ts

+9
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ subtask(TASK_COMPILE_SOLIDITY_RUN_SOLCJS)
674674
subtask(TASK_COMPILE_SOLIDITY_RUN_SOLC)
675675
.addParam("input", undefined, undefined, types.any)
676676
.addParam("solcPath", undefined, undefined, types.string)
677+
.addOptionalParam("solcVersion", undefined, undefined, types.string)
677678
.setAction(
678679
async ({
679680
input,
@@ -684,6 +685,14 @@ subtask(TASK_COMPILE_SOLIDITY_RUN_SOLC)
684685
solcPath: string;
685686
solcVersion?: string;
686687
}) => {
688+
if (solcVersion !== undefined && semver.parse(solcVersion) === null) {
689+
throw new HardhatError(ERRORS.ARGUMENTS.INVALID_VALUE_FOR_TYPE, {
690+
value: solcVersion,
691+
name: "solcVersion",
692+
type: "string",
693+
});
694+
}
695+
687696
const compiler = new NativeCompiler(solcPath, solcVersion);
688697

689698
return compiler.compile(input);

packages/hardhat-core/src/internal/solidity/compiler/index.ts

-8
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,6 @@ export class NativeCompiler implements ICompiler {
7979
// Logic to make sure that solc default import callback is not being used.
8080
// If solcVersion is not defined or <= 0.6.8, do not add extra args.
8181
if (this._solcVersion !== undefined) {
82-
if (semver.parse(this._solcVersion) === null) {
83-
throw new HardhatError(ERRORS.ARGUMENTS.INVALID_VALUE_FOR_TYPE, {
84-
value: this._solcVersion,
85-
name: "_solcVersion",
86-
type: "string",
87-
});
88-
}
89-
9082
if (semver.gte(this._solcVersion, "0.8.22")) {
9183
// version >= 0.8.22
9284
args.push("--no-import-callback");

0 commit comments

Comments
 (0)