Skip to content

feat: mms-1876 swap pre populated #30929

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 9 commits into from
Mar 13, 2025
Merged

Conversation

GustavoRSSilva
Copy link
Contributor

@GustavoRSSilva GustavoRSSilva commented Mar 12, 2025

Description

Set a default token populated when going to the swap page

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Go to the swap page
  2. Check token populated

Screenshots/Recordings

Before

After

Screen.Recording.2025-03-12.at.11.44.16.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.

@GustavoRSSilva GustavoRSSilva requested a review from a team as a code owner March 12, 2025 11:46
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-swaps-and-bridge For issues with Swaps or Bridging label Mar 12, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [8c6052c]
Page Load Metrics (2031 ± 149 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint166326001991247119
domContentLoaded16352403187617584
load166428922031311149
domInteractive257336136
backgroundConnect1159415016579
firstReactRender15153513919
getState64107210450
initialActions01000
loadScripts12041823142812962
setupStore8189354923
uiStartup184754102696961461
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 170 Bytes (0.00%)
  • common: 2.27 KiB (0.02%)

ghgoodreau
ghgoodreau previously approved these changes Mar 12, 2025
@@ -754,6 +755,15 @@ export default function PrepareSwapPage({
}
}, [showQuotesLoadingAnimation]);

// Set the default destination token for the swap
useEffect(() => {
if (!selectedToToken?.address && DEFAULT_TO_TOKEN_BY_NETWORK[chainId]) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a condition here to skip pre-populating the toToken if the default token === fromToken?

Repro steps:

  • From homepage, go to asset details page for the default token (i.e, USDC on ethereum)
  • Click Swap from there
  • See that the Swap page has USDC -> USDC filled in, which is an invalid route

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updating it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @micaelae , I refactored the PR, to use a hook, not only we need to take that edge case, but always return one of the main from and to pair.

@metamaskbot
Copy link
Collaborator

Builds ready [dc6fd5e]
Page Load Metrics (2200 ± 191 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint44827322042483232
domContentLoaded169127572088307148
load171630452200398191
domInteractive27191544019
backgroundConnect1762111915976
firstReactRender15123443015
getState6176505225
initialActions01000
loadScripts125320741570230110
setupStore889333014
uiStartup197848852759863414
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 1.67 KiB (0.02%)
  • common: 2.27 KiB (0.02%)

@metamaskbot
Copy link
Collaborator

Builds ready [b28ecff]
Page Load Metrics (5090 ± 2687 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint47015974400340221931
domContentLoaded175822132474355862682
load187622220509055952687
domInteractive271199162309148
backgroundConnect94934342238114
firstReactRender25153713617
getState2342316212359
initialActions01000
loadScripts132821033406854472616
setupStore12247867637
uiStartup219022417667456072692
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 1.67 KiB (0.02%)
  • common: 2.27 KiB (0.02%)

@metamaskbot
Copy link
Collaborator

Builds ready [bdd3c6c]
Page Load Metrics (4027 ± 2571 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint43126913340654592621
domContentLoaded175226796367253872587
load186826834402753542571
domInteractive277249415273
backgroundConnect441147361317152
firstReactRender21134783617
getState1077618018087
initialActions01000
loadScripts132226286300053732580
setupStore11415849847
uiStartup240827062547053212555
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 1.67 KiB (0.02%)
  • common: 2.27 KiB (0.02%)

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

Builds ready [11a2614]
Page Load Metrics (2967 ± 728 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1765773227341354650
domContentLoaded1666719824681229590
load1786845229671516728
domInteractive27267736431
backgroundConnect1351050459279134
firstReactRender55158932914
getState5872124618388
initialActions01000
loadScripts124358281789986473
setupStore313241148139
uiStartup260911088478922141063
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 1.67 KiB (0.02%)
  • common: 2.27 KiB (0.02%)

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 13, 2025
@GustavoRSSilva GustavoRSSilva added this pull request to the merge queue Mar 13, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 13, 2025
@GustavoRSSilva GustavoRSSilva added this pull request to the merge queue Mar 13, 2025
Merged via the queue into main with commit 8eadf35 Mar 13, 2025
76 checks passed
@GustavoRSSilva GustavoRSSilva deleted the mms-1876-swap-prepopulated branch March 13, 2025 22:50
@github-actions github-actions bot locked and limited conversation to collaborators Mar 13, 2025
@metamaskbot metamaskbot added the release-12.16.0 Issue or pull request that will be included in release 12.16.0 label Mar 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.16.0 Issue or pull request that will be included in release 12.16.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