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",