Compare commits
5 Commits
b799686cd4
...
feature/co
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8135b78b5c | ||
| 812fc01a98 | |||
|
|
811c125cb9 | ||
|
|
3005813f2c | ||
|
|
5565e76796 |
@@ -577,19 +577,6 @@
|
|||||||
<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"
|
||||||
|
|||||||
@@ -15,6 +15,21 @@
|
|||||||
--color-section: #dddddd;
|
--color-section: #dddddd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes copy-flash {
|
||||||
|
0% {
|
||||||
|
background-color: var(--color-fg);
|
||||||
|
color: var(--color-bg);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
background-color: transparent;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.copy-flash {
|
||||||
|
animation: copy-flash 500ms ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
width: 396px;
|
width: 396px;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const {
|
|||||||
$,
|
$,
|
||||||
showView,
|
showView,
|
||||||
showFlash,
|
showFlash,
|
||||||
|
flashCopyElement,
|
||||||
balanceLinesForAddress,
|
balanceLinesForAddress,
|
||||||
addressDotHtml,
|
addressDotHtml,
|
||||||
addressTitle,
|
addressTitle,
|
||||||
@@ -237,9 +238,11 @@ function renderTransactions(txs) {
|
|||||||
function init(_ctx) {
|
function init(_ctx) {
|
||||||
ctx = _ctx;
|
ctx = _ctx;
|
||||||
$("address-full").addEventListener("click", () => {
|
$("address-full").addEventListener("click", () => {
|
||||||
const addr = $("address-full").dataset.full;
|
const el = $("address-full");
|
||||||
|
const addr = el.dataset.full;
|
||||||
if (addr) {
|
if (addr) {
|
||||||
navigator.clipboard.writeText(addr);
|
navigator.clipboard.writeText(addr);
|
||||||
|
flashCopyElement(el);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -354,17 +357,21 @@ function init(_ctx) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("export-privkey-value").addEventListener("click", () => {
|
$("export-privkey-value").addEventListener("click", () => {
|
||||||
const key = $("export-privkey-value").textContent;
|
const el = $("export-privkey-value");
|
||||||
|
const key = el.textContent;
|
||||||
if (key) {
|
if (key) {
|
||||||
navigator.clipboard.writeText(key);
|
navigator.clipboard.writeText(key);
|
||||||
|
flashCopyElement(el);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("export-privkey-address").addEventListener("click", () => {
|
$("export-privkey-address").addEventListener("click", () => {
|
||||||
const full = $("export-privkey-address").dataset.full;
|
const el = $("export-privkey-address");
|
||||||
|
const full = el.dataset.full;
|
||||||
if (full) {
|
if (full) {
|
||||||
navigator.clipboard.writeText(full);
|
navigator.clipboard.writeText(full);
|
||||||
|
flashCopyElement(el);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ const {
|
|||||||
$,
|
$,
|
||||||
showView,
|
showView,
|
||||||
showFlash,
|
showFlash,
|
||||||
|
flashCopyElement,
|
||||||
addressDotHtml,
|
addressDotHtml,
|
||||||
addressTitle,
|
addressTitle,
|
||||||
escapeHtml,
|
escapeHtml,
|
||||||
@@ -313,9 +314,11 @@ function renderTransactions(txs) {
|
|||||||
function init(_ctx) {
|
function init(_ctx) {
|
||||||
ctx = _ctx;
|
ctx = _ctx;
|
||||||
$("address-token-full").addEventListener("click", () => {
|
$("address-token-full").addEventListener("click", () => {
|
||||||
const addr = $("address-token-full").dataset.full;
|
const el = $("address-token-full");
|
||||||
|
const addr = el.dataset.full;
|
||||||
if (addr) {
|
if (addr) {
|
||||||
navigator.clipboard.writeText(addr);
|
navigator.clipboard.writeText(addr);
|
||||||
|
flashCopyElement(el);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -324,6 +327,7 @@ function init(_ctx) {
|
|||||||
const copyEl = e.target.closest("[data-copy]");
|
const copyEl = e.target.closest("[data-copy]");
|
||||||
if (copyEl) {
|
if (copyEl) {
|
||||||
navigator.clipboard.writeText(copyEl.dataset.copy);
|
navigator.clipboard.writeText(copyEl.dataset.copy);
|
||||||
|
flashCopyElement(copyEl);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -372,6 +376,7 @@ function init(_ctx) {
|
|||||||
if (copyEl) {
|
if (copyEl) {
|
||||||
copyEl.addEventListener("click", () => {
|
copyEl.addEventListener("click", () => {
|
||||||
navigator.clipboard.writeText(copyEl.dataset.copy);
|
navigator.clipboard.writeText(copyEl.dataset.copy);
|
||||||
|
flashCopyElement(copyEl);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ const {
|
|||||||
hideError,
|
hideError,
|
||||||
showView,
|
showView,
|
||||||
showFlash,
|
showFlash,
|
||||||
|
flashCopyElement,
|
||||||
addressTitle,
|
addressTitle,
|
||||||
addressDotHtml,
|
addressDotHtml,
|
||||||
escapeHtml,
|
escapeHtml,
|
||||||
@@ -116,6 +117,7 @@ function show(txInfo) {
|
|||||||
if (copyEl) {
|
if (copyEl) {
|
||||||
copyEl.onclick = () => {
|
copyEl.onclick = () => {
|
||||||
navigator.clipboard.writeText(copyEl.dataset.copy);
|
navigator.clipboard.writeText(copyEl.dataset.copy);
|
||||||
|
flashCopyElement(copyEl);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -243,14 +245,7 @@ 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.display = "";
|
|
||||||
recipientWarning.style.visibility = "hidden";
|
|
||||||
|
|
||||||
estimateGas(txInfo);
|
estimateGas(txInfo);
|
||||||
checkRecipientHistory(txInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function estimateGas(txInfo) {
|
async function estimateGas(txInfo) {
|
||||||
@@ -293,34 +288,6 @@ 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 — hide the reserved space entirely
|
|
||||||
el.style.display = "none";
|
|
||||||
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";
|
|
||||||
}
|
|
||||||
} 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";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
@@ -76,6 +76,18 @@ function clearFlash() {
|
|||||||
$("flash-msg").textContent = "";
|
$("flash-msg").textContent = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function flashCopyElement(el) {
|
||||||
|
el.classList.remove("copy-flash");
|
||||||
|
// Force reflow so re-adding the class restarts the animation.
|
||||||
|
void el.offsetWidth;
|
||||||
|
el.classList.add("copy-flash");
|
||||||
|
el.addEventListener(
|
||||||
|
"animationend",
|
||||||
|
() => el.classList.remove("copy-flash"),
|
||||||
|
{ once: true },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function showFlash(msg, duration = 2000) {
|
function showFlash(msg, duration = 2000) {
|
||||||
clearFlash();
|
clearFlash();
|
||||||
$("flash-msg").textContent = msg;
|
$("flash-msg").textContent = msg;
|
||||||
@@ -265,6 +277,7 @@ module.exports = {
|
|||||||
hideError,
|
hideError,
|
||||||
showView,
|
showView,
|
||||||
showFlash,
|
showFlash,
|
||||||
|
flashCopyElement,
|
||||||
balanceLine,
|
balanceLine,
|
||||||
balanceLinesForAddress,
|
balanceLinesForAddress,
|
||||||
addressColor,
|
addressColor,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const {
|
|||||||
$,
|
$,
|
||||||
showView,
|
showView,
|
||||||
showFlash,
|
showFlash,
|
||||||
|
flashCopyElement,
|
||||||
balanceLinesForAddress,
|
balanceLinesForAddress,
|
||||||
isoDate,
|
isoDate,
|
||||||
timeAgo,
|
timeAgo,
|
||||||
@@ -85,8 +86,9 @@ function renderActiveAddress() {
|
|||||||
el.innerHTML =
|
el.innerHTML =
|
||||||
`<span class="underline decoration-dashed cursor-pointer" id="active-addr-copy">${dot}${escapeHtml(addr)}</span>` +
|
`<span class="underline decoration-dashed cursor-pointer" id="active-addr-copy">${dot}${escapeHtml(addr)}</span>` +
|
||||||
`<a href="${link}" target="_blank" rel="noopener" class="inline-flex items-center">${EXT_ICON}</a>`;
|
`<a href="${link}" target="_blank" rel="noopener" class="inline-flex items-center">${EXT_ICON}</a>`;
|
||||||
$("active-addr-copy").addEventListener("click", () => {
|
$("active-addr-copy").addEventListener("click", (e) => {
|
||||||
navigator.clipboard.writeText(addr);
|
navigator.clipboard.writeText(addr);
|
||||||
|
flashCopyElement(e.currentTarget);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const {
|
|||||||
$,
|
$,
|
||||||
showView,
|
showView,
|
||||||
showFlash,
|
showFlash,
|
||||||
|
flashCopyElement,
|
||||||
formatAddressHtml,
|
formatAddressHtml,
|
||||||
addressTitle,
|
addressTitle,
|
||||||
} = require("./helpers");
|
} = require("./helpers");
|
||||||
@@ -61,17 +62,21 @@ function show() {
|
|||||||
|
|
||||||
function init(ctx) {
|
function init(ctx) {
|
||||||
$("receive-address-block").addEventListener("click", () => {
|
$("receive-address-block").addEventListener("click", () => {
|
||||||
const addr = $("receive-address-block").dataset.full;
|
const el = $("receive-address-block");
|
||||||
|
const addr = el.dataset.full;
|
||||||
if (addr) {
|
if (addr) {
|
||||||
navigator.clipboard.writeText(addr);
|
navigator.clipboard.writeText(addr);
|
||||||
|
flashCopyElement(el);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("btn-receive-copy").addEventListener("click", () => {
|
$("btn-receive-copy").addEventListener("click", () => {
|
||||||
const addr = $("receive-address-block").dataset.full;
|
const block = $("receive-address-block");
|
||||||
|
const addr = block.dataset.full;
|
||||||
if (addr) {
|
if (addr) {
|
||||||
navigator.clipboard.writeText(addr);
|
navigator.clipboard.writeText(addr);
|
||||||
|
flashCopyElement(block);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ const {
|
|||||||
$,
|
$,
|
||||||
showView,
|
showView,
|
||||||
showFlash,
|
showFlash,
|
||||||
|
flashCopyElement,
|
||||||
addressDotHtml,
|
addressDotHtml,
|
||||||
addressTitle,
|
addressTitle,
|
||||||
escapeHtml,
|
escapeHtml,
|
||||||
@@ -158,8 +159,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");
|
||||||
|
|
||||||
@@ -169,6 +171,7 @@ function render() {
|
|||||||
.forEach((el) => {
|
.forEach((el) => {
|
||||||
el.onclick = () => {
|
el.onclick = () => {
|
||||||
navigator.clipboard.writeText(el.dataset.copy);
|
navigator.clipboard.writeText(el.dataset.copy);
|
||||||
|
flashCopyElement(el);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -246,6 +249,7 @@ async function loadCalldata(txHash, toAddress) {
|
|||||||
container.querySelectorAll("[data-copy]").forEach((el) => {
|
container.querySelectorAll("[data-copy]").forEach((el) => {
|
||||||
el.onclick = () => {
|
el.onclick = () => {
|
||||||
navigator.clipboard.writeText(el.dataset.copy);
|
navigator.clipboard.writeText(el.dataset.copy);
|
||||||
|
flashCopyElement(el);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const {
|
|||||||
$,
|
$,
|
||||||
showView,
|
showView,
|
||||||
showFlash,
|
showFlash,
|
||||||
|
flashCopyElement,
|
||||||
addressDotHtml,
|
addressDotHtml,
|
||||||
addressTitle,
|
addressTitle,
|
||||||
escapeHtml,
|
escapeHtml,
|
||||||
@@ -59,6 +60,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)
|
||||||
@@ -66,6 +77,7 @@ function attachCopyHandlers(viewId) {
|
|||||||
.forEach((el) => {
|
.forEach((el) => {
|
||||||
el.onclick = () => {
|
el.onclick = () => {
|
||||||
navigator.clipboard.writeText(el.dataset.copy);
|
navigator.clipboard.writeText(el.dataset.copy);
|
||||||
|
flashCopyElement(el);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -189,7 +201,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