fix: AddToken screen is unreachable — ReferenceError: showView is not defined #150

Closed
opened 2026-08-09 03:41:48 +02:00 by clawbot · 0 comments
Collaborator

Problem

src/popup/views/addToken.js:1 imports:

const { $, showFlash, goBack } = require("./helpers");

but src/popup/views/addToken.js:24 calls showView("add-token"). showView
is not in scope and there is no global, so show() throws a ReferenceError
every single time.

Effect: clicking "+ Token" on AddressDetail does nothing visible, and it
corrupts the navigation stack
pushCurrentView() in
src/popup/index.js:76-79 has already pushed "address" before the throw, so
the user's subsequent "Back" behaviour is wrong.

This makes the AddToken screen documented at README.md:489-501 and the
"Adding ERC-20 Tokens" flow in docs/README.md completely unreachable. The
only working add-token path today is Settings -> SettingsAddToken.

Regression introduced by a22f33d ("fix: implement proper view navigation
stack (#146)"), which rewrote the import from { $, showView, showFlash } to
{ $, showFlash, goBack }.

Implementation requirements

  • Add showView back to the destructured import in addToken.js:1. Verify
    against src/popup/views/helpers.js that showView is exported and that
    goBack/showFlash are genuinely still used in this module; drop any that
    are not rather than leaving unused imports behind.
  • Confirm the nav-stack interaction is correct after the fix: entering
    AddToken from AddressDetail and pressing "Back" must return to
    AddressDetail exactly once, with no stale entry left on the stack.
  • Do not paper over this with a try/catch or a global.
  • This bug and #(TransactionDetail ERC-20 crash) are the same class of defect
    (used-but-not-imported) and are invisible to make check because
    script/lint is only prettier --check. The systemic fix is tracked
    separately as the ESLint issue; this issue is the point fix only.

Definition of done

  • "+ Token" on AddressDetail opens the AddToken screen.
  • The common-token quick-pick buttons populate the contract address field.
  • Adding a token by contract address returns to AddressDetail and the
    token appears in the balance list.
  • "Back" from AddToken returns to AddressDetail, and a second "Back"
    returns to Home (no duplicated or orphaned stack entry).
  • A regression test covers this. Since the views are currently untestable
    (no jsdom environment configured), either add the jsdom test env and a
    test that addToken.show() does not throw, or — if that proves
    disproportionate — state in the PR why, and ensure the ESLint issue will
    catch the class instead.
  • TODO.md updated in the same commit.
  • make check passes.
## Problem `src/popup/views/addToken.js:1` imports: ```js const { $, showFlash, goBack } = require("./helpers"); ``` but `src/popup/views/addToken.js:24` calls `showView("add-token")`. `showView` is not in scope and there is no global, so `show()` throws a `ReferenceError` every single time. Effect: clicking "+ Token" on AddressDetail does nothing visible, **and it corrupts the navigation stack** — `pushCurrentView()` in `src/popup/index.js:76-79` has already pushed `"address"` before the throw, so the user's subsequent "Back" behaviour is wrong. This makes the AddToken screen documented at `README.md:489-501` and the "Adding ERC-20 Tokens" flow in `docs/README.md` completely unreachable. The only working add-token path today is Settings -> SettingsAddToken. Regression introduced by `a22f33d` ("fix: implement proper view navigation stack (#146)"), which rewrote the import from `{ $, showView, showFlash }` to `{ $, showFlash, goBack }`. ## Implementation requirements - Add `showView` back to the destructured import in `addToken.js:1`. Verify against `src/popup/views/helpers.js` that `showView` is exported and that `goBack`/`showFlash` are genuinely still used in this module; drop any that are not rather than leaving unused imports behind. - Confirm the nav-stack interaction is correct after the fix: entering AddToken from AddressDetail and pressing "Back" must return to AddressDetail exactly once, with no stale entry left on the stack. - Do not paper over this with a `try/catch` or a global. - This bug and #(TransactionDetail ERC-20 crash) are the same class of defect (used-but-not-imported) and are invisible to `make check` because `script/lint` is only `prettier --check`. The systemic fix is tracked separately as the ESLint issue; this issue is the point fix only. ## Definition of done - [ ] "+ Token" on AddressDetail opens the AddToken screen. - [ ] The common-token quick-pick buttons populate the contract address field. - [ ] Adding a token by contract address returns to AddressDetail and the token appears in the balance list. - [ ] "Back" from AddToken returns to AddressDetail, and a second "Back" returns to Home (no duplicated or orphaned stack entry). - [ ] A regression test covers this. Since the views are currently untestable (no jsdom environment configured), either add the jsdom test env and a test that `addToken.show()` does not throw, or — if that proves disproportionate — state in the PR why, and ensure the ESLint issue will catch the class instead. - [ ] `TODO.md` updated in the same commit. - [ ] `make check` passes.
clawbot added this to the 1.0.0 milestone 2026-08-09 03:41:48 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/AutistMask#150