Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThe PR modifies wallet disconnection logic to support asynchronous permission revocation. The Deposit button's click handler now awaits the deposit operation before triggering disconnect. The connectDisconnect function converts to async and revokes external wallet permissions before disconnection. Unused global Window type augmentations are removed. Changes
Sequence DiagramsequenceDiagram
autonumber
actor User
participant Deposit Button
participant deposit()
participant connectDisconnect()
participant External Wallet
participant Ethereum Provider
User->>Deposit Button: Click
Deposit Button->>deposit(): await
deposit()->>Deposit Button: Complete
Deposit Button->>connectDisconnect(): invoke (now async)
alt External Wallet Exists
connectDisconnect()->>External Wallet: getEthereumProvider()
External Wallet-->>Ethereum Provider: provider
connectDisconnect()->>Ethereum Provider: wallet_revokePermissions
Ethereum Provider-->>connectDisconnect(): result
end
connectDisconnect()->>External Wallet: Disconnect
External Wallet-->>connectDisconnect(): Done
connectDisconnect()-->>User: Complete
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
components/TopupPage/Deposit.tsx (1)
73-76: Consider awaitingconnectDisconnectfor clearer async flow and error handlingThis achieves the “disconnect after topup” behavior by awaiting
deposit()before callingconnectDisconnect(). SinceconnectDisconnectis now async, you may want toawait connectDisconnect()as well so that:
- the full deposit + disconnect sequence is explicit and completed within the handler, and
- any errors from the disconnect flow are surfaced in the same place as deposit errors.
If you intentionally want disconnect to be fire‑and‑forget, this is fine as‑is, but a brief comment could help future readers understand that choice.
hooks/useTopup.ts (1)
33-47: AsyncconnectDisconnectflow is solid; consider minor refinementsThe new flow is robust:
- When connected, you try to revoke
eth_accountsviawallet_revokePermissions, andexternalWallet?.disconnect()infinallyguarantees cleanup even if the revoke call fails or throws.A few optional tweaks to consider:
- If
connectWallet()is async in@privy-io/react-auth, you might want toawait connectWallet()so callers ofconnectDisconnectcan reliably know when the connect flow has finished.- Depending on UX needs, you may want to catch/log non‑supported
wallet_revokePermissionserrors (some providers may not implement it) while still proceeding to disconnect.- If disconnect itself is async, consider awaiting it so that any downstream callers can rely on completion.
None of these are blockers; the current logic already meets the “disconnect after topup” goal with proper cleanup.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
components/TopupPage/Deposit.tsx(1 hunks)hooks/useTopup.ts(2 hunks)types/global.d.ts(0 hunks)
💤 Files with no reviewable changes (1)
- types/global.d.ts
🔇 Additional comments (1)
hooks/useTopup.ts (1)
18-18: TighterhasExternalWalletcheck looks goodSwitching to
Boolean(externalWallet?.address)makes the presence check better aligned with an actually connected wallet rather than any non‑null object. This should reduce false positives where an externalWallet instance exists but is not yet connected.
Summary by CodeRabbit
Release Notes
Bug Fixes
Chores