UNPKG

dop-stick

Version:

Source control tooling for versionable-upgradeable smart contracts

103 lines 4.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DeploymentLogAdapter = void 0; const terminal_1 = require("../core/terminal"); class DeploymentLogAdapter { constructor() { this.totalModules = 0; this.currentModule = 0; this.currentLine = 0; } startDeployment(networkInfo) { this.networkInfo = networkInfo; terminal_1.Terminal.writeLine(''); terminal_1.Terminal.writeLine(''); terminal_1.Terminal.writeLine('📦 DEPLOYMENTS'); terminal_1.Terminal.writeLine('═══════════'); terminal_1.Terminal.writeLine(''); terminal_1.Terminal.writeLine(`Network: ${networkInfo.name}`); terminal_1.Terminal.writeLine(`ChainId: ${networkInfo.chainId}`); terminal_1.Terminal.writeLine(`Gas Price: ${networkInfo.gasPrice} gwei`); terminal_1.Terminal.writeLine(''); } logPreDeploymentChecks(checks) { terminal_1.Terminal.writeLine('Validating deployment...'); checks.forEach(check => { var _a, _b; switch (check.type) { case 'cuts': terminal_1.Terminal.writeLine(`• Cuts validation ${check.status === 'success' ? '✓' : '✖'} ${(_a = check.details) === null || _a === void 0 ? void 0 : _a.moduleCount} modules (${(_b = check.details) === null || _b === void 0 ? void 0 : _b.functionCount} functions)`); break; case 'emergency': terminal_1.Terminal.writeLine(`• Emergency status ${check.status === 'success' ? '✓' : '✖'} Diamond active`); break; case 'gas': terminal_1.Terminal.writeLine(`• Gas price check ${check.status === 'success' ? '✓' : '✖'} Normal mode`); break; } }); terminal_1.Terminal.writeLine(''); } setTotalModules(total) { this.totalModules = total; terminal_1.Terminal.writeLine(`Deploying ${total} modules...`); terminal_1.Terminal.writeLine(''); } startModuleDeployment(moduleName, index) { this.currentModule = index; terminal_1.Terminal.writeLine(`\n[${index + 1}/${this.totalModules}] ${moduleName}`); terminal_1.Terminal.writeLine(terminal_1.Terminal.style('⌛ Deploying...', terminal_1.Terminal.colors.yellow)); } updateModuleProgress(progress) { if (progress.bytecodeSize) { terminal_1.Terminal.writeLine(`• Bytecode size: ${(progress.bytecodeSize / 1024).toFixed(1)} KB`); } if (progress.txHash) { terminal_1.Terminal.writeLine(`• TxHash: ${progress.txHash}`); } if (progress.address) { terminal_1.Terminal.writeLine(terminal_1.Terminal.style(`✓ Contract deployed at ${progress.address}`, terminal_1.Terminal.colors.green)); } if (progress.error) { terminal_1.Terminal.writeLine(terminal_1.Terminal.style(`✖ Deployment failed: ${progress.error}`, terminal_1.Terminal.colors.red)); } if (progress.gasUsed) { terminal_1.Terminal.writeLine(`• Gas used: ${formatGas(progress.gasUsed)}`); } } displaySummary(results, duration) { const successful = results.filter(r => r.status === 'success'); const failed = results.filter(r => r.status === 'failed'); terminal_1.Terminal.writeLine('\nDeployment Summary'); terminal_1.Terminal.writeLine('═════════════════'); terminal_1.Terminal.writeLine(`Duration: ${formatDuration(duration)}`); terminal_1.Terminal.writeLine(`Success: ${successful.length}/${this.totalModules} modules\n`); if (successful.length > 0) { terminal_1.Terminal.writeLine('Deployed Contracts'); successful.forEach(result => { terminal_1.Terminal.writeLine(`• ${result.moduleName} (${formatGas(result.gasUsed)} gas)`); terminal_1.Terminal.writeLine(` ✓ ${result.address}`); }); terminal_1.Terminal.writeLine(''); } if (failed.length > 0) { terminal_1.Terminal.writeLine('Failed Deployments'); failed.forEach(result => { terminal_1.Terminal.writeLine(`• ${result.moduleName}`); terminal_1.Terminal.writeLine(` ✖ ${result.error}`); }); terminal_1.Terminal.writeLine(''); } } } exports.DeploymentLogAdapter = DeploymentLogAdapter; // Helper functions function formatGas(gas) { return gas.gt(1000000) ? `${(gas.toNumber() / 1000000).toFixed(1)}M` : `${(gas.toNumber() / 1000).toFixed(1)}K`; } function formatDuration(ms) { return `${(ms / 1000).toFixed(1)}s`; } //# sourceMappingURL=deploymentLogAdapter.js.map