-
-
Notifications
You must be signed in to change notification settings - Fork 220
feat: use remote-feature-flag-controller for bridge flags #5708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the BridgeController and related utilities to consume feature flags via the RemoteFeatureFlagController rather than the Bridge API. Key changes include:
- Refactoring the feature flag validation and type definitions to use a unified PlatformConfig.
- Modifying the fetch function to retrieve feature flags using a messenger call instead of direct API fetch.
- Updating selectors, tests, and changelogs to align with the new feature flag structure.
Reviewed Changes
Copilot reviewed 11 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
packages/bridge-controller/src/utils/validators.ts | Updated validator to check against PlatformConfigSchema instead of legacy keys. |
packages/bridge-controller/src/utils/fetch.ts | Rewrote feature flag fetching to use the RemoteFeatureFlagController and updated config extraction. |
packages/bridge-controller/src/utils/fetch.test.ts | Modified tests to work with the new fetch signature and default config behavior. |
packages/bridge-controller/src/types.ts | Removed client-specific feature flag keys and updated type definitions. |
packages/bridge-controller/src/selectors.ts | Removed featureFlagsKey parameter and simplified state access. |
packages/bridge-controller/src/constants/bridge.ts | Updated default state configuration to use the new flattened structure. |
packages/bridge-controller/src/bridge-controller.ts | Adjusted feature flag usage and interval configuration logic. |
packages/bridge-controller/src/bridge-controller.test.ts | Updated tests to validate the new feature flag values and messenger mocks. |
packages/bridge-controller/CHANGELOG.md | Added a breaking change note regarding the new feature flag source. |
Files not reviewed (3)
- packages/bridge-controller/package.json: Language not supported
- packages/bridge-controller/tsconfig.build.json: Language not supported
- packages/bridge-controller/tsconfig.json: Language not supported
Comments suppressed due to low confidence (2)
packages/bridge-controller/src/utils/fetch.ts:46
- Remove or replace this debugging log before production deployment to avoid leaking internal state information.
console.log('HELLO remoteFeatureFlagControllerState', remoteFeatureFlagControllerState);
packages/bridge-controller/src/utils/fetch.test.ts:226
- [nitpick] Consider updating the test description to more accurately reflect that the function returns a fallback default config on error rather than throwing an exception.
it('should handle fetch error', async () => {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
69af7a1
to
f1847b2
Compare
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
…eFeatureFlagController
b225df4
to
47d1bd5
Compare
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
@@ -350,14 +336,13 @@ export enum BridgeUserAction { | |||
UPDATE_QUOTE_PARAMS = 'updateBridgeQuoteRequestParams', | |||
} | |||
export enum BridgeBackgroundAction { | |||
SET_FEATURE_FLAGS = 'setBridgeFeatureFlags', | |||
SET_CHAIN_INTERVAL_LENGTH = 'setChainIntervalLength', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do the clients need to call this handler? Or can we set the interval length within the controller as needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#setIntervalLength
used to be called inside setBridgeFeatureFlags
but since that's gone now, I just put it into its own function setChainIntervalLength
and made it public to maintain the previous behavior where it could be called by clients, on say Bridge UI init.
I do notice that we previously called #setIntervalLength
(now setChainIntervalLength
) inside updateBridgeQuoteRequestParams
. Do we need to call this from the client if it's called when we update the quote request?
@@ -60,7 +60,8 @@ export type BridgeAppState = BridgeControllerState & { | |||
gasFeeEstimates: GasFeeEstimates; | |||
} & ExchangeRateControllerState & { | |||
participateInMetaMetrics: boolean; | |||
}; | |||
} & { bridgeConfig: Json }; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use this as the expected type from clients instead? So we can just pass in the entire state of the RemoteFeatureFlagsController
} & { | |
remoteFeatureFlags: { | |
bridgeConfig: Json; | |
}; | |
}; |
}; | ||
|
||
const createFeatureFlagsSelector = createSelector_.withTypes<{ | ||
bridgeConfig: unknown; | ||
}>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment as above regarding remoteFeatureFlags controller stat
Explanation
This PR updates the
BridgeController
to consume feature flags from theRemoteFeatureFlagController
rather than the Bridge API.References
Checklist