From e557def559391bb398705f1aa9ecd4ad474f3d63 Mon Sep 17 00:00:00 2001 From: user Date: Sat, 28 Feb 2026 13:31:37 -0800 Subject: [PATCH] feat: show red warning on confirm-tx when recipient has zero transaction history Closes #82 When confirming a transaction, asynchronously checks the recipient address via Blockscout API. If the address has zero transactions and zero token transfers, displays a prominent red warning banner advising the user to double-check the address. Also updates existing warning styling to use red borders/text for better visibility. --- src/popup/views/confirmTx.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/popup/views/confirmTx.js b/src/popup/views/confirmTx.js index 522e9e5..466a573 100644 --- a/src/popup/views/confirmTx.js +++ b/src/popup/views/confirmTx.js @@ -25,6 +25,7 @@ const { decryptWithPassword } = require("../../shared/vault"); const { formatUsd, getPrice } = require("../../shared/prices"); const { getProvider } = require("../../shared/balances"); const { isScamAddress } = require("../../shared/scamlist"); +const { DEFAULT_BLOCKSCOUT_URL } = require("../../shared/constants"); const { ERC20_ABI } = require("../../shared/constants"); const { log } = require("../../shared/log"); const makeBlockie = require("ethereum-blockies-base64"); @@ -181,7 +182,7 @@ function show(txInfo) { warningsEl.innerHTML = warnings .map( (w) => - `
WARNING: ${w}
`, + `
⚠ WARNING: ${w}
`, ) .join(""); warningsEl.classList.remove("hidden"); @@ -244,6 +245,7 @@ function show(txInfo) { showView("confirm-tx"); estimateGas(txInfo); + checkRecipientHistory(txInfo, warnings); } async function estimateGas(txInfo) { @@ -286,6 +288,33 @@ async function estimateGas(txInfo) { } } +async function checkRecipientHistory(txInfo, existingWarnings) { + try { + const blockscoutUrl = state.blockscoutUrl || DEFAULT_BLOCKSCOUT_URL; + const resp = await fetch(blockscoutUrl + "/addresses/" + txInfo.to); + if (!resp.ok) return; + const data = await resp.json(); + const txCount = + (parseInt(data.transactions_count || "0", 10) || 0) + + (parseInt(data.token_transfers_count || "0", 10) || 0); + if (txCount === 0) { + existingWarnings.push( + "This address has ZERO transaction history. It may be incorrect. Double-check before sending.", + ); + const warningsEl = $("confirm-warnings"); + warningsEl.innerHTML = existingWarnings + .map( + (w) => + `
⚠ WARNING: ${w}
`, + ) + .join(""); + warningsEl.classList.remove("hidden"); + } + } catch (e) { + log.errorf("recipient history check failed:", e.message); + } +} + function init(ctx) { $("btn-confirm-send").addEventListener("click", async () => { const password = $("confirm-tx-password").value; -- 2.49.1