You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
This PR migrates MetaMetricsController to inherit from BaseController V2
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
[](https://codespaces.new/MetaMask/metamask-extension/pull/28113?quickstart=1)
## **Related issues**
Fixes: #25925
## **Manual testing steps**
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<!-- [screenshots/recordings] -->
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
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
controllerName
exists which holds the name of the controller.controllerMetadata
exists which holds the metadata for the state.getDefaultMetaMetricsControllerState
.MetaMetricsController
inherits fromBaseController
.MetaMetricsController
has a constructor which takes a partialstate
option (instead ofinitState
) and amessenger
option (among other options).getDefaultMetaMetricsControllerState
function.NetworkController:networkDidChange
via the messenger instead of taking aonNetworkDidChange
callback.NetworkController:getState
->selectedNetworkClientId
->NetworkController:getNetworkClientById
->configuration.chainId
) instead of taking agetCurrentChainId
option.PreferencesController:getState
and usesPreferencesController:stateChange
to track the locale as it changes instead of taking apreferencesStore
option.this.state
is used to access state instead ofthis.store.getState
.this.update
is used to update state instead ofthis.store.updateState
.MetaMetricsControllerState
type exists and represents the current shape of the state object.MetaMetricsControllerGetStateAction
andMetaMetricsControllerStateChangeEvent
types exist.MetaMetricsControllerActions
andMetaMetricsControllerEvents
types exist.AllowedActions
andAllowedEvents
types exist.MetaMetricsControllerMessenger
type exists and expectsNetworkController:networkDidChange
,NetworkController:getState
,NetworkController:getNetworkClientById
,PreferencesController:getState
, andPreferencesController:stateChange
to be allowed.MetaMetricsControllerState
exists and represents the current shape of the state object.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 ofmetaMetricsController.store.getState()
.Stakeholder review needed before the work gets merged
References
The text was updated successfully, but these errors were encountered: