fix: prevent double symbol display on tx broadcast status views
All checks were successful
check / check (push) Successful in 22s
All checks were successful
check / check (push) Successful in 22s
The decodeCalldata function in approval.js was embedding the token symbol into the Amount value string (e.g. '2.0000 USDT'). This value was then assigned to pendingTxDetails.amount, and txStatus.js would append the symbol again, producing '2.0000 USDT ETH' (or '2.0000 USDT USDT' when the token was in TOKEN_BY_ADDRESS). Fix: decodeCalldata now provides a rawValue field (numeric only) on Amount details. pendingTxDetails.amount uses rawValue when available, so txStatus.js can append the correct symbol exactly once. Affected paths: - approve() decoded amount (approve calldata) - transfer() decoded amount (transfer calldata) - pendingTxDetails.amount assignment Audited all other amount+symbol display sites: - txStatus.js showWait/showSuccess/showError: correctly derive symbol from txInfo.token, no duplication - confirmTx.js show(): builds symbol independently, amount is raw — OK - send.js: amount is raw user input — OK - addressToken.js: uses balanceLine helper — OK - transactions.js parseTx/parseTokenTransfer: separate value/symbol — OK Fixes #59
This commit is contained in:
@@ -78,10 +78,12 @@ function decodeCalldata(data, toAddress) {
|
||||
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||
);
|
||||
const isUnlimited = rawAmount === maxUint;
|
||||
const amountRaw = isUnlimited
|
||||
? "Unlimited"
|
||||
: formatTxValue(formatUnits(rawAmount, tokenDecimals));
|
||||
const amountStr = isUnlimited
|
||||
? "Unlimited"
|
||||
: formatTxValue(formatUnits(rawAmount, tokenDecimals)) +
|
||||
(tokenSymbol ? " " + tokenSymbol : "");
|
||||
: amountRaw + (tokenSymbol ? " " + tokenSymbol : "");
|
||||
|
||||
return {
|
||||
name: "Token Approval",
|
||||
@@ -100,7 +102,11 @@ function decodeCalldata(data, toAddress) {
|
||||
value: spender,
|
||||
address: spender,
|
||||
},
|
||||
{ label: "Amount", value: amountStr },
|
||||
{
|
||||
label: "Amount",
|
||||
value: amountStr,
|
||||
rawValue: amountRaw,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
@@ -108,9 +114,11 @@ function decodeCalldata(data, toAddress) {
|
||||
if (parsed.name === "transfer") {
|
||||
const to = parsed.args[0];
|
||||
const rawAmount = parsed.args[1];
|
||||
const amountRaw = formatTxValue(
|
||||
formatUnits(rawAmount, tokenDecimals),
|
||||
);
|
||||
const amountStr =
|
||||
formatTxValue(formatUnits(rawAmount, tokenDecimals)) +
|
||||
(tokenSymbol ? " " + tokenSymbol : "");
|
||||
amountRaw + (tokenSymbol ? " " + tokenSymbol : "");
|
||||
|
||||
return {
|
||||
name: "Token Transfer",
|
||||
@@ -125,7 +133,11 @@ function decodeCalldata(data, toAddress) {
|
||||
isToken: true,
|
||||
},
|
||||
{ label: "Recipient", value: to, address: to },
|
||||
{ label: "Amount", value: amountStr },
|
||||
{
|
||||
label: "Amount",
|
||||
value: amountStr,
|
||||
rawValue: amountRaw,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
@@ -163,7 +175,7 @@ function showTxApproval(details) {
|
||||
pendingTxDetails.to = d.address;
|
||||
}
|
||||
if (d.label === "Amount") {
|
||||
pendingTxDetails.amount = d.value;
|
||||
pendingTxDetails.amount = d.rawValue || d.value;
|
||||
}
|
||||
}
|
||||
if (token) {
|
||||
|
||||
Reference in New Issue
Block a user