Compare commits
3 Commits
c8d1f96770
...
issue-99-b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bffc463942 | ||
| dc8ec7d28f | |||
|
|
2fbed343db |
@@ -172,6 +172,8 @@ function showTxApproval(details) {
|
|||||||
// If this is an ERC-20 call, try to extract the real recipient and amount
|
// If this is an ERC-20 call, try to extract the real recipient and amount
|
||||||
const decoded = decodeCalldata(details.txParams.data, toAddr || "");
|
const decoded = decodeCalldata(details.txParams.data, toAddr || "");
|
||||||
if (decoded && decoded.details) {
|
if (decoded && decoded.details) {
|
||||||
|
let decodedTokenAddr = null;
|
||||||
|
let decodedTokenSymbol = null;
|
||||||
for (const d of decoded.details) {
|
for (const d of decoded.details) {
|
||||||
if (d.label === "Recipient" && d.address) {
|
if (d.label === "Recipient" && d.address) {
|
||||||
pendingTxDetails.to = d.address;
|
pendingTxDetails.to = d.address;
|
||||||
@@ -179,10 +181,20 @@ function showTxApproval(details) {
|
|||||||
if (d.label === "Amount") {
|
if (d.label === "Amount") {
|
||||||
pendingTxDetails.amount = d.rawValue || d.value;
|
pendingTxDetails.amount = d.rawValue || d.value;
|
||||||
}
|
}
|
||||||
|
if (d.label === "Token In" && d.isToken && d.address) {
|
||||||
|
const t = TOKEN_BY_ADDRESS.get(d.address.toLowerCase());
|
||||||
|
if (t) {
|
||||||
|
decodedTokenAddr = d.address;
|
||||||
|
decodedTokenSymbol = t.symbol;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (token) {
|
if (token) {
|
||||||
pendingTxDetails.token = toAddr;
|
pendingTxDetails.token = toAddr;
|
||||||
pendingTxDetails.tokenSymbol = token.symbol;
|
pendingTxDetails.tokenSymbol = token.symbol;
|
||||||
|
} else if (decodedTokenAddr) {
|
||||||
|
pendingTxDetails.token = decodedTokenAddr;
|
||||||
|
pendingTxDetails.tokenSymbol = decodedTokenSymbol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,10 +43,21 @@ function toAddressHtml(address) {
|
|||||||
if (title) {
|
if (title) {
|
||||||
return (
|
return (
|
||||||
`<div class="flex items-center font-bold">${dot}${escapeHtml(title)}</div>` +
|
`<div class="flex items-center font-bold">${dot}${escapeHtml(title)}</div>` +
|
||||||
`<div class="break-all">${escapeHtml(address)}${extLink}</div>`
|
`<div class="break-all underline decoration-dashed cursor-pointer" data-copy="${escapeHtml(address)}">${escapeHtml(address)}</div>` +
|
||||||
|
extLink
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return `<div class="flex items-center">${dot}<span class="break-all">${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) {
|
||||||
@@ -139,7 +150,7 @@ function etherscanTokenLink(address) {
|
|||||||
|
|
||||||
function decodedDetailsHtml(decoded) {
|
function decodedDetailsHtml(decoded) {
|
||||||
if (!decoded || !decoded.details) return "";
|
if (!decoded || !decoded.details) return "";
|
||||||
let html = "";
|
let html = `<div class="border border-border border-dashed p-2 mb-3">`;
|
||||||
if (decoded.name) {
|
if (decoded.name) {
|
||||||
html += `<div class="mb-2"><div class="text-xs text-muted mb-1">Action</div>`;
|
html += `<div class="mb-2"><div class="text-xs text-muted mb-1">Action</div>`;
|
||||||
html += `<div class="font-bold">${escapeHtml(decoded.name)}</div></div>`;
|
html += `<div class="font-bold">${escapeHtml(decoded.name)}</div></div>`;
|
||||||
@@ -164,20 +175,36 @@ function decodedDetailsHtml(decoded) {
|
|||||||
}
|
}
|
||||||
html += `</div>`;
|
html += `</div>`;
|
||||||
}
|
}
|
||||||
|
html += `</div>`;
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderSuccess() {
|
function renderSuccess() {
|
||||||
const d = state.viewData;
|
const d = state.viewData;
|
||||||
if (!d || !d.hash) return;
|
if (!d || !d.hash) return;
|
||||||
$("success-tx-summary").textContent = d.amount + " " + d.symbol;
|
|
||||||
$("success-tx-to").innerHTML = toAddressHtml(d.to);
|
const hasDecoded = d.decoded && d.decoded.details;
|
||||||
$("success-tx-block").textContent = String(d.blockNumber);
|
|
||||||
|
// When decoded details are present, the Amount and To are already
|
||||||
|
// shown inside the decoded well — hide the top-level duplicates.
|
||||||
|
const summarySection = $("success-tx-summary").parentElement;
|
||||||
|
const toSection = $("success-tx-to").parentElement;
|
||||||
|
if (hasDecoded) {
|
||||||
|
summarySection.classList.add("hidden");
|
||||||
|
toSection.classList.add("hidden");
|
||||||
|
} else {
|
||||||
|
summarySection.classList.remove("hidden");
|
||||||
|
toSection.classList.remove("hidden");
|
||||||
|
$("success-tx-summary").textContent = d.amount + " " + d.symbol;
|
||||||
|
$("success-tx-to").innerHTML = toAddressHtml(d.to);
|
||||||
|
}
|
||||||
|
|
||||||
|
$("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
|
||||||
const decodedEl = $("success-tx-decoded");
|
const decodedEl = $("success-tx-decoded");
|
||||||
if (decodedEl && d.decoded) {
|
if (decodedEl && hasDecoded) {
|
||||||
decodedEl.innerHTML = decodedDetailsHtml(d.decoded);
|
decodedEl.innerHTML = decodedDetailsHtml(d.decoded);
|
||||||
decodedEl.classList.remove("hidden");
|
decodedEl.classList.remove("hidden");
|
||||||
} else if (decodedEl) {
|
} else if (decodedEl) {
|
||||||
|
|||||||
@@ -445,12 +445,18 @@ function decode(data, toAddress) {
|
|||||||
const maxUint160 = BigInt(
|
const maxUint160 = BigInt(
|
||||||
"0xffffffffffffffffffffffffffffffffffffffff",
|
"0xffffffffffffffffffffffffffffffffffffffff",
|
||||||
);
|
);
|
||||||
const amountStr =
|
const isUnlimited = inputAmount >= maxUint160;
|
||||||
inputAmount >= maxUint160
|
const amountRaw = isUnlimited
|
||||||
? "Unlimited"
|
? "Unlimited"
|
||||||
: formatAmount(inputAmount, inInfo.decimals) +
|
: formatAmount(inputAmount, inInfo.decimals);
|
||||||
(inSymbol ? " " + inSymbol : "");
|
const amountStr = isUnlimited
|
||||||
details.push({ label: "Amount", value: amountStr });
|
? "Unlimited"
|
||||||
|
: amountRaw + (inSymbol ? " " + inSymbol : "");
|
||||||
|
details.push({
|
||||||
|
label: "Amount",
|
||||||
|
value: amountStr,
|
||||||
|
rawValue: amountRaw,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outSymbol) {
|
if (outSymbol) {
|
||||||
|
|||||||
Reference in New Issue
Block a user