improve(sdk): preserve EOA wallet connections on logout#482
improve(sdk): preserve EOA wallet connections on logout#482
Conversation
Instead of unconditionally calling disconnect() on the active wallet (which nukes EOA wallets from connectedWallets and revokes permissions), use useConnectionManager() to clear only the active-wallet stores for EOA wallets. This preserves the wallet in connectedWallets and keeps thirdweb:active-wallet-id in localStorage, allowing autoConnectCore to silently reconnect via eth_accounts on next login — no approval popup. Ecosystem/smart wallets still get full disconnect() for proper auth cleanup. The blank modal fix is preserved since activeAccount is still cleared to undefined in both paths. Also DRYs up authenticateUser by extracting finalizeAuth helper. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @aqt-dev's task in 2m 4s —— View job PR Review: improve(sdk): preserve EOA wallet connections on logout
The approach is sound and the Issue 1 — Bypassing thirdweb's internal stores (Medium)
mgr.activeAccountStore.setValue(undefined);
mgr.activeWalletStore.setValue(undefined);
mgr.activeWalletChainStore.setValue(undefined);
mgr.activeWalletConnectionStatusStore.setValue("disconnected");This directly mutates thirdweb's internal store objects rather than going through any public API. While these stores are exposed on Issue 2 — Inconsistent EOA handling in the
|
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the authentication and logout mechanisms within the SDK, primarily focusing on improving the user experience for EOA wallet users. It introduces a nuanced logout process that preserves EOA wallet connections, allowing for silent re-authentication on subsequent logins, while maintaining robust disconnection for other wallet types. Additionally, it addresses a blank modal display issue and streamlines the authentication code through refactoring. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request improves the logout flow by preserving EOA wallet connections, which avoids requiring users to re-approve connections on subsequent logins. This is achieved by directly clearing thirdweb's active-wallet stores for EOA wallets instead of performing a full disconnect. The changes also include a good refactoring to reduce duplication in the authentication logic. I have one minor suggestion to improve code clarity.
| const mgr = connectionManager; | ||
| mgr.activeAccountStore.setValue(undefined); | ||
| mgr.activeWalletStore.setValue(undefined); | ||
| mgr.activeWalletChainStore.setValue(undefined); | ||
| mgr.activeWalletConnectionStatusStore.setValue("disconnected"); |
There was a problem hiding this comment.
To improve readability and avoid an unnecessary local variable, you can use connectionManager directly.
| const mgr = connectionManager; | |
| mgr.activeAccountStore.setValue(undefined); | |
| mgr.activeWalletStore.setValue(undefined); | |
| mgr.activeWalletChainStore.setValue(undefined); | |
| mgr.activeWalletConnectionStatusStore.setValue("disconnected"); | |
| connectionManager.activeAccountStore.setValue(undefined); | |
| connectionManager.activeWalletStore.setValue(undefined); | |
| connectionManager.activeWalletChainStore.setValue(undefined); | |
| connectionManager.activeWalletConnectionStatusStore.setValue("disconnected"); |
Summary
useConnectionManager()instead of callingdisconnect()disconnect()for proper auth cleanupactiveAccountis cleared toundefinedin both pathsauthenticateUserby extractingfinalizeAuthhelperHow it works
On logout, the active wallet is now handled differently based on type:
disconnect()— revokes auth, removes fromconnectedWalletsactiveAccountStore,activeWalletStore,activeWalletChainStore,activeWalletConnectionStatusStoredirectly — wallet stays inconnectedWallets,thirdweb:active-wallet-idstays in localStorage,autoConnectCoresilently reconnects viaeth_accountson next login (no approval popup)Test plan
isAuthenticated=false,isConnected=false,isAuthenticating=false,user=undefined🤖 Generated with Claude Code