Skip to content

Conversation

@bfullam
Copy link
Contributor

@bfullam bfullam commented Oct 16, 2025

Description

Adds the Tron network to swaps/bridge.

Changelog

CHANGELOG entry: added Tron network support in swaps

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

Adds Tron support to swaps and bridge, filters non‑tradable Tron tokens, updates fee/status handling, defaults, and dependencies.

  • Bridge/Swaps Integration
    • Allow TrxScope.Mainnet in swaps (isSwapsAllowed) and bridge (ALLOWED_BRIDGE_CHAIN_IDS, network name map).
    • Add Tron default swap token (USDT TRC20) in default-swap-dest-tokens.ts and BIP44 pairs.
  • Token Handling
    • New isTradableToken utility to exclude Tron resource tokens (Energy, Bandwidth, Max Bandwidth).
    • useTokens now filters non‑tradable tokens, normalizes non‑EVM addresses, and improves deduping/exclusions.
  • UI/Logic
    • TransactionDetails: safer multichain fee sum (handles partially fungible fees) and unified status selection.
    • Asset utils: mark Solana/Tron assets as swaps‑allowed.
  • Tests
    • Extensive tests for non‑EVM normalization, Tron token filtering, deduplication, and edge cases.
  • Dependencies
    • Bump @metamask/bridge-controller and @metamask/bridge-status-controller to ^60.1.0; @metamask/tron-wallet-snap to ^1.7.x (lockfile updated).
  • Docs
    • Minor README fixes (overlay usage, sample E2E notes).

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

@bfullam bfullam requested a review from a team as a code owner October 16, 2025 15:51
@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 Oct 16, 2025
cursor[bot]

This comment was marked as outdated.

@bfullam bfullam requested a review from a team as a code owner October 21, 2025 00:37
cursor[bot]

This comment was marked as outdated.

@bfullam bfullam requested a review from a team as a code owner November 4, 2025 18:07
Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

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

Approving lint fix on component library file to unblock on behalf of @MetaMask/design-system-engineers

### `color`

Optional prop to configure the color of the BottomSheetOverlay.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like a linting fix? If you revert this file you will no longer need CO review from @MetaMask/design-system-engineers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like I can't revert this, actually. These cahnges are being forced by the pre-commit hook.

bergarces
bergarces previously approved these changes Nov 11, 2025
GeorgeGkas and others added 5 commits November 11, 2025 18:27
<!--
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**

Tron Snap currently treats 'energy' and 'bandwidth' as assets, which
causes them to appear in asset lists, including the Swaps asset pickers.
Since these are not tradeable assets, we need to implement filtering on
the asset pickers to exclude them from the UI. We ensure that 'energy'
and 'bandwidth' are not displayed in asset pickers where tradeable
assets are expected.

<!--
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?
-->

## **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: Remove non-tradable assets from asset picker

## **Related issues**

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

## **Manual testing steps**

```gherkin
- Ensure `Energy`, `Bandwidth` and `Max bandwidth` tokens are not rendered in asset picker.
- Ensure that all tokens excepts the one mentioned above are still there.
```

## **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]
> Filters Tron resource tokens (Energy, Bandwidth, Max Bandwidth) from
bridge token lists and adds comprehensive tests, including non-EVM
address normalization and edge cases.
> 
> - **Bridge Utils**:
> - Add `isTradableToken` utility to exclude Tron resource tokens
(`Energy`, `Bandwidth`, `Max Bandwidth`) on `TrxScope.Mainnet`.
> - **Hook (`useTokens`)**:
> - Filter non-tradable tokens via `isTradableToken` when building
`tokensWithoutBalance`, `allTokens`, and `tokensToRender`.
> - **Tests**:
>   - Expand `useTokens.test.ts` to cover:
> - Non-EVM address normalization via `formatAddressToAssetId` and error
on empty normalization.
> - Filtering of Tron non-tradable tokens across `tokensWithBalance`,
`topTokens`, and `remainingTokens`.
> - Deduplication/combination logic and handling of undefined/null
arrays and exclusions.
> - Add unit tests for `isTradableToken` with Tron and non-Tron
scenarios.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
38c4cfc. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@socket-security
Copy link

socket-security bot commented Nov 12, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​metamask/​tron-wallet-snap@​1.6.1 ⏵ 1.7.4100 +11007696 +1100
Updatednpm/​@​metamask/​bridge-status-controller@​56.0.0 ⏵ 60.1.099 +110078 +198 +1100
Updatednpm/​@​metamask/​bridge-controller@​56.0.3 ⏵ 60.1.099 +110079 +198 +1100

View full report

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 72.72727% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.91%. Comparing base (e1acbc5) to head (17ef016).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...mponents/TransactionDetails/TransactionDetails.tsx 50.00% 3 Missing and 1 partial ⚠️
app/components/Views/Asset/utils.ts 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #21294      +/-   ##
==========================================
- Coverage   77.91%   77.91%   -0.01%     
==========================================
  Files        3852     3853       +1     
  Lines       98566    98653      +87     
  Branches    19374    19403      +29     
==========================================
+ Hits        76801    76866      +65     
- Misses      16501    16517      +16     
- Partials     5264     5270       +6     

☔ 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.

@bfullam bfullam enabled auto-merge November 12, 2025 15:44
@sonarqubecloud
Copy link

@bfullam bfullam added this pull request to the merge queue Nov 12, 2025
auto-merge was automatically disabled November 12, 2025 17:10

Pull Request is not mergeable

Merged via the queue into main with commit c930907 Nov 12, 2025
149 of 152 checks passed
@bfullam bfullam deleted the swaps-tron-integration branch November 12, 2025 17:18
@github-actions github-actions bot locked and limited conversation to collaborators Nov 12, 2025
@metamaskbot metamaskbot added the release-7.60.0 Issue or pull request that will be included in release 7.60.0 label Nov 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants