Parallelize address scanning and unify address display formatting
Some checks failed
check / check (push) Has been cancelled
Some checks failed
check / check (push) Has been cancelled
Scanning: check all gap-limit addresses in parallel per batch instead of sequentially. For a wallet with 1 used address this reduces from 12 sequential RPC round-trips to 1 parallel batch + 1 small follow-up. Display: add shared formatAddressHtml(address, ensName, maxLen) and escapeHtml() to helpers.js. Use them in confirm-tx (was missing color dot entirely) and approval view. Remove duplicate escapeHtml from addressDetail.js.
This commit is contained in:
@@ -137,6 +137,27 @@ function addressDotHtml(address) {
|
||||
return `<span style="width:8px;height:8px;border-radius:50%;display:inline-block;background:${color};margin-right:4px;vertical-align:middle;flex-shrink:0;"></span>`;
|
||||
}
|
||||
|
||||
function escapeHtml(s) {
|
||||
const div = document.createElement("div");
|
||||
div.textContent = s;
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
// Render an address with color dot, optional ENS name, optional truncation.
|
||||
// When ensName is provided, shows ENS name (bold) on one line and
|
||||
// the address below it. Otherwise shows just the dotted address.
|
||||
function formatAddressHtml(address, ensName, maxLen) {
|
||||
const dot = addressDotHtml(address);
|
||||
const displayAddr = maxLen ? truncateMiddle(address, maxLen) : address;
|
||||
if (ensName) {
|
||||
return (
|
||||
`<div class="flex items-center font-bold">${dot}${escapeHtml(ensName)}</div>` +
|
||||
`<div class="break-all">${escapeHtml(displayAddr)}</div>`
|
||||
);
|
||||
}
|
||||
return `<div class="flex items-center">${dot}<span class="break-all">${escapeHtml(displayAddr)}</span></div>`;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
$,
|
||||
showError,
|
||||
@@ -146,5 +167,7 @@ module.exports = {
|
||||
balanceLinesForAddress,
|
||||
addressColor,
|
||||
addressDotHtml,
|
||||
escapeHtml,
|
||||
formatAddressHtml,
|
||||
truncateMiddle,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user