From 9abe570e43f2d238c372b62932f256d17c7519f2 Mon Sep 17 00:00:00 2001 From: sneak Date: Thu, 26 Feb 2026 02:22:38 +0700 Subject: [PATCH] Truncate counterparty address in tx list based on amount width For every character beyond 10 in the amount string (e.g. "17.1900 USDT" is 12 chars, 2 excess), remove that many characters from the middle of the counterparty address, replaced with an ellipsis. Hover shows the full address; clicking goes to tx detail which also shows it in full. Prevents the address from wrapping onto a second line. --- src/popup/views/addressDetail.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/popup/views/addressDetail.js b/src/popup/views/addressDetail.js index 945f6ea..b2770af 100644 --- a/src/popup/views/addressDetail.js +++ b/src/popup/views/addressDetail.js @@ -65,6 +65,16 @@ function timeAgo(timestamp) { return years + " year" + (years !== 1 ? "s" : "") + " ago"; } +function truncateAddress(address, amountLen) { + const excess = amountLen - 10; + if (excess <= 0) return address; + const charsToRemove = excess; + const available = address.length - charsToRemove - 1; + if (available < 10) return address; + const half = Math.floor(available / 2); + return address.slice(0, half) + "\u2026" + address.slice(-half); +} + function escapeHtml(s) { const div = document.createElement("div"); div.textContent = s; @@ -115,14 +125,16 @@ function renderTransactions(txs) { line1.appendChild(age); line1.appendChild(dir); + const amountStr = tx.value + " " + tx.symbol; const line2 = document.createElement("div"); line2.className = "flex justify-between"; const addr = document.createElement("span"); - addr.className = "break-all pr-2"; - addr.textContent = counterparty; + addr.className = "pr-2"; + addr.textContent = truncateAddress(counterparty, amountStr.length); + addr.title = counterparty; const amount = document.createElement("span"); amount.className = "shrink-0"; - amount.textContent = tx.value + " " + tx.symbol; + amount.textContent = amountStr; line2.appendChild(addr); line2.appendChild(amount);