Improve Hardhat config (#2612)
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
This commit is contained in:
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -28,7 +28,7 @@ jobs:
|
|||||||
- run: npm run test
|
- run: npm run test
|
||||||
env:
|
env:
|
||||||
FORCE_COLOR: 1
|
FORCE_COLOR: 1
|
||||||
ENABLE_GAS_REPORT: 1
|
ENABLE_GAS_REPORT: true
|
||||||
- name: Print gas report
|
- name: Print gas report
|
||||||
run: cat gas-report.txt
|
run: cat gas-report.txt
|
||||||
|
|
||||||
|
|||||||
@ -1,27 +1,38 @@
|
|||||||
|
/// ENVVAR
|
||||||
|
// - ENABLE_GAS_REPORT
|
||||||
|
// - CI
|
||||||
|
// - COMPILE_MODE
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const argv = require('yargs/yargs')()
|
||||||
|
.env('')
|
||||||
|
.boolean('enableGasReport')
|
||||||
|
.boolean('ci')
|
||||||
|
.string('compileMode')
|
||||||
|
.argv;
|
||||||
|
|
||||||
require('@nomiclabs/hardhat-truffle5');
|
require('@nomiclabs/hardhat-truffle5');
|
||||||
require('@nomiclabs/hardhat-solhint');
|
require('@nomiclabs/hardhat-solhint');
|
||||||
require('solidity-coverage');
|
require('solidity-coverage');
|
||||||
require('hardhat-gas-reporter');
|
|
||||||
|
if (argv.enableGasReport) {
|
||||||
|
require('hardhat-gas-reporter');
|
||||||
|
}
|
||||||
|
|
||||||
for (const f of fs.readdirSync(path.join(__dirname, 'hardhat'))) {
|
for (const f of fs.readdirSync(path.join(__dirname, 'hardhat'))) {
|
||||||
require(path.join(__dirname, 'hardhat', f));
|
require(path.join(__dirname, 'hardhat', f));
|
||||||
}
|
}
|
||||||
|
|
||||||
const enableGasReport = !!process.env.ENABLE_GAS_REPORT;
|
|
||||||
const enableProduction = process.env.COMPILE_MODE === 'production';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type import('hardhat/config').HardhatUserConfig
|
* @type import('hardhat/config').HardhatUserConfig
|
||||||
*/
|
*/
|
||||||
module.exports = {
|
module.exports = {
|
||||||
solidity: {
|
solidity: {
|
||||||
version: '0.8.0',
|
version: '0.8.3',
|
||||||
settings: {
|
settings: {
|
||||||
optimizer: {
|
optimizer: {
|
||||||
enabled: enableGasReport || enableProduction,
|
enabled: argv.enableGasReport || argv.compileMode === 'production',
|
||||||
runs: 200,
|
runs: 200,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -32,8 +43,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
gasReporter: {
|
gasReporter: {
|
||||||
enable: enableGasReport,
|
|
||||||
currency: 'USD',
|
currency: 'USD',
|
||||||
outputFile: process.env.CI ? 'gas-report.txt' : undefined,
|
outputFile: argv.ci ? 'gas-report.txt' : undefined,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
1953
package-lock.json
generated
1953
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -27,7 +27,7 @@
|
|||||||
"release": "scripts/release/release.sh",
|
"release": "scripts/release/release.sh",
|
||||||
"version": "scripts/release/version.sh",
|
"version": "scripts/release/version.sh",
|
||||||
"test": "hardhat test",
|
"test": "hardhat test",
|
||||||
"gas-report": "env ENABLE_GAS_REPORT=1 npm run test"
|
"gas-report": "env ENABLE_GAS_REPORT=true npm run test"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -76,6 +76,7 @@
|
|||||||
"solhint": "^3.2.0",
|
"solhint": "^3.2.0",
|
||||||
"solidity-coverage": "^0.7.11",
|
"solidity-coverage": "^0.7.11",
|
||||||
"solidity-docgen": "^0.5.3",
|
"solidity-docgen": "^0.5.3",
|
||||||
"web3": "^1.3.0"
|
"web3": "^1.3.0",
|
||||||
|
"yargs": "^16.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user