core
core copied to clipboard
Convert TokenRatesController from BaseControllerV1 to BaseControllerV2
Considering that converting TokenDetectionController to BaseController v2 took longer than expected due to unforeseen changes, we want to be more conscientious about converting TokenRatesController.
Figure out all of the changes we would want to make in upgrading this controller, outline those changes here and create new tickets if appropriate.
- The
TokenRatesControllerclass can extend theStaticIntervalPollingController“mixin” type, which extends BaseControllerV2. -
StaticIntervalPollingControllerwill accept type parameters needed for BaseControllerV2 (name, state and messenger types)- We can rename
TokenRatesConfigtoTokenRatesControllerConfig - We can rename
TokenRatesStatetoTokenRatesControllerState - We should add types for actions and events needed by the
TokenRatesControllermessengers- It would be useful for external clients to have access to a
startand astopaction to toggle the polling
- It would be useful for external clients to have access to a
- We can rename
- Since we can now use the messenger, we can remove these constructor options in favour of messenger events or actions:
-
getNetworkClientById -
onPreferencesStateChange -
onTokensStateChange -
onNetworkStateChange
-
- Tests should be refactored to support the new controller version
- In addition to that, we can create a
withControllerhelper to make tests more readable and easier to be maintained
- In addition to that, we can create a