Compare commits
1 Commits
93565c7196
...
fix/55-swa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
868f7a6ff8 |
@@ -999,18 +999,18 @@
|
|||||||
class="text-xs"
|
class="text-xs"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="tx-detail-rawdata-section" class="hidden">
|
||||||
|
<div class="text-xs text-muted mb-1">Raw data</div>
|
||||||
|
<div
|
||||||
|
id="tx-detail-rawdata"
|
||||||
|
class="text-xs break-all font-mono border border-border border-dashed p-2"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<div class="text-xs text-muted mb-1">Transaction hash</div>
|
<div class="text-xs text-muted mb-1">Transaction hash</div>
|
||||||
<div id="tx-detail-hash" class="text-xs break-all"></div>
|
<div id="tx-detail-hash" class="text-xs break-all"></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="tx-detail-rawdata-section" class="mb-4 hidden">
|
|
||||||
<div class="text-xs text-muted mb-1">Raw data</div>
|
|
||||||
<div
|
|
||||||
id="tx-detail-rawdata"
|
|
||||||
class="text-xs break-all font-mono border border-border border-dashed p-2"
|
|
||||||
></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- ============ TRANSACTION APPROVAL ============ -->
|
<!-- ============ TRANSACTION APPROVAL ============ -->
|
||||||
|
|||||||
@@ -186,12 +186,10 @@ function renderTransactions(txs) {
|
|||||||
let html = "";
|
let html = "";
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (const tx of txs) {
|
for (const tx of txs) {
|
||||||
// For swap transactions, show the user's own labelled wallet
|
|
||||||
// address instead of the contract address (see issue #55).
|
|
||||||
const counterparty =
|
const counterparty =
|
||||||
tx.direction === "contract" && tx.directionLabel === "Swap"
|
tx.direction === "contract"
|
||||||
? tx.from
|
? tx.from
|
||||||
: tx.direction === "sent" || tx.direction === "contract"
|
: tx.direction === "sent"
|
||||||
? tx.to
|
? tx.to
|
||||||
: tx.from;
|
: tx.from;
|
||||||
const ensName = ensNameMap.get(counterparty) || null;
|
const ensName = ensNameMap.get(counterparty) || null;
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ function show() {
|
|||||||
|
|
||||||
// Determine token symbol and balance
|
// Determine token symbol and balance
|
||||||
let symbol, amount, price;
|
let symbol, amount, price;
|
||||||
const knownToken = TOKEN_BY_ADDRESS.get(tokenId.toLowerCase());
|
|
||||||
if (tokenId === "ETH") {
|
if (tokenId === "ETH") {
|
||||||
symbol = "ETH";
|
symbol = "ETH";
|
||||||
amount = parseFloat(addr.balance || "0");
|
amount = parseFloat(addr.balance || "0");
|
||||||
@@ -96,14 +95,7 @@ function show() {
|
|||||||
const tb = (addr.tokenBalances || []).find(
|
const tb = (addr.tokenBalances || []).find(
|
||||||
(t) => t.address.toLowerCase() === tokenId.toLowerCase(),
|
(t) => t.address.toLowerCase() === tokenId.toLowerCase(),
|
||||||
);
|
);
|
||||||
const tracked = (state.trackedTokens || []).find(
|
symbol = tb ? tb.symbol : "?";
|
||||||
(t) => t.address.toLowerCase() === tokenId.toLowerCase(),
|
|
||||||
);
|
|
||||||
symbol =
|
|
||||||
(tb && tb.symbol) ||
|
|
||||||
(tracked && tracked.symbol) ||
|
|
||||||
(knownToken && knownToken.symbol) ||
|
|
||||||
"?";
|
|
||||||
amount = tb ? parseFloat(tb.balance || "0") : 0;
|
amount = tb ? parseFloat(tb.balance || "0") : 0;
|
||||||
price = getPrice(symbol);
|
price = getPrice(symbol);
|
||||||
}
|
}
|
||||||
@@ -146,32 +138,13 @@ function show() {
|
|||||||
const tb = (addr.tokenBalances || []).find(
|
const tb = (addr.tokenBalances || []).find(
|
||||||
(t) => t.address.toLowerCase() === tokenId.toLowerCase(),
|
(t) => t.address.toLowerCase() === tokenId.toLowerCase(),
|
||||||
);
|
);
|
||||||
const tracked = (state.trackedTokens || []).find(
|
const tokenName = tb && tb.name ? escapeHtml(tb.name) : null;
|
||||||
(t) => t.address.toLowerCase() === tokenId.toLowerCase(),
|
const tokenSymbol = tb && tb.symbol ? escapeHtml(tb.symbol) : null;
|
||||||
);
|
const tokenDecimals = tb && tb.decimals != null ? tb.decimals : null;
|
||||||
const rawName =
|
|
||||||
(tb && tb.name) ||
|
|
||||||
(tracked && tracked.name) ||
|
|
||||||
(knownToken && knownToken.name) ||
|
|
||||||
null;
|
|
||||||
const rawSymbol =
|
|
||||||
(tb && tb.symbol) ||
|
|
||||||
(tracked && tracked.symbol) ||
|
|
||||||
(knownToken && knownToken.symbol) ||
|
|
||||||
null;
|
|
||||||
const tokenName = rawName ? escapeHtml(rawName) : null;
|
|
||||||
const tokenSymbol = rawSymbol ? escapeHtml(rawSymbol) : null;
|
|
||||||
const tokenDecimals =
|
|
||||||
tb && tb.decimals != null
|
|
||||||
? tb.decimals
|
|
||||||
: tracked && tracked.decimals != null
|
|
||||||
? tracked.decimals
|
|
||||||
: knownToken && knownToken.decimals != null
|
|
||||||
? knownToken.decimals
|
|
||||||
: null;
|
|
||||||
const tokenHolders = tb && tb.holders != null ? tb.holders : null;
|
const tokenHolders = tb && tb.holders != null ? tb.holders : null;
|
||||||
const dot = addressDotHtml(tokenId);
|
const dot = addressDotHtml(tokenId);
|
||||||
const tokenLink = `https://etherscan.io/token/${escapeHtml(tokenId)}`;
|
const tokenLink = `https://etherscan.io/token/${escapeHtml(tokenId)}`;
|
||||||
|
const knownToken = TOKEN_BY_ADDRESS.get(tokenId.toLowerCase());
|
||||||
const projectUrl = knownToken && knownToken.url ? knownToken.url : null;
|
const projectUrl = knownToken && knownToken.url ? knownToken.url : null;
|
||||||
let infoHtml = `<div class="font-bold mb-2">Contract Address</div>`;
|
let infoHtml = `<div class="font-bold mb-2">Contract Address</div>`;
|
||||||
infoHtml +=
|
infoHtml +=
|
||||||
|
|||||||
@@ -103,15 +103,10 @@ function renderHomeTxList(ctx) {
|
|||||||
let html = "";
|
let html = "";
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (const tx of homeTxs) {
|
for (const tx of homeTxs) {
|
||||||
// For swap transactions, show the user's own labelled wallet
|
|
||||||
// address (the one that initiated the swap) instead of the
|
|
||||||
// contract address which is not useful in the list view.
|
|
||||||
const counterparty =
|
const counterparty =
|
||||||
tx.direction === "contract" && tx.directionLabel === "Swap"
|
tx.direction === "sent" || tx.direction === "contract"
|
||||||
? tx.from
|
? tx.to
|
||||||
: tx.direction === "sent" || tx.direction === "contract"
|
: tx.from;
|
||||||
? tx.to
|
|
||||||
: tx.from;
|
|
||||||
const dirLabel = tx.directionLabel;
|
const dirLabel = tx.directionLabel;
|
||||||
const amountStr = tx.value
|
const amountStr = tx.value
|
||||||
? escapeHtml(tx.value + " " + tx.symbol)
|
? escapeHtml(tx.value + " " + tx.symbol)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const {
|
|||||||
const { state, currentAddress } = require("../../shared/state");
|
const { state, currentAddress } = require("../../shared/state");
|
||||||
let ctx;
|
let ctx;
|
||||||
const { getProvider } = require("../../shared/balances");
|
const { getProvider } = require("../../shared/balances");
|
||||||
const { KNOWN_SYMBOLS, TOKEN_BY_ADDRESS } = require("../../shared/tokenList");
|
const { KNOWN_SYMBOLS } = require("../../shared/tokenList");
|
||||||
|
|
||||||
const EXT_ICON =
|
const EXT_ICON =
|
||||||
`<span style="display:inline-block;width:10px;height:10px;margin-left:4px;vertical-align:middle">` +
|
`<span style="display:inline-block;width:10px;height:10px;margin-left:4px;vertical-align:middle">` +
|
||||||
@@ -73,15 +73,7 @@ function updateSendBalance() {
|
|||||||
const tb = (addr.tokenBalances || []).find(
|
const tb = (addr.tokenBalances || []).find(
|
||||||
(t) => t.address.toLowerCase() === token.toLowerCase(),
|
(t) => t.address.toLowerCase() === token.toLowerCase(),
|
||||||
);
|
);
|
||||||
const knownToken = TOKEN_BY_ADDRESS.get(token.toLowerCase());
|
const symbol = tb ? tb.symbol : "?";
|
||||||
const tracked = (state.trackedTokens || []).find(
|
|
||||||
(t) => t.address.toLowerCase() === token.toLowerCase(),
|
|
||||||
);
|
|
||||||
const symbol =
|
|
||||||
(tb && tb.symbol) ||
|
|
||||||
(tracked && tracked.symbol) ||
|
|
||||||
(knownToken && knownToken.symbol) ||
|
|
||||||
"?";
|
|
||||||
const bal = tb ? tb.balance || "0" : "0";
|
const bal = tb ? tb.balance || "0" : "0";
|
||||||
$("send-balance").textContent =
|
$("send-balance").textContent =
|
||||||
"Current balance: " + bal + " " + symbol;
|
"Current balance: " + bal + " " + symbol;
|
||||||
@@ -132,15 +124,7 @@ function init(_ctx) {
|
|||||||
const tb = (addr.tokenBalances || []).find(
|
const tb = (addr.tokenBalances || []).find(
|
||||||
(t) => t.address.toLowerCase() === token.toLowerCase(),
|
(t) => t.address.toLowerCase() === token.toLowerCase(),
|
||||||
);
|
);
|
||||||
const knownTk = TOKEN_BY_ADDRESS.get(token.toLowerCase());
|
tokenSymbol = tb ? tb.symbol : "?";
|
||||||
const trackedTk = (state.trackedTokens || []).find(
|
|
||||||
(t) => t.address.toLowerCase() === token.toLowerCase(),
|
|
||||||
);
|
|
||||||
tokenSymbol =
|
|
||||||
(tb && tb.symbol) ||
|
|
||||||
(trackedTk && trackedTk.symbol) ||
|
|
||||||
(knownTk && knownTk.symbol) ||
|
|
||||||
"?";
|
|
||||||
tokenBalance = tb ? tb.balance || "0" : "0";
|
tokenBalance = tb ? tb.balance || "0" : "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,19 +37,11 @@ function blockieHtml(address) {
|
|||||||
return `<img src="${src}" width="48" height="48" style="image-rendering:pixelated;border-radius:50%;display:inline-block">`;
|
return `<img src="${src}" width="48" height="48" style="image-rendering:pixelated;border-radius:50%;display:inline-block">`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function etherscanLinkHtml(url) {
|
|
||||||
return (
|
|
||||||
`<a href="${url}" target="_blank" rel="noopener" ` +
|
|
||||||
`class="inline-flex items-center"` +
|
|
||||||
`>${EXT_ICON}</a>`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function txAddressHtml(address, ensName, title) {
|
function txAddressHtml(address, ensName, title) {
|
||||||
const blockie = blockieHtml(address);
|
const blockie = blockieHtml(address);
|
||||||
const dot = addressDotHtml(address);
|
const dot = addressDotHtml(address);
|
||||||
const link = `https://etherscan.io/address/${address}`;
|
const link = `https://etherscan.io/address/${address}`;
|
||||||
const extLink = etherscanLinkHtml(link);
|
const extLink = `<a href="${link}" target="_blank" rel="noopener" class="inline-flex items-center">${EXT_ICON}</a>`;
|
||||||
let html = `<div class="mb-1">${blockie}</div>`;
|
let html = `<div class="mb-1">${blockie}</div>`;
|
||||||
if (title) {
|
if (title) {
|
||||||
html += `<div class="font-bold">${escapeHtml(title)}</div>`;
|
html += `<div class="font-bold">${escapeHtml(title)}</div>`;
|
||||||
@@ -58,10 +50,10 @@ function txAddressHtml(address, ensName, title) {
|
|||||||
html +=
|
html +=
|
||||||
`<div class="flex items-center">${dot}` +
|
`<div class="flex items-center">${dot}` +
|
||||||
copyableHtml(ensName, "") +
|
copyableHtml(ensName, "") +
|
||||||
`</div>` +
|
|
||||||
`<div class="flex items-center">${dot}` +
|
|
||||||
copyableHtml(address, "break-all") +
|
|
||||||
extLink +
|
extLink +
|
||||||
|
`</div>` +
|
||||||
|
`<div class="break-all">` +
|
||||||
|
copyableHtml(address, "break-all") +
|
||||||
`</div>`;
|
`</div>`;
|
||||||
} else {
|
} else {
|
||||||
html +=
|
html +=
|
||||||
@@ -75,7 +67,7 @@ function txAddressHtml(address, ensName, title) {
|
|||||||
|
|
||||||
function txHashHtml(hash) {
|
function txHashHtml(hash) {
|
||||||
const link = `https://etherscan.io/tx/${hash}`;
|
const link = `https://etherscan.io/tx/${hash}`;
|
||||||
const extLink = etherscanLinkHtml(link);
|
const extLink = `<a href="${link}" target="_blank" rel="noopener" class="inline-flex items-center">${EXT_ICON}</a>`;
|
||||||
return copyableHtml(hash, "break-all") + extLink;
|
return copyableHtml(hash, "break-all") + extLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,6 +93,9 @@ function show(tx) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
render();
|
render();
|
||||||
|
if (tx.isContractCall || tx.direction === "contract") {
|
||||||
|
loadCalldata(tx.hash, tx.to);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function render() {
|
function render() {
|
||||||
@@ -149,15 +144,9 @@ function render() {
|
|||||||
if (headingEl) headingEl.textContent = "Transaction";
|
if (headingEl) headingEl.textContent = "Transaction";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide calldata and raw data sections; re-fetch if this is a contract call
|
// Hide calldata section by default; loadCalldata will show it if needed
|
||||||
const calldataSection = $("tx-detail-calldata-section");
|
const calldataSection = $("tx-detail-calldata-section");
|
||||||
if (calldataSection) calldataSection.classList.add("hidden");
|
if (calldataSection) calldataSection.classList.add("hidden");
|
||||||
const rawDataSection = $("tx-detail-rawdata-section");
|
|
||||||
if (rawDataSection) rawDataSection.classList.add("hidden");
|
|
||||||
|
|
||||||
if (tx.isContractCall || tx.direction === "contract") {
|
|
||||||
loadCalldata(tx.hash, tx.to);
|
|
||||||
}
|
|
||||||
|
|
||||||
$("tx-detail-time").textContent =
|
$("tx-detail-time").textContent =
|
||||||
isoDate(tx.timestamp) + " (" + timeAgo(tx.timestamp) + ")";
|
isoDate(tx.timestamp) + " (" + timeAgo(tx.timestamp) + ")";
|
||||||
@@ -204,20 +193,9 @@ async function loadCalldata(txHash, toAddress) {
|
|||||||
for (const d of decoded.details || []) {
|
for (const d of decoded.details || []) {
|
||||||
detailsHtml += `<div class="mb-2">`;
|
detailsHtml += `<div class="mb-2">`;
|
||||||
detailsHtml += `<div class="text-muted">${escapeHtml(d.label)}</div>`;
|
detailsHtml += `<div class="text-muted">${escapeHtml(d.label)}</div>`;
|
||||||
if (d.address && d.isToken) {
|
if (d.address) {
|
||||||
// Token entry: show symbol on its own line, then dot + address + Etherscan link
|
|
||||||
const dot = addressDotHtml(d.address);
|
const dot = addressDotHtml(d.address);
|
||||||
const tokenSymbol = d.value.match(/^(\S+)\s*\(/)?.[1];
|
detailsHtml += `<div>${dot}${copyableHtml(d.value, "break-all")}</div>`;
|
||||||
if (tokenSymbol) {
|
|
||||||
detailsHtml += `<div class="font-bold">${escapeHtml(tokenSymbol)}</div>`;
|
|
||||||
}
|
|
||||||
const etherscanUrl = `https://etherscan.io/token/${d.address}`;
|
|
||||||
detailsHtml += `<div class="flex items-center">${dot}${copyableHtml(d.address, "break-all")}${etherscanLinkHtml(etherscanUrl)}</div>`;
|
|
||||||
} else if (d.address) {
|
|
||||||
// Protocol/contract entry: show name + Etherscan link
|
|
||||||
const dot = addressDotHtml(d.address);
|
|
||||||
const etherscanUrl = `https://etherscan.io/address/${d.address}`;
|
|
||||||
detailsHtml += `<div class="flex items-center">${dot}${copyableHtml(d.value, "break-all")}${etherscanLinkHtml(etherscanUrl)}</div>`;
|
|
||||||
} else {
|
} else {
|
||||||
detailsHtml += `<div class="font-bold">${escapeHtml(d.value)}</div>`;
|
detailsHtml += `<div class="font-bold">${escapeHtml(d.value)}</div>`;
|
||||||
}
|
}
|
||||||
@@ -241,16 +219,13 @@ async function loadCalldata(txHash, toAddress) {
|
|||||||
|
|
||||||
section.classList.remove("hidden");
|
section.classList.remove("hidden");
|
||||||
|
|
||||||
// Bind copy handlers for new elements (including raw data now outside section)
|
// Bind copy handlers for new elements
|
||||||
const copyTargets = [section, rawSection].filter(Boolean);
|
section.querySelectorAll("[data-copy]").forEach((el) => {
|
||||||
for (const container of copyTargets) {
|
el.onclick = () => {
|
||||||
container.querySelectorAll("[data-copy]").forEach((el) => {
|
navigator.clipboard.writeText(el.dataset.copy);
|
||||||
el.onclick = () => {
|
showFlash("Copied!");
|
||||||
navigator.clipboard.writeText(el.dataset.copy);
|
};
|
||||||
showFlash("Copied!");
|
});
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.errorf("loadCalldata failed:", e.message);
|
log.errorf("loadCalldata failed:", e.message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ async function fetchTokenBalances(address, blockscoutUrl, trackedTokens) {
|
|||||||
|
|
||||||
balances.push({
|
balances.push({
|
||||||
address: item.token.address_hash,
|
address: item.token.address_hash,
|
||||||
name: item.token.name || "",
|
|
||||||
symbol: item.token.symbol || "???",
|
symbol: item.token.symbol || "???",
|
||||||
decimals: decimals,
|
decimals: decimals,
|
||||||
balance: bal,
|
balance: bal,
|
||||||
|
|||||||
Reference in New Issue
Block a user