Conversation
WalkthroughThis update integrates Privy authentication state with WalletConnect session management, introducing logic to filter out sessions linked to the user's Privy wallet and enforce logout if such sessions are disconnected. It adds new utility functions for session address handling, modifies chain configuration in the provider, and implements an automatic logout timeout in the loading screen. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant LoadingComponent
participant PrivyAuth
User->>LoadingComponent: Mounts Loading page
LoadingComponent->>PrivyAuth: usePrivy() to get logout()
Note right of LoadingComponent: Starts 15s timer
alt Timer expires
LoadingComponent->>PrivyAuth: logout()
end
sequenceDiagram
participant User
participant WalletConnectDropdown
participant WalletConnectService
participant PrivyAuth
WalletConnectDropdown->>PrivyAuth: usePrivy() to get user address
WalletConnectDropdown->>WalletConnectService: get active sessions
WalletConnectService->>WalletConnectDropdown: returns sessions
WalletConnectDropdown->>WalletConnectDropdown: Filter sessions using isAddressInSessionViaPrivy
WalletConnectDropdown->>User: Display filtered sessions
sequenceDiagram
participant User
participant WalletConnectService
participant PrivyAuth
User->>WalletConnectService: Disconnect session
WalletConnectService->>WalletConnectService: Check if session is linked to Privy user
alt Session is linked to Privy
WalletConnectService->>PrivyAuth: logout()
WalletConnectService->>User: Reload page
else Session is not linked to Privy
WalletConnectService->>User: Continue as usual
end
Possibly related PRs
Suggested reviewers
Poem
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Deploying x with
|
| Latest commit: |
7fbb98e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://025c23da.x-e62.pages.dev |
| Branch Preview URL: | https://fix-pro-3209-change-chainid.x-e62.pages.dev |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
src/utils/walletConnect.ts (2)
22-27: Consider supporting any WalletConnect namespace & add defensive parsingThe current implementation extracts accounts only from the
eip155namespace and blindly splits by':', assuming the third chunk is always the address.
- Projects that support multiple namespaces (e.g.
cosmos,polkadot) will silently ignore those accounts.- If an entry is malformed (less than three chunks),
acc.split(':')[2]will produceundefined, propagating into the returned array.- const accounts: string[] = session.namespaces?.eip155?.accounts || []; - return accounts.map((acc) => acc.split(':')[2]); + // Collect accounts from **all** namespaces + const namespaceAccounts = Object.values(session.namespaces ?? {}) + .flatMap((ns: any) => ns.accounts ?? []) as string[]; + + return namespaceAccounts + .map((acc) => { + const parts = acc.split(':'); + return parts.length === 3 ? parts[2] : undefined; + }) + .filter(Boolean) as string[];This keeps the helper generic and avoids leaking
undefinedvalues into the callers.
29-36: Minor naming improvement
EOAAddressis capital-cased like a type, but it’s a value. Prefer camelCase (eoaAddress) to stay consistent with the rest of the codebase.src/services/walletConnect.ts (1)
69-75: Non-blocking: handlelogoutfailures gracefullyIn
handleLogout, a failure inlogout()will currently swallow the error and still reload the page.
Logging or surfacing the error (and skippingreload()upon failure) would help diagnose issues during sign-out flows.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
package-lock.jsonis excluded by!**/package-lock.jsonsrc/apps/pillarx-app/components/MediaGridCollection/tests/__snapshots__/DisplayCollectionImage.test.tsx.snapis excluded by!**/*.snapsrc/apps/pillarx-app/components/TokenMarketDataRow/tests/__snapshots__/LeftColumnTokenMarketDataRow.test.tsx.snapis excluded by!**/*.snapsrc/apps/pillarx-app/components/TokensWithMarketDataTile/test/__snapshots__/TokensWithMarketDataTile.test.tsx.snapis excluded by!**/*.snap
📒 Files selected for processing (6)
package.json(1 hunks)src/apps/pillarx-app/components/WalletConnectDropdown/WalletConnectDropdown.tsx(4 hunks)src/containers/Main.tsx(1 hunks)src/pages/Loading.tsx(3 hunks)src/services/walletConnect.ts(12 hunks)src/utils/walletConnect.ts(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/apps/pillarx-app/components/WalletConnectDropdown/WalletConnectDropdown.tsx (1)
src/utils/walletConnect.ts (1)
isAddressInSessionViaPrivy(29-37)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: build
- GitHub Check: Cloudflare Pages
🔇 Additional comments (9)
package.json (1)
36-36: Updated @reown/walletkit dependency.The dependency has been updated from version
^1.1.2to^1.2.4to support enhanced WalletConnect integration with Privy authentication.src/containers/Main.tsx (2)
18-18: Simplified chain imports.Imports have been reduced to only include
mainnetandsepoliachains, which aligns with the PR objective of fixing the wallet connect flow.
332-336: Streamlined Privy provider configuration.The Privy provider configuration was simplified by removing the
supportedChainsarray, leaving onlydefaultChain(set to mainnet or sepolia based on environment) andembeddedWalletssettings. This change supports the PR objective of setting the default blockchain network of Privy to Mainnet.src/pages/Loading.tsx (2)
2-2: Added Privy authentication integration.The
usePrivyhook has been imported to access thelogoutfunction, integrating Privy's authentication capabilities into the Loading component.Also applies to: 17-17
39-49:Details
❓ Verification inconclusive
Implemented auto-logout safety mechanism.
An automatic logout feature has been added that triggers after 15 seconds in the loading state. This prevents users from getting stuck in loading screens during failed wallet connections.
Consider if 15 seconds is sufficient time for users on slower connections or devices. You might want to verify this timing through user testing or add a visual countdown to inform users before the logout occurs.
🏁 Script executed:
#!/bin/bash # Check for any other timeout values used for similar automatic logout mechanisms rg -A 1 -B 1 "setTimeout.*logout" --glob "*.{ts,tsx,js,jsx}" | grep -v "15000"Length of output: 62994
No additional auto-logout timeouts found
– Verified across the codebase: the onlysetTimeoutinvokinglogoutis the new 15 000 ms instance insrc/pages/Loading.tsx(lines 39–49).The 15-second delay stands alone—please confirm it suits users on slower connections or devices. You may also consider adding a visible countdown or making the timeout configurable to improve UX.
src/apps/pillarx-app/components/WalletConnectDropdown/WalletConnectDropdown.tsx (3)
5-5: Added Privy integration for wallet identification.Imported
usePrivyhook and utility functionisAddressInSessionViaPrivyto access the current user's wallet address and check for its presence in WalletConnect sessions.Also applies to: 11-13, 42-42
130-137: Implemented session filtering for connected wallet.Added logic to filter out WalletConnect sessions that are linked to the user's own Privy wallet. This prevents confusion by not showing the user's own wallet as a separate WalletConnect session.
The filtering assumes
user?.wallet?.addressis always available when needed. Consider adding a null check to handle cases where the user object or wallet address might not be available:- !isAddressInSessionViaPrivy(session, user?.wallet?.address || '') + !user?.wallet?.address || !isAddressInSessionViaPrivy(session, user.wallet.address)
139-139: Updated session count and rendering to use filtered sessions.Modified the active sessions count and session list rendering to use the filtered sessions list, ensuring consistency in the UI with the implemented session filtering logic.
Also applies to: 252-252
src/services/walletConnect.ts (1)
490-508:prevSessionsRefmight miss the very first deletion event
prevSessionsRef.currentis updated only whenactiveSessionschanges or when listeners are attached (line 691).
If the provider emits asession_deletebefore either effect executes, the ref will still be{}and the deleted session lookup will fail.Consider populating the ref immediately after
setActiveSessionsin places where the initial fetch happens (e.g. afterwalletKit.getActiveSessions()ininitWalletKit) or inside the event callback by falling back toactiveSessions[deletedTopic]when the ref misses.
Description
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Summary by CodeRabbit