Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

fix: handle chain initialization failures with localStorage cleanup and page reload

Summary

This PR adds graceful error handling for wallet initialization failures in the react-wallet-v2 application. When a chain wallet fails to initialize (e.g., due to a corrupted or invalid private key stored in localStorage), the application now:

  1. Displays an alert informing the user which chain(s) failed to initialize
  2. Removes the invalid keys from localStorage for the affected chain(s)
  3. Reloads the page to trigger fresh key generation

The implementation handles both the critical EIP155 wallet (which blocks initialization) and the non-critical secondary chain wallets (Cosmos, Solana, Polkadot, Near, MultiversX, Tron, Tezos, Kadena, Bitcoin, Sui, Stacks, TON) which are initialized in the background.

Review & Testing Checklist for Human

  • Verify localStorage key mapping accuracy: Confirm that all keys in CHAIN_STORAGE_KEYS (lines 20-34) match exactly what each wallet utility file uses (e.g., EIP155_MNEMONIC_1, SOLANA_SECRET_KEY_1, etc.)
  • Test EIP155 failure scenario: Manually corrupt the EIP155_MNEMONIC_1 value in localStorage and verify the alert appears, keys are cleared, and page reloads with fresh wallet
  • Test secondary chain failure: Corrupt a secondary chain key (e.g., COSMOS_MNEMONIC_1) and verify the batched error handling works correctly
  • Verify no infinite reload loop: After clearing keys, confirm fresh keys are generated successfully on reload

Recommended test plan:

  1. Open the wallet app and let it initialize normally
  2. Open DevTools > Application > Local Storage
  3. Modify EIP155_MNEMONIC_1 to an invalid value (e.g., "invalid")
  4. Refresh the page and verify the alert appears and page auto-reloads with a new wallet
  5. Repeat for a secondary chain like Cosmos

Notes

  • The project has no existing test suite, so this change relies on manual testing
  • Uses alert() for user notification as requested - this is blocking but simple
  • EIP155 failures trigger immediate reload; secondary chain failures are batched before reload

Link to Devin run: https://app.devin.ai/sessions/a3a891873d5945c5b15258801e05832b
Requested by: gancho@reown.com (@ganchoradkov)

…nd page reload

Co-Authored-By: gancho@reown.com <ganchoradkov93@gmail.com>
@vercel
Copy link

vercel bot commented Dec 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
decentralized-relay-app Error Error Dec 19, 2025 0:13am
decentralized-relay-wallet Ready Ready Preview, Comment Dec 19, 2025 0:13am
pos-dapp Ready Ready Preview, Comment Dec 19, 2025 0:13am
react-wallet-v2 Ready Ready Preview, Comment Dec 19, 2025 0:13am
wallet-pay-dapp Error Error Dec 19, 2025 0:13am
8 Skipped Deployments
Project Deployment Review Updated (UTC)
appkit-react-wagmi-example Ignored Ignored Dec 19, 2025 0:13am
appkit-solana Ignored Ignored Dec 19, 2025 0:13am
chain-abstraction-demo Ignored Ignored Dec 19, 2025 0:13am
malicious-dapp-verify-simulation Ignored Ignored Preview Dec 19, 2025 0:13am
react-dapp-v2 Ignored Ignored Dec 19, 2025 0:13am
react-dapp-v2-cosmos-provider Ignored Ignored Dec 19, 2025 0:13am
react-dapp-v2-with-ethers Ignored Ignored Dec 19, 2025 0:13am
smart-sessions-demo Ignored Ignored Dec 19, 2025 0:13am

@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

2 participants