Skip to content

Conversation

@Prithpal-Sooriya
Copy link
Contributor

@Prithpal-Sooriya Prithpal-Sooriya commented Nov 20, 2025

Explanation

Currently we have fragmented logic in mobile and extension selectors due to TRON staked assets (energy and bandwidth).
This PR unifies this logic via an optional selector option to filter out TRON staked assets.

Default behaviour is to filter TRON staked assets.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Note

Adds an optional (default on) filter to exclude Tron staking resources in selectAssetsBySelectedAccountGroup, with tests and changelog update.

  • Selectors:
    • Add Tron resource constants and filtering (TRON_RESOURCE, TRON_RESOURCE_SYMBOLS_SET).
    • Extend selectAssetsBySelectedAccountGroup to accept options { filterTronStakedTokens } (defaults to true) and filter Tron staking tokens across TrxScope networks.
    • Enable memoization for selector args/results via weakMapMemoize.
  • Tests:
    • Add Tron fixtures in src/selectors/__fixtures__/arrange-tron-state.ts.
    • Add unit tests validating filtering on/off in token-selectors.test.ts.
  • Changelog:
    • Document new optional Tron filtering for selectAssetsBySelectedAccountGroup.

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

@Prithpal-Sooriya Prithpal-Sooriya requested a review from a team as a code owner November 20, 2025 00:08
@Prithpal-Sooriya Prithpal-Sooriya requested a review from a team as a code owner November 20, 2025 00:11
@Prithpal-Sooriya Prithpal-Sooriya force-pushed the feat/add-tron-filtering-options-to-asset-selector branch from 0e70cad to e6a0939 Compare November 20, 2025 00:12
expect(result).toStrictEqual(expectedMockResult);
});

const arrangeTronState = () => {
Copy link
Contributor Author

@Prithpal-Sooriya Prithpal-Sooriya Nov 20, 2025

Choose a reason for hiding this comment

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

I really hate this test suite...

Like sure this uses realistic state data, but MAN its ridiculously difficult to add new tests since you need to understand the WHOLE STATE.

It would be much much nicer if we can:

  1. Create JSON objects for each state we want to test. We have a fixtures folder that we can shove this in.
  2. Break up the selector parts into modular atomic functions that we can mock and test in isolation.

(state) => state.accountTree,
(
_state,
opts: SelectAccountGroupAssetOpts = defaultSelectAccountGroupAssetOpts,
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok for now, but I'm not a big fan of this as it can force recalculations based on filters. Also, if we add more chains that have different needs we are going to end up with very messy logic here.

IMO, the problem with Tron should have been solved by expanding the asset type to contain underlying metada (the tron resources), so all these Tron resources would have been added inside the main Tron asset, which will always be present. By adding those "resources" to the list of assets, even though we don't want to display them most of the time, we are causing situations like this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep I 100% agree with this.

R.E. selector recalculations - yep noticed this too. Converted to a weakmap memo on arguments to reduce this. Likewise I decoupled the filtering logic, but I can imagine this selector getting real messy down the line.

TRON tokens are a bit of a mess, I agree it would be good if either:

  1. There was a separation between normal tokens and staking tokens
  2. Tron team does not expose staking tokens immediately (most flows should not show these tokens), only on some rare screens should they be visible (which can be a separate call not going through our controllers)

@Prithpal-Sooriya Prithpal-Sooriya added this pull request to the merge queue Nov 20, 2025
Merged via the queue into main with commit 39f7d66 Nov 20, 2025
273 checks passed
@Prithpal-Sooriya Prithpal-Sooriya deleted the feat/add-tron-filtering-options-to-asset-selector branch November 20, 2025 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants