dop-stick
Version:
Source control tooling for versionable-upgradeable smart contracts
159 lines • 7.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MiningTimelineAdapter = void 0;
const timelineLogAdapter_1 = require("./timelineLogAdapter");
const terminal_1 = require("../core/terminal");
const logFormatters_1 = require("../logFormatters");
const ICONS = {
MINING: '⛏️',
NETWORK: '🌐',
CONFIG: '📦',
MODULES: '🔍',
CACHE: '💾',
DEPLOYMENT: '🚀',
DIAMOND: '💎',
POST_DEPLOY: '🔄',
SUCCESS: '✓',
ERROR: '✖',
PENDING: '⠋',
CORE: '⚙️',
SUMMARY: '📊',
CACHE_UPDATE: '💾',
WARNING: '⚠',
INFO: 'ℹ'
};
const COLORS = {
HEADER: '\x1b[95m',
SUCCESS: terminal_1.Terminal.colors.success,
PENDING: terminal_1.Terminal.colors.muted,
ERROR: '\x1b[31m',
RESET: terminal_1.Terminal.colors.reset,
WARNING: '\x1b[33m',
INFO: '\x1b[36m' // Cyan
};
class MiningTimelineAdapter {
constructor() {
this.timeline = new timelineLogAdapter_1.TimelineLogAdapter();
this.startTime = Date.now();
}
startMining(networkInfo) {
this.timeline.startSection('💎 DIAMOND MINING PROCESS');
this.timeline.logStep(`${ICONS.NETWORK} ${COLORS.HEADER}Network Info${COLORS.RESET}`);
this.timeline.logInnerStep(`• Network: ${networkInfo.name}`, 1);
this.timeline.logInnerStep(`• ChainId: ${networkInfo.chainId}`, 1);
this.timeline.logInnerStep(`• Gas Price: ${networkInfo.gasPrice} gwei`, 1);
this.timeline.logEmptyStep();
}
logUpgradeConfigStatus(found, path) {
this.timeline.logStep(`${ICONS.CONFIG} ${COLORS.HEADER}Upgrade Configuration${COLORS.RESET}`);
if (found) {
this.timeline.logInnerStep(`• Found at: ${path}`, 1);
}
else {
this.timeline.logInnerColoredStep(`• Not found at: ${path}`, 1, COLORS.ERROR);
}
this.timeline.logEmptyStep();
}
logModuleCutsProgress(coreFacets, moduleFacets) {
this.timeline.logStep(`${ICONS.MODULES} ${COLORS.HEADER}Module Processing${COLORS.RESET}`);
this.timeline.logInnerStep(`• Core Facets: ${coreFacets}`, 1);
this.timeline.logInnerStep(`• Module Facets: ${moduleFacets}`, 1);
this.timeline.logEmptyStep();
}
logCacheStatus(enabled, status) {
this.timeline.logStep(`${ICONS.CACHE} ${COLORS.HEADER}Cache Management${COLORS.RESET}`);
this.timeline.logInnerStep(`• Status: ${enabled ? 'Enabled' : 'Disabled'}`, 1);
const statusColor = status === 'found' ? COLORS.SUCCESS :
status === 'invalid' ? COLORS.ERROR :
COLORS.PENDING;
this.timeline.logInnerColoredStep(`• Cache: ${status}`, 1, statusColor);
this.timeline.logEmptyStep();
}
logDeploymentMode(mode) {
this.timeline.logStep(`${ICONS.DEPLOYMENT} ${COLORS.HEADER}Deployment Mode${COLORS.RESET}`);
this.timeline.logInnerStep(`• Mode: ${mode}`, 1);
this.timeline.logEmptyStep();
}
logDiamondDeployment(standard) {
this.timeline.logStep(`${ICONS.DIAMOND} ${COLORS.HEADER}Diamond Deployment${COLORS.RESET}`);
this.timeline.logInnerStep(`• Standard: ${standard}`, 1);
}
updateDiamondStatus(status, address) {
const statusIcon = status === 'success' ? ICONS.SUCCESS :
status === 'failed' ? ICONS.ERROR :
ICONS.PENDING;
const statusColor = status === 'success' ? COLORS.SUCCESS :
status === 'failed' ? COLORS.ERROR :
COLORS.PENDING;
this.timeline.logInnerColoredStep(`• Status: ${statusIcon} ${status}`, 1, statusColor);
if (address) {
this.timeline.logInnerStep(`• Address: ${logFormatters_1.LogFormatters.makeAddressCopyable(address)}`, 1);
}
this.timeline.logEmptyStep();
}
logPostDeployment(required) {
this.timeline.logStep(`${ICONS.POST_DEPLOY} ${COLORS.HEADER}Post-Deployment${COLORS.RESET}`);
this.timeline.logInnerStep(`• Required: ${required ? 'Yes' : 'No'}`, 1);
}
updatePostDeploymentStatus(status, error) {
const statusColor = status === 'complete' ? COLORS.SUCCESS :
status === 'failed' ? COLORS.ERROR :
COLORS.PENDING;
this.timeline.logInnerColoredStep(`• Status: ${status}`, 1, statusColor);
if (error) {
this.timeline.logInnerColoredStep(`• Error: ${error}`, 1, COLORS.ERROR);
}
this.timeline.logEmptyStep();
}
completeMining(duration) {
const durationStr = (duration / 1000).toFixed(1);
this.timeline.logSuccessWithTime(`Mining process completed in ${durationStr}s`);
}
logCacheValidation(status) {
const statusColor = status === 'valid' ? COLORS.SUCCESS :
status === 'invalid' ? COLORS.ERROR :
COLORS.PENDING;
this.timeline.logInnerColoredStep(`• Cache validation: ${status}`, 1, statusColor);
}
logUndeployedCuts(count) {
this.timeline.logStep(`${ICONS.MODULES} Undeployed Cuts`);
this.timeline.logInnerStep(`• Count: ${count}`, 1);
this.timeline.logEmptyStep();
}
logCacheSave(success) {
const icon = success ? ICONS.SUCCESS : ICONS.ERROR;
const color = success ? COLORS.SUCCESS : COLORS.ERROR;
this.timeline.logInnerColoredStep(`${icon} Cache updated`, 1, color);
}
logDeploymentSummary(summary) {
this.timeline.logStep(`${ICONS.SUMMARY} Deployment Summary`);
this.timeline.logInnerStep(`• Diamond: ${logFormatters_1.LogFormatters.makeAddressCopyable(summary.diamondAddress)}`, 1);
this.timeline.logInnerStep(`• Total Facets: ${summary.totalFacets}`, 1);
this.timeline.logInnerStep(`• Core Facets: ${summary.coreFacets}`, 1);
this.timeline.logInnerStep(`• Modules: ${summary.modules}`, 1);
this.timeline.logInnerStep(`• Standard: ${summary.standardType}`, 1);
this.timeline.logInnerStep(`• Network: ${summary.network} (${summary.chainId})`, 1);
this.timeline.logEmptyStep();
}
logCoreFacetsExtraction(count) {
this.timeline.logStep(`${ICONS.CORE} Core Facets Extraction`);
this.timeline.logInnerStep(`• Extracted: ${count} facets`, 1);
this.timeline.logEmptyStep();
}
logError(message) {
this.timeline.logStep(`${ICONS.ERROR} Error`);
this.timeline.logInnerColoredStep(`• ${message}`, 1, COLORS.ERROR);
this.timeline.logEmptyStep();
}
log(message, type = 'info') {
const icon = type === 'error' ? ICONS.ERROR :
type === 'warning' ? ICONS.WARNING :
ICONS.INFO;
const color = type === 'error' ? COLORS.ERROR :
type === 'warning' ? COLORS.WARNING :
COLORS.INFO;
this.timeline.logColoredStep(`${icon} ${message}`, 0, color);
}
}
exports.MiningTimelineAdapter = MiningTimelineAdapter;
//# sourceMappingURL=miningTimelineAdapter.js.map