Skip to content

feat: sync V2 ramps orders from User Storage#44367

Open
georgeweiler wants to merge 4 commits into
mainfrom
feat/ramps-order-syncing
Open

feat: sync V2 ramps orders from User Storage#44367
georgeweiler wants to merge 4 commits into
mainfrom
feat/ramps-order-syncing

Conversation

@georgeweiler

@georgeweiler georgeweiler commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Delegates User Storage + auth actions to the ramps messenger so RampsController.syncOrdersWithUserStorage() can run.
  • Exposes syncRampsOrdersWithUserStorage on the ramps background API.
  • Pulls remote V2 orders on unlock via useRampsOrderSyncing in MetamaskIdentityProvider (same gates as account/contact sync).
  • selectIsRampsSyncingEnabled defaults to true when absent from persisted state.
  • Adds Backup & Sync Buy & sell orders sub-toggle (BACKUPANDSYNC_FEATURES.rampsSyncing), matching mobile.
  • Synced orders land in RampsController.orders / existing hooks and selectors (no dedicated orders history UI in this PR).

Depends on

Works with

QA / debugging (separate branch)

Orders home-tab demo for manual verification lives on feat/ramps-orders-qa-tab (not included here). Use that branch to inspect synced orders and trigger manual sync during cross-client testing.

Cross-client flow

  1. Mobile creates V2 order with Backup & Sync + Buy & sell orders enabled.
  2. Extension unlock with same signed-in profile → useRampsOrderSyncing runs full sync.
  3. Order is available via useRampsOrders / selectRampsOrders.
  4. Disabling Buy & sell orders on either client blocks sync.

Local testing (until core packages are published)

Copy built packages from core feat/ramps-order-syncing into extension node_modules:

yarn workspace @metamask/profile-sync-controller run build
yarn workspace @metamask/ramps-controller run build

rm -rf node_modules/@metamask/profile-sync-controller/dist node_modules/@metamask/ramps-controller/dist
cp -R ../core/packages/profile-sync-controller/dist node_modules/@metamask/profile-sync-controller/dist
cp -R ../core/packages/ramps-controller/dist node_modules/@metamask/ramps-controller/dist

Then:

  1. Complete a V2 buy on mobile (with Backup & Sync on)
  2. Unlock extension with the same SRP / signed-in profile
  3. Inspect RampsController.orders (or use feat/ramps-orders-qa-tab Orders tab)

Test plan

  • Unit tests for messenger API, useRampsOrderSyncing, identity provider, selectors
  • Backup & Sync ramps toggle unit tests
  • Manual: mobile order → extension unlock pull (verified)
  • Bump @metamask/ramps-controller + @metamask/profile-sync-controller once core Allow running CircleCI locally #9474 is published

Note

Medium Risk
Syncs ramps order data to User Storage behind the same auth and preference gates as other backup features, but depends on unpublished core work and bidirectional merge behavior in RampsController.

Overview
Adds cross-device sync for V2 ramps (buy & sell) orders through Backup and Sync User Storage, aligned with account and contact syncing.

The ramps messenger now delegates User Storage and authentication actions so RampsController.syncOrdersWithUserStorage() can run in the background; syncRampsOrdersWithUserStorage is exposed on the ramps API and UI store actions. On unlock, useRampsOrderSyncing in MetamaskIdentityProvider triggers a full sync when the user is signed in, Backup and Sync is on, external services are enabled, and onboarding is complete—same gating pattern as the other sync hooks.

Users get a new Backup and Sync sub-toggle “Buy & sell orders” (BACKUPANDSYNC_FEATURES.rampsSyncing); turning off all sub-features (including ramps) still cascades to disable the main Backup and Sync toggle. selectIsRampsSyncingEnabled defaults to true when the flag is missing from persisted state. Synced orders populate existing RampsController.orders / hooks; this PR does not add a dedicated orders history UI.

Reviewed by Cursor Bugbot for commit bd074e8. Bugbot is set up for automated code reviews on this repo. Configure here.

Wire RampsController order syncing so orders created on mobile can be
pulled into the extension on unlock, without adding ramps UI.

Co-authored-by: Cursor <cursoragent@cursor.com>
@georgeweiler georgeweiler requested a review from a team as a code owner July 11, 2026 13:23
@github-actions

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 Jul 11, 2026

Copy link
Copy Markdown
Contributor

✨ Files requiring CODEOWNER review ✨

🔑 @MetaMask/accounts-engineers (8 files, +404 -5)
  • 📁 ui/
    • 📁 components/
      • 📁 app/
        • 📁 identity/
          • 📁 backup-and-sync-features-toggles/
            • 📄 backup-and-sync-features-toggles.test.tsx +70 -4
            • 📄 backup-and-sync-features-toggles.tsx +19 -1
    • 📁 contexts/
      • 📁 identity/
        • 📄 index.test.tsx +40 -0
        • 📄 index.tsx +9 -0
    • 📁 hooks/
      • 📁 identity/
        • 📁 useRampsOrderSyncing/
          • 📄 useRampsOrderSyncing.test.tsx +167 -0
          • 📄 useRampsOrderSyncing.ts +67 -0
    • 📁 selectors/
      • 📁 identity/
        • 📄 backup-and-sync.test.ts +19 -0
        • 📄 backup-and-sync.ts +13 -0

@metamask-ci

metamask-ci Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor
Builds ready [1f54a22]
Deprecated Browserify fallback builds
⚡ Performance Benchmarks (Total: 🟢 17 pass · 🟡 0 warn · 🔴 0 fail)

Baseline (latest main): 1716549 | Date: 6/29/2026 | Pipeline: 29154220417 | Baseline logs

Interaction Benchmarks · Samples: 5
Benchmarkchrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
confirmTx
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
bridgeUserActions
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
User Journey Benchmarks · Samples: 5 · mock API

⚠️ Missing data: chrome/webpack/userJourneyAssets, chrome/webpack/userJourneyTransactions

Benchmarkchrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
importSrpHome
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
assetDetails
[Sentry log · main/release]
🟢 [CI log]
solanaAssetDetails
[Sentry log · main/release]
🟢 [CI log]
sendTransactions
[Sentry log · main/release]
🟢 [CI log]
swap
[Sentry log · main/release]
🟢 [CI log]
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-webpack
dappPageLoad
[Sentry log · main/release]
🟢 [CI log]
Bundle sizes
  • background: 14.22 MiB
  • ui: 17.06 MiB
  • common: 0 Bytes
  • other: 998.07 KiB
  • contentScripts: 1.87 MiB
  • zip: 27.03 MiB
No matching bundle-size baseline was found in the history data, so diff values are omitted.

Match mobile by exposing a Buy & sell orders sub-toggle, and include
ramps syncing in the reverse-cascade that disables the main Backup &
Sync switch when every sub-feature is off.

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

metamask-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
Builds ready [5b063e4]
Deprecated Browserify fallback builds
⚡ Performance Benchmarks (Total: 🟢 17 pass · 🟡 0 warn · 🔴 0 fail)

Baseline (latest main): 41ca3b9 | Date: 7/16/2026 | Pipeline: 29495402797 | Baseline logs

Interaction Benchmarks · Samples: 5
Benchmarkchrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
confirmTx
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
bridgeUserActions
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
User Journey Benchmarks · Samples: 5 · mock API

⚠️ Missing data: chrome/webpack/userJourneyAssets, chrome/webpack/userJourneyTransactions

Benchmarkchrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
importSrpHome
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
assetDetails
[Sentry log · main/release]
🟢 [CI log]
solanaAssetDetails
[Sentry log · main/release]
🟢 [CI log]
sendTransactions
[Sentry log · main/release]
🟢 [CI log]
swap
[Sentry log · main/release]
🟢 [CI log]
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: +15%
Bundle sizes
  • background: 14.26 MiB
  • ui: 17.15 MiB
  • common: 0 Bytes
  • other: 998.07 KiB
  • contentScripts: 1.87 MiB
  • zip: 27.12 MiB
No matching bundle-size baseline was found in the history data, so diff values are omitted.

georgeweiler and others added 2 commits July 16, 2026 10:10
Required after merging main so RampsController can read
moneyHeadlessAllProviders for quote widening alongside order sync.

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

metamask-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
Builds ready [bd074e8]
Deprecated Browserify fallback builds
⚡ Performance Benchmarks (Total: 🟢 17 pass · 🟡 0 warn · 🔴 0 fail)

Baseline (latest main): 2ba6714 | Date: 7/16/2026 | Pipeline: 29515209701 | Baseline logs

Interaction Benchmarks · Samples: 5
Benchmarkchrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
confirmTx
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
bridgeUserActions
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
User Journey Benchmarks · Samples: 5 · mock API

⚠️ Missing data: chrome/webpack/userJourneyAssets, chrome/webpack/userJourneyTransactions

Benchmarkchrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
importSrpHome
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
assetDetails
[Sentry log · main/release]
🟢 [CI log]
solanaAssetDetails
[Sentry log · main/release]
🟢 [CI log]
sendTransactions
[Sentry log · main/release]
🟢 [CI log]
swap
[Sentry log · main/release]
🟢 [CI log]
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-webpack
dappPageLoad
[Sentry log · main/release]
🟢 [CI log]
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 539 Bytes (0%)
  • ui: 1.89 KiB (0.01%)
  • common: 0 Bytes (0%)
  • other: 0 Bytes (0%)
  • contentScripts: 14 Bytes (0%)
  • zip: 589 Bytes (0%)

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