Skip to content

Commit

Permalink
opitmized table
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsam4 committed Feb 14, 2019
1 parent f381de3 commit ba5c75a
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions scripts/calculateSize.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,17 @@ async function printSize() {
let files = await readFiles();
console.log(`NOTE- Maximum size of contracts allowed to deloyed on the Ethereum mainnet is 24 KB(EIP170)`);
console.log(`---- Size of the contracts ----`);
let contracts = new Array();
let size = new Array();
let dataTable = [['Contracts', 'Size in KB']];
files.forEach(item => {
let content = JSON.parse(fs.readFileSync(`./build/contracts/${item}`).toString()).deployedBytecode;
let sizeInKB = content.toString().length / 2 / 1024;
size.push(sizeInKB);
if (sizeInKB > 24)
contracts.push(chalk.red(path.basename(item, ".json")));
dataTable.push([chalk.red(path.basename(item, ".json")),chalk.red(sizeInKB)]);
else if (sizeInKB > 20)
contracts.push(chalk.yellow(path.basename(item, ".json")));
dataTable.push([chalk.yellow(path.basename(item, ".json")),chalk.yellow(sizeInKB)]);
else
contracts.push(chalk.green(path.basename(item, ".json")));
dataTable.push([chalk.green(path.basename(item, ".json")),chalk.green(sizeInKB)]);
});
let dataTable = [['Contracts', 'Size in KB']];
for (let i = 0; i < contracts.length; i++) {
dataTable.push([
contracts[i],
size[i]
]);
}
console.log(table(dataTable));
}

Expand Down

0 comments on commit ba5c75a

Please sign in to comment.