Compare commits
7 Commits
b799686cd4
...
8c071ae508
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c071ae508 | ||
|
|
a3c2b8227a | ||
|
|
f9f3e7b85a | ||
| 812fc01a98 | |||
|
|
811c125cb9 | ||
|
|
3005813f2c | ||
|
|
5565e76796 |
@@ -577,6 +577,19 @@
|
|||||||
<div id="confirm-fee-amount" class="text-xs"></div>
|
<div id="confirm-fee-amount" class="text-xs"></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="confirm-warnings" class="mb-2 hidden"></div>
|
<div id="confirm-warnings" class="mb-2 hidden"></div>
|
||||||
|
<div
|
||||||
|
id="confirm-recipient-warning"
|
||||||
|
class="mb-2"
|
||||||
|
style="visibility: hidden"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="border border-red-500 border-dashed p-2 text-xs font-bold text-red-500"
|
||||||
|
>
|
||||||
|
WARNING: The recipient address has ZERO transaction
|
||||||
|
history. This may indicate a fresh or unused address.
|
||||||
|
Double-check the address before sending.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
id="confirm-errors"
|
id="confirm-errors"
|
||||||
class="mb-2 border border-border border-dashed p-2 hidden"
|
class="mb-2 border border-border border-dashed p-2 hidden"
|
||||||
|
|||||||
@@ -243,7 +243,13 @@ function show(txInfo) {
|
|||||||
state.viewData = { pendingTx: txInfo };
|
state.viewData = { pendingTx: txInfo };
|
||||||
showView("confirm-tx");
|
showView("confirm-tx");
|
||||||
|
|
||||||
|
// 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.visibility = "hidden";
|
||||||
|
|
||||||
estimateGas(txInfo);
|
estimateGas(txInfo);
|
||||||
|
checkRecipientHistory(txInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function estimateGas(txInfo) {
|
async function estimateGas(txInfo) {
|
||||||
@@ -286,6 +292,30 @@ async function estimateGas(txInfo) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function checkRecipientHistory(txInfo) {
|
||||||
|
const el = $("confirm-recipient-warning");
|
||||||
|
try {
|
||||||
|
const provider = getProvider(state.rpcUrl);
|
||||||
|
// Skip warning for contract addresses — they may legitimately
|
||||||
|
// have zero outgoing transactions (getTransactionCount returns
|
||||||
|
// the nonce, i.e. sent-tx count only).
|
||||||
|
const code = await provider.getCode(txInfo.to);
|
||||||
|
if (code && code !== "0x") {
|
||||||
|
// 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";
|
||||||
|
}
|
||||||
|
// If txCount > 0, leave visibility:hidden — space stays reserved
|
||||||
|
} catch (e) {
|
||||||
|
log.errorf("recipient history check failed:", e.message);
|
||||||
|
// On error, leave visibility:hidden — no layout shift, no false warning
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function init(ctx) {
|
function init(ctx) {
|
||||||
$("btn-confirm-send").addEventListener("click", async () => {
|
$("btn-confirm-send").addEventListener("click", async () => {
|
||||||
const password = $("confirm-tx-password").value;
|
const password = $("confirm-tx-password").value;
|
||||||
|
|||||||
@@ -158,8 +158,9 @@ function render() {
|
|||||||
loadCalldata(tx.hash, tx.to);
|
loadCalldata(tx.hash, tx.to);
|
||||||
}
|
}
|
||||||
|
|
||||||
$("tx-detail-time").textContent =
|
const isoStr = isoDate(tx.timestamp);
|
||||||
isoDate(tx.timestamp) + " (" + timeAgo(tx.timestamp) + ")";
|
$("tx-detail-time").innerHTML =
|
||||||
|
copyableHtml(isoStr) + " (" + escapeHtml(timeAgo(tx.timestamp)) + ")";
|
||||||
$("tx-detail-status").textContent = tx.isError ? "Failed" : "Success";
|
$("tx-detail-status").textContent = tx.isError ? "Failed" : "Success";
|
||||||
showView("transaction");
|
showView("transaction");
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,16 @@ function txHashHtml(hash) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function blockNumberHtml(blockNumber) {
|
||||||
|
const num = String(blockNumber);
|
||||||
|
const link = `https://etherscan.io/block/${num}`;
|
||||||
|
const extLink = `<a href="${link}" target="_blank" rel="noopener" class="inline-flex items-center">${EXT_ICON}</a>`;
|
||||||
|
return (
|
||||||
|
`<span class="underline decoration-dashed cursor-pointer" data-copy="${escapeHtml(num)}">${escapeHtml(num)}</span>` +
|
||||||
|
extLink
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function attachCopyHandlers(viewId) {
|
function attachCopyHandlers(viewId) {
|
||||||
document
|
document
|
||||||
.getElementById(viewId)
|
.getElementById(viewId)
|
||||||
@@ -189,7 +199,7 @@ function renderSuccess() {
|
|||||||
$("success-tx-to").innerHTML = toAddressHtml(d.to);
|
$("success-tx-to").innerHTML = toAddressHtml(d.to);
|
||||||
}
|
}
|
||||||
|
|
||||||
$("success-tx-block").textContent = String(d.blockNumber);
|
$("success-tx-block").innerHTML = blockNumberHtml(d.blockNumber);
|
||||||
$("success-tx-hash").innerHTML = txHashHtml(d.hash);
|
$("success-tx-hash").innerHTML = txHashHtml(d.hash);
|
||||||
|
|
||||||
// Show decoded calldata details if present
|
// Show decoded calldata details if present
|
||||||
|
|||||||
Reference in New Issue
Block a user