fix: the swap summary is shown only for a transaction sent to a Universal Router (closes #520)
check / check (push) Canceled after 0s
e2e / e2e-chrome (push) Canceled after 0s
e2e / e2e-firefox (push) Canceled after 0s

The Universal Router decoder recognised execute() by its selector alone, so
the same calldata sent to any address was described as a swap through the
router. It now keeps the router deployments Uniswap publishes for Ethereum
Mainnet and Sepolia, and decodes only a transaction sent to one of them on
its network, ignoring address case. TxApproval passes the transaction's
chain id, TransactionDetail the active network's.

Model: opus-5-5
This commit was merged in pull request #579.
This commit is contained in:
2026-10-19 04:40:55 +02:00
parent 85fa864db4
commit 8b6c2b4df9
12 changed files with 445 additions and 70 deletions
+17 -5
View File
@@ -79,9 +79,10 @@ function tokenAmountText(rawAmount, decimals, symbol) {
};
}
// Try to decode calldata using known ABIs.
// Try to decode calldata sent to `toAddress` on the network with chain id
// `chainId`, using known ABIs.
// Returns { name, description, details } or null.
function decodeCalldata(data, toAddress) {
function decodeCalldata(data, toAddress, chainId) {
if (!data || data === "0x" || data.length < 10) return null;
// Where a token's scale is looked for, for every decoder below: the ERC-20
@@ -185,7 +186,12 @@ function decodeCalldata(data, toAddress) {
}
// Try Uniswap Universal Router
const routerResult = uniswap.decode(data, toAddress, decimalsSources);
const routerResult = uniswap.decode(
data,
toAddress,
chainId,
decimalsSources,
);
if (routerResult) return routerResult;
return null;
@@ -269,8 +275,14 @@ function showTxApproval(details) {
chainId: approvedTx.chainId,
};
// If this is an ERC-20 call, try to extract the real recipient and amount
const decoded = decodeCalldata(approvedTx.data, toAddr || "");
// If this is an ERC-20 call, try to extract the real recipient and amount.
// Decoded for the network the transaction is for, which the Network line
// names.
const decoded = decodeCalldata(
approvedTx.data,
toAddr || "",
approvedTx.chainId,
);
if (decoded && decoded.details) {
// The asset the status summary is counted in: an ERC-20 call's Token
// contract, or a swap's input token. Its symbol is resolved from the