From be18c18205b64964512dae4daa7ff2bae9255d93 Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Thu, 11 Jan 2024 14:37:41 +0100 Subject: [PATCH] trying to fix gas report generation --- .github/workflows/checks.yml | 1 + hardhat.config.js | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 7a44045a11b..a603d9c78eb 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -30,6 +30,7 @@ jobs: env: FORCE_COLOR: 1 GAS: true + GAS_REPORT: gasReporterOutput.json steps: - uses: actions/checkout@v4 - name: Set up environment diff --git a/hardhat.config.js b/hardhat.config.js index dac13f5e0a4..11b08a9c129 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -55,11 +55,16 @@ const argv = require('yargs/yargs')() }, }).argv; +// implies doesn't work correcly. we force gas if gasReport is set +argv.gas ||= !!argv.gasReport + require('@nomicfoundation/hardhat-toolbox'); require('@nomicfoundation/hardhat-ethers'); require('hardhat-ignore-warnings'); require('hardhat-exposed'); require('solidity-docgen'); +argv.coverage && require('solidity-coverage'); +argv.gas && require('hardhat-gas-reporter'); argv.foundry && require('@nomicfoundation/hardhat-foundry'); if (argv.foundry && argv.coverage) { @@ -101,6 +106,7 @@ module.exports = { networks: { hardhat: { allowUnlimitedContractSize: !withOptimizations, + initialBaseFeePerGas: argv.coverage ? 0 : undefined, }, }, exposed: { @@ -108,23 +114,15 @@ module.exports = { initializers: true, exclude: ['vendor/**/*'], }, - docgen: require('./docs/config'), -}; - -if (argv.gas) { - require('hardhat-gas-reporter'); - module.exports.gasReporter = { + gasReporter: { + enabled: argv.gas, showMethodSig: true, currency: 'USD', outputFile: argv.gasReport, coinmarketcap: argv.coinmarketcap, - }; -} - -if (argv.coverage) { - require('solidity-coverage'); - module.exports.networks.hardhat.initialBaseFeePerGas = 0; -} + }, + docgen: require('./docs/config'), +}; function hasFoundry() { return proc.spawnSync('forge', ['-V'], { stdio: 'ignore' }).error === undefined;