Skip to content
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

Migrate MetaMetricsController to BaseController v2 #25925

Open
1 of 9 tasks
mcmire opened this issue Jul 18, 2024 · 0 comments
Open
1 of 9 tasks

Migrate MetaMetricsController to BaseController v2 #25925

mcmire opened this issue Jul 18, 2024 · 0 comments
Assignees

Comments

@mcmire
Copy link
Contributor

mcmire commented Jul 18, 2024

What is this about?

Following the Wallet Framework team's OKRs for Q3 2024, we want to bring MetaMetricsController up to date with our latest controller patterns.

Scenario

No response

Design

No response

Technical Details

No response

Threat Modeling Framework

No response

Acceptance Criteria

  • A constant called controllerName exists which holds the name of the controller.
  • A constant called controllerMetadata exists which holds the metadata for the state.
  • The default state object is extracted to a function called getDefaultMetaMetricsControllerState.
  • MetaMetricsController inherits from BaseController.
    • The MetaMetricsController has a constructor which takes a partial state option (instead of initState) and a messenger option (among other options).
    • The default state passed to ObservableStore is extracted and wrapped in a getDefaultMetaMetricsControllerState function.
    • The constructor subscribes to NetworkController:networkDidChange via the messenger instead of taking a onNetworkDidChange callback.
    • The constructor obtains the current chain ID from the NetworkController (NetworkController:getState -> selectedNetworkClientId -> NetworkController:getNetworkClientById -> configuration.chainId) instead of taking a getCurrentChainId option.
    • The constructor gets the initial locale via PreferencesController:getState and uses PreferencesController:stateChange to track the locale as it changes instead of taking a preferencesStore option.
    • this.state is used to access state instead of this.store.getState.
    • this.update is used to update state instead of this.store.updateState.
  • Supporting types exist.
    • The MetaMetricsControllerState type exists and represents the current shape of the state object.
    • The MetaMetricsControllerGetStateAction and MetaMetricsControllerStateChangeEvent types exist.
    • The MetaMetricsControllerActions and MetaMetricsControllerEvents types exist.
    • The AllowedActions and AllowedEvents types exist.
    • The MetaMetricsControllerMessenger type exists and expects NetworkController:networkDidChange, NetworkController:getState, NetworkController:getNetworkClientById, PreferencesController:getState, and PreferencesController:stateChange to be allowed.
    • MetaMetricsControllerState exists and represents the current shape of the state object.
  • The tests are updated to follow suit.
    • getMetaMetricsController creates a messenger and passes it to the controller.
    • getMetaMetricsController pre-registers action handlers using mock functions and returns those action handler mocks to be customized in tests.
    • metaMetricsController.state is used to access state instead of metaMetricsController.store.getState().

Stakeholder review needed before the work gets merged

  • Engineering (needed in most cases)
  • Design
  • Product
  • QA (automation tests are required to pass before merging PRs but not all changes are covered by automation tests - please review if QA is needed beyond automation tests)
  • Security
  • Legal
  • Marketing
  • Management (please specify)
  • Other (please specify)

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants