-
Notifications
You must be signed in to change notification settings - Fork 5
fix: update transaction and balance cache when balance changes are detected #437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pedroanastacio
merged 5 commits into
staging
from
p2/fix/update-transaction-and-balance-cache
Jan 15, 2026
Merged
fix: update transaction and balance cache when balance changes are detected #437
pedroanastacio
merged 5 commits into
staging
from
p2/fix/update-transaction-and-balance-cache
Jan 15, 2026
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ce changes are detected
guimroque
reviewed
Jan 15, 2026
guimroque
reviewed
Jan 15, 2026
guimroque
reviewed
Jan 15, 2026
guimroque
reviewed
Jan 15, 2026
guimroque
reviewed
Jan 15, 2026
guimroque
reviewed
Jan 15, 2026
Member
guimroque
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review - Summary
What was done
- Added two new endpoints to check balance differences between cache and blockchain:
/user/check-balances/- checks all predicates for a user/predicate/check-balances/:predicateId- checks specific predicate
- Added socket events
BALANCE_OUTDATED_USERandBALANCE_OUTDATED_PREDICATEto notify UI when cache is updated - Added
compareBalancesutility function to detect balance changes - Added
getBalancesFromBlockchainmethod to ProviderWithCache for direct blockchain queries - Implemented cache invalidation and update logic when balance changes are detected
Positive Points
- Good separation of concerns with dedicated service methods
- Proper error handling with try/catch blocks
- Uses existing authentication and permission middlewares
- Implements proper TypeScript interfaces
- Good use of Promise.all for concurrent balance checks
- Includes safety limit (MAX_PREDICATES_TO_CHECK_BALANCE = 50)
- Proper cache invalidation strategy
Issues Found
- Missing input validation for predicateId parameter
- Potential performance issues with concurrent database queries
- Console.log statements should be removed
- Missing error context in some catch blocks
- Socket event naming inconsistency
Total comments: 5 (1 critical, 3 important, 1 suggestion)
guimroque
approved these changes
Jan 15, 2026
Member
guimroque
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! ✅
Previous issues have been fixed. Code approved.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Summary
/user/check-balances/) to check balances of all predicates related to user and emit socket event if the cached balances are different from the blockchain balance/predicate/check-balances/:predicateId) to check balances of the given predicate and emit socket event if the cached balances are different from the blockchain balanceBALANCE_OUTDATED_USERBALANCE_OUTDATED_PREDICATEcompareBalances) to compare cached balances with blockchain balancesChecklist