feat: AUS Perps Watchlist#9010
Conversation
|
@metamaskbot publish-previews |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
* main: (497 commits) Release/1053.0.0 (#9195) Revert @metamask/transaction-pay-controller changes not required (#9194) chore: add discovery event names (#9178) chore: deprecate CurrencyRateController (#9182) Release/1052.0.0 (#9188) fix: getQuoteUser function is broken if request is not postQuote (#9187) fix(network-controller): Remove deprecated NetworkControllerGetNetworkConfigurationByNetworkClientId type (#9185) fix(network-controller): Remove MegaETH v1 default configuration (#9183) Release/1051.0.0 (#9181) fix: MM Pay transaction with isQuoteRequired that have same source and destination chain and token (#9150) Release/1050.0.0 (#9180) fix(network-controller): Only consider failover endpoints when using Infura (#9125) feat(assets-controllers): add isDeprecated to multichain controllers (#9044) refactor(smart-transactions-controller): import AuthenticationController namespace (#9167) Release 1049.0.0 (#9177) fix(transaction-pay-controller): vault musd via sentinel (#9161) Release 1048.0.0 (#9174) chore: remove orphaned semver.sh helper (#9172) fix(rpc-service): Consider all Infura HTTP errors as service failures except 400 and 429 (#9123) chore: remove outdated migrate-tags guide (#9171) ...
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 4 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a5c5a19. Configure here.
| await this.messenger.call( | ||
| 'AuthenticatedUserStorageService:putNotificationPreferences', | ||
| nextPrefs, | ||
| ); |
There was a problem hiding this comment.
Concurrent toggles lose watchlist updates
Medium Severity
Each toggle performs its own GET-merge-PUT without coordinating with other in-flight toggles. Rapid successive calls can read the same remote snapshot and the last write wins, so an earlier optimistic change may never reach AUS even though the UI already updated.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit a5c5a19. Configure here.


Explanation
Persists
state.watchlistMarketsto AUS so the watchlist follows the user across devices and clients, rather than being device-local only.What changed
toggleWatchlistMarketnow performs an optimistic local update first (UI is instant), then syncs to AUS. If the remote write fails, local state is reverted.Integration (client PRs)
Each client needs to grant the PerpsController messenger two new allowed actions:
AuthenticatedUserStorageService:getNotificationPreferencesAuthenticatedUserStorageService:putNotificationPreferencesNo other wiring needed —
AuthenticatedUserStorageServiceis already running whereverNotificationServicesControlleris wired, andAuthenticationController:getBearerTokenwas already allowed.References
Checklist
Note
Medium Risk
Introduces cross-device preference writes via read-merge-PUT on the shared notification preferences blob and a breaking async API on
toggleWatchlistMarket; mitigations include optimistic UI with revert, silent local fallback, and broad test coverage.Overview
Perps watchlists are now synced to Authenticated User Storage (AUS) inside notification preferences, so favorites follow the signed-in user across devices instead of staying device-local only.
toggleWatchlistMarketis async (Promise<void>): it updates local state optimistically, emits favorite analytics, then read-merge-writesperps.watchlistMarketsfor the active exchange (hyperliquid/myx) and current network. Failed remote writes revert local state. Unauthenticated users, missing preference blobs, and unmapped providers (e.g.aggregated) keep local-only behavior without throwing.On
init(), a non-blocking#syncWatchlistFromRemotehydrates localwatchlistMarketsfrom AUS when remote data exists, or one-time migrates existing local lists into AUS when the blob exists but has no watchlist for that exchange. New exportresolveWatchlistExchangeKeymapsactiveProviderto the AUS schema key.Clients must allow
AuthenticatedUserStorageService:getNotificationPreferencesandputNotificationPreferenceson the Perps controller messenger. Tests cover optimistic updates, merge writes, revert on PUT failure, aggregated skip, and init hydration/migration.Reviewed by Cursor Bugbot for commit 4b926a3. Bugbot is set up for automated code reviews on this repo. Configure here.