feat!: Use RemoteFeatureFlagController for isRpcFailoverEnabled#9013
Conversation
| describe('disableRpcFailover', () => { | ||
| describe('if the controller was initialized with isRpcFailoverEnabled = true', () => { | ||
| it('calls disableRpcFailover on only the network clients whose RPC endpoints have configured failover URLs', async () => { | ||
| const originalCreateAutoManagedNetworkClient = |
There was a problem hiding this comment.
This spy needed to be applied earlier to ensure it caught the first call to createAutoManagedNetworkClient
RemoteFeatureFlagController for isRpcFailoverEnabledRemoteFeatureFlagController for isRpcFailoverEnabled
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 5ffe1c5. Configure here.
| */ | ||
| init(): void { | ||
| const state = this.messenger.call('RemoteFeatureFlagController:getState'); | ||
| this.#updateRpcFailoverEnabled(getIsRpcFailoverEnabled(state)); |
There was a problem hiding this comment.
Init eagerly builds all clients
Medium Severity
init routes through #updateRpcFailoverEnabled, which populates the auto-managed network client registry whenever the remote failover flag is true. The old constructor only stored the boolean and deferred client creation until the network was first used, so startup can now create every network client early when the flag is on.
Reviewed by Cursor Bugbot for commit 5ffe1c5. Configure here.
There was a problem hiding this comment.
This is done at init time anyways via initializeProvider in both clients. Should not matter.
| ); | ||
|
|
||
| this.messenger.subscribe( | ||
| // eslint-disable-next-line no-restricted-syntax |
There was a problem hiding this comment.
What is the restricted syntax here? 🤔
There was a problem hiding this comment.
We have a special rule for stateChanged / stateChange. But not many controllers have exported types for it yet, so I can't really use the new format here.


Explanation
This PR enables use of the
RemoteFeatureFlagControllerto automatically determine the state ofisRpcFailoverEnabled. Thus, the constructor argument has been removed and ainitfunction has been introduced.References
https://consensyssoftware.atlassian.net/browse/WPC-1053
Checklist
Note
High Risk
Breaking API and required init/messenger setup; mis-wiring leaves failover off or stale, and failover changes affect live RPC routing for configured endpoints.
Overview
Breaking change:
NetworkControllerno longer acceptsisRpcFailoverEnabledin the constructor. RPC failover is driven byRemoteFeatureFlagControllervia thewalletFrameworkRpcFailoverEnabledflag.Consumers must wire
RemoteFeatureFlagController:getStateandRemoteFeatureFlagController:stateChangeon the network controller messenger, callinit()after construction to apply the initial flag, and drop any manualisRpcFailoverEnabledoption. The controller subscribes to remote flag updates and toggles failover through the existing#updateRpcFailoverEnabledpath (same behavior asenableRpcFailover/disableRpcFailover).Adds
@metamask/remote-feature-flag-controller,getIsRpcFailoverEnabledinselectors.ts, dependency graph/README updates, and test helpers that mock the remote flag and callinit()inwithController.Reviewed by Cursor Bugbot for commit 5ffe1c5. Bugbot is set up for automated code reviews on this repo. Configure here.