hardhat-contract-sizer
Advanced tools
Comparing version
{ | ||
"name": "hardhat-contract-sizer", | ||
"version": "2.6.1", | ||
"version": "2.7.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Output Solidity contract sizes with Hardhat", |
@@ -10,2 +10,4 @@ # Hardhat Contract Sizer | ||
```bash | ||
npm install --save-dev hardhat-contract-sizer | ||
# or | ||
yarn add --dev hardhat-contract-sizer | ||
@@ -46,2 +48,4 @@ ``` | ||
```bash | ||
npx hardhat size-contracts | ||
# or | ||
yarn run hardhat size-contracts | ||
@@ -53,3 +57,5 @@ ``` | ||
```bash | ||
npx hardhat size-contracts --no-compile | ||
# or | ||
yarn run hardhat size-contracts --no-compile | ||
``` |
@@ -73,3 +73,2 @@ const fs = require('fs'); | ||
const table = new Table({ | ||
head: [chalk.bold('Contract Name'), chalk.bold('Size (KiB)'), chalk.bold('Change (KiB)')], | ||
style: { head: [], border: [], 'padding-left': 2, 'padding-right': 2 }, | ||
@@ -94,4 +93,30 @@ chars: { | ||
let largeContracts = 0; | ||
const compiler = hre.config.solidity.compilers[0]; | ||
table.push([ | ||
{ | ||
content: chalk.gray(`Solc version: ${ compiler.version }`), | ||
}, | ||
{ | ||
content: chalk.gray(`Optimizer enabled: ${ compiler.settings.optimizer.enabled }`), | ||
}, | ||
{ | ||
content: chalk.gray(`Runs: ${ compiler.settings.optimizer.runs }`), | ||
}, | ||
]); | ||
table.push([ | ||
{ | ||
content: chalk.bold('Contract Name'), | ||
}, | ||
{ | ||
content: chalk.bold('Size (KiB)'), | ||
}, | ||
{ | ||
content: chalk.bold('Change (KiB)'), | ||
}, | ||
]); | ||
let oversizedContracts = 0; | ||
for (let item of outputData) { | ||
@@ -106,3 +131,3 @@ if (!item.size) { | ||
size = chalk.red.bold(size); | ||
largeContracts++; | ||
oversizedContracts++; | ||
} else if (item.size > SIZE_LIMIT * 0.9) { | ||
@@ -119,2 +144,4 @@ size = chalk.yellow.bold(size); | ||
diff = chalk.red(`+${ formatSize(item.size - item.previousSize) }`); | ||
} else { | ||
diff = chalk.yellow(formatSize(0)); | ||
} | ||
@@ -132,6 +159,6 @@ } | ||
if (largeContracts > 0) { | ||
if (oversizedContracts > 0) { | ||
console.log(); | ||
const message = `Warning: ${ largeContracts } contracts exceed the size limit for mainnet deployment.`; | ||
const message = `Warning: ${ oversizedContracts } contracts exceed the size limit for mainnet deployment (${ formatSize(SIZE_LIMIT)} KiB).`; | ||
@@ -138,0 +165,0 @@ if (config.strict) { |
9992
7.24%248
10.71%59
11.32%