-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## **Description** This PR refactors the TokenCell component to be more chain-agnostic, introducing several improvements: - **Separation of Concerns**: `TokenCell` and `TokenListItem` now serve distinct purposes, making changes and testing easier. `TokenListItem` is used in the Asset Picker, while `TokenCell` handles tokens for the main token list. - **Shared Business Logic**: Introduced a `useTokenDisplayInfo` hook to centralize shared data, reducing reliance on prop overrides while keeping markup in their respective components. - **Style Cleanup**: Removed styles that were not applied to the main token list. - **Removed `NativeToken`**: This legacy component, originally needed for PortfolioView, is no longer required. Native and non-EVM tokens will now be integrated into the existing token list. `useNativeTokenBalance` is still used in `TokenList` for now but may be removed soon during multichain integration. - **Type & Prop Consolidation**: Simplified type definitions and streamlined prop passing from AssetList → TokenList → TokenCell. - **Component Decomposition**: Broke `TokenCell` into smaller, manageable components for better control and maintainability, eliminating excessive complexity. This uncovered a few unexpected patterns with the previous implementation that I believe were not correct. I've added comments to point out where. Also memoized these smaller components to help improve performance and avoid unnecessary re-renders. [](https://codespaces.new/MetaMask/metamask-extension/pull/30238?quickstart=1) ## **Related issues** Multichain effort ## **Manual testing steps** App should function as normal without regressions. The next PR will integrate with the new multichain controllers, and add in the multichain feature flag / code fences to prevent unecessary polling. ## **Screenshots/Recordings** https://github.com/user-attachments/assets/ad7bff01-4e0d-4716-9a96-23c926b90044 ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/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-extension/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.
- Loading branch information
Showing
31 changed files
with
973 additions
and
499 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
50 changes: 0 additions & 50 deletions
50
ui/components/app/assets/asset-list/native-token/native-token.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export { default as useAssetListTokenDetection } from './useAssetListTokenDetection'; | ||
export { default as useNativeTokenBalance } from './useNativeTokenBalance'; | ||
export { default as useNetworkFilter } from './useNetworkFilter'; | ||
export { default as usePrimaryCurrencyProperties } from './usePrimaryCurrencyProperties'; | ||
export { default as useTokenDisplayInfo } from './useTokenDisplayInfo'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
70 changes: 0 additions & 70 deletions
70
ui/components/app/assets/hooks/useSortedFilteredTokens.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.