From d6f26d9e00c2eb948cb7a210530cd3aa78ab26ba Mon Sep 17 00:00:00 2001 From: truefibot Date: Wed, 14 Jun 2023 10:35:00 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=A4=20Handle=20solc=20compiler=20downl?= =?UTF-8?q?oad=20manually=20on=20CI=20(#1363)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hardhat.config.ts | 25 +++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/hardhat.config.ts b/hardhat.config.ts index f5ee3d6..29763b5 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -8,6 +8,31 @@ import 'hardhat-gas-reporter' import mocharc from './.mocharc.json' import compiler from './.compiler.json' +import { subtask } from 'hardhat/internal/core/config/config-env' +import { TASK_COMPILE_SOLIDITY_GET_SOLC_BUILD } from 'hardhat/builtin-tasks/task-names' +import path from 'path' + +// eslint-disable-next-line turbo/no-undeclared-env-vars +const isCI = process.env.CI + +// Override for CI to use downloaded solc compiler +// Based on: https://github.com/NomicFoundation/hardhat/issues/1639#issuecomment-876291261 +subtask(TASK_COMPILE_SOLIDITY_GET_SOLC_BUILD, (args: any, hre: any, runSuper: any) => { + if (isCI && args.solcVersion === '0.8.16') { + const compilerPath = path.join(__dirname, '..', '..', '..', 'tools-cache', 'hardhat', 'solc-v0.8.16') + + return { + compilerPath, + isSolcJs: false, + version: args.solcVersion, + longVersion: '0.8.16', + } + } + + // we just use the default subtask if the version is not 0.8.5 + return runSuper() +}) + module.exports = { paths: { sources: './contracts', diff --git a/package.json b/package.json index e8a0a22..e190b85 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "ethereum-mars": "0.2.6-dev.eb75a27", "ethereum-waffle": "4.0.10", "ethers": "^5.7.1", - "hardhat": "^2.14.0", + "hardhat": "^2.15.0", "hardhat-gas-reporter": "^1.0.9", "hardhat-waffle-dev": "2.0.5-dev.ffdc567", "mocha": "^10.0.0",