#include "balance_recent_tx.h" #include "../../config/version.h" #include "../../util/text_format.h" #include #include #include namespace dragonx { namespace ui { namespace { std::string truncateRecentAddress(const std::string& address, int maxLen) { if (maxLen <= 3 || address.length() <= static_cast(maxLen)) return address; int half = (maxLen - 3) / 2; return address.substr(0, half) + "..." + address.substr(address.length() - half); } std::string formatRecentAmount(const std::string& type, double amount) { char buffer[32]; snprintf(buffer, sizeof(buffer), "%s%.4f %s", type == "send" ? "-" : "+", std::abs(amount), DRAGONX_TICKER); return std::string(buffer); } std::string recentTimeAgo(int64_t timestamp) { return util::formatTimeAgoShort(timestamp); } } RecentTxDisplay buildRecentTxDisplay(const TransactionInfo& tx, int addressMaxLen) { return { tx.getTypeDisplay(), truncateRecentAddress(tx.address, addressMaxLen), formatRecentAmount(tx.type, tx.amount), recentTimeAgo(tx.timestamp) }; } } // namespace ui } // namespace dragonx