Skip to content
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
fix/SUP-166-alfajores-balance-loading
Mar 11, 2025
Merged

Fix: Prevented incorrect error handling on getting token balances and corrected cGHS address for Alfajores#205
Andrew718PLTS merged 2 commits intomainfrom
fix/SUP-166-alfajores-balance-loading

Conversation

@Andrew718PLTS
Copy link
Copy Markdown
Contributor

@Andrew718PLTS Andrew718PLTS commented Mar 10, 2025

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 catch block 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.

  1. Navigate to the preview and connect your wallet where you have tokens on the Alfajores.
  2. Change the network to Alfajores.
  3. Wait until the balances are loaded.

While token/s addresses are not correct

  1. Check out the branch and change any token address to an incorrect one.
  2. Run locally and connect your wallet where you have tokens on the Alfajores.
  3. Change the network to Alfajores.
  4. Wait until the warning notification toast is loaded and the console error is displayed.

Related issues

  • Fixes #issue number here

Checklist before requesting a review

  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • The PR title follows the conventions
  • I have run the regression tests

Copilot AI review requested due to automatic review settings March 10, 2025 16:58
@linear
Copy link
Copy Markdown

linear bot commented Mar 10, 2025

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mento-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 11, 2025 10:04am

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copy link
Copy Markdown
Contributor

@chapati23 chapati23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Andrew718PLTS Andrew718PLTS merged commit 30e5a24 into main Mar 11, 2025
7 checks passed
@Andrew718PLTS Andrew718PLTS deleted the fix/SUP-166-alfajores-balance-loading branch March 11, 2025 15:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants