UNPKG

dop-stick

Version:

Source control tooling for versionable-upgradeable smart contracts

35 lines 1.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LogFormatters = void 0; const terminal_1 = require("./core/terminal"); class LogFormatters { static makeHashCopyable(hash, short = true) { if (short) { const shortHash = `${hash.slice(0, 6)}...${hash.slice(-4)}`; // Wrap the entire string including icon in the OSC 52 sequence return `${shortHash} ${this.COLORS.PENDING}\x1b]52;c;${Buffer.from(hash).toString('base64')}\x07${this.COPY_ICON}${this.COLORS.RESET}`; } return `\x1b]52;c;${Buffer.from(hash).toString('base64')}\x07${hash}`; } static makeAddressCopyable(address, short = true) { if (short) { const shortAddress = `${address.slice(0, 6)}...${address.slice(-4)}`; // Wrap the entire string including icon in the OSC 52 sequence return `${shortAddress} ${this.COLORS.PENDING}\x1b]52;c;${Buffer.from(address).toString('base64')}\x07${this.COPY_ICON}${this.COLORS.RESET}`; } return `\x1b]52;c;${Buffer.from(address).toString('base64')}\x07${address}`; } // Helper method to create OSC 52 sequence static createCopyableSequence(text, icon = true) { const base64 = Buffer.from(text).toString('base64'); const sequence = `\x1b]52;c;${base64}\x07`; return icon ? `${sequence}${this.COPY_ICON}` : sequence; } } exports.LogFormatters = LogFormatters; LogFormatters.COLORS = { PENDING: terminal_1.Terminal.colors.muted, RESET: terminal_1.Terminal.colors.reset }; LogFormatters.COPY_ICON = '⧉'; //# sourceMappingURL=logFormatters.js.map