Skip to content

Conversation

@cermakjiri
Copy link
Contributor

@cermakjiri cermakjiri commented Nov 21, 2025

Please, let's focus on important feedback, no NITs this time, else it will be merge never. 🙏

Design

Figma

Major changes

  • 9f5b5fc feat: add new TradingFormInputAssetPicker as the To field in buy and swap
  • 92cc538 refactor: migrate from useTradingInfo to useTradingAssets
  • 6ae589d refactor(suite): extend common asset-picker components for the asset-picker in trading
  • ee4c8b8 refactor(product-components): update TopAssets, SearchAsset, AssetLogo
  • afe40bd refactor: migrate from useTradingInfo to useTradingUtils

Minor changes

  • 4503519 fix(suite): fix re-rendering issue in TradingFormOffersSwitcher in swap and quotes update in buy
  • 51daa47 refactor(suite): add special AssetSearchWithNetworkFilter component for global send and receive
  • 7f8e8c5 fix(suite): prevent default form submit of trading form
  • 8908313 feat: add propperly typed hasOwn util
  • f83f368 refactor(suite-common): remove unused constant
  • caf16e4 refactor(suite-common): improve derived types of network configs
  • 5cce798 refactor(suite): use constant for default trading crypto symbol

Description

  • Implement new to input with asset picker in buy and swap (packages/suite/src/views/wallet/trading/common/TradingForm/TradingFormInput/TradingFormInputAssetPicker)
  • A lot of changes is related to removing the useTradingInfo with its utils and types (toCryptoOption, TradingCryptoSelectItemProps) and adding new ones (e.g. useTradingAssets, useTradingUtils, TradingAssetOption, etc.). This even related to suite-native.
    • Remove useTradingInfo hook (it was wrongly memoized and was causing unnecessary re-renders). Instead, add several specialized hooks:
      • useCoinsAndPlatforms: Returns a fn for getting coins and platforms instead of memoized object. There's ref. preventing the callback being re-validated all the time.
      • useTradingAssets: methods for creating asset list items and getting default trading asset option. Now there're sorted as they come from API (i.e. from highest trading volume).
      • useTradingUtils: trading utils with the context of coins and platforms
      • There was a bug useTradingInfo: Some tokens weren't actually rendered even though they had exchange: true flag set (e.g. seach for zksync) Only the zksync was missing.
  • Then I encountered issues with missing FormProvider, invalid types / unnecessary type casting, etc. in trading. That's another bunch of changes and these we hard to expect beforehand.

Notes for QA

Please test the to field in buy and swap.

Related Issue

Resolve #22838
Resolve #22835

Screenshots:

Swap

Zaznam.obrazovky.2025-12-01.v.16.44.41.mov

Buy

Zaznam.obrazovky.2025-12-01.v.16.46.38.mov

🔍🖥️ Suite web test results: View in Currents

🔍🖥️ Suite desktop test results: View in Currents

🔍🖥️ Suite native android test results: View in Currents

@cermakjiri cermakjiri self-assigned this Nov 21, 2025
@cermakjiri cermakjiri marked this pull request as draft November 21, 2025 16:24
@cermakjiri cermakjiri changed the base branch from develop to feat/22838-top-assets November 25, 2025 14:36
@cermakjiri cermakjiri force-pushed the feat/22838-swap-to-asset-picker branch from 7ab878e to 2e79284 Compare November 26, 2025 15:59
@cermakjiri cermakjiri force-pushed the feat/22838-top-assets branch from d9b6ecb to 79e681a Compare November 28, 2025 12:28
@cermakjiri cermakjiri force-pushed the feat/22838-top-assets branch 4 times, most recently from 31a477b to e0b6ee6 Compare November 28, 2025 12:44
@cermakjiri cermakjiri force-pushed the feat/22838-swap-to-asset-picker branch 7 times, most recently from 4cb762f to 0faa786 Compare November 30, 2025 13:44
@cermakjiri cermakjiri force-pushed the feat/22838-top-assets branch from e0b6ee6 to fef5c22 Compare November 30, 2025 14:12
@cermakjiri cermakjiri force-pushed the feat/22838-swap-to-asset-picker branch 2 times, most recently from cf07501 to e8f1417 Compare November 30, 2025 14:42
@cermakjiri cermakjiri force-pushed the feat/22838-top-assets branch from fef5c22 to a586d57 Compare December 1, 2025 11:51
@cermakjiri cermakjiri force-pushed the feat/22838-swap-to-asset-picker branch from e8f1417 to 540db0f Compare December 1, 2025 11:56
@cermakjiri cermakjiri force-pushed the feat/22838-top-assets branch from a586d57 to 11b799f Compare December 1, 2025 12:20
@cermakjiri cermakjiri force-pushed the feat/22838-swap-to-asset-picker branch from 540db0f to 32d3d5f Compare December 1, 2025 12:36
@cermakjiri cermakjiri force-pushed the feat/22838-top-assets branch from 11b799f to d4e9aa0 Compare December 1, 2025 12:38
@cermakjiri cermakjiri force-pushed the feat/22838-swap-to-asset-picker branch from 32d3d5f to 6ef4f5f Compare December 1, 2025 12:39
Base automatically changed from feat/22838-top-assets to develop December 1, 2025 13:13
@cermakjiri cermakjiri force-pushed the feat/22838-swap-to-asset-picker branch from 6ef4f5f to 1aaf0d9 Compare December 1, 2025 13:14
@cermakjiri cermakjiri force-pushed the feat/22838-swap-to-asset-picker branch from f18e159 to 43d85eb Compare December 3, 2025 09:14
@cermakjiri cermakjiri force-pushed the feat/22838-swap-to-asset-picker branch from 43d85eb to 1b19b9d Compare December 3, 2025 09:32
@cermakjiri cermakjiri marked this pull request as draft December 4, 2025 08:02
@cermakjiri cermakjiri force-pushed the feat/22838-swap-to-asset-picker branch 2 times, most recently from 45b78a9 to 73d8573 Compare December 4, 2025 11:17
@cermakjiri
Copy link
Contributor Author

Yes, I agree the PR got much bigger than I initially intended. To make it little bit easier I've divided it to special commits so it's possible to review one group of changes at the time. 🙏

@cermakjiri cermakjiri marked this pull request as ready for review December 4, 2025 11:18
@cermakjiri cermakjiri requested review from a team and izmy and removed request for a team December 4, 2025 12:55
@cermakjiri cermakjiri force-pushed the feat/22838-swap-to-asset-picker branch from 7374854 to c595ea2 Compare December 4, 2025 14:44
- Add a simple hook called `useCoinsAndPlatforms` that memoizes the trading info from Redux and returns callback with stable reference for getting the data.
- The `useTradeingInfo` hook was incorrectly memoize. The `useTradeingUtils` uses the correctly memoized `useCoinsAndPlatforms` hook.
If clicking on disabled input, the click propagates to the form and submits it (some form values are then pushed to URL search params).
- Display `NetworkIcon` even if AssetLogo image failed to load.
- Prevent opening search asset dropdown on focus (fixes bug when you clicked on an dropdown option and the dropdown got closed and opened agained). Plus add testing IDs.
-  TopAssets: add style for hover state and add test ID.
…or global send and receive

Don't use common component since global send and receive is attached to Redux.
…picker in trading

Plus fix memo. issue in useModal.
- Create a new hooks for handling trading asset options.
    - It's now currectly memoized, greatly simplified and provides set of network symbols found in the trading info data.
    - Also, the types has been greatly improved. There's now `asset.isNativeToken` boolean which easily narrows types.
- However, this change required to migrate all old types related to this hook including those ones in suite-native workspace.
    - Instead of `toCryptoOption` method, there're now `createAssetOption` and `createDefaultAssetOption` method. Also the `useTradingAssets` hook now returns `createAssetOptionFromCryptoId` method.
@cermakjiri cermakjiri force-pushed the feat/22838-swap-to-asset-picker branch from c595ea2 to e8b5b55 Compare December 8, 2025 10:59
@trezor-bot
Copy link
Contributor

trezor-bot bot commented Dec 8, 2025

✅ Previously successful run of [Test] PR Suite Web e2e tests workflow has been found.
⏭️ Skipping tests for this run.
💡 If you are unsure about your latest changes, please rerun the workflow manually. (Use the Re-run all jobs option)

@cermakjiri cermakjiri force-pushed the feat/22838-swap-to-asset-picker branch from 84d9a73 to 39edc99 Compare December 8, 2025 11:59
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.

Create select asset modal for TO field Update useTradingInfo hook

5 participants