Skip to content

Commit ba5c75a

Browse files
committed
opitmized table
1 parent f381de3 commit ba5c75a

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

scripts/calculateSize.js

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,17 @@ async function printSize() {
1818
let files = await readFiles();
1919
console.log(`NOTE- Maximum size of contracts allowed to deloyed on the Ethereum mainnet is 24 KB(EIP170)`);
2020
console.log(`---- Size of the contracts ----`);
21-
let contracts = new Array();
22-
let size = new Array();
21+
let dataTable = [['Contracts', 'Size in KB']];
2322
files.forEach(item => {
2423
let content = JSON.parse(fs.readFileSync(`./build/contracts/${item}`).toString()).deployedBytecode;
2524
let sizeInKB = content.toString().length / 2 / 1024;
26-
size.push(sizeInKB);
2725
if (sizeInKB > 24)
28-
contracts.push(chalk.red(path.basename(item, ".json")));
26+
dataTable.push([chalk.red(path.basename(item, ".json")),chalk.red(sizeInKB)]);
2927
else if (sizeInKB > 20)
30-
contracts.push(chalk.yellow(path.basename(item, ".json")));
28+
dataTable.push([chalk.yellow(path.basename(item, ".json")),chalk.yellow(sizeInKB)]);
3129
else
32-
contracts.push(chalk.green(path.basename(item, ".json")));
30+
dataTable.push([chalk.green(path.basename(item, ".json")),chalk.green(sizeInKB)]);
3331
});
34-
let dataTable = [['Contracts', 'Size in KB']];
35-
for (let i = 0; i < contracts.length; i++) {
36-
dataTable.push([
37-
contracts[i],
38-
size[i]
39-
]);
40-
}
4132
console.log(table(dataTable));
4233
}
4334

0 commit comments

Comments
 (0)