Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hardhat-contract-sizer

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hardhat-contract-sizer - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

6

.eslintrc.js
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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc