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);