Skip to content
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

refactor: support non-evm tokens in asset-picker #30313

Merged
merged 44 commits into from
Feb 25, 2025

Conversation

micaelae
Copy link
Member

@micaelae micaelae commented Feb 14, 2025

Description

The main goal of this PR is to enable displaying non-evm tokens and their balances in the AssetPicker. The general approach is to find instances in which components and hooks read evm-specific data and replace them with multichain equivalents

In addition to that, this enables networks that use CAIP chainIds to be selectable in the asset-picker

Changes

  • types: allow non-hex chainId values
  • asset-picker-modal: show non-evm tokens that have balances
  • AssetList.tsxm asset-picker: read currency and account balance info from multichain selectors
  • Asset.tsx: read token data from props instead of getTokenList selector
  • token-list-item: only parse chainId as in if it's a hex value
  • useMultichainBalances: calculate token balances for non-evm tokens and include them in resulting sorted list
  • multichain.ts: add a placeholder network configuration for solana

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Set BRIDGE_USE_DEV_APIS=1 in .metamaskrc
  2. Swap + Send flow should still work for EVM chains
  3. Bridge flow should still work when bridging EVM -> EVM

Screenshots/Recordings

Before

After

Screen.Recording.2025-02-25.at.11.42.25.AM.mov

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.

@micaelae micaelae force-pushed the mms1867-asset-picker-caip-multichain branch 3 times, most recently from 05048d3 to f128290 Compare February 19, 2025 03:29
@micaelae micaelae force-pushed the mms1867-asset-picker-caip-multichain branch from f128290 to e83df81 Compare February 19, 2025 16:26
@metamaskbot
Copy link
Collaborator

Builds ready [e1c1d5c]
Page Load Metrics (1719 ± 68 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint36918821632312150
domContentLoaded14802061169213866
load14892066171914168
domInteractive26120482613
backgroundConnect97227199
firstReactRender1589472613
getState469202211
initialActions01000
loadScripts10261608123313565
setupStore812911
uiStartup16832450196116780
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 785 Bytes (0.01%)
  • common: 822 Bytes (0.01%)

@metamaskbot
Copy link
Collaborator

Builds ready [da1c4e5]
Page Load Metrics (1824 ± 71 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint32121311745358172
domContentLoaded15511973178413565
load15802141182414971
domInteractive28144483115
backgroundConnect13172433517
firstReactRender1578292010
getState681302613
initialActions01000
loadScripts10881526133012460
setupStore86917157
uiStartup17652471208717885
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 785 Bytes (0.01%)
  • common: 822 Bytes (0.01%)

@metamaskbot
Copy link
Collaborator

Builds ready [da3158b]
Page Load Metrics (1487 ± 50 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint13621737149010751
domContentLoaded13261721146611053
load13621735148710450
domInteractive237534188
backgroundConnect86729199
firstReactRender136521178
getState45715168
initialActions01000
loadScripts955126110658943
setupStore75212126
uiStartup15531958168811254
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 785 Bytes (0.01%)
  • common: 822 Bytes (0.01%)

Copy link
Contributor

@gambinish gambinish left a comment

Choose a reason for hiding this comment

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

Pulled down and tested these:

  1. [flask] When navigating to swaps, I see SPL tokens to choose from to create my swap pair
  2. [flask] When navigating to bridge, I see SPL tokens to choose from to create my bridge pair
  3. Swap/Bridge flows work as expected on evm

@micaelae micaelae enabled auto-merge February 25, 2025 22:01
balance: balancesByAssetId[caipAssetId]?.amount ?? '0',
decimals: assetMetadataById[caipAssetId]?.units[0]?.decimals,
image: assetMetadataById[caipAssetId]?.iconUrl ?? '',
type: type === 'token' ? AssetType.token : AssetType.native,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have a constant for token?

Copy link
Contributor

@darkwing darkwing left a comment

Choose a reason for hiding this comment

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

Approving with a bunch of nits I hope we can potentially address.

@micaelae micaelae added this pull request to the merge queue Feb 25, 2025
Merged via the queue into main with commit 64dbed6 Feb 25, 2025
83 of 85 checks passed
@micaelae micaelae deleted the mms1867-asset-picker-caip-multichain branch February 25, 2025 23:00
@github-actions github-actions bot locked and limited conversation to collaborators Feb 25, 2025
@metamaskbot metamaskbot added the release-12.14.0 Issue or pull request that will be included in release 12.14.0 label Feb 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.14.0 Issue or pull request that will be included in release 12.14.0 team-bridge team-swaps
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants