hardhat-contract-sizer
Advanced tools
Comparing version 2.0.2 to 2.0.3
module.exports = { | ||
'env': { | ||
'browser': true, | ||
'commonjs': true, | ||
'node': true, | ||
'es6': true, | ||
@@ -12,3 +11,2 @@ }, | ||
'task': 'readonly', | ||
'Buffer': 'readonly', | ||
}, | ||
@@ -63,5 +61,3 @@ 'parserOptions': { | ||
], | ||
// override | ||
'vue/max-attributes-per-line': 0, | ||
}, | ||
}; |
26
index.js
@@ -1,3 +0,1 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { extendConfig } = require('hardhat/config'); | ||
@@ -28,17 +26,18 @@ const colors = require('colors/safe'); | ||
task(NAME, DESC, async function (args, hre) { | ||
let files = await hre.artifacts.getArtifactPaths(); | ||
const contracts = []; | ||
let contracts = files.map(function (file) { | ||
let name = file.replace(hre.config.paths.root, ''); | ||
for (let name of await hre.artifacts.getAllFullyQualifiedNames()) { | ||
const { deployedBytecode } = await hre.artifacts.readArtifact(name); | ||
const size = Buffer.from( | ||
deployedBytecode.replace(/__\$\w*\$__/g, '0'.repeat(40)).slice(2), | ||
'hex' | ||
).length; | ||
if (!hre.config.contractSizer.disambiguatePaths) { | ||
name = path.basename(name).replace('.json', ''); | ||
name = name.split(':').pop(); | ||
} | ||
let { deployedBytecode } = JSON.parse(fs.readFileSync(file)); | ||
let size = Buffer.from(deployedBytecode.slice(2), 'hex').length; | ||
contracts.push({ name, size }); | ||
} | ||
return { name, size }; | ||
}); | ||
if (hre.config.contractSizer.alphaSort) { | ||
@@ -50,3 +49,3 @@ contracts.sort((a, b) => a.name.toUpperCase() > b.name.toUpperCase() ? 1 : -1); | ||
let table = new Table({ | ||
const table = new Table({ | ||
head: [colors.bold('Contract Name'), 'Size (Kb)'], | ||
@@ -79,3 +78,2 @@ style: { head: [], border: [], 'padding-left': 2, 'padding-right': 2 }, | ||
let name = contract.name; | ||
let size = (contract.size / 1024).toFixed(2); | ||
@@ -91,3 +89,3 @@ | ||
table.push([ | ||
{ content: name }, | ||
{ content: contract.name }, | ||
{ content: size, hAlign: 'right' }, | ||
@@ -94,0 +92,0 @@ ]); |
{ | ||
"name": "hardhat-contract-sizer", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Output Solidity contract sizes with Hardhat", |
@@ -5,3 +5,3 @@ # Hardhat Contract Sizer | ||
Versions of this plugin prior to `2.0.0` were released as `buidler-contract-sizer`. | ||
> Versions of this plugin prior to `2.0.0` were released as `buidler-contract-sizer`. | ||
@@ -8,0 +8,0 @@ ## Installation |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
1
6535
164