fix: always name a swap's output token, by address when no symbol is known (closes #346) #352
Reference in New Issue
Block a user
Delete Branch "fix/346-swap-token-out-line"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #346
The defect
In
src/shared/uniswap.jstheToken Outdetail line was pushed onlyif (outSymbol). A token absent from the bundled list has no symbol, so the line was dropped entirely — the dApp approval screen showed aMin. receivedfigure with no statement of which token is being received. Affects every token not in the bundled list, which is every newly listed token.The fix
The line is now keyed on the resolved token address, with the address as the label when there is no symbol — the same fallback the
Token Inline in this same file already made. One condition, no new presentation:Token Out= the address,isToken: true, so the popup rendersUnknown tokenabove the address block, as it does forToken In.SYMBOL (0x...).UNWRAP_WETH: unchanged,ETH, no address.Composition with #340 (same screen, same affected population): for a token nothing knows the scale of,
Token Outnames the address andMin. receivedreads1000000000 base units (decimals unknown). The address says which token, the figure says how much and declares the scale unknown — no address stands next to a number that silently means something else. Covered by a test. When the scale is known (tracked token) but the symbol is not, the line is still the address and the amount is a real quantity.Fail-first evidence
Mutation:
git stash push src/shared/uniswap.js— the exactsrc/change reverted,tests/uniswapTokenOut.test.jsleft in place — thenmake test.undefinedbecausedetails.find((d) => d.label === "Token Out")finds nothing: the line is absent, which is the defect. The two regression tests in the same file (bundled token, native ETH) passed against head, so the change is additive.With the fix:
Test Suites: 47 passed,Tests: 895 passed.Verification
make checkgreen ona1e9d0b, rebased onnextat43784ca:Tests: 895 passed, 895 total(47 suites) — no(cached)line; jest ran the suites.test-verify-build: 46 case(s) passedcheck-censored: 165 tracked file(s) inspectedlintlayer executed rather than reportingCACHED:#11 [lint 1/1] RUN make lint/$ eslint . && prettier --check ./All matched files use Prettier code style!/#11 DONE 4.9s. No lint was run on the host.make fmtrun;TODO.mdupdated in the same commit.Note
tests/uniswapTokenOut.test.jsbuilds its unlisted-token constant throughgetAddress(): the ABI decode hands back a checksummed address, so that is the form the line carries.PASS — DoD of #346 met; fail-first reproduced in an independent clone (3 failed / 892 passed with only
src/shared/uniswap.jsreverted, the 2 regression tests in the new file passing either way),make checkgreen with thelintstage executing (notCACHED), all three CI contexts green ona1e9d0b, noToken Outpath regressed.Non-blocking, pre-existing, out of scope for this issue: symbol resolution (
tokenInfo()insrc/shared/uniswap.js,tokenLabel()insrc/popup/views/approval.js) reads only the bundled list, so a token the user tracks with a symbol still renders asUnknown tokenabove its address while #340 correctly takes its decimals from that same tracked entry. Worth a follow-up issue; not a defect of this change.