Compare commits
1 Commits
issue-99-b
...
feature/82
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd69e1e215 |
@@ -86,6 +86,42 @@ function valueWithUsd(text, usdAmount) {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderWarnings(warnings) {
|
||||||
|
const warningsEl = $("confirm-warnings");
|
||||||
|
if (warnings.length > 0) {
|
||||||
|
warningsEl.innerHTML = warnings
|
||||||
|
.map(
|
||||||
|
(w) =>
|
||||||
|
`<div class="border border-border border-dashed p-2 mb-1 text-xs font-bold" style="color:#c00">WARNING: ${w}</div>`,
|
||||||
|
)
|
||||||
|
.join("");
|
||||||
|
warningsEl.classList.remove("hidden");
|
||||||
|
} else {
|
||||||
|
warningsEl.classList.add("hidden");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkAddressHistory(address, existingWarnings) {
|
||||||
|
try {
|
||||||
|
const provider = getProvider(state.rpcUrl);
|
||||||
|
const [balance, txCount] = await Promise.all([
|
||||||
|
provider.getBalance(address),
|
||||||
|
provider.getTransactionCount(address),
|
||||||
|
]);
|
||||||
|
if (balance === 0n && txCount === 0) {
|
||||||
|
const warnings = existingWarnings.slice();
|
||||||
|
warnings.push(
|
||||||
|
"This address has ZERO transaction history. " +
|
||||||
|
"It has never sent or received funds. " +
|
||||||
|
"Double-check that the address is correct before sending.",
|
||||||
|
);
|
||||||
|
renderWarnings(warnings);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
log.errorf("address history check failed:", e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function show(txInfo) {
|
function show(txInfo) {
|
||||||
pendingTx = txInfo;
|
pendingTx = txInfo;
|
||||||
|
|
||||||
@@ -176,18 +212,10 @@ function show(txInfo) {
|
|||||||
warnings.push("You are sending to your own address.");
|
warnings.push("You are sending to your own address.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const warningsEl = $("confirm-warnings");
|
renderWarnings(warnings);
|
||||||
if (warnings.length > 0) {
|
|
||||||
warningsEl.innerHTML = warnings
|
// Async check: warn if destination address has zero transaction history
|
||||||
.map(
|
checkAddressHistory(txInfo.to, warnings);
|
||||||
(w) =>
|
|
||||||
`<div class="border border-border border-dashed p-2 mb-1 text-xs font-bold">WARNING: ${w}</div>`,
|
|
||||||
)
|
|
||||||
.join("");
|
|
||||||
warningsEl.classList.remove("hidden");
|
|
||||||
} else {
|
|
||||||
warningsEl.classList.add("hidden");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for errors
|
// Check for errors
|
||||||
const errors = [];
|
const errors = [];
|
||||||
|
|||||||
@@ -50,16 +50,6 @@ function toAddressHtml(address) {
|
|||||||
return `<div class="flex items-center">${dot}<span class="break-all underline decoration-dashed cursor-pointer" data-copy="${escapeHtml(address)}">${escapeHtml(address)}</span>${extLink}</div>`;
|
return `<div class="flex items-center">${dot}<span class="break-all underline decoration-dashed cursor-pointer" data-copy="${escapeHtml(address)}">${escapeHtml(address)}</span>${extLink}</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 txHashHtml(hash) {
|
function txHashHtml(hash) {
|
||||||
const link = `https://etherscan.io/tx/${hash}`;
|
const link = `https://etherscan.io/tx/${hash}`;
|
||||||
const extLink = `<a href="${link}" target="_blank" rel="noopener" class="inline-flex items-center">${EXT_ICON}</a>`;
|
const extLink = `<a href="${link}" target="_blank" rel="noopener" class="inline-flex items-center">${EXT_ICON}</a>`;
|
||||||
@@ -199,7 +189,7 @@ function renderSuccess() {
|
|||||||
$("success-tx-to").innerHTML = toAddressHtml(d.to);
|
$("success-tx-to").innerHTML = toAddressHtml(d.to);
|
||||||
}
|
}
|
||||||
|
|
||||||
$("success-tx-block").innerHTML = blockNumberHtml(d.blockNumber);
|
$("success-tx-block").textContent = String(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