interface
interface copied to clipboard
fix: prevent app crash when wallet locks during Supply modal interaction
Summary
Fixes #2382 - Prevents app crash when wallet is locked while Supply modal is open
Changes
- ✅ Fixed
UserAuthenticatedcomponent to handle disconnection gracefully - ✅ Added
WalletGuardprovider to monitor wallet disconnection events - ✅ Enhanced
SupplyModalwith connection state guards - ✅ Added
TransactionErrorBoundaryfor additional safety - ✅ Integrated providers in
_app.page.tsxwith proper hierarchy
Problem
When users lock their wallet extension (MetaMask/Rabby/Ambire) while the Supply modal is open, the app crashes with:
Uncaught Error: Invariant failed: User data loaded but no user found
Solution
Implemented a two-part defensive strategy:
- Global Wallet Guard: Monitors disconnection and closes modals automatically
- Component-Level Guards: Graceful handling with "Connect Wallet" UI
Testing
- Connect wallet (MetaMask/Rabby/Ambire)
- Open Supply modal
- Lock wallet extension
- Before: App crashes with client exception
- After: Modal gracefully shows "Connect Wallet" prompt
Impact
- Improves UX reliability
- Prevents data loss during wallet disconnection events
- Establishes pattern for other transaction modals
Screenshots
N/A - Fix is for preventing crashes, behavior change is the absence of errors
Checklist
- [x] Code follows project conventions
- [x] No breaking changes
- [x] Tested with MetaMask, Rabby wallets
- [x] Ready for review