Conversation
…oming transaction via WebSocket.
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 resolves a bug where the UI's account balance remained stale after receiving incoming transactions via WebSocket. Previously, the system only triggered account refreshes for outgoing transactions or manual page reloads. The implemented solution ensures that when an incoming transaction is detected via WebSocket and no outgoing transactions are pending, the account data is explicitly refreshed, providing real-time balance updates to the user interface. 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 addresses an issue where the account balance wasn't updating for incoming WebSocket transactions. The fix involves explicitly calling refreshAccount() for such cases, which seems correct. My review includes a few suggestions to improve code consistency and performance. I've pointed out a minor formatting issue in the CHANGELOG.md and suggested refactoring in trackTransactions.ts to reorder imports for better organization and to optimize state access for slightly better performance.
Issue
Account balance does not update in the UI after receiving an incoming transaction via WebSocket.
Reproduce
Issue exists on sdk-dapp v5 (Zustand store).
transactionCompletedWebSocket event fires and theTransactionReceivedToastappears — but the account balance displayed on the dashboard remains staleRoot cause
trackTransactions→recheckStatus→checkTransactionStatusexits early when there are no pending outgoing transaction sessions (entries.length === 0). This is always the case for incoming transactions since the wallet has no session tracking them.For outgoing transactions,
checkBatchcallsrefreshAccount()once the batch completes, which updates the Zustand account store. For incoming transactions, nothing triggeredrefreshAccount(), leaving the balance stale until a page refresh.In sdk-dapp v4 (Redux-based) this was handled internally by the store. In v5 (Zustand),
setAccountmust be called explicitly viarefreshAccount().Fix
In
setupWebSocketTrackinginsidetrackTransactions.ts, after callingrecheckStatus(), check whether there are no pending outgoing sessions. If so (incoming transaction case) and the user is logged in, callrefreshAccount().File:
src/methods/trackTransactions/trackTransactions.tsThis is intentionally placed inside
setupWebSocketTracking(WS event subscriber only) rather than incheckTransactionStatusorrecheckStatus, to avoid triggering unnecessary API calls on:recheckStatus()call at startup (line 81)Additional changes
None.
Contains breaking changes
Updated CHANGELOG
Testing