UNPKG

dop-stick

Version:

Source control tooling for versionable-upgradeable smart contracts

120 lines • 5.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ParallelDeploymentLogAdapter = void 0; const logger_1 = require("../core/logger"); const terminal_1 = require("../core/terminal"); class ParallelDeploymentLogAdapter { constructor() { this.deploymentStates = new Map(); this.renderedStates = new Set(); } startParallelDeployment() { logger_1.Logger.section('šŸ“¦ PARALLEL DEPLOYMENT', '', { style: 'line' }); } logWalletPreparation(wallets) { logger_1.Logger.writeLine('\nāš™ļø Preparing wallets...'); wallets.forEach(({ moduleName, address }) => { logger_1.Logger.writeLine(`• ${terminal_1.Terminal.colors.magenta}${moduleName}${terminal_1.Terminal.colors.reset} → ${address}`); }); logger_1.Logger.writeLine('\nšŸš€ Deploying contracts in parallel...\n'); } shouldRenderState(state) { const stateKey = `${state.moduleName}-${state.txHash || ''}-${state.address || ''}`; if (this.renderedStates.has(stateKey)) { return false; } this.renderedStates.add(stateKey); return true; } getModulePrefix(state) { if (state.error) { return `${terminal_1.Terminal.colors.error}āœ–${terminal_1.Terminal.colors.reset}`; } if (state.isComplete && state.address) { return `${terminal_1.Terminal.colors.success}āœ“${terminal_1.Terminal.colors.reset}`; } if (state.txHash) { return `${terminal_1.Terminal.colors.yellow}āŒ›${terminal_1.Terminal.colors.reset}`; } return `${terminal_1.Terminal.colors.cyan}ā—†${terminal_1.Terminal.colors.reset}`; } renderDeploymentStates() { const sortedStates = Array.from(this.deploymentStates.values()) .sort((a, b) => a.index - b.index); let output = ''; for (const state of sortedStates) { if (this.shouldRenderState(state)) { const prefix = this.getModulePrefix(state); output += `${prefix} ${terminal_1.Terminal.colors.magenta}${state.moduleName}${terminal_1.Terminal.colors.reset}\n`; output += `• Bytecode: ${(state.stats.bytecodeSize / 1024).toFixed(1)} KB\n`; if (state.txHash) { output += `• TxHash: ${state.txHash}\n`; output += `āŒ› Waiting for confirmation...\n`; } if (state.isComplete && state.address) { if (state.stats.gasUsed) { output += `• Gas Used: ${state.stats.gasUsed} (${state.stats.ethCost} ETH)\n`; } output += `• Deployed to ${state.address}`; if (state.stats.blockNumber) { output += ` (Block #${state.stats.blockNumber})`; } output += '\n'; } if (state.error) { output += `• Error: ${state.error}\n`; } output += '\n'; } } if (output) { logger_1.Logger.write(output); } } startModuleDeployment(moduleName, index, total, stats) { this.deploymentStates.set(moduleName, { index, total, moduleName, stats, isComplete: false }); this.renderDeploymentStates(); } logTransactionSent(moduleName, txHash) { const state = this.deploymentStates.get(moduleName); if (state) { state.txHash = txHash; this.renderDeploymentStates(); } } logDeploymentSuccess(moduleName, address, stats) { const state = this.deploymentStates.get(moduleName); if (state) { state.address = address; state.stats = { ...state.stats, ...stats }; state.isComplete = true; this.renderDeploymentStates(); } } logDeploymentError(moduleName, error) { const state = this.deploymentStates.get(moduleName); if (state) { state.error = error; state.isComplete = true; this.renderDeploymentStates(); } } logFinalSummary(stats) { logger_1.Logger.writeLine('āœ“ All deployments completed successfully'); logger_1.Logger.writeLine('───────────────────'); logger_1.Logger.writeLine(`• Total modules: ${stats.totalModules}`); logger_1.Logger.writeLine(`• Total bytecode: ${(stats.totalBytecode / 1024).toFixed(1)} KB`); logger_1.Logger.writeLine(`• Total gas used: ${stats.totalGas} (${stats.totalEth} ETH)`); logger_1.Logger.writeLine(`• Total deployment time: ${(stats.deploymentTime / 1000).toFixed(1)}s`); } } exports.ParallelDeploymentLogAdapter = ParallelDeploymentLogAdapter; //# sourceMappingURL=parallelDeploymentLogAdapter.js.map