Skip to content

fix: skip useInsufficientNativeReserveError if non evm cp-7.77.0#29992

Merged
infiniteflower merged 2 commits into
mainfrom
fix/swaps-non-evm-quote-crash-7.77RC
May 12, 2026
Merged

fix: skip useInsufficientNativeReserveError if non evm cp-7.77.0#29992
infiniteflower merged 2 commits into
mainfrom
fix/swaps-non-evm-quote-crash-7.77RC

Conversation

@infiniteflower

@infiniteflower infiniteflower commented May 11, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes an issue introduced by #29712, where the app would crash if a user tries to get a non-EVM swap quote. The fix was to skip useInsufficientNativeReserveError if it is a non-EVM network.

Changelog

CHANGELOG entry: Fixed app crashing when trying to get a Swaps quote for non-EVM networks

Related issues

Fixes: #29987

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

Screen.Recording.2026-05-11.at.12.15.57.PM.mov

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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

Low Risk
Low risk guard change that prevents running EVM-only reserve logic on non-EVM chain IDs; main risk is accidentally suppressing the warning on chains that should still be checked.

Overview
Prevents crashes when requesting swap/bridge quotes on non-EVM networks by short-circuiting useInsufficientNativeReserveError when token.chainId is non-EVM.

Adds regression coverage ensuring the native-reserve warning is not shown for Solana swaps, and extends the hook tests to assert it returns undefined for multiple non-EVM native tokens (Solana/Bitcoin/Tron). Also updates the hook test store setup to use legacy_createStore.

Reviewed by Cursor Bugbot for commit a00c033. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label May 11, 2026
@metamaskbotv2 metamaskbotv2 Bot added the team-swaps-and-bridge Swaps and Bridge team label May 11, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.54%. Comparing base (3751d9a) to head (400f75b).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #29992      +/-   ##
==========================================
- Coverage   81.54%   81.54%   -0.01%     
==========================================
  Files        5343     5345       +2     
  Lines      142128   142199      +71     
  Branches    32411    32437      +26     
==========================================
+ Hits       115899   115956      +57     
- Misses      18299    18304       +5     
- Partials     7930     7939       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot added size-S and removed size-XS labels May 11, 2026
@infiniteflower infiniteflower marked this pull request as ready for review May 11, 2026 16:47
@infiniteflower infiniteflower requested a review from a team as a code owner May 11, 2026 16:47

@maxime-oe maxime-oe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm. Thank you for this fix.

@infiniteflower infiniteflower enabled auto-merge May 11, 2026 18:09
@infiniteflower infiniteflower removed the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label May 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeSwap, SmokeConfirmations, SmokeNetworkExpansion
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 92%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are a targeted bug fix in the Bridge/Swap flow:

  1. useInsufficientNativeReserveError/index.ts: Adds isNonEvmChainId(token.chainId) as an early-return guard, preventing a false "insufficient native reserve" error from being shown when the source token is on a non-EVM chain (Solana, Bitcoin, Tron, etc.). This is a one-line logic fix with clear, bounded scope.

  2. Test files: Two test files add coverage for the new non-EVM guard — one unit test for the hook itself (SOL, BTC, TRX tokens) and one integration test in BridgeView verifying the warning is absent for Solana source tokens.

Tag selection rationale:

  • SmokeSwap: Directly covers swap and bridge trading flows, which is exactly what this hook is used in. The fix affects the Bridge/Swap UI for non-EVM tokens.
  • SmokeConfirmations: Required per SmokeSwap tag description — "When selecting SmokeSwap, also select SmokeConfirmations (transaction confirmations are part of the flow)."
  • SmokeNetworkExpansion: The fix specifically targets Solana (non-EVM) token handling in the bridge flow. SmokeNetworkExpansion covers Solana Wallet Standard compliance and multi-chain provider architecture, making it directly relevant to validate that Solana bridge flows work correctly without the false warning.

Tags NOT selected:

  • No changes to core controllers, Engine, accounts, identity, network management, snaps, browser, staking, money, perps, predictions, or onboarding flows.
  • The change is purely within the Bridge UI hook layer with no cascade effects to other subsystems.

Performance Test Selection:
The change is a one-line early-return guard in a hook that computes an error state. It does not affect rendering performance, list rendering, data loading, state management at scale, or any performance-sensitive code paths. No performance tests are warranted.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@infiniteflower infiniteflower added this pull request to the merge queue May 12, 2026
Merged via the queue into main with commit 662560f May 12, 2026
150 of 151 checks passed
@infiniteflower infiniteflower deleted the fix/swaps-non-evm-quote-crash-7.77RC branch May 12, 2026 14:51
@github-actions github-actions Bot locked and limited conversation to collaborators May 12, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.78.0 Issue or pull request that will be included in release 7.78.0 label May 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: App crashes when trying to get a quote for non EVM Swaps

4 participants