Make active address display copyable with etherscan link
Some checks failed
check / check (push) Has been cancelled
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:
@@ -4,6 +4,7 @@ const {
|
|||||||
showFlash,
|
showFlash,
|
||||||
balanceLinesForAddress,
|
balanceLinesForAddress,
|
||||||
addressDotHtml,
|
addressDotHtml,
|
||||||
|
escapeHtml,
|
||||||
} = require("./helpers");
|
} = require("./helpers");
|
||||||
const { state, saveState, currentAddress } = require("../../shared/state");
|
const { state, saveState, currentAddress } = require("../../shared/state");
|
||||||
const { updateSendBalance, renderSendTokenSelect } = require("./send");
|
const { updateSendBalance, renderSendTokenSelect } = require("./send");
|
||||||
@@ -21,12 +22,27 @@ function renderTotalValue() {
|
|||||||
el.textContent = formatUsd(getTotalValueUsd(state.wallets));
|
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() {
|
function renderActiveAddress() {
|
||||||
const el = $("active-address-display");
|
const el = $("active-address-display");
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
if (state.activeAddress) {
|
if (state.activeAddress) {
|
||||||
const dot = addressDotHtml(state.activeAddress);
|
const addr = state.activeAddress;
|
||||||
el.innerHTML = dot + 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 {
|
} else {
|
||||||
el.textContent = "";
|
el.textContent = "";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user