Skip to content

feat(identity): add ramps order Backup & Sync controls - #46044

Draft
georgeweiler wants to merge 1 commit into
feat/ramps-order-sync-plumbingfrom
feat/ramps-order-sync-settings
Draft

feat(identity): add ramps order Backup & Sync controls#46044
georgeweiler wants to merge 1 commit into
feat/ramps-order-sync-plumbingfrom
feat/ramps-order-sync-settings

Conversation

@georgeweiler

@georgeweiler georgeweiler commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Description

Part 3 of 5 replacing #44367. Stacked on #46043.

Adds Buy & sell orders to the Backup & Sync settings, including selectors, parent-toggle cascading, persisted state typing, and identity test fixtures. When the wallet unlocks, the identity provider requests a ramps order sync only when onboarding, authentication, external-services, Backup & Sync, and ramps-sync gates all pass.

This slice also adopts the final Profile Sync preview from MetaMask/core#9474. That preview replaces Snap keyring access with KeyringController:withKeyringV2Unsafe, so the identity messengers and generated LavaMoat policies are updated atomically.

Primary ownership is @MetaMask/accounts-engineers; the small E2E fixture/page-object changes additionally involve @MetaMask/qa and @MetaMask/extension-platform.

Changelog

CHANGELOG entry: Added Backup & Sync support for buy and sell order history

Related issues

Depends on #46043 and MetaMask/core#9474.
Replaces part of #44367.

Manual testing steps

  1. Build and load the extension, then complete onboarding and unlock the wallet.
  2. Open Settings → Security & privacy → Backup & Sync and enable Backup & Sync.
  3. Verify Buy & sell orders appears as an enabled sub-toggle.
  4. Disable Buy & sell orders, unlock again, and confirm ramps order syncing does not run.
  5. Re-enable it, upload a ramps order from another MetaMask client for the same SRP, unlock, and confirm the order reaches RampsController.orders.
  6. Disable every Backup & Sync sub-feature and confirm the parent Backup & Sync toggle turns off.

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.

Stack: #46042#46043#46044#46045#46046

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
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.

@metamask-ci

metamask-ci Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

✨ Files requiring CODEOWNER review ✨

🔑 @MetaMask/accounts-engineers (16 files, +328 -11)
  • 📁 app/
    • 📁 scripts/
      • 📁 messenger-client-init/
        • 📁 messengers/
          • 📁 identity/
            • 📄 authentication-controller-messenger.test.ts +8 -0
            • 📄 authentication-controller-messenger.ts +4 -4
            • 📄 user-storage-controller-messenger.test.ts +14 -0
            • 📄 user-storage-controller-messenger.ts +1 -2
  • 📁 test/
    • 📁 e2e/
      • 📁 helpers/
        • 📁 identity/
          • 📁 user-storage/
            • 📄 userStorageMockttpController.ts +5 -0
      • 📁 tests/
        • 📁 identity/
          • 📄 mocks.ts +5 -0
  • 📁 ui/
    • 📁 components/
      • 📁 app/
        • 📁 identity/
          • 📁 backup-and-sync-features-toggles/
            • 📄 backup-and-sync-features-toggles.test.tsx +35 -4
            • 📄 backup-and-sync-features-toggles.tsx +19 -1
          • 📁 backup-and-sync-toggle/
            • 📄 backup-and-sync-toggle.test.tsx +16 -0
            • 📄 backup-and-sync-toggle.tsx +16 -0
    • 📁 contexts/
      • 📁 identity/
        • 📄 index.test.tsx +24 -0
        • 📄 index.tsx +9 -0
    • 📁 hooks/
      • 📁 identity/
        • 📁 useRampsOrderSyncing/
          • 📄 useRampsOrderSyncing.test.tsx +95 -0
          • 📄 useRampsOrderSyncing.ts +48 -0
    • 📁 selectors/
      • 📁 identity/
        • 📄 backup-and-sync.test.ts +16 -0
        • 📄 backup-and-sync.ts +13 -0

👨‍🔧 @MetaMask/extension-platform (1 files, +2 -1)
  • 📁 test/
    • 📁 e2e/
      • 📁 fixtures/
        • 📄 onboarding-fixture.json +2 -1

📜 @MetaMask/policy-reviewers (8 files, +160 -24)
  • 📁 lavamoat/
    • 📁 webpack/
      • 📁 mv2/
        • 📁 beta/
          • 📄 policy.json +20 -3
        • 📁 experimental/
          • 📄 policy.json +20 -3
        • 📁 flask/
          • 📄 policy.json +20 -3
        • 📁 main/
          • 📄 policy.json +20 -3
      • 📁 mv3/
        • 📁 beta/
          • 📄 policy.json +20 -3
        • 📁 experimental/
          • 📄 policy.json +20 -3
        • 📁 flask/
          • 📄 policy.json +20 -3
        • 📁 main/
          • 📄 policy.json +20 -3

Tip

Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers.


🧪 @MetaMask/qa (2 files, +11 -1)
  • 📁 test/
    • 📁 e2e/
      • 📁 fixtures/
        • 📄 onboarding-fixture.json +2 -1
      • 📁 page-objects/
        • 📁 pages/
          • 📁 settings/
            • 📄 backup-and-sync-settings.ts +9 -0

@metamask-ci

metamask-ci Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor
Builds ready [bab241c]
⚡ Performance Benchmarks (Total: 🟢 15 pass · 🟡 5 warn · 🔴 4 fail)

Baseline (latest main): 171ed20 | Date: 7/28/2026 | Pipeline: 33829740103 | Baseline logs

Metricschrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🔴 load_new_account(p95) [CI log]🔴 load_new_account(p95) [CI log]
onboardingNewWallet
[Sentry log · main/release]
🔴 [CI log]🔴 [CI log]

Regressions (🔴 4 failures)

Interaction Benchmarks · Samples: 5 🔴 2
Benchmarkchrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🔴 [CI log]
🔴 load_new_account
🔴 [CI log]
🔴 load_new_account
confirmTx
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
bridgeUserActions
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • loadNewAccount/load_new_account: +191%
  • loadNewAccount/total: +191%
  • confirmTx/longTaskTotalDuration: -20%
  • confirmTx/longTaskMaxDuration: +19%
  • confirmTx/tbt: -36%
  • confirmTx/inp: -17%
  • bridgeUserActions/bridge_load_page: +13%
  • bridgeUserActions/longTaskCount: +11%
  • bridgeUserActions/longTaskTotalDuration: +27%
  • bridgeUserActions/longTaskMaxDuration: +19%
  • bridgeUserActions/tbt: +64%
  • loadNewAccount/load_new_account: +193%
  • loadNewAccount/total: +193%
  • loadNewAccount/inp: -17%
  • loadNewAccount/fcp: -54%
  • loadNewAccount/lcp: +1295%
  • confirmTx/longTaskCount: -100%
  • confirmTx/longTaskTotalDuration: -100%
  • confirmTx/longTaskMaxDuration: -100%
  • confirmTx/tbt: -100%
  • confirmTx/inp: -32%
  • confirmTx/fcp: -63%
  • confirmTx/lcp: +1552%
  • bridgeUserActions/bridge_load_page: +79%
  • bridgeUserActions/bridge_load_asset_picker: +116%
  • bridgeUserActions/bridge_search_token: -11%
  • bridgeUserActions/longTaskCount: -100%
  • bridgeUserActions/longTaskTotalDuration: -100%
  • bridgeUserActions/longTaskMaxDuration: -100%
  • bridgeUserActions/tbt: -100%
  • bridgeUserActions/total: +15%
  • bridgeUserActions/inp: -15%
  • bridgeUserActions/fcp: -41%
  • bridgeUserActions/lcp: +1202%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 confirmTx/LCP: p75 2.8s
Startup Benchmarks · Samples: 100
Benchmarkchrome-webpackfirefox-webpack
startupStandardHome
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
startupPowerUserHome
[Sentry log · main/release]
🟡 [CI log]

📈 Results compared to the previous 5 runs on main

  • startupStandardHome/firstReactRender: -99%
  • startupStandardHome/initialActions: -33%
  • startupStandardHome/domInteractive: -21%
  • startupStandardHome/firstReactRender: -98%
  • startupStandardHome/initialActions: -50%
  • startupStandardHome/setupStore: +34%
  • startupStandardHome/fcp: -11%
  • startupPowerUserHome/domInteractive: -48%
  • startupPowerUserHome/backgroundConnect: -20%
  • startupPowerUserHome/firstReactRender: -99%
  • startupPowerUserHome/initialActions: -44%
  • startupPowerUserHome/setupStore: -75%
  • startupPowerUserHome/numNetworkReqs: -52%
  • startupPowerUserHome/inp: +19%
  • startupPowerUserHome/fcp: -44%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 startupPowerUserHome/INP: p75 224ms
  • 🟡 startupPowerUserHome/LCP: p75 2.9s
User Journey Benchmarks · Samples: 5 · mock API 🔴 2
Benchmarkchrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
onboardingNewWallet
[Sentry log · main/release]
🔴 [CI log]
🔴 total
🔴 [CI log]
🔴 total
assetDetails
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
solanaAssetDetails
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
importSrpHome
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
sendTransactions
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
swap
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]

📈 Results compared to the previous 5 runs on main

  • onboardingImportWallet/srpButtonToSrpForm: +29%
  • onboardingImportWallet/confirmSrpToPwForm: +35%
  • onboardingImportWallet/pwFormToMetricsScreen: +18%
  • onboardingImportWallet/metricsToWalletReadyScreen: +23%
  • onboardingImportWallet/doneButtonToHomeScreen: -92%
  • onboardingImportWallet/openAccountMenuToAccountListLoaded: -94%
  • onboardingImportWallet/longTaskCount: -100%
  • onboardingImportWallet/longTaskTotalDuration: -100%
  • onboardingImportWallet/longTaskMaxDuration: -100%
  • onboardingImportWallet/tbt: -100%
  • onboardingImportWallet/total: -91%
  • onboardingNewWallet/agreeButtonToOnboardingSuccess: -12%
  • onboardingNewWallet/doneButtonToAssetList: -15%
  • onboardingNewWallet/longTaskCount: -100%
  • onboardingNewWallet/longTaskTotalDuration: -100%
  • onboardingNewWallet/longTaskMaxDuration: -100%
  • onboardingNewWallet/tbt: -100%
  • onboardingNewWallet/total: -15%
  • solanaAssetDetails/assetClickToPriceChart: +293%
  • solanaAssetDetails/longTaskCount: -100%
  • solanaAssetDetails/longTaskTotalDuration: -100%
  • solanaAssetDetails/longTaskMaxDuration: -100%
  • solanaAssetDetails/tbt: -100%
  • solanaAssetDetails/total: +293%
  • solanaAssetDetails/fcp: +12%
  • importSrpHome/loginToHomeScreen: -22%
  • importSrpHome/longTaskCount: -37%
  • importSrpHome/longTaskTotalDuration: -58%
  • importSrpHome/longTaskMaxDuration: -56%
  • importSrpHome/tbt: -68%
  • importSrpHome/inp: -61%
  • importSrpHome/cls: +443%
  • sendTransactions/openSendPageFromHome: -21%
  • sendTransactions/reviewTransactionToConfirmationPage: -98%
  • sendTransactions/longTaskCount: -100%
  • sendTransactions/longTaskTotalDuration: -100%
  • sendTransactions/longTaskMaxDuration: -100%
  • sendTransactions/tbt: -100%
  • sendTransactions/total: -95%
  • sendTransactions/inp: -48%
  • sendTransactions/lcp: -61%
  • sendTransactions/cls: +171%
  • swap/openSwapPageFromHome: +804%
  • swap/fetchAndDisplaySwapQuotes: +85%
  • swap/longTaskCount: -100%
  • swap/longTaskTotalDuration: -100%
  • swap/longTaskMaxDuration: -100%
  • swap/tbt: -100%
  • swap/total: +100%
  • swap/inp: -15%
  • swap/lcp: -68%
  • swap/cls: -92%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 assetDetails/FCP: p75 1.8s
  • 🟡 sendTransactions/FCP: p75 2.0s
  • 🟡 swap/FCP: p75 2.0s
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-webpack
dappPageLoad
[Sentry log · main/release]
🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • dappPageLoad/pageLoadTime: -58%
  • dappPageLoad/firstPaint: -46%
  • dappPageLoad/firstContentfulPaint: -46%
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 31.39 KiB (0.21%)
  • ui: 15.94 KiB (0.08%)
  • common: 0 Bytes (0%)
  • other: 0 Bytes (0%)
  • contentScripts: 1.86 KiB (0.1%)
  • zip: 13.36 KiB (0.06%)

Co-authored-by: Cursor <cursoragent@cursor.com>
@sonarqubecloud

sonarqubecloud Bot commented Sep 9, 2026

Copy link
Copy Markdown

@metamask-ci

metamask-ci Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor
Builds ready [fbc4e37]
⚡ Performance Benchmarks (Total: 🟢 14 pass · 🟡 8 warn · 🔴 3 fail)

Baseline (latest main): 171ed20 | Date: 7/28/2026 | Pipeline: 34334214709 | Baseline logs

Metricschrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🔴 load_new_account(p95) [CI log]🔴 load_new_account(p95) [CI log]
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🔴 [CI log]

Regressions (🔴 3 failures)

Interaction Benchmarks · Samples: 5 🔴 2
Benchmarkchrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🔴 [CI log]
🔴 load_new_account
🔴 [CI log]
🔴 load_new_account
confirmTx
[Sentry log · main/release]
🟡 [CI log]🟢 [CI log]
bridgeUserActions
[Sentry log · main/release]
🟡 [CI log]🟡 [CI log]

📈 Results compared to the previous 5 runs on main

  • loadNewAccount/load_new_account: +190%
  • loadNewAccount/total: +190%
  • confirmTx/longTaskTotalDuration: -15%
  • confirmTx/longTaskMaxDuration: +29%
  • confirmTx/tbt: -26%
  • bridgeUserActions/bridge_load_page: +45%
  • bridgeUserActions/bridge_load_asset_picker: +15%
  • bridgeUserActions/longTaskCount: +67%
  • bridgeUserActions/longTaskTotalDuration: +60%
  • bridgeUserActions/longTaskMaxDuration: +27%
  • bridgeUserActions/tbt: +84%
  • loadNewAccount/load_new_account: +197%
  • loadNewAccount/total: +197%
  • loadNewAccount/fcp: +16%
  • loadNewAccount/lcp: +1244%
  • confirmTx/longTaskCount: -100%
  • confirmTx/longTaskTotalDuration: -100%
  • confirmTx/longTaskMaxDuration: -100%
  • confirmTx/tbt: -100%
  • confirmTx/inp: -17%
  • confirmTx/fcp: -37%
  • confirmTx/lcp: +1282%
  • bridgeUserActions/bridge_load_page: +82%
  • bridgeUserActions/bridge_load_asset_picker: +218%
  • bridgeUserActions/longTaskCount: -100%
  • bridgeUserActions/longTaskTotalDuration: -100%
  • bridgeUserActions/longTaskMaxDuration: -100%
  • bridgeUserActions/tbt: -100%
  • bridgeUserActions/total: +43%
  • bridgeUserActions/inp: +15%
  • bridgeUserActions/fcp: +13%
  • bridgeUserActions/lcp: +1206%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 loadNewAccount/FCP: p75 1.8s
  • 🟡 confirmTx/FCP: p75 1.8s
  • 🟡 bridgeUserActions/FCP: p75 1.8s
  • 🟡 loadNewAccount/FCP: p75 2.0s
  • 🟡 bridgeUserActions/FCP: p75 2.0s
Startup Benchmarks · Samples: 100
Benchmarkchrome-webpackfirefox-webpack
startupStandardHome
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
startupPowerUserHome
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]

📈 Results compared to the previous 5 runs on main

  • startupStandardHome/firstReactRender: -99%
  • startupStandardHome/initialActions: -33%
  • startupStandardHome/firstReactRender: -98%
  • startupStandardHome/initialActions: -50%
  • startupStandardHome/setupStore: +29%
  • startupPowerUserHome/load: +12%
  • startupPowerUserHome/domContentLoaded: +12%
  • startupPowerUserHome/domInteractive: -34%
  • startupPowerUserHome/backgroundConnect: -10%
  • startupPowerUserHome/firstReactRender: -99%
  • startupPowerUserHome/initialActions: -44%
  • startupPowerUserHome/loadScripts: +11%
  • startupPowerUserHome/setupStore: -70%
  • startupPowerUserHome/numNetworkReqs: -53%
  • startupPowerUserHome/fcp: -32%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 startupPowerUserHome/LCP: p75 3.0s
User Journey Benchmarks · Samples: 5 · mock API 🔴 1
Benchmarkchrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🔴 [CI log]
🔴 total
assetDetails
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
solanaAssetDetails
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
importSrpHome
[Sentry log · main/release]
🟡 [CI log]🟡 [CI log]
sendTransactions
[Sentry log · main/release]
🟡 [CI log]🟢 [CI log]
swap
[Sentry log · main/release]
🟡 [CI log]🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • onboardingImportWallet/srpButtonToSrpForm: +48%
  • onboardingImportWallet/confirmSrpToPwForm: +49%
  • onboardingImportWallet/pwFormToMetricsScreen: +41%
  • onboardingImportWallet/metricsToWalletReadyScreen: +39%
  • onboardingImportWallet/doneButtonToHomeScreen: -92%
  • onboardingImportWallet/openAccountMenuToAccountListLoaded: -94%
  • onboardingImportWallet/longTaskCount: -100%
  • onboardingImportWallet/longTaskTotalDuration: -100%
  • onboardingImportWallet/longTaskMaxDuration: -100%
  • onboardingImportWallet/tbt: -100%
  • onboardingImportWallet/total: -91%
  • onboardingNewWallet/srpButtonToPwForm: +27%
  • onboardingNewWallet/skipBackupToMetricsScreen: +16%
  • onboardingNewWallet/agreeButtonToOnboardingSuccess: +11%
  • onboardingNewWallet/doneButtonToAssetList: -81%
  • onboardingNewWallet/longTaskCount: -100%
  • onboardingNewWallet/longTaskTotalDuration: -100%
  • onboardingNewWallet/longTaskMaxDuration: -100%
  • onboardingNewWallet/tbt: -100%
  • onboardingNewWallet/total: -77%
  • solanaAssetDetails/assetClickToPriceChart: +254%
  • solanaAssetDetails/longTaskCount: -100%
  • solanaAssetDetails/longTaskTotalDuration: -100%
  • solanaAssetDetails/longTaskMaxDuration: -100%
  • solanaAssetDetails/tbt: -100%
  • solanaAssetDetails/total: +254%
  • importSrpHome/loginToHomeScreen: -20%
  • importSrpHome/homeAfterImportWithNewWallet: -14%
  • importSrpHome/longTaskCount: -37%
  • importSrpHome/longTaskTotalDuration: -48%
  • importSrpHome/longTaskMaxDuration: -52%
  • importSrpHome/tbt: -60%
  • importSrpHome/total: -14%
  • importSrpHome/inp: -64%
  • importSrpHome/cls: +484%
  • sendTransactions/openSendPageFromHome: +29%
  • sendTransactions/selectTokenToSendFormLoaded: +171%
  • sendTransactions/reviewTransactionToConfirmationPage: -98%
  • sendTransactions/longTaskCount: -100%
  • sendTransactions/longTaskTotalDuration: -100%
  • sendTransactions/longTaskMaxDuration: -100%
  • sendTransactions/tbt: -100%
  • sendTransactions/total: -91%
  • sendTransactions/inp: -15%
  • sendTransactions/fcp: +14%
  • sendTransactions/lcp: -63%
  • sendTransactions/cls: +171%
  • swap/openSwapPageFromHome: +852%
  • swap/fetchAndDisplaySwapQuotes: +87%
  • swap/longTaskCount: -100%
  • swap/longTaskTotalDuration: -100%
  • swap/longTaskMaxDuration: -100%
  • swap/tbt: -100%
  • swap/total: +103%
  • swap/lcp: -70%
  • swap/cls: -92%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 importSrpHome/FCP: p75 1.8s
  • 🟡 sendTransactions/FCP: p75 1.9s
  • 🟡 swap/FCP: p75 1.8s
  • 🟡 importSrpHome/FCP: p75 1.9s
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-webpack
dappPageLoad
[Sentry log · main/release]
🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • dappPageLoad/pageLoadTime: -57%
  • dappPageLoad/firstPaint: -41%
  • dappPageLoad/firstContentfulPaint: -41%
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 30.9 KiB (0.21%)
  • ui: 18.4 KiB (0.1%)
  • common: 0 Bytes (0%)
  • other: 0 Bytes (0%)
  • contentScripts: 1.9 KiB (0.1%)
  • zip: 13.81 KiB (0.06%)

@georgeweiler
georgeweiler added this pull request to stack #46179 September 9, 2026 10:03
pull Bot pushed a commit to Reality2byte/metamask-extension that referenced this pull request Sep 9, 2026
## **Description**

Part 1 of 5 replacing MetaMask#44367.

Local development sometimes needs DEV Profile Sync (for example staging
ramps). Identity JWTs are shared by many `getBearerToken` consumers, so
flipping every `yarn start` to DEV by default would mint DEV tokens
against services that still talk to PRD.

This follows the Mobile pattern:

1. Opt in with `MM_DEV_API_ENV=dev` in `.metamaskrc` (default remains
prod). Restart `yarn start` after changing it.
2. A single source (`devApiEnv` / `loadAuthenticationConfig`) is used by
AuthenticationController, User Storage, Profile Metrics, Config
Registry, and Authenticated User Storage so those backends agree.
3. Settings → Debug → Backup and sync shows the current identity env and
can clear the persisted auth session via `performSignOut` after you flip
the flag.

`FORCE_AUTH_MATCH_BUILD` is unchanged for beta/UAT. Notifications,
shield, money-account, bridge, and perps stay on PRD in this PR.

## **Changelog**

CHANGELOG entry: null

## **Related issues**

Replaces part of MetaMask#44367.

## **Manual testing steps**

1. Leave `MM_DEV_API_ENV` unset and confirm Profile Sync still uses
production (`oidc.api.cx.metamask.io`).
2. Set `MM_DEV_API_ENV=dev` in `.metamaskrc` and restart `yarn start`.
3. Open Settings → Debug → Backup and sync, confirm the identity env
shows `dev`, and click Clear auth session.
4. Unlock / sign in to Backup & Sync and confirm Network requests go to
`oidc.dev-api.cx.metamask.io`.
5. Unset the flag, restart, clear the session again, and confirm
production identity is restored.

<!--
## **Screenshots/Recordings**
### **Before**
### **After**
-->

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **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.

---

Stack: MetaMask#46042MetaMask#46043MetaMask#46044MetaMask#46045MetaMask#46046

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes authentication environment selection and JWT/backend alignment
for Backup & Sync and related identity services; misconfiguration could
break sign-in until the session is cleared.
> 
> **Overview**
> Adds an **opt-in local dev switch** (`MM_DEV_API_ENV=dev` in
`.metamaskrc`) so Profile Sync identity stays on **prod by default**
during `yarn start`, avoiding DEV JWTs against services that still use
PRD.
> 
> **`devApiEnv()`** and updated **`loadAuthenticationConfig()`**
centralize env selection: DEV only when development build + explicit
flag; **`FORCE_AUTH_MATCH_BUILD`** still maps beta/uat to UAT; non-local
builds ignore the flag. **Authenticated User Storage** init now maps
**`Env.DEV`** → `dev` so it stays aligned with auth JWT env.
> 
> **Settings → Debug → Backup and sync** shows the active identity env
and adds **Clear auth session** (`performSignOut`) for after flipping
the flag. Docs/build defaults (`builds.yml`, `.metamaskrc.dist`) and
unit tests cover the new behavior.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
e68779f. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant