()
| 15 | } |
| 16 | |
| 17 | async 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 | |
| 35 | printSize(); |
no test coverage detected