Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (63)
📝 WalkthroughWalkthroughIntroduces multi-chain wallet linking by replacing single per-user Changes
Sequence DiagramssequenceDiagram
participant User
participant Frontend
participant AuthService
participant ChainService as Chain Service<br/>(EVM/Stellar)
participant UserService
participant Database
rect rgba(100, 150, 200, 0.5)
note over User,Database: Initial Login on Chain 1 (e.g., EVM)
User->>Frontend: Click "Sign In"
Frontend->>ChainService: verifyAndConsume(signature)
ChainService->>Database: Verify signature, extract address
ChainService-->>Frontend: address (e.g., 0x123...)
Frontend->>AuthService: login({ chainKind, message, signature })
AuthService->>UserService: resolveOrCreateUser(address, chainKind)
UserService->>Database: CREATE User + INSERT UserWallet
Database-->>UserService: user.id, wallet
AuthService->>Database: Mint tokens (user.id, username only)
Database-->>AuthService: access_token, refresh_token
AuthService-->>Frontend: tokens
Frontend->>Frontend: Store auth_token, refresh_token cookies
end
rect rgba(150, 200, 100, 0.5)
note over User,Database: Link Additional Wallet on Chain 2 (e.g., Stellar)
User->>Frontend: Click "Link Stellar Wallet"
Frontend->>ChainService: verifyAndConsume(transaction)
ChainService-->>Frontend: address (stellar address)
Frontend->>AuthService: linkWallet(userId, { chainKind, transaction })
AuthService->>UserService: Check for conflict (duplicate address or existing wallet for chain)
UserService->>Database: Verify no duplicate (address, chainKind)
UserService->>Database: INSERT UserWallet (same userId, new chainKind)
Database-->>UserService: new wallet row
AuthService->>Database: Mint tokens (same user.id, username)
Database-->>AuthService: access_token, refresh_token
AuthService-->>Frontend: LinkWalletResponse { id, address, chainKind, createdAt }
Frontend->>Frontend: Invalidate current-user cache
end
sequenceDiagram
participant User
participant ConnectHubModal
participant ChainAdapter as ChainAdapter<br/>(EVM/Stellar)
participant WalletProvider as Wallet Provider
participant AuthHook as Auth Hook<br/>(useEvmLogin)
participant AuthService
participant UserService as User Service
rect rgba(100, 150, 200, 0.5)
note over User,UserService: Unified Chain Connection & Sign-In Flow
User->>ConnectHubModal: Open modal
ConnectHubModal->>ChainAdapter: Render adapter row
User->>ConnectHubModal: Click "Connect"
ConnectHubModal->>ChainAdapter: call connect()
ChainAdapter->>WalletProvider: Connect wallet
WalletProvider-->>ChainAdapter: address, chainId (or error)
ChainAdapter-->>ConnectHubModal: Update status → "connected"
ConnectHubModal-->>User: Show "Sign in required" suffix
end
rect rgba(150, 200, 100, 0.5)
note over User,UserService: Sign-In / Link Wallet Flow
User->>ConnectHubModal: Click "Sign in required" / auth action
ConnectHubModal->>AuthHook: call signIn()
AuthHook->>AuthService: requestChallenge() + sign message/tx
AuthService-->>AuthHook: challenge signed
AuthHook->>AuthService: submitLogin() or submitLinkWallet()
AuthService->>UserService: Verify signature, check wallet link status
alt Wallet not linked (auth_token exists)
UserService->>AuthService: Need to link
AuthService-->>AuthHook: { mode: "link", data: LinkWalletResponse }
else Fresh login
AuthService-->>AuthHook: { mode: "login", data: LoginResponse }
end
AuthHook->>AuthHook: Store cookies, invalidate user cache
AuthHook-->>ConnectHubModal: Update adapter status
ConnectHubModal-->>User: Show "authenticated" or updated address
end
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Summary by CodeRabbit
Release Notes
New Features
Documentation