Skip to content

Conversation

@jpuri
Copy link
Contributor

@jpuri jpuri commented Nov 28, 2025

Description

Dapp swap comparison related code cleanup.

Changelog

CHANGELOG entry:

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/6346

Manual testing steps

  1. Submit dapp swap
  2. Check dapp swap comparison work as expected

Screenshots/Recordings

NA

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.

Note

Moves swap tx decoding to middleware, introduces swapInfo storage with incremental updates, simplifies UI hooks/metrics, and removes deprecated tokenAddresses.

  • Background/State:
    • Add swapInfo to DappSwapComparisonData (src/dest token addresses and amounts); remove tokenAddresses.
    • setDappSwapComparisonData now merges per-transaction updates instead of overwriting.
  • Middleware (app/scripts/lib/dapp-swap/dapp-swap-util.ts):
    • Parse commands and extract quotes input/amountMin; persist swapInfo via controller before fetching quotes.
    • Store quotes and latency; include commands on errors; drop tokenAddresses.
  • Shared Utils:
    • getDataFromSwap returns command values directly; associated tests updated (no tokenAddresses).
  • UI Hooks:
    • useDappSwapComparisonInfo: remove in-UI decoding and batch validation; consume middleware-provided swapInfo/commands; compute metrics using swapInfo.destTokenAmountMin; remove request detection latency property.
    • useDappSwapComparisonLatencyMetrics: remove request detection latency tracking; keep total latency.
    • Selectors updated to expose swapInfo.
  • Tests: Adjusted across utils and hooks to new swapInfo shape, metrics, and removed fields.

Written by Cursor Bugbot for commit 39caf8c. This will update automatically on new commits. Configure here.

@jpuri jpuri added team-confirmations Push issues to confirmations team no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed labels Nov 28, 2025
@github-actions
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
Copy link
Collaborator

✨ Files requiring CODEOWNER review ✨

@MetaMask/confirmations (5 files, +87 -143)
  • 📁 ui/
    • 📁 pages/
      • 📁 confirmations/
        • 📁 hooks/
          • 📁 transactions/
            • 📁 dapp-swap-comparison/
              • 📄 useDappSwapComparisonInfo.test.ts +18 -4
              • 📄 useDappSwapComparisonInfo.ts +63 -123
              • 📄 useDappSwapComparisonLatencyMetrics.test.ts +0 -2
              • 📄 useDappSwapComparisonLatencyMetrics.ts +0 -13
        • 📁 selectors/
          • 📄 confirm.ts +6 -1

@jpuri jpuri marked this pull request as ready for review November 28, 2025 16:21
@jpuri jpuri requested a review from a team as a code owner November 28, 2025 16:21
srcTokenAmount: quotesInput?.srcTokenAmount as Hex,
destTokenAmountMin: amountMin as Hex,
},
});
Copy link

Choose a reason for hiding this comment

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

Bug: Missing commands in successful swap comparison data storage

The commands variable is parsed from transaction data at line 106 but is never stored in setDappSwapComparisonData during the success path. The initial call (lines 117-124) stores only swapInfo, and the successful quote fetch callback (lines 135-138) stores only quotes and latency. Only error handlers include commands. The UI code expects commands from dappSwapComparisonData to populate metrics like swap_dapp_commands. Since commands isn't stored on success, metrics will incorrectly receive empty strings for this field.

Fix in Cursor Fix in Web

@metamaskbot
Copy link
Collaborator

Builds ready [2c7106e]
UI Startup Metrics (1208 ± 113 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1208991164011312741431
load1016841137810510831203
domContentLoaded1010837135710310771198
domInteractive241492192175
firstPaint67489138741210511193
backgroundConnect20418326313208233
firstReactRender2919168163245
getState341487124155
initialActions106113
loadScripts81364511371008811001
setupStore1272541421
numNetworkReqs1257821577
BrowserifyPower User HomeuiStartup20501770284724121962569
load1016879147112410311321
domContentLoaded1004874146512510221315
domInteractive35171432834123
firstPaint5029813633589471081
backgroundConnect248198838103223510
firstReactRender6140125166698
getState18613275263198240
initialActions107113
loadScripts79968212141218121116
setupStore2064682440
numNetworkReqs105652825498270
WebpackStandard HomeuiStartup8547141123988921051
load65657489482675849
domContentLoaded65156888781671844
domInteractive2815126242397
firstPaint23488894177210647
backgroundConnect135128161228
firstReactRender292196103348
getState261378113444
initialActions105112
loadScripts64856687880668833
setupStore1162231218
numNetworkReqs1257720574
WebpackPower User HomeuiStartup16591300258126119192159
load6945961277106698934
domContentLoaded6835881270107686927
domInteractive38171883436135
firstPaint2871071279207279699
backgroundConnect48868812618536
firstReactRender62489496778
getState17813624619187216
initialActions102112
loadScripts6805861259105684917
setupStore211066112348
numNetworkReqs1666542684218405
FirefoxBrowserifyStandard HomeuiStartup13051093174613313921548
load107492014119011451229
domContentLoaded107492014119011451229
domInteractive58301772983104
firstPaint------
backgroundConnect52232283967145
firstReactRender22183952336
getState146146201155
initialActions103122
loadScripts104390413267811031179
setupStore135164171039
numNetworkReqs1156716663
BrowserifyPower User HomeuiStartup26482001416555028074111
load1188999242025811571563
domContentLoaded1187999241925811571563
domInteractive11233517113105481
firstPaint------
backgroundConnect119261389151116315
firstReactRender5836148175999
getState27337842203341767
initialActions3030426
loadScripts1144950189521211191542
setupStore1768797213246689
numNetworkReqs98583045881234
WebpackStandard HomeuiStartup14991276209915415991788
load1244106215469913091442
domContentLoaded1244106215469913091442
domInteractive61272113683129
firstPaint------
backgroundConnect47211832845109
firstReactRender26215762737
getState1277591321
initialActions103012
loadScripts1218104615199412861387
setupStore135108151136
numNetworkReqs1157016759
WebpackPower User HomeuiStartup29512267467563032624478
load14961117274440915082581
domContentLoaded14961116273740915082581
domInteractive13731929168101494
firstPaint------
backgroundConnect178281108247137984
firstReactRender6044229216385
getState29777937216417777
initialActions3161837
loadScripts14081098272529814811983
setupStore1757740212193712
numNetworkReqs101632566178243
📊 Page Load Benchmark Results

Current Commit: 2c7106e | Date: 11/28/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.07s (±44ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 743ms (±41ms) 🟢 | historical mean value: 723ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 79ms (±14ms) 🟢 | historical mean value: 79ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.07s 44ms 1.03s 1.41s 1.09s 1.41s
domContentLoaded 743ms 41ms 716ms 1.07s 766ms 1.07s
firstPaint 79ms 14ms 64ms 204ms 92ms 204ms
firstContentfulPaint 79ms 14ms 64ms 204ms 92ms 204ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed size-M team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants