fix: only a permit whose amount is the Amount figure names Token In (closes #370)
A PERMIT2_PERMIT named Token In whether or not its amount stood as the Amount figure, so the approval screen could show a permit's token, or an allowance, where the swap's own input belonged. A permit whose spender was not the router, or that the router may let fail, had no line naming its spender. Now only a permit whose amount stands names Token In. Every other permit, before the swap steps or after them, leaves Token In and Amount as they read with no permit and gets three lines of its own: Permit2 allowance, Allowance token and Allowance spender. README Transaction Decoding, its unknown token scale passage and the TxApproval element list match. Model: opus-5-5
This commit is contained in:
@@ -2809,7 +2809,7 @@ describe("the allow-revert flag", () => {
|
||||
mark: " (allowed to fail)",
|
||||
},
|
||||
])(
|
||||
"on $router, a PERMIT2_PERMIT with the flag is listed as 'Permit2 Permit$mark', and the swap reads as without the flag",
|
||||
"on $router, a PERMIT2_PERMIT with the flag is listed as 'Permit2 Permit$mark', and the swap's lines read as without the flag",
|
||||
({ address, mark }) => {
|
||||
const steps = [
|
||||
permit2Permit(USDT, USDT_2000),
|
||||
@@ -2824,9 +2824,30 @@ describe("the allow-revert flag", () => {
|
||||
expect(detail(withFlag, "Steps").value).toBe(
|
||||
"Permit2 Permit" + mark + " → V3 Swap (Exact In)",
|
||||
);
|
||||
const withoutSteps = (r) =>
|
||||
r.details.filter((d) => d.label !== "Steps");
|
||||
expect(withoutSteps(withFlag)).toEqual(withoutSteps(plain));
|
||||
// The permit names the router at ROUTER as its spender, so its
|
||||
// amount stands as the Amount figure only there, and only without
|
||||
// the flag. With the flag it stands on no router and gets lines
|
||||
// of its own, and the swap step names Token In: the same token,
|
||||
// its address in lowercase.
|
||||
const permitLines = [
|
||||
"Permit2 allowance",
|
||||
"Allowance token",
|
||||
"Allowance spender",
|
||||
];
|
||||
const swapLines = (r) =>
|
||||
r.details.filter(
|
||||
(d) =>
|
||||
!["Steps", "Token In", ...permitLines].includes(
|
||||
d.label,
|
||||
),
|
||||
);
|
||||
expect(swapLines(withFlag)).toEqual(swapLines(plain));
|
||||
expect(detail(withFlag, "Token In").address.toLowerCase()).toBe(
|
||||
detail(plain, "Token In").address.toLowerCase(),
|
||||
);
|
||||
expect(
|
||||
labels(withFlag).filter((l) => permitLines.includes(l)),
|
||||
).toEqual(permitLines);
|
||||
expect(detail(withFlag, "Min. received").value).toBe("1.0000 WETH");
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user