Make active address display copyable with etherscan link
Some checks failed
check / check (push) Has been cancelled

Click the active address above Send/Receive to copy it. A small
box-arrow icon links to the address on etherscan.
This commit is contained in:
2026-02-26 15:53:56 +07:00
parent fce907df55
commit e8e5edf5f2

View File

@@ -4,6 +4,7 @@ const {
showFlash,
balanceLinesForAddress,
addressDotHtml,
escapeHtml,
} = require("./helpers");
const { state, saveState, currentAddress } = require("../../shared/state");
const { updateSendBalance, renderSendTokenSelect } = require("./send");
@@ -21,12 +22,27 @@ function renderTotalValue() {
el.textContent = formatUsd(getTotalValueUsd(state.wallets));
}
const EXT_ICON =
`<span style="display:inline-block;width:10px;height:10px;margin-left:4px;vertical-align:middle">` +
`<svg viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5">` +
`<path d="M4.5 1.5H2a.5.5 0 00-.5.5v8a.5.5 0 00.5.5h8a.5.5 0 00.5-.5V7.5"/>` +
`<path d="M7 1.5h3.5V5M7 5.5L10.5 1.5"/>` +
`</svg></span>`;
function renderActiveAddress() {
const el = $("active-address-display");
if (!el) return;
if (state.activeAddress) {
const dot = addressDotHtml(state.activeAddress);
el.innerHTML = dot + state.activeAddress;
const addr = state.activeAddress;
const dot = addressDotHtml(addr);
const link = `https://etherscan.io/address/${addr}`;
el.innerHTML =
`<span class="underline decoration-dashed cursor-pointer" id="active-addr-copy">${dot}${escapeHtml(addr)}</span>` +
`<a href="${link}" target="_blank" rel="noopener" class="inline-flex items-center">${EXT_ICON}</a>`;
$("active-addr-copy").addEventListener("click", () => {
navigator.clipboard.writeText(addr);
showFlash("Copied!");
});
} else {
el.textContent = "";
}