-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
refactor: migrate isSwapsAllowed legacy utility to isBridgeAllowed #24292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
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. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsThis PR is a refactoring change that migrates the Key changes:
The risk is medium because:
Selected tags:
|
| let isSwapsAssetAllowed; | ||
| if (asset.isETH || asset.isNative) { | ||
| const isChainAllowed = isSwapsAllowed(asset.chainId); | ||
| const isChainAllowed = isBridgeAllowed(asset.chainId); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|



Description
Remove deprecated
isSwapsAllowedutility in favor of the similarisBridgeAllowedone. 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
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Consolidates network allowlist and gating logic to Bridge.
isSwapsAllowedusages withisBridgeAllowedin Card Add Funds, Asset utils, SendFlow Amount, and related testsAppConstants.BRIDGE.ACTIVEandisBridgeAllowed(...)@metamask/bridge-controller(ALLOWED_BRIDGE_CHAIN_IDS,AllowedBridgeChainIds) and removes local allowlist/typesisBridgeAllowedsignatureNETWORK_TO_SHORT_NETWORK_NAME_MAPand bridge constants; no UI logic changes beyond gating/allowlist sourceWritten by Cursor Bugbot for commit fbbbe1b. This will update automatically on new commits. Configure here.