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 getDefaultAccountTrackerControllerState.
The class is renamed to AccountTrackerController and relocated to app/scripts/controllers along with its test file.
AccountTrackerController inherits from BaseController.
The AccountTrackerController has a constructor which takes a partial state option (instead of initState) and a messenger option (instead of controllerMessenger), among other options.
The default state passed to ObservableStore (initState) is extracted and wrapped in a getDefaultAccountTrackerControllerState function.
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 uses the NetworkController:getNetworkClientById messenger action instead of taking a getNetworkClientById option.
The constructor uses the PreferencesController:getState messenger action instead of taking a preferencesController option.
The constructor uses the OnboardingController:getState messenger action and OnboardingController:stateChange messenger event instead of taking a onboardingController 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 AccountTrackerControllerState type exists and represents the current shape of the state object.
The AccountTrackerControllerGetStateAction and AccountTrackerControllerStateChangeEvent types exist.
The AccountTrackerControllerActions and AccountTrackerControllerEvents types exist.
The AllowedActions and AllowedEvents types exist.
The AccountTrackerControllerMessenger type exists and expects NetworkController:getState, NetworkController:getNetworkClientById, PreferencesController:getState, OnboardingController:getState, and OnboardingController:stateChange to be allowed.
The tests are updated to follow suit.
buildAccountTracker is renamed to buildAccountTrackerController.
buildAccountTrackerController pre-registers action handlers using mock functions and returns those action handler mocks to be customized in tests.
accountTrackerController.state is used to access state instead of accountTrackerController.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)
What is this about?
Following the Wallet Framework team's OKRs for Q3 2024, we want to bring
AccountTracker
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.getDefaultAccountTrackerControllerState
.AccountTrackerController
and relocated toapp/scripts/controllers
along with its test file.AccountTrackerController
inherits fromBaseController
.AccountTrackerController
has a constructor which takes a partialstate
option (instead ofinitState
) and amessenger
option (instead ofcontrollerMessenger
), among other options.initState
) is extracted and wrapped in agetDefaultAccountTrackerControllerState
function.NetworkController:getState
->selectedNetworkClientId
->NetworkController:getNetworkClientById
->configuration.chainId
) instead of taking agetCurrentChainId
option.NetworkController:getNetworkClientById
messenger action instead of taking agetNetworkClientById
option.PreferencesController:getState
messenger action instead of taking apreferencesController
option.OnboardingController:getState
messenger action andOnboardingController:stateChange
messenger event instead of taking aonboardingController
option.this.state
is used to access state instead ofthis.store.getState
.this.update
is used to update state instead ofthis.store.updateState
.AccountTrackerControllerState
type exists and represents the current shape of the state object.AccountTrackerControllerGetStateAction
andAccountTrackerControllerStateChangeEvent
types exist.AccountTrackerControllerActions
andAccountTrackerControllerEvents
types exist.AllowedActions
andAllowedEvents
types exist.AccountTrackerControllerMessenger
type exists and expectsNetworkController:getState
,NetworkController:getNetworkClientById
,PreferencesController:getState
,OnboardingController:getState
, andOnboardingController:stateChange
to be allowed.buildAccountTracker
is renamed tobuildAccountTrackerController
.buildAccountTrackerController
pre-registers action handlers using mock functions and returns those action handler mocks to be customized in tests.accountTrackerController.state
is used to access state instead ofaccountTrackerController.store.getState()
.Stakeholder review needed before the work gets merged
References
The text was updated successfully, but these errors were encountered: