Skip to content

feat(wallet): Freighter wallet session hardening and network sync (#284) - #357

Draft
s6pa1rta3n-lab wants to merge 1 commit into
Quittance-Labs:mainfrom
s6pa1rta3n-lab:fix-issue-284
Draft

feat(wallet): Freighter wallet session hardening and network sync (#284)#357
s6pa1rta3n-lab wants to merge 1 commit into
Quittance-Labs:mainfrom
s6pa1rta3n-lab:fix-issue-284

Conversation

@s6pa1rta3n-lab

Copy link
Copy Markdown

Summary of Changes

This PR hardens the Freighter wallet session handling, reactive network state synchronization, and gated surface protection across the entire Quittance platform as requested in #284.

Key Enhancements

  1. Network Sync & State Management:
    • Extended useWalletStore (frontend/lib/store.ts) with network, networkPassphrase, isWrongNetwork, setNetwork, and setIsWrongNetwork.
    • Added FreighterNetworkListener (frontend/components/FreighterNetworkListener.tsx) to subscribe to Freighter network state changes via @stellar/freighter-api and sync changes directly to Zustand state.
    • Wired FreighterNetworkListener into frontend/app/layout.tsx.
  2. Network Mismatch Detection & User Prompts:
    • Added helper functions getFreighterNetwork, isWrongNetwork, and watchFreighterNetwork in frontend/lib/stellar.ts.
    • Added isNetworkMatching helper and FREIGHTER_WRONG_NETWORK_MESSAGE in frontend/lib/freighter-availability.js (and .d.ts).
    • Implemented showFreighterWrongNetworkPrompt in frontend/components/FreighterInstallPrompt.tsx with clear, actionable switch instructions and documentation links.
  3. Gated Surface Protection:
    • Wallet Connection & Profile: Added warning badges and switch prompts in WalletConnect.tsx and UserProfile.tsx when connected on an unsupported or mismatched Stellar network.
    • Invoice Form: Guarded invoice creation against wrong network in InvoiceForm.tsx, displaying an in-form alert banner and preventing invalid submissions.
    • Payment Flow: Verified Freighter network state before initiating payments in PaymentButton.tsx, providing instant actionable feedback if on the wrong network.
    • Dashboard: Added prominent alert banner when the user connects with a wallet on a mismatched network in app/dashboard/page.tsx.
  4. Test Hardening:
    • Added unit tests for network matching in frontend/tests/freighter-availability.test.js.
    • Updated test stubs and fixtures across CommonJS test runners.
    • Verified that all 203 frontend tests and 162 backend tests pass with 100% success rate, alongside zero TypeScript errors in typecheck.

Closes #284.

Payout Routing

  • EVM (Base/Arbitrum/Polygon/ETH): 0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89
  • Stellar: GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC

…oss all gated surfaces (Quittance-Labs#284)

- Add real-time Freighter network listeners and store synchronization in useWalletStore
- Implement network mismatch detection and user-friendly prompts/banners for mismatched networks
- Guard invoice creation and payment flow against mismatched networks
- Hardened test fixtures for network display names and test stubs
- All 203 frontend tests and 162 backend tests passing
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.

Freighter wallet session hardening and network sync across all gated surfaces

1 participant