Skip to content

fix(bridge): support disabled networks in swap deeplinks#28670

Merged
bfullam merged 6 commits intomainfrom
swaps-deeplink-defaults-fix
Apr 10, 2026
Merged

fix(bridge): support disabled networks in swap deeplinks#28670
bfullam merged 6 commits intomainfrom
swaps-deeplink-defaults-fix

Conversation

@bfullam
Copy link
Copy Markdown
Contributor

@bfullam bfullam commented Apr 10, 2026

Description

This fixes SWAPS-4336, where swap deeplinks targeting supported but disabled networks could fall back to the default Bridge pair and show an unexpected network-added toast. The deeplink flow now checks swap support first, enables already-known networks in the background, auto-adds supported missing EVM networks from PopularList, and consumes one-shot toast suppression correctly so deeplink and Bridge token-selector adds stay silent while normal manual add/remove toasts still behave as expected.

Changelog

CHANGELOG entry: Fixed swap deeplinks on supported disabled networks so the requested chain opens without an extra network-added toast.

Related issues

Refs: SWAPS-4336

Manual testing steps

Feature: open swap deeplinks on supported disabled networks

  Scenario: deeplink adds a supported disabled network without showing an add toast
    Given Sei is disabled in the wallet
    When the user opens a swap deeplink for "SEI -> USDC" on Sei
    Then Bridge opens with "SEI -> USDC" selected on Sei
    And no "network added" toast is shown

  Scenario: manual re-add still shows the add toast after deeplink suppression is consumed
    Given Sei was added by deeplink and then disabled again
    When the user adds Sei back manually
    Then a "network added" toast is shown
    When the user removes Sei again
    Then a "network removed" toast is shown

  Scenario: bridge token selection adds a missing supported network silently
    Given a supported EVM network from the Bridge token selector is disabled
    When the user selects a token on that network in Bridge
    Then the network is added in the background
    And no "network added" toast is shown

Screenshots/Recordings

Before

N/A

After

N/A

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

Medium Risk
Changes deeplink-driven network enablement and auto-add behavior for Bridge/Swaps, which can affect navigation, network configuration state, and user-facing toasts. Risk is moderated by added unit tests, but failures could still cause incorrect chain selection or missing/extra notifications.

Overview
Fixes swap deeplinks so supported-but-disabled (or missing) source/dest chains are made available before BridgeView mounts, instead of falling back to default params.

Adds one-shot suppression for network-added toasts via networkToastSuppression, wires Main's add/remove network toast logic through shouldShowNetworkListToast, and uses the suppression when Bridge token selection or swap deeplinks auto-add EVM networks from PopularList (clearing suppression on failures).

Extends handleSwapUrl to verify swap support (ALLOWED_BRIDGE_CHAIN_IDS), best-effort enable known chains, auto-add supported missing EVM networks, and drop unsupported/unavailable dest tokens; expands tests to cover these scenarios.

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

@bfullam bfullam requested review from a team as code owners April 10, 2026 14:12
@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.

@metamaskbot metamaskbot added the team-swaps-and-bridge Swaps and Bridge team label Apr 10, 2026
@github-actions github-actions bot added size-M risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 10, 2026
@bfullam bfullam changed the title Fix swap deeplink handling for supported disabled networks fix(bridge): support disabled networks in swap deeplinks Apr 10, 2026
@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 10, 2026
@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 10, 2026
@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 10, 2026
@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 10, 2026
@github-actions github-actions bot added size-L risk-medium Moderate testing recommended · Possible bug introduction risk and removed size-M risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeTrade, SmokeConfirmations, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeWalletPlatform
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

E2E Test Selection:

The PR introduces several interconnected changes:

  1. networkToastSuppression.ts (new utility): A one-shot suppression mechanism for "network added" toasts, using a module-level Set. This is consumed by multiple components.

  2. handleSwapUrl.ts (DeeplinkManager - CRITICAL path): Significantly enhanced to auto-add missing EVM networks from the popular list and enable CAIP/non-EVM chains before navigating to the Bridge view. This directly affects the swap/bridge deep link flow tested by swap-deeplink-smoke.spec.ts (tagged SmokeTrade). The Solana/CAIP chain handling also touches SmokeNetworkExpansion territory.

  3. Nav/Main/index.js (core navigation): The network toast logic was refactored - removed the isOnBridgeRoute bypass and replaced it with the new suppression utility. This is a shared component that affects all flows involving network addition/deletion toasts. The shouldShowNetworkListToast function now gates toast display.

  4. useTokenSelection.ts (Bridge hook): Added toast suppression when auto-adding networks during token selection in the Bridge UI.

Tag selection rationale:

  • SmokeTrade: Directly affected - deep link swap/bridge flows now auto-add networks and suppress toasts. The swap-deeplink-smoke.spec.ts is tagged SmokeTrade. Bridge token selection (useTokenSelection.ts) is also SmokeTrade territory.
  • SmokeConfirmations: Required per SmokeTrade dependency rule ("when selecting SmokeTrade for swap/bridge, also select SmokeConfirmations").
  • SmokeNetworkAbstractions: Network management toast behavior changed in Nav/Main/index.js. The popular network auto-add logic in handleSwapUrl.ts interacts with NetworkController.addNetwork. Network manager tests could be affected by toast suppression changes.
  • SmokeNetworkExpansion: The handleSwapUrl.ts now handles CAIP chain IDs (Solana) with enableChainInBackground and isCaipChainId checks. Per tag description, when selecting SmokeNetworkExpansion for Solana flows, also select SmokeConfirmations (already included).
  • SmokeWalletPlatform: Nav/Main/index.js is the core navigation component. The toast logic change (removing isOnBridgeRoute bypass, adding suppression check) could affect any flow that adds networks. This is a shared infrastructure change.

Performance Test Selection:
The changes are focused on deep link handling logic, toast suppression utility, and network auto-add flows. These are event-driven, non-rendering code paths that don't affect UI rendering performance, list rendering, animations, or app startup. No performance-sensitive components (account lists, asset loading, login flows) are modified. Performance tests are not warranted.

View GitHub Actions results

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b3efc14. Configure here.

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
16 value mismatches detected (expected — fixture represents an existing user).
View details

@bfullam bfullam enabled auto-merge April 10, 2026 17:04
@bfullam bfullam added this pull request to the merge queue Apr 10, 2026
Merged via the queue into main with commit 61d3687 Apr 10, 2026
190 of 193 checks passed
@bfullam bfullam deleted the swaps-deeplink-defaults-fix branch April 10, 2026 20:57
@github-actions github-actions bot locked and limited conversation to collaborators Apr 10, 2026
@metamaskbot metamaskbot added the release-7.74.0 Issue or pull request that will be included in release 7.74.0 label Apr 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.74.0 Issue or pull request that will be included in release 7.74.0 risk-medium Moderate testing recommended · Possible bug introduction risk size-L team-swaps-and-bridge Swaps and Bridge team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants