difcli
Version:
CLI tool for Diffuse Prime
134 lines • 4.49 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConsoleFormatter = void 0;
const chalk_1 = __importDefault(require("chalk"));
class ConsoleFormatter {
/**
* Creates a standardized section header
*/
static sectionHeader(title, width = 60) {
console.log(chalk_1.default.blue(title));
console.log(chalk_1.default.gray('─'.repeat(width)));
}
/**
* Creates a standardized transaction header
*/
static transactionHeader(title, chainType, width = 60) {
console.log(chalk_1.default.blue(title));
console.log(chalk_1.default.gray('─'.repeat(width)));
console.log(`Chain: ${chalk_1.default.cyan(chainType)}`);
}
/**
* Displays contract information in a standardized format
*/
static contractInfo(label, address, network) {
console.log(chalk_1.default.cyan(`${label}:`));
console.log(` Address: ${chalk_1.default.green(address)}`);
if (network) {
console.log(` Network: ${chalk_1.default.yellow(network)}`);
}
}
/**
* Displays balance information
*/
static balanceInfo(label, balance, symbol) {
const balanceText = symbol ? `${balance} ${symbol}` : balance;
console.log(`${label}: ${chalk_1.default.green(balanceText)}`);
}
/**
* Displays success message
*/
static success(message) {
console.log(chalk_1.default.green(`✅ ${message}`));
}
/**
* Displays error message
*/
static error(message) {
console.log(chalk_1.default.red(`❌ ${message}`));
}
/**
* Displays warning message
*/
static warning(message) {
console.log(chalk_1.default.yellow(`⚠️ ${message}`));
}
/**
* Displays info message
*/
static info(message) {
console.log(chalk_1.default.cyan(`ℹ️ ${message}`));
}
/**
* Displays transaction hash
*/
static transactionHash(label, hash) {
console.log(`${label}: ${chalk_1.default.green(hash)}`);
}
/**
* Displays transaction receipt information
*/
static transactionReceipt(receipt) {
console.log('');
if (receipt.status === 'success') {
ConsoleFormatter.success('Transaction Successful!');
console.log(`Block Number: ${chalk_1.default.yellow(receipt.blockNumber.toString())}`);
console.log(`Gas Used: ${chalk_1.default.yellow(receipt.gasUsed.toString())}`);
}
else {
ConsoleFormatter.error('Transaction Failed!');
console.log(`Status: ${chalk_1.default.red(receipt.status)}`);
}
}
/**
* Displays a separator line
*/
static separator(width = 60) {
console.log(chalk_1.default.gray('─'.repeat(width)));
}
/**
* Creates a status indicator with icon
*/
static status(status, message) {
switch (status) {
case 'success':
ConsoleFormatter.success(message);
break;
case 'error':
ConsoleFormatter.error(message);
break;
case 'warning':
ConsoleFormatter.warning(message);
break;
case 'info':
ConsoleFormatter.info(message);
break;
}
}
/**
* Displays wallet information
*/
static walletInfo(address, type = 'EOA') {
console.log(chalk_1.default.blue('Wallet Information:'));
ConsoleFormatter.separator(50);
console.log(`Address: ${chalk_1.default.green(address)}`);
console.log(`Type: ${chalk_1.default.magenta(type)}`);
ConsoleFormatter.separator(50);
}
/**
* Displays chain information
*/
static chainInfo(chainName, rpcUrl, vaultAddress, tokenAddress) {
console.log(chalk_1.default.blue('Chain Information:'));
ConsoleFormatter.separator(50);
console.log(`Chain: ${chalk_1.default.cyan(chainName)}`);
console.log(`RPC: ${chalk_1.default.gray(rpcUrl)}`);
console.log(`Vault: ${chalk_1.default.gray(vaultAddress)}`);
console.log(`Token: ${chalk_1.default.gray(tokenAddress)}`);
}
}
exports.ConsoleFormatter = ConsoleFormatter;
//# sourceMappingURL=console-utils.js.map