Skip to content

Conversation

@infiniteflower
Copy link
Contributor

@infiniteflower infiniteflower commented Nov 21, 2025

Description

This PR removes more constants imported from @metamask/swaps-controller.

Related to #23040

Changelog

CHANGELOG entry:

Related issues

Fixes:

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

Replaces swaps-controller chain ID constants with CHAIN_IDS from transaction-controller across bridge components, card logic/SDK, and tests.

  • Bridge:
    • Replace chain constants with CHAIN_IDS in BridgeDestNetworksBar (update ChainPopularity, ShortChainNames).
    • Migrate allowed chains to CHAIN_IDS in utils/index.ts; adjust isBridgeAllowed and related tests.
  • Card:
    • Use CHAIN_IDS.LINEA_MAINNET in useAssetBalances and useGetPriorityCardToken (including CAIP formatting) and update references accordingly.
    • Update CardSDK to derive lineaChainId from CHAIN_IDS.LINEA_MAINNET.
    • Revise associated tests to reference CHAIN_IDS and updated CAIP values.
  • Selectors/Tests:
    • Update multichain EVM tests to use CHAIN_IDS for mainnet/polygon and related assertions.

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

@github-actions
Copy link
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 Nov 21, 2025
@infiniteflower infiniteflower changed the title Chore/swaps controller constants remove chore: swaps controller remove constants 2 Nov 21, 2025
@infiniteflower infiniteflower added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Nov 21, 2025
@github-actions
Copy link
Contributor

🔍 Smart E2E Test Selection

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

This PR is a pure refactoring effort that migrates chain ID constant imports from @metamask/swaps-controller/dist/constants to @metamask/transaction-controller's CHAIN_IDS.

Analysis Summary:

  1. Nature of Changes: The changes replace constant imports and their usages across 11 files:

    • Bridge components (3 files): BridgeDestNetworksBar, Bridge utils
    • Card components (7 files): CardHome, useAssetBalances, useGetPriorityCardToken, CardSDK, and related tests
    • Multichain selectors (1 file): EVM selector tests
  2. Functional Impact: This is a like-for-like constant replacement with no functional changes:

    • ETH_CHAIN_IDCHAIN_IDS.MAINNET
    • LINEA_CHAIN_IDCHAIN_IDS.LINEA_MAINNET
    • BSC_CHAIN_IDCHAIN_IDS.BSC
    • And similar mappings for other chains (Base, Arbitrum, Polygon, etc.)
  3. Test Coverage: All affected test files have been updated accordingly, including mocks that were referencing the old constants.

  4. Risk Assessment: Low risk because:

    • No logic changes, only import path and constant name changes
    • Constants represent the same values (chain IDs)
    • Comprehensive unit test updates included
    • This is a standard refactoring pattern

Test Tag Selection Rationale:

  • SmokeTrade: Selected because Bridge functionality is part of the trading/DEX flow, and the Bridge components were modified
  • SmokeCard: Selected because 7 out of 11 files are related to Card functionality (hooks, SDK, views, utils)

These two tags provide targeted coverage of the affected functional areas. While the risk is low due to the refactoring nature, running these specific smoke tests ensures the Bridge and Card features continue to work correctly with the new constant imports.

View GitHub Actions results

@sonarqubecloud
Copy link

@infiniteflower infiniteflower marked this pull request as ready for review November 24, 2025 12:22
@infiniteflower infiniteflower requested review from a team as code owners November 24, 2025 12:22
allowanceState: AllowanceState.NotEnabled,
isStaked: false,
caipChainId: LINEA_CHAIN_ID,
caipChainId: formatChainIdToCaip(CHAIN_IDS.LINEA_MAINNET),
Copy link
Contributor Author

@infiniteflower infiniteflower Nov 24, 2025

Choose a reason for hiding this comment

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

This is actually a different value from before. The field is caipChainId but a hex value was incorrectly being passed in before (TS did not complain for some reason). The new value is actually a CAIP chain id now.

Copy link
Contributor

@GeorgeGkas GeorgeGkas left a comment

Choose a reason for hiding this comment

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

lgtm

@infiniteflower infiniteflower added this pull request to the merge queue Nov 24, 2025
github-merge-queue bot pushed a commit that referenced this pull request Nov 24, 2025
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

This PR removes more constants imported from
`@metamask/swaps-controller`.

Related to #23040

## **Changelog**

<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`

If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`

(This helps the Release Engineer do their job more quickly and
accurately)
-->

CHANGELOG entry:

## **Related issues**

Fixes:

## **Manual testing steps**

```gherkin
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**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **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.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Replaces swaps-controller chain ID constants with CHAIN_IDS from
transaction-controller across bridge components, card logic/SDK, and
tests.
> 
> - **Bridge**:
> - Replace chain constants with `CHAIN_IDS` in `BridgeDestNetworksBar`
(update `ChainPopularity`, `ShortChainNames`).
> - Migrate allowed chains to `CHAIN_IDS` in `utils/index.ts`; adjust
`isBridgeAllowed` and related tests.
> - **Card**:
> - Use `CHAIN_IDS.LINEA_MAINNET` in `useAssetBalances` and
`useGetPriorityCardToken` (including CAIP formatting) and update
references accordingly.
> - Update `CardSDK` to derive `lineaChainId` from
`CHAIN_IDS.LINEA_MAINNET`.
> - Revise associated tests to reference `CHAIN_IDS` and updated CAIP
values.
> - **Selectors/Tests**:
> - Update multichain EVM tests to use `CHAIN_IDS` for mainnet/polygon
and related assertions.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
9046975. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 24, 2025
@infiniteflower infiniteflower added this pull request to the merge queue Nov 24, 2025
Merged via the queue into main with commit 6214dee Nov 24, 2025
94 checks passed
@infiniteflower infiniteflower deleted the chore/swaps-controller-constants-remove branch November 24, 2025 16:56
@github-actions github-actions bot locked and limited conversation to collaborators Nov 24, 2025
@metamaskbot metamaskbot added the release-7.61.0 Issue or pull request that will be included in release 7.61.0 label Nov 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed release-7.61.0 Issue or pull request that will be included in release 7.61.0 team-swaps-and-bridge Swaps and Bridge team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants