Skip to content

fix: balance and token icons are unavailable when the bridge page is reopened #31343

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

Merged
merged 6 commits into from
Mar 28, 2025

Conversation

micaelae
Copy link
Member

@micaelae micaelae commented Mar 27, 2025

Description

Open in GitHub Codespaces

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/MMS-2147

Manual testing steps

  1. Request a Bridge quote with src=native token
  2. Close extension popup
  3. Open popup again
  4. Balance should be repopulated and token icons should be visible

Screenshots/Recordings

Before

After

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.

@metamaskbot metamaskbot added the team-swaps-and-bridge For issues with Swaps or Bridging label Mar 27, 2025
@micaelae micaelae requested a review from Copilot March 27, 2025 05:12
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses an issue where balance and token icons were unavailable when the bridge page was reopened by updating both the balance fetching logic and the token icon assignment.

  • Adjusts the balance lookup in useLatestBalance to correctly select a CAIP asset type based on native status.
  • Revises token icon assignment logic in the prepare-bridge-page to prioritize available icon URLs.
  • Updates token type definitions to include an optional iconUrl field.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
ui/hooks/bridge/useLatestBalance.ts Updates balance lookup logic using a CAIP asset type based on native address detection.
ui/pages/bridge/prepare/prepare-bridge-page.tsx Modifies token icon assignment for both toToken and fromToken, mixing icon and iconUrl sources.
shared/types/bridge.ts Adds iconUrl to the BridgeAsset type for enhanced token image support.
Comments suppressed due to low confidence (2)

ui/pages/bridge/prepare/prepare-bridge-page.tsx:257

  • The toToken image property now uses srcAsset.icon as the primary source instead of destAsset.icon; please verify that this change is intentional to match the expected behavior of the bridge page.
image: srcAsset.icon ?? destAsset.iconUrl ?? '',

ui/pages/bridge/prepare/prepare-bridge-page.tsx:265

  • Switching from the nullish coalescing operator (??) to the logical OR (||) on this line means falsy values like an empty string are treated differently; please confirm if this behavior is desired.
image: srcAsset.icon || srcAsset.iconUrl || '',

@metamaskbot
Copy link
Collaborator

Builds ready [b779fab]
Page Load Metrics (2903 ± 1366 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint155914743278228281358
domContentLoaded147014609264128181353
load155714814290328461366
domInteractive252059142440211
backgroundConnect301382265307147
firstReactRender20271756330
getState574713018187
initialActions02010
loadScripts108114141208128001344
setupStore9370638139
uiStartup176515933451338821864
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 487 Bytes (0.01%)
  • common: 0 Bytes (0.00%)

@micaelae micaelae marked this pull request as ready for review March 27, 2025 06:00
@micaelae micaelae requested a review from a team as a code owner March 27, 2025 06:00
@metamaskbot
Copy link
Collaborator

Builds ready [d691a93]
UI Startup Metrics (1220 ± 67 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1220110915126712601339
load10759771302641153997
domContentLoaded10699721295631151993
domInteractive17137281629
firstPaint7581291242420223988
backgroundConnect106547910
firstReactRender18153731925
getState11431768
initialActions001000
loadScripts814703103464854908
setupStore7419279
WebpackHomeuiStartup974769114257973992
load83363797562875905
domContentLoaded82763096962870901
domInteractive16126881438
firstPaint44457917341855917
backgroundConnect16113441626
firstReactRender14123021416
getState7413279
initialActions001001
loadScripts82562095962868899
setupStore8511189
FirefoxBrowserifyHomeuiStartup14101232196315814481825
load12601064178514813061662
domContentLoaded12601064178514813051662
domInteractive10137214299098
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2717134162751
firstReactRender24206152528
getState8347678
initialActions001001
loadScripts12351043176214812791630
setupStore7445568
WebpackHomeuiStartup9718321463138900980
load8507331268123819950
domContentLoaded8497321268123818949
domInteractive115322183021897
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect20136892135
firstReactRender19162831925
getState104751179
initialActions002001
loadScripts8337201245119830974
setupStore8556678
Bundle size diffs
  • background: 0 Bytes (0%)
  • ui: 362 Bytes (0.01%)
  • common: 0 Bytes (0%)

@metamaskbot
Copy link
Collaborator

✨ Files requiring CODEOWNER review ✨

🔄 @MetaMask/swaps-engineers

  • ui/hooks/bridge/useLatestBalance.ts
  • ui/pages/bridge/prepare/prepare-bridge-page.tsx

@micaelae micaelae force-pushed the mms2147-balance-resets-on-reopen branch from fa3e9e5 to 70f3b09 Compare March 27, 2025 21:24
@micaelae micaelae enabled auto-merge March 27, 2025 21:34
GustavoRSSilva
GustavoRSSilva previously approved these changes Mar 27, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [a49e380]
UI Startup Metrics (1177 ± 51 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1177107713165112111263
load1025936116348951987
domContentLoaded1019932115449948991
domInteractive16133251529
firstPaint6931491163402256984
backgroundConnect1167311910
firstReactRender19144561932
getState11434768
initialActions001001
loadScripts80570194250837897
setupStore8522378
WebpackHomeuiStartup962836123776961982
load82260194656846913
domContentLoaded81558393756842901
domInteractive15124871432
firstPaint47955932345835900
backgroundConnect16125581540
firstReactRender14123341325
getState7411178
initialActions001000
loadScripts81357392756840899
setupStore8533489
FirefoxBrowserifyHomeuiStartup14221240199916614531872
load12801060182216113201707
domContentLoaded12801060182116113201707
domInteractive11037186258198
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect24165052733
firstReactRender23195462532
getState7435479
initialActions001001
loadScripts12581041179015912981668
setupStore6423367
WebpackHomeuiStartup9758261534156894970
load8547211331138809945
domContentLoaded8547201331138809945
domInteractive112351802613790
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect211394122433
firstReactRender18162721824
getState93921189
initialActions001001
loadScripts8377071302135812967
setupStore7449578
Bundle size diffs
  • background: 0 Bytes (0%)
  • ui: 61 Bytes (0%)
  • common: 0 Bytes (0%)

@micaelae micaelae added this pull request to the merge queue Mar 28, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [ea01374]
UI Startup Metrics (1172 ± 50 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1172108414005011951257
load1014893115248949991
domContentLoaded1009884114449954998
domInteractive16133751532
firstPaint7311351159392254985
backgroundConnect106547910
firstReactRender19144851927
getState11437769
initialActions001000
loadScripts79867792849828882
setupStore8419278
WebpackHomeuiStartup964762126085969990
load82061394763851911
domContentLoaded81459693664846904
domInteractive16124681437
firstPaint51155939350840907
backgroundConnect16114781539
firstReactRender14123341425
getState7415278
initialActions001001
loadScripts81158692563844894
setupStore7519279
FirefoxBrowserifyHomeuiStartup14171236195515714361827
load12711072180415113021656
domContentLoaded12701072180315113011656
domInteractive10538170298696
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2817131192535
firstReactRender23195252529
getState7438479
initialActions001001
loadScripts12451051177914712761630
setupStore6412267
WebpackHomeuiStartup9718231573168898988
load8517181349148812887
domContentLoaded8517181349148812887
domInteractive115342182815496
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2113101152033
firstReactRender18162821925
getState8468779
initialActions001001
loadScripts8357051322144804911
setupStore8561878
Bundle size diffs
  • background: 0 Bytes (0%)
  • ui: 61 Bytes (0%)
  • common: 0 Bytes (0%)

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 28, 2025
@micaelae micaelae added this pull request to the merge queue Mar 28, 2025
Merged via the queue into main with commit 1e33e5f Mar 28, 2025
147 checks passed
@micaelae micaelae deleted the mms2147-balance-resets-on-reopen branch March 28, 2025 17:28
@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 2025
@metamaskbot metamaskbot added the release-12.17.0 Issue or pull request that will be included in release 12.17.0 label Mar 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.17.0 Issue or pull request that will be included in release 12.17.0 team-swaps-and-bridge For issues with Swaps or Bridging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants