This repository was archived by the owner on Aug 26, 2025. It is now read-only.
Fix: Prevented incorrect error handling on getting token balances and corrected cGHS address for Alfajores#205
Merged
Andrew718PLTS merged 2 commits intomainfrom Mar 11, 2025
Conversation
… corrected cGHS address for Alfajores
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
PR Overview
This PR fixes the error handling issue when fetching token balances on Alfajores and updates the cGHS token address. The changes include:
- Refactoring the token balance fetching logic to use a try/catch block to prevent the entire operation from failing for a single token.
- Updating the error messaging in the polling worker.
- Correcting the cGHS token address in the token configuration.
Reviewed Changes
| File | Description |
|---|---|
| src/features/accounts/fetchBalances.ts | Refactor to use getTokenBalance with try/catch and update balance fetching. |
| src/features/polling/PollingWorker.tsx | Update error message and logging for balance fetching failures. |
| src/config/tokens.ts | Update the cGHS token address for Alfajores. |
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
src/features/accounts/fetchBalances.ts:41
- getTokenBalance returns undefined when an error occurs (see lines 54-57), but tokenBalances is force-cast to a mapping of string values, which may lead to a type inconsistency. Consider handling undefined balance values or updating the return type accordingly.
return tokenBalances as Record<TokenId, string>
chapati23
approved these changes
Mar 11, 2025
Contributor
chapati23
left a comment
There was a problem hiding this comment.
tested this on the preview url on alfajores and it fetched balances correctly
nice work on improving the error handling for balance fetching as well
nvtaveras
approved these changes
Mar 11, 2025
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
We couldn't get balances on Alfajores because of the incorrect error handling on getting token balances - it was trying to get the balance of the token with the address that is not correct (cGHS, this way we faced the issue). Now, I replaced it with
try catchblock to prevent throwing an error when there's an issue with some of the tokens. Instead, we load all the tokens we can and display the responsive console error to make it more understandable and prevent problems like this.Other changes
Updated address for the 'cGHS' token.
Tested
While token/s addresses are correct.
While token/s addresses are not correct
Related issues
Checklist before requesting a review