feat: AUS Perps Watchlist#9010
Conversation
| const prefs = await this.messenger.call( | ||
| 'AuthenticatedUserStorageService:getNotificationPreferences', | ||
| ); |
There was a problem hiding this comment.
@aganglada One note on storage approach: why NotificationPreferences and not AssetsWatchlistBlob or some other purpose built storage blob like PerpsWatchlistBlob.
The AUS package actually has two separate storage endpoints:
getAssetsWatchlist/setAssetsWatchlist→/assets-watchlist— a dedicated, atomic watchlist blob ({ version: 1, assets: string[] })getNotificationPreferences/putNotificationPreferences→/preferences/notifications— a combined blob covering wallet activity, marketing, perps, and social AI settings
At first glance assets-watchlist would be the cleaner fit — or potentially even a new purpose built storage endpoint perps-watchlist, but per the ticket spec we are following the existing schema. Using a separate endpoint would arguably be cleaner because we don't need to do this read-merge-write pattern, which runs the risk of accidentally clobbering our existing notification settings.
The tradeoff to be aware of with this approach: every watchlist toggle now does a GET → merge → PUT on the entire notification preferences blob. This is the same pattern NotificationServicesController uses for wallet account updates, so it's consistent with the existing codebase — but it does mean a concurrent notification preference change and a watchlist toggle could race. That's worth keeping in mind as the perps notification work continues.
Should we consider storing this under a dedicated endpoint in @metamask/authenticated-user-storage instead?
There was a problem hiding this comment.
If we do want to have this purpose built endpoint (I think we should), the changes needed would roughly follow the pattern of asset-watchlist:
- New server endpoint in user storage API (likely a GET/PUT)
- New methods and types on
@metamask/authenticated-user-storage - Simplify this sync code in
perps-controller, which would make things much cleaner
Explanation
References
Checklist