feat(wallet): wire RemoteFeatureFlagController into default initialization#8969
Open
sirtimid wants to merge 6 commits into
Open
feat(wallet): wire RemoteFeatureFlagController into default initialization#8969sirtimid wants to merge 6 commits into
RemoteFeatureFlagController into default initialization#8969sirtimid wants to merge 6 commits into
Conversation
…ization Adds `RemoteFeatureFlagController` to the wallet's default controller ensemble, exposing per-platform constructor values through a new `instanceOptions.remoteFeatureFlagController` slot: `clientConfigApiService`, `getMetaMetricsId`, `clientVersion`, `prevClientVersion`, `fetchInterval`, and `disabled`. Each is injectable with an inert/neutral default so the controller is usable headlessly; extension and mobile inject their own values. The controller's messenger is a plain namespaced child with no delegation. `prevClientVersion` lets consumers trigger feature-flag cache invalidation when the client version changes between sessions. Closes #8794 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…feature-flag-controller # Conflicts: # packages/wallet/CHANGELOG.md
…tureFlagController Migrates the RemoteFeatureFlagController instance to the per-controller directory convention (introduced by #8953, extended by #8977): `instances/remote-feature-flag-controller/` now holds the config, the colocated test, and a `RemoteFeatureFlagControllerInstanceOptions` type in its own `types.ts`. `InstanceSpecificOptions` references that type instead of an inline shape, and `instances/index.ts` + the CODEOWNERS `## Initialization` entry use the directory form. No public exports or option shapes change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…g-controller' into sirtimid/wire-remote-feature-flag-controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
This wires
RemoteFeatureFlagControllerinto@metamask/wallet's default controller initialization, so the wallet manages remote feature flags as part of its ensemble. It exposes the controller's standard messenger surface —RemoteFeatureFlagController:getState/:stateChangeplus its method-actions (updateRemoteFeatureFlags,enable,disable,setFlagOverride,removeFlagOverride,clearAllFlagOverrides).@metamask/walletis the shared controller-integration layer formetamask-extension,metamask-mobile, andwallet-cli. The controller's constructor values that differ between those clients are therefore injectable via a newinstanceOptions.remoteFeatureFlagControllerslot rather than hardcoded, each with a platform-agnostic default so a headless consumer can construct the wallet with no options at all. Values identical everywhere are not exposed.The controller's messenger is a plain namespaced child with no delegation — the controller's own messenger type only allows its own actions/events, and both clients already construct it that way. The per-client orchestration that reads
PreferencesController/OnboardingController(extension) or a basic-functionality selector (mobile) to enable/disable the controller is not part of the controller and is not delegated here: those sources aren't wallet controllers (mobile's isn't even a controller). Clients keep that orchestration in their own glue and drive it over the shared messenger via the exposedRemoteFeatureFlagController:enable/:disableactions; the wallet only takes the initialdisabledvalue and agetMetaMetricsIdcallback as injectable options.Per-environment options
clientConfigApiServicenew ClientConfigApiService({ fetch, config: { client: Extension, distribution, environment } })new ClientConfigApiService({ fetch, config: { client: Mobile, environment, distribution } })getMetaMetricsId() => MetaMetricsController:getMetaMetricsId() => analyticsId() => ''clientVersiongetBaseSemVerVersion()getBaseSemVerVersion()'0.0.0'prevClientVersionpersistedState.AppMetadataController.currentAppVersionpersistedState.AppMetadataController.currentAppVersionundefinedfetchInterval15 * 60 * 1000__DEV__ ? 1000 : DEFAULT_FETCH_INTERVALdisabled!completedOnboarding || !useExternalServices!selectBasicFunctionalityEnabled(state)false)The dynamic enable/disable toggling (subscribing to the sources above and calling
enable/disable) stays client-side; only the initialdisabledvalue is an option here.References
Current client construction sites (live
main):Closes #8794.
Checklist
🤖 Generated with Claude Code
Note
Medium Risk
Changes how shared wallets expose remote feature flags; misconfigured clients that omit
clientConfigApiServiceget empty flags silently, and duplicate controller wiring in consumers could collide like ApprovalController.Overview
@metamask/walletnow buildsRemoteFeatureFlagControlleras part of default initialization and exposes its messenger actions (getState,updateRemoteFeatureFlags, overrides, etc.) on the shared wallet messenger.A new
instanceOptions.remoteFeatureFlagControllerslot forwards platform-specific settings (clientConfigApiService,getMetaMetricsId,clientVersion,prevClientVersion,fetchInterval,disabled) with headless-safe defaults: a no-network config service that returns no flags, empty metrics id, and0.0.0SemVer.prevClientVersionvsclientVersiondrives cache invalidation on app upgrades. Runtime enable/disable from extension/mobile preferences stays client-side via messenger actions, not wallet wiring.Adds
@metamask/remote-feature-flag-controllerdependency, initialization module + types, unit andWalletintegration tests, changelog entry, README dependency edge, and CODEOWNERS for the new init path.Reviewed by Cursor Bugbot for commit c704d42. Bugbot is set up for automated code reviews on this repo. Configure here.