fix: the approval screen names the address a swap's output is paid to (closes #594)
The swap decoder read no recipient, so a swap paying its output to another address still showed Min. received. It now reads the address each swap step, SWEEP, WRAP_ETH, UNWRAP_WETH, V4 TAKE and TAKE_ALL pays. Min. received shows only when some step pays the sender, none pays another address, none that may pay one went unread, and the output does not stay in the router with no later SWEEP or UNWRAP_WETH paying it out. A payment to the V2 pair the next V2 swap spends as already paid is a hop, not a payout. Otherwise it reads Min. paid out, with Paid to lines. Model: opus-5-5
This commit was merged in pull request #598.
This commit is contained in:
@@ -79,10 +79,10 @@ function tokenAmountText(rawAmount, decimals, symbol) {
|
||||
};
|
||||
}
|
||||
|
||||
// Try to decode calldata sent to `toAddress` on the network with chain id
|
||||
// `chainId`, using known ABIs.
|
||||
// Try to decode calldata sent from `fromAddress` to `toAddress` on the network
|
||||
// with chain id `chainId`, using known ABIs.
|
||||
// Returns { name, description, details } or null.
|
||||
function decodeCalldata(data, toAddress, chainId) {
|
||||
function decodeCalldata(data, toAddress, chainId, fromAddress) {
|
||||
if (!data || data === "0x" || data.length < 10) return null;
|
||||
|
||||
// Where a token's scale is looked for, for every decoder below: the ERC-20
|
||||
@@ -191,6 +191,7 @@ function decodeCalldata(data, toAddress, chainId) {
|
||||
toAddress,
|
||||
chainId,
|
||||
decimalsSources,
|
||||
fromAddress,
|
||||
);
|
||||
if (routerResult) return routerResult;
|
||||
|
||||
@@ -277,11 +278,12 @@ function showTxApproval(details) {
|
||||
|
||||
// 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.
|
||||
// names, and the address the From line names.
|
||||
const decoded = decodeCalldata(
|
||||
approvedTx.data,
|
||||
toAddr || "",
|
||||
approvedTx.chainId,
|
||||
details.approvedFrom,
|
||||
);
|
||||
if (decoded && decoded.details) {
|
||||
// The asset the status summary is counted in: an ERC-20 call's Token
|
||||
|
||||
Reference in New Issue
Block a user