Skip to content

Conversation

@AntonioVentilii
Copy link
Collaborator

Motivation

We would like to show the complete balance in the network drop down: that means normal balances and stake balances (including claimable rewards).

Changes

  • Create utils to map stake balances per network (similar to normal balances).
  • Create derived store based on enabled tokens.
  • Adapt component NetworkSwitcherList.

Tests

Added tests.

Copilot AI review requested due to automatic review settings November 27, 2025 08:16
@AntonioVentilii AntonioVentilii requested review from a team as code owners November 27, 2025 08:16
Copy link
Contributor

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.

Pull request overview

This PR enhances the network switcher dropdown to display complete token balances by adding staking balances (including claimable rewards) alongside regular balances. The implementation follows existing patterns in the codebase by creating a utility function to aggregate stake balances per network and a derived store to make the data reactive.

Key changes:

  • Added sumMainnetTokensUsdStakeBalancesPerNetwork utility function to aggregate stake and claimable balances per network
  • Created enabledMainnetTokensUsdStakeBalancesPerNetwork derived store based on enabledFungibleTokensUi
  • Updated NetworkSwitcherList component to include stake balances in the total balance calculation

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/frontend/src/lib/utils/tokens.utils.ts Added new utility function to sum stake balances per network for mainnet tokens; includes grammar fixes in comments
src/frontend/src/lib/derived/tokens.derived.ts Added new derived store for stake balances per network; includes grammar fixes in comments
src/frontend/src/lib/components/networks/NetworkSwitcherList.svelte Updated to include stake balances in the total balance display for the network switcher
src/frontend/src/tests/lib/utils/tokens.utils.spec.ts Added comprehensive test coverage for the new utility function including edge cases
src/frontend/src/lib/utils/token.utils.ts Grammar fix in JSDoc comment (no functional changes)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@AntonioVentilii AntonioVentilii marked this pull request as draft November 27, 2025 08:33
@AntonioVentilii AntonioVentilii marked this pull request as ready for review November 27, 2025 08:50
Copy link
Contributor

@DenysKarmazynDFINITY DenysKarmazynDFINITY left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@AntonioVentilii AntonioVentilii added this pull request to the merge queue Nov 27, 2025
Merged via the queue into main with commit 4c962ea Nov 27, 2025
79 checks passed
@AntonioVentilii AntonioVentilii deleted the feat-frontend/Add-the-stake-balance-in-the-network-switcher-list branch November 27, 2025 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants