feat: show red warning when sending to address with zero tx history #98
@@ -580,14 +580,7 @@
|
||||
<div
|
||||
id="confirm-recipient-warning"
|
||||
class="mb-2"
|
||||
style="
|
||||
overflow: hidden;
|
||||
transition:
|
||||
max-height 0.3s ease,
|
||||
opacity 0.3s ease;
|
||||
max-height: 60px;
|
||||
opacity: 0;
|
||||
"
|
||||
style="visibility: hidden"
|
||||
>
|
||||
<div
|
||||
class="border border-red-500 border-dashed p-2 text-xs font-bold text-red-500"
|
||||
|
||||
@@ -243,11 +243,8 @@ function show(txInfo) {
|
||||
state.viewData = { pendingTx: txInfo };
|
||||
showView("confirm-tx");
|
||||
|
||||
// Reset recipient warning: reserve space (max-height) while the async
|
||||
// check runs, then collapse smoothly if not needed.
|
||||
const recipientWarning = $("confirm-recipient-warning");
|
||||
recipientWarning.style.maxHeight = "60px";
|
||||
recipientWarning.style.opacity = "0";
|
||||
// Reset recipient warning to hidden (space always reserved, no layout shift)
|
||||
$("confirm-recipient-warning").style.visibility = "hidden";
|
||||
|
||||
estimateGas(txInfo);
|
||||
checkRecipientHistory(txInfo);
|
||||
@@ -302,25 +299,14 @@ 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 — no warning needed, collapse smoothly
|
||||
el.style.maxHeight = "0";
|
||||
el.style.opacity = "0";
|
||||
return;
|
||||
}
|
||||
const txCount = await provider.getTransactionCount(txInfo.to);
|
||||
if (txCount === 0) {
|
||||
// Show warning: fade in (space already reserved)
|
||||
el.style.opacity = "1";
|
||||
} else {
|
||||
// Recipient has history — collapse the reserved space smoothly
|
||||
el.style.maxHeight = "0";
|
||||
el.style.opacity = "0";
|
||||
el.style.visibility = "visible";
|
||||
}
|
||||
} catch (e) {
|
||||
log.errorf("recipient history check failed:", e.message);
|
||||
// On error, collapse space — no false warning
|
||||
el.style.maxHeight = "0";
|
||||
el.style.opacity = "0";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user