-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: remove Tron non tradable assets from token selector #22471
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: swaps-tron-integration
Are you sure you want to change the base?
feat: remove Tron non tradable assets from token selector #22471
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. |
|
| return !tokensWithBalanceSet.has(tokenKey); | ||
| }); | ||
| }) | ||
| .filter(includeOnlyTradableTokens); |
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.
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);
});
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.
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.
…ut-non-tradable-assets
|
|
||
| export const isTradableToken = (token: BridgeToken) => { | ||
| if ( | ||
| token.chainId?.includes('tron:') && |
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.
Here we can/should compare to the actual chainId, stored in TrxScope.Mainnet. E.g.
token.chainId === TrxScope.Mainnet



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
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Introduces
isTradableTokenand updatesuseTokensto filter Tron Mainnet resource tokens (Energy,Bandwidth,Max Bandwidth) from bridge token lists, with comprehensive tests.utils/isTradableTokento mark non-tradable Tron Mainnet tokens (Energy,Bandwidth,Max Bandwidth) as excluded.isTradableTokenintohooks/useTokensfiltering fortokensWithoutBalance,allTokens, andtokensToRender.isTradableTokencovering 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.