Skip to content

useWallet's missing-context guard is unreachable #91

Description

@luchobonatti

Description

useWallet at app/src/hooks/useWallet.ts:6 throws when the wallet context is
falsy, but WalletProvider at app/src/providers/WalletProvider.tsx:40
creates the context with a real default object (behind a @ts-ignore), so
that throw branch can never execute.

Steps to reproduce

  1. Render any component that calls useWallet() without wrapping it in
    WalletProvider.
  2. Observe that it returns the default context object instead of throwing.

Expected vs actual behavior

Expected: calling useWallet() outside a WalletProvider throws, since
the hook exists to guard against exactly that.
Actual: it silently returns the default context object, so the guard
never fires.

Additional context

app/src/components/NetworkPill.test.tsx depends on exactly this behavior —
it renders NetworkPill with no WalletProvider and asserts the
deterministic disconnected state that only works because useWallet()
doesn't throw. Fixing the guard to actually throw will turn that test red;
whoever picks this up needs to wrap that test's render in WalletProvider or
a stub context, which is a two-line change, not a redesign.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions