MCPcopy Create free account
hub / github.com/PolymathNetwork/polymath-core / printSize

Function printSize

scripts/calculateSize.js:17–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15}
16
17async function printSize() {
18 let files = await readFiles();
19 console.log(`NOTE- Maximum size of contracts allowed to deloyed on the Ethereum mainnet is 24 KB(EIP170)`);
20 console.log(`---- Size of the contracts ----`);
21 let dataTable = [['Contracts', 'Size in KB']];
22 files.forEach(item => {
23 let content = JSON.parse(fs.readFileSync(`./build/contracts/${item}`).toString()).deployedBytecode;
24 let sizeInKB = content.toString().length / 2 / 1024;
25 if (sizeInKB > 24)
26 dataTable.push([chalk.red(path.basename(item, ".json")),chalk.red(sizeInKB)]);
27 else if (sizeInKB > 20)
28 dataTable.push([chalk.yellow(path.basename(item, ".json")),chalk.yellow(sizeInKB)]);
29 else
30 dataTable.push([chalk.green(path.basename(item, ".json")),chalk.green(sizeInKB)]);
31 });
32 console.log(table(dataTable));
33}
34
35printSize();

Callers 1

calculateSize.jsFile · 0.85

Calls 1

readFilesFunction · 0.70

Tested by

no test coverage detected