Skip to content

Conversation

@GeorgeGkas
Copy link
Contributor

@GeorgeGkas GeorgeGkas commented Jan 7, 2026

Description

Remove deprecated isSwapsAllowed utility in favor of the similar isBridgeAllowed one. Remove all legacy references to allowed swap networks list and use the one provided by the bridge controller package to act as a single source of truth.

Changelog

CHANGELOG entry: null

Related issues

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

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

Consolidates network allowlist and gating logic to Bridge.

  • Replaces isSwapsAllowed usages with isBridgeAllowed in Card Add Funds, Asset utils, SendFlow Amount, and related tests
  • Gates crypto funding/swap UI via AppConstants.BRIDGE.ACTIVE and isBridgeAllowed(...)
  • Sources allowlist from @metamask/bridge-controller (ALLOWED_BRIDGE_CHAIN_IDS, AllowedBridgeChainIds) and removes local allowlist/types
  • Updates imports in Bridge TransactionAsset and Snap UI to use controller types/utilities; widens isBridgeAllowed signature
  • Keeps NETWORK_TO_SHORT_NETWORK_NAME_MAP and bridge constants; no UI logic changes beyond gating/allowlist source

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

@GeorgeGkas GeorgeGkas added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Jan 7, 2026
@GeorgeGkas GeorgeGkas requested review from a team as code owners January 7, 2026 17:33
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 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 7, 2026
@github-actions github-actions bot added the size-S label Jan 7, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

🔍 Smart E2E Test Selection

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

This PR is a refactoring change that migrates the ALLOWED_BRIDGE_CHAIN_IDS constant and AllowedBridgeChainIds type from local constants to the @metamask/bridge-controller package. It also replaces isSwapsAllowed with isBridgeAllowed in several components.

Key changes:

  1. app/constants/bridge.ts: Removed ALLOWED_BRIDGE_CHAIN_IDS array and AllowedBridgeChainIds type - now imported from @metamask/bridge-controller
  2. app/components/UI/Bridge/utils/index.ts: isBridgeAllowed function now uses ALLOWED_BRIDGE_CHAIN_IDS from the controller package
  3. AddFundsBottomSheet: Changed from isSwapsAllowed to isBridgeAllowed and from AppConstants.SWAPS.ACTIVE to AppConstants.BRIDGE.ACTIVE
  4. Asset/utils.ts: Changed from isSwapsAllowed to isBridgeAllowed
  5. SendFlow/Amount/index.js: Changed from isSwapsAllowed to isBridgeAllowed for swap suggestions
  6. Import updates: Several files now import AllowedBridgeChainIds from @metamask/bridge-controller

The risk is medium because:

  • The logic change (swaps → bridge) could affect which chains are allowed for swaps/bridge operations
  • The allowed chain IDs list may differ between the old local constant and the new controller constant
  • Multiple user-facing features are affected (Card add funds, Asset swap button, Send flow swap suggestions)

Selected tags:

  • SmokeTrade: Bridge functionality tests (bridge-action-smoke.spec.ts)
  • SmokeCard: Card home add funds tests that use the AddFundsBottomSheet
  • SmokeSwaps: Swap functionality that relies on bridge allowed check
  • SmokeConfirmationsRedesigned: Send flow tests that may be affected by the Amount component changes

View GitHub Actions results

let isSwapsAssetAllowed;
if (asset.isETH || asset.isNative) {
const isChainAllowed = isSwapsAllowed(asset.chainId);
const isChainAllowed = isBridgeAllowed(asset.chainId);
Copy link

Choose a reason for hiding this comment

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

Bitcoin chain support lost in swap allowed migration

High Severity

The migration from isSwapsAllowed to isBridgeAllowed removes explicit Bitcoin (BtcScope.Mainnet) support. The old isSwapsAllowed function had a special case that returned true for Bitcoin, Solana, and Tron chains. While utils.ts has explicit overrides for Solana and Tron, there's no override for Bitcoin. The new isBridgeAllowed only checks ALLOWED_BRIDGE_CHAIN_IDS from @metamask/bridge-controller, and if Bitcoin isn't in that list (the old local version didn't include it), Bitcoin assets will no longer be allowed for swaps.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is not correct, isBridgeAllowed consumes ALLOWED_BRIDGE_CHAIN_IDS from @metamask/bridge-controller which contains trx, btc ans solana.

import {
ALLOWED_BRIDGE_CHAIN_IDS,
isNonEvmChainId,
} from '@metamask/bridge-controller';
Copy link

Choose a reason for hiding this comment

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

Solana conditional build support lost in chain migration

Medium Severity

The migration from the local ALLOWED_CHAIN_IDS to ALLOWED_BRIDGE_CHAIN_IDS from @metamask/bridge-controller removes build-time conditional compilation for Solana. The old code used ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) to only include SolScope.Mainnet when the keyring-snaps feature flag was enabled. The package constant doesn't have this conditional logic, potentially enabling Solana bridging/swapping in builds where keyring-snaps is disabled and Solana support is not intended.

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

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

keyring-snaps is enabled by default for all future builds so there is no issue here.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 7, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed size-S team-swaps-and-bridge Swaps and Bridge team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants