Skip to content

feat: init AUS watchlist integration#31734

Merged
gambinish merged 11 commits into
mainfrom
perps/watchlist-integrate-aus
Jun 29, 2026
Merged

feat: init AUS watchlist integration#31734
gambinish merged 11 commits into
mainfrom
perps/watchlist-integrate-aus

Conversation

@gambinish

@gambinish gambinish commented Jun 15, 2026

Copy link
Copy Markdown
Member

Description

Integrates the Perps watchlist with the Authenticated User Storage (AUS) service, so a user's watched markets are persisted to remote storage and synced across devices when they are authenticated.

Changes

@metamask/perps-controller bump to ^9.0.0 (package.json, yarn.lock)

  • The new controller version implements optimistic local updates and AUS sync inside toggleWatchlistMarket. On add/remove, it writes the updated watchlist into the perps.watchlistMarkets field of NotificationPreferences via AuthenticatedUserStorageService:putNotificationPreferences. It gracefully degrades to local-only when the user is unauthenticated or the preferences blob has not yet been initialised.

Messenger wiring (perps-controller-messenger/index.ts)

  • Delegates AuthenticatedUserStorageService:getNotificationPreferences and AuthenticatedUserStorageService:putNotificationPreferences actions to the PerpsControllerMessenger so the controller can call them through the root messenger.

usePerpsWatchlistActions hook cleanup (usePerpsWatchlistActions.ts)

  • Removed the TODO scaffolding comments for optimistic UI and User Storage API seams — those are now handled inside the controller.
  • toggleWatchlistMarket calls are now properly await-ed so errors surface and the error toast works correctly.

Integration tests (perps-controller/index.test.ts, perps-controller-messenger/index.test.ts)

  • New integration test suite (PerpsController watchlist ↔ AuthenticatedUserStorageService) covering: add writes the symbol to AUS, remove deletes it, list merges correctly with existing remote symbols, rollback on failed write, and graceful no-op when the preferences blob is null.
  • Messenger test confirms the two new AUS actions are delegated.

Changelog

CHANGELOG entry: Integrate AUS Perps Watchlist

Related issues

Fixes: TAT-2663

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

Screen.Recording.2026-06-15.at.1.23.59.PM.mov

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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

Medium Risk
Touches cross-device user preference persistence via Authenticated User Storage; risk is mitigated by controller-owned rollback, skipped writes when prefs are uninitialized, and new integration coverage.

Overview
Wires Perps watchlist persistence to Authenticated User Storage (AUS) by adopting @metamask/perps-controller ^9.0.0 (via package.json resolution). Watchlist add/remove now runs optimistic local updates and syncs perps.watchlistMarkets through NotificationPreferences, with local-only behavior when prefs are missing or the user is unauthenticated.

usePerpsWatchlistActions drops the old optimistic/AUS TODO scaffolding and documents that PerpsController.toggleWatchlistMarket owns that behavior. Analytics for favorite/unfavorite only fire after confirming the symbol is actually on or off the list post-toggle (so failed adds or rollbacks do not emit misleading events).

Adds integration tests on the real controller: AUS read/write on toggle, merge with remote symbols, rollback when putNotificationPreferences fails, and skipping remote writes when getNotificationPreferences is null. Messenger test copy is updated to describe AUS notification-preference delegation.

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

@github-actions github-actions Bot added the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label Jun 15, 2026
@metamask-ci metamask-ci Bot added the team-perps Perps team label Jun 15, 2026
@metamask-ci

metamask-ci Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

PR template — items to address before "Ready for review"

Warnings — informational, address before merging:

  • Manual testing steps still contain template content (the Gherkin example title or a [...] placeholder). Replace with real steps, or write N/A — <reason>.

See docs/readme/ready-for-review.md for the full Definition of Ready for Review.

Comment thread app/core/Engine/messengers/perps-controller-messenger/index.ts Outdated
@gambinish gambinish added the DO-NOT-MERGE Pull requests that should not be merged label Jun 22, 2026
@gambinish

gambinish commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

Adding do-not-merge label until the latest perps-controller npm package gets released

@gambinish gambinish removed the DO-NOT-MERGE Pull requests that should not be merged label Jun 24, 2026
@gambinish gambinish marked this pull request as ready for review June 24, 2026 17:28
@gambinish gambinish requested a review from a team as a code owner June 24, 2026 17:28
@github-actions github-actions Bot added size-M risk:high AI analysis: high risk and removed size-S labels Jun 24, 2026
Comment thread app/components/UI/Perps/hooks/usePerpsWatchlistActions.ts
@gambinish

Copy link
Copy Markdown
Member Author

This PR will need to go in after #32343 which integrates the terminal API

@gambinish

Copy link
Copy Markdown
Member Author

@metamaskbot publish-preview

@gambinish gambinish removed the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label Jun 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeConfirmations, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeSwap, SmokeStake, SmokeWalletPlatform, SmokeMoney, SmokePerps, SmokeMultiChainAPI, SmokePredictions, SmokeSeedlessOnboarding, SmokeBrowser, SmokeSnaps
  • Selected Performance tags: @PerformancePreps
  • Risk Level: high
  • AI Confidence: 100%
click to see 🤖 AI reasoning details

E2E Test Selection:
Hard rule (controller-version-update): @MetaMask controller package version updated in package.json: @metamask/perps-controller. Running all tests.

Performance Test Selection:
The package.json resolution bumps @metamask/perps-controller to ^9.0.0 (new major version), which introduces optimistic UI and AUS sync in the controller. This could affect perps market loading, position management, and the add funds flow performance. The @PerformancePreps tag covers perpetuals trading performance including perps market loading, position management, add funds flow, and order execution — all of which could be impacted by the controller upgrade.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@gambinish gambinish enabled auto-merge June 29, 2026 15:06
@gambinish gambinish disabled auto-merge June 29, 2026 15:06
@gambinish gambinish enabled auto-merge June 29, 2026 15:06
@gambinish gambinish added this pull request to the merge queue Jun 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚡ Performance Test Results

ℹ️ Performance test results are currently non-blocking and will not block this PR.

All tests passed · 1 tests · 1 device

📱 Devices tested (1)

Android: Google Pixel 8 Pro (v14.0)

✅ Passed Tests (1)
Test Platform Device Duration Team Recording
Perps add funds Android Google Pixel 8 Pro (v14.0) 9.39s @mm-perps-engineering-team 📹 Watch

Branch: perps/watchlist-integrate-aus · Build: Normal · Commit: 6780f15 · View full run

Merged via the queue into main with commit 5216c01 Jun 29, 2026
202 of 204 checks passed
@gambinish gambinish deleted the perps/watchlist-integrate-aus branch June 29, 2026 16:14
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 29, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-8.2.0 Issue or pull request that will be included in release 8.2.0 label Jun 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-8.2.0 Issue or pull request that will be included in release 8.2.0 risk:high AI analysis: high risk size-M team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants