Skip to content

chore: integrate authenticated user storage package#29114

Merged
zone-live merged 22 commits into
mainfrom
TSA-369-integrate-authenticated-user-storage-packaage
Apr 23, 2026
Merged

chore: integrate authenticated user storage package#29114
zone-live merged 22 commits into
mainfrom
TSA-369-integrate-authenticated-user-storage-packaage

Conversation

@zone-live
Copy link
Copy Markdown
Contributor

@zone-live zone-live commented Apr 21, 2026

Description

Wires AuthenticatedUserStorageService into the Engine (messenger, init, types, constants) and refactors useNotificationPreferences to persist SocialAI preferences remotely.

Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-04-22.at.13.20.17.mov

Changelog

CHANGELOG entry: null

Related issues

Fixes:

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

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
Medium risk because it adds a new Engine service/messenger and changes notification-preferences persistence to remote read/merge/write with optimistic UI updates, which could impact user settings if the integration is incorrect.

Overview
Adds remote persistence for Social Leaderboard notification preferences. useNotificationPreferences is refactored from local state to an account-scoped useQuery read plus serialized read/merge/write PUTs via Engine.controllerMessenger to AuthenticatedUserStorageService, using a muted-trader opt-out list (mutedTraderProfileIds) and optimistic overlays with rollback/error handling and cache priming.

Wires AuthenticatedUserStorageService into the app runtime. Engine now initializes the service (hardcoded prod environment), adds a dedicated messenger delegating AuthenticationController:getBearerToken, and updates Engine types/constants plus DATA_SERVICES; package dependency is added.

Improves Notification Preferences UI stability and tests. The view shows a new PreferencesSkeleton while remote prefs load (avoids toggle flash), caches currency Intl.NumberFormat instances, updates selector IDs/localized title casing, and rewrites/extends tests to cover loading, muted traders, and hook-driven interactions.

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

@zone-live zone-live added the team-social-ai Social & AI team label Apr 21, 2026
@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.

@socket-security
Copy link
Copy Markdown

socket-security Bot commented Apr 21, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​metamask/​authenticated-user-storage@​1.0.07310010089100

View full report

@socket-security

This comment was marked as resolved.

@zone-live
Copy link
Copy Markdown
Contributor Author

@SocketSecurity ignore npm/@metamask/authenticated-user-storage@1.0.0.

@zone-live zone-live marked this pull request as ready for review April 21, 2026 16:12
@zone-live zone-live requested a review from a team as a code owner April 21, 2026 16:12
@github-actions github-actions Bot added the risk-medium Moderate testing recommended · Possible bug introduction risk label Apr 21, 2026
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 21, 2026
@zone-live
Copy link
Copy Markdown
Contributor Author

@SocketSecurity ignore npm/@metamask/authenticated-user-storage@1.0.0

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Integrates @metamask/authenticated-user-storage into the Engine and refactors Social Leaderboard notification preferences to persist remotely via the new service.

Changes:

  • Adds AuthenticatedUserStorageService messenger + init wiring (Engine types, constants, factories, tests).
  • Refactors useNotificationPreferences to a remote GET/PUT flow with optimistic UI overlay and serialized writes.
  • Updates Notification Preferences UI to show a preferences-loading skeleton and adjusts tests/strings accordingly.

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
yarn.lock Locks @metamask/authenticated-user-storage@^1.0.0 and dependencies.
package.json Adds @metamask/authenticated-user-storage dependency.
locales/languages/en.json Capitalizes notification preferences title string.
babel.config.tests.js Excludes new init files from env var inlining in tests.
app/core/Engine/types.ts Registers new service types/actions/events in Engine typing.
app/core/Engine/messengers/index.ts Adds messenger factory entry for the new service.
app/core/Engine/messengers/authenticated-user-storage-service-messenger.ts Creates restricted messenger delegating bearer token access.
app/core/Engine/messengers/authenticated-user-storage-service-messenger.test.ts Basic messenger creation test.
app/core/Engine/controllers/authenticated-user-storage-service-init.ts Initializes the service (environment pinned to prod).
app/core/Engine/controllers/authenticated-user-storage-service-init.test.ts Tests init and environment selection.
app/core/Engine/constants.ts Marks service as stateless/non-controller.
app/core/Engine/Engine.ts Wires service initialization and exposure on Engine.context.
app/components/Views/SocialLeaderboard/NotificationPreferencesView/hooks/useNotificationPreferences.ts Replaces local state with remote read/merge/write persistence + optimistic overlay.
app/components/Views/SocialLeaderboard/NotificationPreferencesView/hooks/useNotificationPreferences.test.ts Adds/updates tests for new remote persistence behavior.
app/components/Views/SocialLeaderboard/NotificationPreferencesView/hooks/index.ts Updates exported types to SocialAIPreference.
app/components/Views/SocialLeaderboard/NotificationPreferencesView/components/Skeletons.tsx Adds PreferencesSkeleton for preference-loading state.
app/components/Views/SocialLeaderboard/NotificationPreferencesView/NotificationPreferencesView.tsx Consumes new hook API, shows skeleton, caches currency formatter.
app/components/Views/SocialLeaderboard/NotificationPreferencesView/NotificationPreferencesView.testIds.ts Adds test id for preferences-loading skeleton.
app/components/Views/SocialLeaderboard/NotificationPreferencesView/NotificationPreferencesView.test.tsx Updates tests for new hook + skeleton behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown
Contributor

AI PR Analysis

🚫 Merge safe: false | 🟠 Risk: high

Merge decision: AI analysis did not complete — manual review required before merging.

AI analysis did not complete. Manual review recommended.

View run

@github-actions github-actions Bot added risk:high AI analysis: high risk and removed risk:medium AI analysis: medium risk labels Apr 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeWalletPlatform, SmokeNetworkAbstractions, SmokeConfirmations, SmokeAccounts
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 72%
click to see 🤖 AI reasoning details

E2E Test Selection:

Analysis

Engine Changes (Critical Files)

The PR adds a new AuthenticatedUserStorageService to the Engine:

  • Engine.ts: Adds authenticatedUserStorageServiceInit to the controller init map and messengerClientsByName extraction
  • constants.ts: Adds AuthenticatedUserStorageService to STATELESS_NON_CONTROLLER_NAMES (stateless, no Redux sync needed)
  • types.ts: Adds type definitions for the new service
  • messengers/index.ts: Registers new messenger factory
  • messengers/authenticated-user-storage-service-messenger.ts: New messenger delegating AuthenticationController:getBearerToken

Risk Assessment: These are purely additive changes. No existing controllers are modified, no initialization order changes, no breaking messenger changes. The new service is Phase 6 (feature-level), not Phase 2 (critical). However, since Engine.ts is modified, there's a risk that the new package (@metamask/authenticated-user-storage) could cause initialization failures that would break all features.

Feature Changes (SocialLeaderboard)

  • useNotificationPreferences hook refactored from local state to AuthenticatedUserStorageService persistence
  • Added PreferencesSkeleton loading state
  • Changed notification semantics (opt-in → opt-out)
  • data-services.ts updated to include the new service in ReactQuery

The SocialLeaderboard/NotificationPreferences feature is part of the Trending tab, which is covered by SmokeWalletPlatform.

package.json

New @metamask/authenticated-user-storage: ^1.0.0 dependency added. This is a new package that could potentially affect app startup if it has issues.

Tag Selection Rationale

  1. SmokeWalletPlatform: The SocialLeaderboard/NotificationPreferences feature is part of the Trending tab. Also covers wallet lifecycle and general platform health to verify Engine initialization still works.
  2. SmokeNetworkAbstractions: Covers notification settings flows (explicitly mentioned in tag description). Also validates Engine initialization for network-dependent features.
  3. SmokeConfirmations: Engine initialization validation - if the new service causes Engine startup issues, transaction confirmations would fail. Important smoke test for Engine health.
  4. SmokeAccounts: The new service uses AuthenticationController:getBearerToken which is tied to authentication/account state. Account tests verify the auth chain still works.

No performance tests needed - the changes are additive service registration and a UI loading skeleton, not performance-critical paths.

Performance Test Selection:
No performance tests needed. The changes are: (1) additive Engine service registration (stateless, no Redux sync), (2) UI loading skeleton for notification preferences, and (3) hook refactoring from local state to remote storage. None of these changes affect critical performance paths like account list rendering, app launch, login, swaps, or asset loading. The new service is a stateless helper that only activates when the NotificationPreferences screen is opened.

View GitHub Actions results

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 a17c632. Configure here.

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
12 value mismatches detected (expected — fixture represents an existing user).
View details

@zone-live zone-live added this pull request to the merge queue Apr 23, 2026
Merged via the queue into main with commit a20763e Apr 23, 2026
114 of 116 checks passed
@zone-live zone-live deleted the TSA-369-integrate-authenticated-user-storage-packaage branch April 23, 2026 10:15
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 23, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.75.0 Issue or pull request that will be included in release 7.75.0 label Apr 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.75.0 Issue or pull request that will be included in release 7.75.0 risk:high AI analysis: high risk risk-medium Moderate testing recommended · Possible bug introduction risk size-XL team-social-ai Social & AI team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants