feat: show red warning when sending to address with zero tx history #98

Merged
sneak merged 6 commits from issue-82-zero-tx-warning into main 2026-03-01 00:54:15 +01:00
Showing only changes of commit 8c071ae508 - Show all commits

View File

@@ -246,7 +246,6 @@ function show(txInfo) {
// Reset recipient warning: reserve space (visibility:hidden) while
// the async check runs, preventing layout shift per README policy.
const recipientWarning = $("confirm-recipient-warning");
recipientWarning.style.display = "";
recipientWarning.style.visibility = "hidden";
estimateGas(txInfo);
@@ -302,22 +301,18 @@ async function checkRecipientHistory(txInfo) {
// the nonce, i.e. sent-tx count only).
const code = await provider.getCode(txInfo.to);
if (code && code !== "0x") {
// Contract address — hide the reserved space entirely
el.style.display = "none";
// Contract address — no warning needed, keep space reserved
// but invisible to prevent layout shift
return;
}
const txCount = await provider.getTransactionCount(txInfo.to);
if (txCount === 0) {
el.style.visibility = "visible";
} else {
// Address has history — collapse the reserved space
el.style.display = "none";
}
// If txCount > 0, leave visibility:hidden — space stays reserved
} catch (e) {
log.errorf("recipient history check failed:", e.message);
// On error, collapse the reserved space rather than showing a
// false warning or leaving an empty gap
el.style.display = "none";
// On error, leave visibility:hidden — no layout shift, no false warning
}
}