harden: say a swap's input token is unknown rather than calling it ETH (closes #357)
All checks were successful
check / check (push) Successful in 31s
e2e / e2e-chrome (push) Successful in 1m47s
e2e / e2e-firefox (push) Successful in 33s

`tokenInfo(null)` answered `{symbol: "ETH", decimals: 18}`, so a swap whose
calldata never named an input currency rendered `Token In: ETH (native)` and
titled itself `Swap ETH -> X`. The approval screen asserted the user was paying
native ETH when nothing had established it.

Null is not how native ETH arrives. v4-core declares `type Currency is address`
and wraps `address(0)` for it; a user-defined value type over `address` carries
the plain `address` ABI encoding, so a native-ETH currency reaches every decode
site here as the truthy string
`0x0000000000000000000000000000000000000000`, and WRAP_ETH sets that same
explicit zero address. A null token means undetermined, on the input side as on
the output side.

The collapse is removed from `tokenInfo()` itself rather than guarded at each
call site, so both sides of the screen answer the same condition the same way:
null refuses, the zero address is still ETH at 18 decimals. `Token In` gains
the refusal branch `Unknown (not named in the calldata)`, now a shared constant
with the `Token Out` branch it must match.
This commit is contained in:
clawbot
2026-08-23 18:13:52 +00:00
parent ad6aa7b20d
commit 6385f4fa42
3 changed files with 227 additions and 26 deletions

10
TODO.md
View File

@@ -45,6 +45,16 @@ but the review is broader than any of them.
# Completed Steps
- 2026-08-23: A swap whose input token the calldata never named is said to be
unknown instead of being called ETH
([#357](https://git.eeqj.de/sneak/AutistMask/issues/357)), the twin on the
input side of [#353](https://git.eeqj.de/sneak/AutistMask/issues/353). A null
`inputToken` rendered as `Token In: ETH (native)` and titled the swap
`Swap ETH -> X`, asserting the user was paying native ETH when nothing in the
calldata said so. The null-means-ETH collapse is now gone from `tokenInfo()`
itself rather than guarded at each call site: null is refused, and native ETH
keeps arriving as the explicit zero address that `WRAP_ETH` and V4's
`Currency.wrap(address(0))` both use.
- 2026-08-23: A swap whose output token the calldata never named is said to be
unknown instead of being called ETH
([#353](https://git.eeqj.de/sneak/AutistMask/issues/353)). `tokenInfo(null)`