Skip to content

Commit

Permalink
Throw error for old solc versions
Browse files Browse the repository at this point in the history
  • Loading branch information
fvictorio committed Oct 29, 2021
1 parent 730353d commit 0e5419e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/hardhat-core/src/builtin-tasks/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ function isConsoleLogError(error: any): boolean {

const log = debug("hardhat:core:tasks:compile");

const COMPILE_TASK_FIRST_SOLC_VERSION_SUPPORTED = "0.4.11";

/**
* Returns a list of absolute paths to all the solidity files in the project.
* This list doesn't include dependencies, for example solidity files inside
Expand Down Expand Up @@ -643,6 +645,18 @@ subtask(TASK_COMPILE_SOLIDITY_COMPILE_SOLC)
},
{ run }
): Promise<{ output: CompilerOutput; solcBuild: SolcBuild }> => {
// versions older than 0.4.11 don't work with hardhat
// see issue https://github.com/nomiclabs/hardhat/issues/2004
if (semver.lt(solcVersion, COMPILE_TASK_FIRST_SOLC_VERSION_SUPPORTED)) {
throw new HardhatError(
ERRORS.BUILTIN_TASKS.COMPILE_TASK_UNSUPPORTED_SOLC_VERSION,
{
version: solcVersion,
firstSupportedVersion: COMPILE_TASK_FIRST_SOLC_VERSION_SUPPORTED,
}
);
}

const solcBuild: SolcBuild = await run(
TASK_COMPILE_SOLIDITY_GET_SOLC_BUILD,
{
Expand Down
10 changes: 10 additions & 0 deletions packages/hardhat-core/src/internal/core/errors-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,16 @@ To start the JSON-RPC server, retry the command without the --network parameter.
if the URL of the JSON-RPC wasn't set.`,
shouldBeReported: false,
},
COMPILE_TASK_UNSUPPORTED_SOLC_VERSION: {
number: 608,
message: `Version %version% is not supported by Hardhat.
The first supported version is %firstSupportedVersion%`,
title: "Unsupported solc version",
description: `This version of solidity is not supported by Hardhtat.
Please use a newer, supported version.`,
shouldBeReported: true,
},
},
ARTIFACTS: {
NOT_FOUND: {
Expand Down

0 comments on commit 0e5419e

Please sign in to comment.