feat: improve wallet session recovery and error handling - #83
Open
Emmycivity wants to merge 1 commit into
Open
Conversation
|
@Emmycivity is attempting to deploy a commit to the alankcr1-6443's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Emmycivity 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Improves wallet session recovery and resilience across app reloads and reconnect scenarios, adds graceful handling of expired and corrupted sessions, and standardizes high-frequency wallet error messages across all wallet interaction points.
Related Issue
Closes #13
Before & After Behavior
window.location.reload()) rather than triggering an active reconnection flow.Login.tsx,DepositModal.tsx,CreditSection.tsx,Perfil.tsx,Retiros.tsx,Tesoreria.tsx), with hardcoded strings and inconsistent cancellation detection.sessionStoreandWalletSessionContextvalidate Stellar address format (isValidStellarAddress) and enforce session TTL (30 days), automatically and cleanly purging corrupted or expired sessions without crashing.useWalletandWalletSessionContextexpose an activereconnect()method,sessionError, andisExpiredstatus, allowing one-click reconnection directly from UI banners.src/lib/walletErrors.tsparses, classifies, and formats all wallet error codes (CANCELLED,POPUP_BLOCKED,WALLET_LOCKED,WALLET_MISSING,SESSION_EXPIRED,ACCOUNT_MISMATCH,ACCOUNT_NOT_FOUND,INSUFFICIENT_BALANCE,INSUFFICIENT_USDC,NO_LIQUIDITY,ACTIVE_LOAN,TIER_INSUFFICIENT,NETWORK_ERROR,CONTRACT_ERROR,GENERIC) with full i18n support in English and Spanish.Changes
Wallet & Session Management
src/lib/walletErrors.tsisValidStellarAddress), and friendly message resolution.src/lib/sessionStore.tssaveSession,restoreSession,clearSession, and session TTL expiration checks (30 days).src/context/WalletSessionContext.tsxreconnect()method,sessionError,isExpired, and clean reset handling.src/hooks/useWallet.tsxreconnect,sessionError,isExpired,clearSessionError, andprovider.src/lib/mobileWalletConnectors.tswalletErrors.src/wallet/FreighterAdapter.tslocalStorageaccess withsessionStore.UI Components & Feedback
src/pages/Login.tsxgetFriendlyWalletMessageand surfaced session expiration feedback on login redirect.src/pages/Index.tsxreconnect()button and error toast feedback.src/components/DepositModal.tsxgetFriendlyWalletMessage.src/components/CreditSection.tsxgetFriendlyWalletMessage.src/pages/Retiros.tsx&src/pages/Tesoreria.tsxlocalStoragereads touseWallet/sessionStoreand standardized contract error handling.src/pages/Perfil.tsxsrc/i18n/locales/en.ts&src/i18n/locales/es.tswallet_errorslocalization namespace for all error scenarios.Testing
src/test/walletSessionAndErrors.test.tsxVerification Results
restoreSessionandWalletSessionProviderintegration tests