fix: a V4 swap action not in the deployed shape is shown as not decoded (closes #358)
The four V4 swap actions are read only as the structs deployed on mainnet and Sepolia. ethers read the newer v4-periphery structs, which add minHopPriceX36, as the deployed ones, and the newer multi-hop exact-in struct showed the offset of its hop-price array as the swap amount. A decode now counts only when encoding it again gives back the same bytes. A swap action that fails that marks its step "V4 Swap (could not be decoded)", and a side its SETTLE or TAKE did not name reads "Unknown (could not be decoded)". The wait and error screens no longer show the ETH value as the amount of a swap whose amount was not read, unless the swap is paid in native ETH. Model: opus-5-5
This commit was merged in pull request #537.
This commit is contained in:
@@ -298,6 +298,23 @@ function showTxApproval(details) {
|
||||
sources,
|
||||
);
|
||||
}
|
||||
// A swap the decoder read no amount for, such as one whose V4 swap
|
||||
// action could not be read or a V4 exact-out swap. The wait and error
|
||||
// screens say the amount could not be decoded, with no currency after
|
||||
// it, rather than show the transaction's ETH value as the amount. A
|
||||
// swap paid in native ETH keeps that value: it is the ETH the swap
|
||||
// pays (for an exact-out swap, the most it pays), not a figure that
|
||||
// had to be read from the calldata.
|
||||
const tokenIn = decoded.details.find((d) => d.label === "Token In");
|
||||
if (
|
||||
tokenIn &&
|
||||
tokenIn.value !== "ETH (native)" &&
|
||||
!decoded.details.some((d) => d.label === "Amount")
|
||||
) {
|
||||
pendingTxDetails.amount = "Unknown (could not be decoded)";
|
||||
pendingTxDetails.token = null;
|
||||
pendingTxDetails.tokenSymbol = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Carry decoded calldata info through to success/error views
|
||||
|
||||
Reference in New Issue
Block a user