Skip to content

Conversation

@GeorgeGkas
Copy link
Contributor

@GeorgeGkas GeorgeGkas commented Nov 11, 2025

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.

Changelog

CHANGELOG entry: Remove non-tradable assets from asset picker

Related issues

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

Manual testing steps

- 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

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

Introduces isTradableToken and updates useTokens to filter Tron Mainnet resource tokens (Energy, Bandwidth, Max Bandwidth) from bridge token lists, with comprehensive tests.

  • Bridge:
    • Filtering: Add utils/isTradableToken to mark non-tradable Tron Mainnet tokens (Energy, Bandwidth, Max Bandwidth) as excluded.
    • Hook updates: Integrate isTradableToken into hooks/useTokens filtering for tokensWithoutBalance, allTokens, and tokensToRender.
    • Tests: Add unit tests for isTradableToken covering EVM, Solana, Tron (mainnet/testnet), CAIP IDs, casing/whitespace, and name presence.

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

@GeorgeGkas GeorgeGkas requested a review from a team as a code owner November 11, 2025 08:57
@GeorgeGkas GeorgeGkas added the team-swaps-and-bridge Swaps and Bridge team label Nov 11, 2025
@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.

@sonarqubecloud
Copy link

return !tokensWithBalanceSet.has(tokenKey);
});
})
.filter(includeOnlyTradableTokens);
Copy link
Contributor

@bfullam bfullam Nov 11, 2025

Choose a reason for hiding this comment

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

Adding this as a separate .filter() means an additional iteration through the entire array, which is fairly inefficient especially for larger lists. Instead, we can optimize this with a util function like isTradableToken() that can be used as part of the existing filter pipes. E.g.

.filter((token) => {
if (!isTradableToken(token)) return false;
const tokenKey = getTokenKey(token);
return !excludedTokensSet.has(tokenKey);
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I thought about that but did not consider the fact that lists can be so big and neither how to ecapsulate it into the existing ones for some reason, isTradableToken is a nice touch.

@GeorgeGkas GeorgeGkas requested a review from bfullam November 11, 2025 17:05

export const isTradableToken = (token: BridgeToken) => {
if (
token.chainId?.includes('tron:') &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Here we can/should compare to the actual chainId, stored in TrxScope.Mainnet. E.g.

token.chainId === TrxScope.Mainnet

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

Labels

size-M team-swaps-and-bridge Swaps and Bridge team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants