-
-
Notifications
You must be signed in to change notification settings - Fork 269
refactor: remove KeyringController:getState dep, init() and destroy()
#7762
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
refactor: remove KeyringController:getState dep, init() and destroy()
#7762
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.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
| 'RemoteFeatureFlagController:getState', | ||
| mockRemoteFeatureFlagGetState, | ||
| ); | ||
| testRootMessenger.registerActionHandler( |
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.
Delegating action without registered handler in test
Low Severity
The PR removed the registerActionHandler call for KeyringController:getState but left 'KeyringController:getState' in the delegate actions array at line 495. This creates inconsistent test code where an action is delegated without a corresponding handler being registered. While this won't cause test failures (since the controller no longer calls this action), it's dead code that was likely an oversight during the refactor.
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.
I noticed these additional things to be removed in tests, but I also wanted to refactor the way some tests use the testRootMessenger, so I left them for another PR where I will propose a more broad refactor of root messenger usage in tests.
| } | ||
| this.messenger.subscribe('KeyringController:lock', () => | ||
| this.stopPolling(), | ||
| ); |
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.
Polling never starts if keyring already unlocked
High Severity
The removal of init() creates a scenario where polling never starts. The controller now only starts polling when KeyringController:unlock event fires, but if the keyring is already unlocked at construction time (e.g., app restart with wallet unlocked), no unlock event fires and startPolling() is never called. The old init() method checked KeyringController:getState to detect this and start polling appropriately. Without it, the controller may silently fail to fetch config data.
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.
The wallet is guaranteed to be locked on initialization, so this is not an issue
464d78b
into
feat/add-config-registry-controller
Explanation
This is a proposal for refactors of changes made in #7668. Specifically, it removes the dependency on
KeyringController:getState, and removes the now unnecessaryinit()method.destroy()is also being removed, as we usually don't manage controller disposal.Tests have been updated accordingly.
References
Checklist
Note
Removes the runtime dependency on
KeyringController:getStateand simplifies polling lifecycle management.KeyringController:unlock/KeyringController:lockin the constructor to start/stop polling;init()anddestroy()(and their handlers) are removedRemoteFeatureFlagControllerGetStateActionKeyringController:getStateusage and init/destroy cases, simplify messenger typings and delegationWritten by Cursor Bugbot for commit 8e526e9. This will update automatically on new commits. Configure here.