2 Commits
Author SHA1 Message Date
sneak 172f2c8a87 fix: each PERMIT2_TRANSFER_FROM shows the amount it moves and where to (closes #611)
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run
The swap decoder now gives three lines for every PERMIT2_TRANSFER_FROM
it reads but a move into the router, after the swap's Amount line: the
amount moved from the sender, the token with its address, and where it
goes (the V2 pair the next swap spends, the sender, or the address
itself on a line of its own). A move into the router keeps its Paid to
and Token moved into the router lines, which already give its amount.
Before, a move to another address or to the next V2 pair showed no
amount at all. Who counts as paid, and so Min. received against Min.
paid out, is unchanged. tokenMovedLine() moves to module level and
takes its label as an argument.

Model: opus-5-5
2026-10-19 21:25:52 +00:00
clawbot 96446f4661 fix: a network switch in Settings updates the testnet banner at once (closes #511)
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run
The Settings network handler now redraws the red banner once the switch
is saved, so it appears on a switch to Sepolia and goes on a switch back
to mainnet while Settings is still on screen. Before, the banner changed
only when the next screen came up. The Chrome browser suite switches
both ways on Settings and reads the banner each time.

Model: opus-5-5
2026-10-19 22:53:11 +02:00
6 changed files with 115 additions and 34 deletions
+21 -15
View File
@@ -418,6 +418,10 @@ Each group of these assertions records a coverage key and a final case demands
the exact set, so a section that silently stopped running reddens the suite
instead of quietly shrinking it.
It also covers the red banner on the Settings screen: switching the network
there to Sepolia must put up the `[TESTNET]` banner, and switching back to
mainnet must take it down, both while Settings is still on screen.
It also covers the confirmation screen, for both a native ETH send and an ERC-20
send: Send disabled while the fee estimate is in flight, enabled once it lands,
the fee block quoting the expected cost and the reserve separately, the distinct
@@ -3114,21 +3118,23 @@ Currently supported:
may pay an address went unread. When no step pays anyone, a single line reads
`Unknown (not named in the calldata)`. Wherever there is a `Paid to` line, the
minimum reads `Min. paid out`. After the `Amount` line (after `Token In` when
there is none), each `PERMIT2_TRANSFER_FROM`, in step order, gives three
lines: `Moved from the sender`, the amount it moves, for example
`1000000.0000 USDT`; `Token moved`, giving the token's address as the
`Token In` line does; and `Moved to`, which reads `The router` for a move into
the router, `The V2 pair the next swap spends` for a hop, and `The sender` for
`address(1)` on every router but `UniversalRouterV1`, and otherwise gives the
address. These lines change neither the `Paid to` lines nor the minimum's
label. A step goes unread when its recipient does not decode as an address, or
when it is a command the decoder does not read: every command other than
`PERMIT2_PERMIT`, `PERMIT2_TRANSFER_FROM`, `V2_SWAP_EXACT_IN`,
`V2_SWAP_EXACT_OUT`, `V3_SWAP_EXACT_IN`, `V4_SWAP`, `SWEEP`, `TRANSFER`,
`PAY_PORTION`, `PAY_PORTION_FULL_PRECISION`, `ACROSS_V4_DEPOSIT_V3`,
`WRAP_ETH`, `UNWRAP_WETH` and `BALANCE_CHECK_ERC20` (`V3_SWAP_EXACT_OUT`,
`PERMIT2_TRANSFER_FROM_BATCH`, `EXECUTE_SUB_PLAN` and the NFT commands among
them), or a type its release names no command for.
there is none), each `PERMIT2_TRANSFER_FROM` but one into the router, in step
order, gives three lines: `Moved from the sender`, the amount it moves, for
example `1000000.0000 USDT`; `Token moved`, giving the token's address as the
`Token In` line does; and `Moved to`, which reads
`The V2 pair the next swap spends` for a hop and `The sender` for `address(1)`
on every router but `UniversalRouterV1`, and otherwise gives the address. A
move into the router needs none of them, because its `Paid to` line and
`Token moved into the router` line already give the amount, the token and
where it goes, and so its amount is shown once. These lines change neither the
`Paid to` lines nor the minimum's label. A step goes unread when its recipient
does not decode as an address, or when it is a command the decoder does not
read: every command other than `PERMIT2_PERMIT`, `PERMIT2_TRANSFER_FROM`,
`V2_SWAP_EXACT_IN`, `V2_SWAP_EXACT_OUT`, `V3_SWAP_EXACT_IN`, `V4_SWAP`,
`SWEEP`, `TRANSFER`, `PAY_PORTION`, `PAY_PORTION_FULL_PRECISION`,
`ACROSS_V4_DEPOSIT_V3`, `WRAP_ETH`, `UNWRAP_WETH` and `BALANCE_CHECK_ERC20`
(`V3_SWAP_EXACT_OUT`, `PERMIT2_TRANSFER_FROM_BATCH`, `EXECUTE_SUB_PLAN` and
the NFT commands among them), or a type its release names no command for.
### Non-Goals Forever
+2 -1
View File
@@ -128,7 +128,8 @@ function showView(name) {
}
// Create or update the debug/insecure warning banner.
// Called on every view switch and after the settings debug toggle changes.
// Called on every view switch, after the settings debug toggle changes, and
// after a network switch in Settings.
// The banner is shown when the compile-time DEBUG constant is true OR when
// the user has enabled runtime debug mode via the settings easter egg, OR
// when the active network is a testnet.
+3 -1
View File
@@ -343,11 +343,13 @@ function init(ctx) {
// switch request.
notify({ type: "AUTISTMASK_NETWORK_CHANGED", chainId: net.chainId });
resetRenderedViews();
// Settings itself is brought up to date for the new network here.
// Settings itself, and the testnet banner above it, are brought up
// to date for the new network here.
markViewRendered("settings");
$("settings-rpc").value = state.rpcUrl;
$("settings-blockscout").value = state.blockscoutUrl;
renderTrackedTokens();
updateDebugBanner(state.currentView);
showFlash("Switched to " + net.name + ".");
});
+6 -6
View File
@@ -1186,11 +1186,12 @@ function decode(data, toAddress, chainId, sources, fromAddress) {
// router, as { token, amount }. Later steps may leave part of it
// there: nothing here checks that they spend all of it.
const movedIntoRouter = [];
// What each PERMIT2_TRANSFER_FROM moves from the sender, in step
// order, whoever counts as paid, as { token, recipient, amount, to }:
// `to` says where it goes, the sender, the router or the V2 pair the
// next swap spends, and is null when it goes to `recipient` as
// written.
// What each PERMIT2_TRANSFER_FROM not into the router moves from the
// sender, in step order, whoever counts as paid, as
// { token, recipient, amount, to }: `to` says where it goes, the
// sender or the V2 pair the next swap spends, and is null when it
// goes to `recipient` as written. A move into the router is in
// `movedIntoRouter`, whose lines give its amount already.
const movedFromSender = [];
// Each token a step paid to the router that no later step paid out
// or spent in full, by its address, lowercased, ETH as the zero
@@ -1326,7 +1327,6 @@ function decode(data, toAddress, chainId, sources, fromAddress) {
movedFromSender.push({ ...p, to: null });
} else if (isRouter(p.recipient)) {
movedIntoRouter.push(p);
movedFromSender.push({ ...p, to: "The router" });
} else if (isHop(i, p.token, p.recipient)) {
movedFromSender.push({
...p,
+59
View File
@@ -1824,6 +1824,65 @@ test("the Settings assertions above all ran (#229)", async (env) => {
);
});
// ------------------------------------------------ testnet banner (#511)
// This suite runs a release build, so the red banner at the top reads
// "[TESTNET]" on Sepolia and is absent on mainnet. A network switch in
// Settings must change it while Settings is still on screen; it used to
// change only when the next screen came up
// (https://git.eeqj.de/sneak/AutistMask/issues/511).
// The banner's text, or null when there is none, once the switch to `net`
// has finished. The switch's flash is the last thing its handler does, and
// showView() clears the flash, so the banner read while that flash is up is
// the one the switch left on the screen it was made from.
async function bannerAfterSwitch(page, net) {
await page.waitForFunction(
(text) => document.getElementById("flash-msg").textContent === text,
"Switched to " + net.name + ".",
);
return page.evaluate(() => {
const banner = document.getElementById("debug-banner");
return {
text: banner === null ? null : banner.textContent,
onSettings: !document
.getElementById("view-settings")
.classList.contains("hidden"),
};
});
}
test("a network switch in Settings shows and removes the testnet banner at once (#511)", async (env) => {
const { mainnet, sepolia } = NETWORKS;
await openSettings(env.page);
assert(
(await env.page.locator("#debug-banner").count()) === 0,
"a banner is up on mainnet before the switch",
);
await env.page.selectOption("#settings-network", "sepolia");
let after = await bannerAfterSwitch(env.page, sepolia);
assert(after.onSettings, "Settings left the screen on the switch");
assert(
after.text === "[TESTNET]",
"after the switch to Sepolia, Settings shows the banner " +
JSON.stringify(after.text) +
', expected "[TESTNET]"',
);
await env.page.selectOption("#settings-network", "mainnet");
after = await bannerAfterSwitch(env.page, mainnet);
assert(after.onSettings, "Settings left the screen on the switch back");
assert(
after.text === null,
"after the switch back to mainnet, Settings still shows the banner " +
JSON.stringify(after.text),
);
await env.page.click("#btn-settings-back");
await visible(env.page, "#view-main");
});
// ------------------------------------------------ dust threshold (#233)
// The popup size README documents the UI as designed for. Pages in this
+24 -11
View File
@@ -1167,6 +1167,14 @@ describe("each transfer command's recipient", () => {
expect(detail(result, "Min. received").value).toBe("1.0000 WETH");
}
// A move to the From address as written shows that address, not The
// sender.
expect(detail(decode(movedThenSwapped(USER)), "Moved to")).toEqual({
label: "Moved to",
value: USER,
address: USER,
});
const toOther = decode(movedThenSwapped(OTHER));
expect(labels(toOther)).toEqual(withMove(PAID_ELSEWHERE));
expect(paidTo(toOther)).toEqual([OTHER]);
@@ -1192,9 +1200,6 @@ describe("each transfer command's recipient", () => {
"Protocol",
"Token In",
"Amount",
"Moved from the sender",
"Token moved",
"Moved to",
"Token Out",
"Paid to",
"Token moved into the router",
@@ -1312,8 +1317,9 @@ describe("each transfer command's recipient", () => {
});
// https://git.eeqj.de/sneak/AutistMask/issues/611: after the swap's own
// Amount, each PERMIT2_TRANSFER_FROM gives the amount of the sender's tokens
// it moves, the token, and where it goes, whoever counts as paid.
// Amount, each PERMIT2_TRANSFER_FROM but one into the router gives the amount
// of the sender's tokens it moves, the token, and where it goes, whoever
// counts as paid.
describe("what each PERMIT2_TRANSFER_FROM moves", () => {
// The WETH/USDC pair on Ethereum Mainnet, as its V2 factory reports it.
const PAIR = "0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc";
@@ -1383,7 +1389,9 @@ describe("what each PERMIT2_TRANSFER_FROM moves", () => {
expect(detail(result, "Min. received").value).toBe("1990.0000 USDC");
});
test("2,000 USDT moved into the router, then a swap of 1 USDT from the router's balance", () => {
// Its Paid to and Token moved into the router lines already say what a
// move into the router moves, so it gets no lines after Amount.
test("2,000 USDT moved into the router, then a swap of 1 USDT from the router's balance, shows the 2,000 USDT once", () => {
const result = decode(
execute(
permit2TransferFrom(USDT, ADDRESS_THIS, USDT_2000),
@@ -1391,10 +1399,11 @@ describe("what each PERMIT2_TRANSFER_FROM moves", () => {
),
);
expect(detail(result, "Amount").value).toBe("1.0000 USDT");
expect(afterAmount(result)).toEqual(
moved("2000.0000 USDT", USDT, "USDT", movedTo("The router")),
);
expect(afterAmount(result)).toEqual([]);
expect(paidTo(result)).toEqual([movedIntoRouter("2000.0000 USDT")]);
expect(
result.details.filter((d) => d.value.includes("2000.0000 USDT")),
).toHaveLength(1);
expect(detail(result, "Min. paid out").value).toBe("1.0000 WETH");
});
@@ -2921,7 +2930,11 @@ describe("the screens show what a PERMIT2_TRANSFER_FROM moves", () => {
])("the $screen screen", async ({ show }) => {
const html = await show(millionToOther);
expect(html).toContain("1000000.0000 USDT");
expect(html).toContain("Moved to");
expect(html).toContain('data-copy="' + OTHER + '"');
// Each line is drawn in a div of its own; the Paid to line names
// OTHER too, so the Moved to line's own div is checked.
const movedToLine = html
.split('<div class="mb-2">')
.find((line) => line.includes(">Moved to<"));
expect(movedToLine).toContain('data-copy="' + OTHER + '"');
});
});