fix: ensure wallet switching after disconnect works for TON/TRON#5547
fix: ensure wallet switching after disconnect works for TON/TRON#5547enesozturk wants to merge 3 commits intomainfrom
Conversation
When disconnecting an active wallet with multi-account feature enabled, explicitly switch to the first available remaining wallet. This ensures consistent behavior across all adapters (EVM, Solana, Bitcoin, TON, TRON). The issue was that while adapters emit 'accountChanged' after disconnect, the event doesn't always trigger the UI update properly for TON/TRON. By explicitly calling handleSwitchWallet, we ensure the active wallet is updated correctly in all cases. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
9 Skipped Deployments
|
|
Visual Regression Test Results ✅ PassedChromatic Build: https://www.chromatic.com/build?appId=6493191bf4b10fed8ca7353f&number=775 👉 Please review the visual changes in Chromatic and accept or reject them. |
…hing Root cause: TON/TRON connectors didn't expose a 'provider' property, causing the AppKit client's accountChanged handler to skip syncConnectedWalletInfo(). When emitFirstAvailableConnection() emits accountChanged after disconnect, the handler checks 'if (connector?.provider)' before calling: - syncProvider() - syncConnectedWalletInfo() // Updates UI with wallet info! Since TON/TRON connectors had no provider property, this block never ran, leaving the UI with stale wallet info after disconnect. Solution: Add provider getter that returns self, allowing the connectors to satisfy the optional provider property in the Connector type definition. This fix eliminates the need for explicit wallet switching workarounds in the UI layer, as the proper events now trigger the correct state updates. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
📦 Bundle Size Check✅ All bundles are within size limits 📊 View detailed bundle sizes> @reown/appkit-monorepo@1.7.1 size /home/runner/work/appkit/appkit > size-limit |
Root Cause Analysis UpdateI've identified and fixed the actual root cause! The issue is that TON/TRON connectors don't expose a The Issue Chain:
export type Connector = {
provider?: Provider | W3mFrameProvider | UniversalProvider
}
if (connector?.provider) { // FALSE for TON/TRON\!
this.syncProvider({...})
this.syncConnectedWalletInfo(chainNamespace) // NEVER CALLED\!
}
The Fix:Added public get provider(): TronConnector {
return this
}This ensures the |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
packages/scaffold-ui/src/views/w3m-profile-wallets-view/index.ts
Outdated
Show resolved
Hide resolved
Removed the explicit wallet switching logic from handleDisconnect as it's
now redundant. The root cause fix (adding provider property to TON/TRON
connectors) ensures that adapters properly emit accountChanged events,
which trigger syncConnectedWalletInfo() and update the UI automatically.
This follows the proper architectural pattern:
Adapter → emit('accountChanged') → syncConnectedWalletInfo() → UI update
Addresses feedback from @0xmkh: switching should be handled at the adapter
level via event emission, not manually in the UI layer.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
✅ Agreed and fixed! Removed the manual switching logic in commit d32a92a. Now relying entirely on adapter-level event handling:
The |
Summary
Fixes the disconnect issue for TON and TRON adapters when multi-account feature is enabled. After disconnecting an active wallet, the UI now explicitly switches to the first available remaining wallet, ensuring consistent behavior across all adapters.
Problem
When a user disconnects an active wallet with other wallets connected:
Root Cause
All adapters (Solana, Bitcoin, TON, TRON) call
emitFirstAvailableConnection()after disconnect, which emits anaccountChangedevent. However, for TON/TRON adapters, this event doesn't consistently trigger the UI state update in the profile wallets view.Solution
Added explicit wallet switching logic in
handleDisconnectthat:handleSwitchWalletwith the first remaining walletThis approach works for all adapters (EVM, Solana, Bitcoin, TON, TRON) and provides consistent behavior.
Changes
packages/scaffold-ui/src/views/w3m-profile-wallets-view/index.ts: UpdatedhandleDisconnectmethod to explicitly switch wallets after disconnecting an active walletTest Plan
🤖 Generated with Claude Code
Closes APKT-4457