core icon indicating copy to clipboard operation
core copied to clipboard

Convert TokenRatesController from BaseControllerV1 to BaseControllerV2

Open desi opened this issue 1 year ago • 1 comments

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.

desi avatar Mar 18 '24 19:03 desi

  • The TokenRatesController class can extend the StaticIntervalPollingController “mixin” type, which extends BaseControllerV2.
  • StaticIntervalPollingController will accept type parameters needed for BaseControllerV2 (name, state and messenger types)
    • We can rename TokenRatesConfig to TokenRatesControllerConfig
    • We can rename TokenRatesState to TokenRatesControllerState
    • We should add types for actions and events needed by the TokenRatesController messengers
      • It would be useful for external clients to have access to a start and a stop action to toggle the polling
  • 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 withController helper to make tests more readable and easier to be maintained

mikesposito avatar Apr 17 '24 13:04 mikesposito