feat: add mUSD conversion hooks, selectors, and confirmation UI (Phase 1)#40223
feat: add mUSD conversion hooks, selectors, and confirmation UI (Phase 1)#40223nickewansmith merged 26 commits intomainfrom
Conversation
|
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. |
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/core-extension-ux (2 files, +7 -0)
👨🔧 @MetaMask/extension-platform (1 files, +3 -1)
🕵️ @MetaMask/extension-privacy-reviewers (1 files, +2 -0)
🔒 @MetaMask/extension-security-team (1 files, +2 -2)
👨🔧 @MetaMask/metamask-earn (12 files, +2561 -5)
🧪 @MetaMask/qa (2 files, +5 -1)
|
8affb61 to
6fba078
Compare
Builds ready [6fba078]
UI Startup Metrics (1383 ± 114 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
6fba078 to
4692dba
Compare
Builds ready [4692dba]
UI Startup Metrics (1333 ± 104 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [674b2a8]
UI Startup Metrics (1445 ± 111 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [38b699c]
⚡ Performance Benchmarks (1376 ± 103 ms)
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚀 Bundle size reduced!]
|
…files, more bugbot
Builds ready [7886c5d]
⚡ Performance Benchmarks (1383 ± 115 ms)
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚀 Bundle size reduced!]
|
| setError(null); | ||
|
|
||
| try { | ||
| const response = await fetch(GEOLOCATION_API_ENDPOINT, { |
There was a problem hiding this comment.
This is a good example of where you can benefit from Tanstack Query so you don't manage your own loading, setLoading, error, setError, states which are error prone
It's ready-to-use in the repo
There was a problem hiding this comment.
I am not that familiar with Tanstack just yet, but I will dive into it this week so that I understand better how I can use it. This PR is mostly to get a core layer in that others can depend on to move forward with development.
| const accountGroupAssets = useSelector(getAssetsBySelectedAccountGroup); | ||
|
|
||
| // Get all account tokens | ||
| const allTokens = useMemo((): TokenWithFiatAmount[] => { |
There was a problem hiding this comment.
Since this PR introduces an musd folder for selectors consider creating and moving some of these logic inside new selectors instead to be more performant
There was a problem hiding this comment.
This makes sense, I have 2 other PRs after this one so I can roll that change in once this core one is merged
|
Builds ready [d249ca1]
⚡ Performance Benchmarks (1371 ± 100 ms)
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
davidmurdoch
left a comment
There was a problem hiding this comment.
LGTM, based on my limited review of CO files only, as this PR does have 2 ✅ already.



Description
Introduce the foundational layer for the mUSD stablecoin conversion feature, ported from metamask-mobile. This phase adds the core hooks, Redux selectors, and confirmation screen components needed to power the conversion flow.
Hooks (ui/hooks/musd/):
Selectors (ui/selectors/musd/):
Confirmation UI (ui/pages/confirmations/):
Also adds mUSD education and icon image assets.
Changelog
CHANGELOG entry: Adds foundational layer for the mUSD stablecoin conversion feature
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/MUSD-335
Fixes: https://consensyssoftware.atlassian.net/browse/MUSD-326
Fixes: https://consensyssoftware.atlassian.net/browse/MUSD-290
Manual testing steps
Screenshots/Recordings
Before
n/a
After
n/a
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches persisted background state, transaction creation/replacement logic, and introduces new network calls (token-cache/geolocation/relay endpoints), which can affect conversion flow correctness and telemetry but is largely additive and behind feature gating.
Overview
Introduces Phase 1 plumbing for mUSD conversion across background + UI. Adds persisted app-state for education seen and per-token CTA dismissals (with new controller mutators exposed via
metamask-controller), expands MetaMetrics with mUSD conversion event names/category, and updates fixtures/state-log snapshots accordingly.Builds out core mUSD client-side utilities and hooks: richer
ui/components/app/musd/constants(chain/asset IDs, relay/geolocation endpoints, helpers), new analytics helpers inmusd-events, allowlist/blocklist + geo-block validation utilities, and transaction helpers to create/replaceTransactionType.musdConversionERC-20 transfer txs (including same-chain enforcement and approval rejection on replacement).Adds initial hooks to orchestrate the conversion flow (
useMusdConversionwith geo gating, education routing, and duplicate-prevention), derive buy availability via ramp token-cache API (useCanBuyMusdwith caching/fail-closed behavior), compute mUSD balances across legacy/multichain assets, show output-amount tag formusdConversionconfirmations (useCustomAmount), and monitor conversion lifecycle for in-progress/success/failure toasts (useMusdConversionToastStatus). Also classifiesmusdConversiontransactions assendfor transaction list grouping, and broadens CODEOWNERS to cover**/musd/**plus the deep link route file.Written by Cursor Bugbot for commit d249ca1. This will update automatically on new commits. Configure here.