Skip to content

Conversation

@GeorgeGkas
Copy link
Contributor

@GeorgeGkas GeorgeGkas commented Jan 8, 2026

Description

fixes an issue where flipping source/dest assets do not update balances when user has zero balance on non-evm chains

Changelog

CHANGELOG entry: fixes an issue where flipping source/dest assets do not update balances when user has zero balance on non-evm chains

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-3693

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Improves useLatestBalance behavior for non‑EVM and token switching scenarios.

  • Resets balance state when token.address changes to avoid stale UI; returns cached balance immediately while fetching new data
  • For non‑EVM chains, uses controller data and sets balance to 0 when token not found or balance is empty/undefined
  • Expands effect deps to include previous/current token address
  • Adds comprehensive tests covering address flips, non‑EVM fallbacks, zero/invalid balances, and race conditions

Written by Cursor Bugbot for commit 330d2db. This will update automatically on new commits. Configure here.

@GeorgeGkas GeorgeGkas requested a review from a team as a code owner January 8, 2026 15:50
@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-swaps-and-bridge Swaps and Bridge team label Jan 8, 2026
@github-actions github-actions bot added the size-M label Jan 8, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeTrade, SmokeSwaps
  • Risk Level: medium
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

The changes are focused on the useLatestBalance hook in the Bridge component, which is used for displaying token balances during bridge/swap operations. The modifications include:

  1. Bug fix for stale balance display: Added logic to reset balance state when token address changes, preventing stale balance from being shown when switching tokens.

  2. Bug fix for non-EVM tokens: Added handling for when non-EVM tokens are not found in the balance controller, setting balance to 0 instead of leaving it undefined/stale.

  3. Comprehensive unit tests: Added extensive test coverage for the new edge cases.

The hook is used in:

  • BridgeView - Main bridge view component
  • QuoteDetailsCard - Quote details display
  • SwapsKeypad - Swap input keypad
  • useBridgeQuoteRequest - Bridge quote request hook

These are all part of the Bridge/Swap functionality, making SmokeTrade (which covers token swaps, bridge, DEX trading) and SmokeSwaps (token swap functionality) the appropriate test tags. The changes are well-contained bug fixes with good test coverage, representing medium risk as they affect user-facing balance display in trading flows.

View GitHub Actions results

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 9, 2026

@GeorgeGkas GeorgeGkas added this pull request to the merge queue Jan 9, 2026
Merged via the queue into main with commit d04eff9 Jan 9, 2026
94 checks passed
@GeorgeGkas GeorgeGkas deleted the swaps-3693-update-non-evm-balance-on-flip branch January 9, 2026 09:20
@github-actions github-actions bot locked and limited conversation to collaborators Jan 9, 2026
@metamaskbot metamaskbot added the release-7.62.0 Issue or pull request that will be included in release 7.62.0 label Jan 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.62.0 Issue or pull request that will be included in release 7.62.0 size-M team-swaps-and-bridge Swaps and Bridge team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants