|
|
|
@ -1,26 +1,29 @@ |
|
|
|
|
/// ENVVAR
|
|
|
|
|
// - CI: output gas report to file instead of stdout
|
|
|
|
|
// - COMPILE_VERSION: compiler version (default: 0.8.20)
|
|
|
|
|
// - SRC: contracts folder to compile (default: contracts)
|
|
|
|
|
// - COMPILE_MODE: production modes enables optimizations (default: development)
|
|
|
|
|
// - IR: enable IR compilation (default: false)
|
|
|
|
|
// - COVERAGE: enable coverage report
|
|
|
|
|
// - ENABLE_GAS_REPORT: enable gas report
|
|
|
|
|
// - COMPILE_MODE: production modes enables optimizations (default: development)
|
|
|
|
|
// - COMPILE_VERSION: compiler version (default: 0.8.20)
|
|
|
|
|
// - COINMARKETCAP: coinmarkercat api key for USD value in gas report
|
|
|
|
|
// - CI: output gas report to file instead of stdout
|
|
|
|
|
|
|
|
|
|
const fs = require('fs'); |
|
|
|
|
const path = require('path'); |
|
|
|
|
const proc = require('child_process'); |
|
|
|
|
|
|
|
|
|
const argv = require('yargs/yargs')() |
|
|
|
|
const { argv } = require('yargs/yargs')() |
|
|
|
|
.env('') |
|
|
|
|
.options({ |
|
|
|
|
coverage: { |
|
|
|
|
type: 'boolean', |
|
|
|
|
default: false, |
|
|
|
|
// Compilation settings
|
|
|
|
|
compiler: { |
|
|
|
|
alias: 'compileVersion', |
|
|
|
|
type: 'string', |
|
|
|
|
default: '0.8.20', |
|
|
|
|
}, |
|
|
|
|
gas: { |
|
|
|
|
alias: 'enableGasReport', |
|
|
|
|
type: 'boolean', |
|
|
|
|
default: false, |
|
|
|
|
src: { |
|
|
|
|
alias: 'source', |
|
|
|
|
type: 'string', |
|
|
|
|
default: 'contracts', |
|
|
|
|
}, |
|
|
|
|
mode: { |
|
|
|
|
alias: 'compileMode', |
|
|
|
@ -33,21 +36,21 @@ const argv = require('yargs/yargs')() |
|
|
|
|
type: 'boolean', |
|
|
|
|
default: false, |
|
|
|
|
}, |
|
|
|
|
foundry: { |
|
|
|
|
alias: 'hasFoundry', |
|
|
|
|
// Extra modules
|
|
|
|
|
coverage: { |
|
|
|
|
type: 'boolean', |
|
|
|
|
default: hasFoundry(), |
|
|
|
|
default: false, |
|
|
|
|
}, |
|
|
|
|
compiler: { |
|
|
|
|
alias: 'compileVersion', |
|
|
|
|
type: 'string', |
|
|
|
|
default: '0.8.20', |
|
|
|
|
gas: { |
|
|
|
|
alias: 'enableGasReport', |
|
|
|
|
type: 'boolean', |
|
|
|
|
default: false, |
|
|
|
|
}, |
|
|
|
|
coinmarketcap: { |
|
|
|
|
alias: 'coinmarketcapApiKey', |
|
|
|
|
type: 'string', |
|
|
|
|
}, |
|
|
|
|
}).argv; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
require('@nomicfoundation/hardhat-chai-matchers'); |
|
|
|
|
require('@nomicfoundation/hardhat-ethers'); |
|
|
|
@ -56,17 +59,13 @@ require('hardhat-gas-reporter'); |
|
|
|
|
require('hardhat-ignore-warnings'); |
|
|
|
|
require('solidity-coverage'); |
|
|
|
|
require('solidity-docgen'); |
|
|
|
|
argv.foundry && require('@nomicfoundation/hardhat-foundry'); |
|
|
|
|
|
|
|
|
|
if (argv.foundry && argv.coverage) { |
|
|
|
|
throw Error('Coverage analysis is incompatible with Foundry. Disable with `FOUNDRY=false` in the environment'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (const f of fs.readdirSync(path.join(__dirname, 'hardhat'))) { |
|
|
|
|
require(path.join(__dirname, 'hardhat', f)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const withOptimizations = argv.gas || argv.coverage || argv.compileMode === 'production'; |
|
|
|
|
const allowUnlimitedContractSize = argv.gas || argv.coverage || argv.compileMode === 'development'; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @type import('hardhat/config').HardhatUserConfig |
|
|
|
@ -96,7 +95,7 @@ module.exports = { |
|
|
|
|
}, |
|
|
|
|
networks: { |
|
|
|
|
hardhat: { |
|
|
|
|
allowUnlimitedContractSize: !withOptimizations, |
|
|
|
|
allowUnlimitedContractSize, |
|
|
|
|
initialBaseFeePerGas: argv.coverage ? 0 : undefined, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
@ -111,9 +110,8 @@ module.exports = { |
|
|
|
|
currency: 'USD', |
|
|
|
|
coinmarketcap: argv.coinmarketcap, |
|
|
|
|
}, |
|
|
|
|
paths: { |
|
|
|
|
sources: argv.src, |
|
|
|
|
}, |
|
|
|
|
docgen: require('./docs/config'), |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function hasFoundry() { |
|
|
|
|
return proc.spawnSync('forge', ['-V'], { stdio: 'ignore' }).error === undefined; |
|
|
|
|
} |
|
|
|
|