Skip to content

feat: add network-mismatch warning for unsupported Stellar network (#… - #149

Merged
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
victorEdeh:feat/117-network-mismatch-warning
Apr 25, 2026
Merged

feat: add network-mismatch warning for unsupported Stellar network (#…#149
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
victorEdeh:feat/117-network-mismatch-warning

Conversation

@victorEdeh

Copy link
Copy Markdown
Contributor

close #117

Summary

Closes #117

Detects when a connected wallet is on a different network than the app's
configured default chain and surfaces a warning banner while disabling
unsafe trade actions. Read-only browsing remains fully available.

Changes

New: src/hooks/useNetworkMismatch.ts

A focused hook that compares the active wallet's chain ID (via wagmi
useChainId) against defaultChain from the app config. Only flags a
mismatch when a wallet is actually connected — disconnected users are
unaffected.

Returns:

  • isMismatch — true when connected and on the wrong chain
  • connectedChainId — wallet's current chain (undefined when disconnected)
  • expectedChainId / expectedChainName — the app's configured chain

New: src/components/common/NetworkMismatchBanner.tsx

Self-contained warning banner that calls useNetworkMismatch internally
and renders nothing when there is no mismatch — safe to place
unconditionally. Styled consistently with WalletConnectCalloutBanner.
Accessible via role="alert" and aria-live="polite".

Updated: src/components/common/CreatorCard.tsx

  • Buy button receives disabled={isNetworkMismatch}
  • handleBuy returns early with a descriptive toast when mismatched
  • BuyActionHelperText receives a disabledReason string when mismatched
  • NetworkMismatchBanner renders below the helper text when connected + mismatched

Updated: src/pages/LandingPage.tsx

  • Desktop and mobile sticky Buy/Sell buttons disabled when mismatched
  • NetworkMismatchBanner renders above the trade buttons in the profile section

New: src/hooks/__tests__/useNetworkMismatch.test.ts

4 unit tests — all passing:

  • No wallet connected → no mismatch
  • Wallet on expected chain → no mismatch
  • Wallet on different chain → mismatch flagged
  • Expected chain id/name always exposed correctly

Behaviour

State Banner Trade buttons Browse
No wallet connected Hidden Unaffected
Wallet on correct network Hidden Enabled
Wallet on wrong network ⚠️ Shown Disabled

Testing locally

  1. Connect a wallet (e.g. MetaMask) to any network other than the app's
    VITE_DEFAULT_CHAIN_ID (default: Base Sepolia, 84532)
  2. The red network-mismatch banner appears on creator cards and the
    profile section
  3. Buy/Sell buttons are disabled; clicking Buy shows a toast directing
    the user to switch networks
  4. Switching the wallet back to Base Sepolia dismisses the banner and
    re-enables trade actions
  5. Disconnecting the wallet hides the banner entirely

…ccesslayerorg#117)

- Add useNetworkMismatch hook that compares the connected wallet's chain
  against the app's defaultChain (wagmi); only flags a mismatch when a
  wallet is actually connected so disconnected users are unaffected
- Add NetworkMismatchBanner component styled consistently with
  WalletConnectCalloutBanner; self-contained (calls the hook internally),
  renders nothing when there is no mismatch, role=alert + aria-live for
  accessibility
- Wire mismatch guard into CreatorCard: buy button disabled, handleBuy
  returns early with a toast, BuyActionHelperText receives disabledReason,
  NetworkMismatchBanner shown when connected + mismatched
- Wire mismatch guard into LandingPage: desktop and mobile Buy/Sell
  buttons disabled, NetworkMismatchBanner shown above trade buttons
- Add useNetworkMismatch unit tests (4/4 passing): disconnected wallet,
  correct chain, wrong chain, static expected-chain values
@drips-wave

drips-wave Bot commented Apr 25, 2026

Copy link
Copy Markdown

@victorEdeh Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Chucks1093
Chucks1093 merged commit a0eb3ba into accesslayerorg:main Apr 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add network-mismatch warning for unsupported Stellar network

2 participants