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 AppStateController to BaseController v2 #25916

Closed
1 of 9 tasks
mcmire opened this issue Jul 17, 2024 · 0 comments · Fixed by #28784
Closed
1 of 9 tasks

Migrate AppStateController to BaseController v2 #25916

mcmire opened this issue Jul 17, 2024 · 0 comments · Fixed by #28784
Assignees
Labels
release-12.10.0 Issue or pull request that will be included in release 12.10.0 team-wallet-framework

Comments

@mcmire
Copy link
Contributor

mcmire commented Jul 17, 2024

What is this about?

Following the Wallet Framework team's OKRs for Q3 2024, we want to bring AppStateController 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 getDefaultAppStateControllerState.
  • AppStateController inherits from BaseController instead of EventEmitter.
    • The AppStateController constructor signature is updated to take a partial state option instead of initState.
    • The constructor no longer takes a preferencesStore option; instead, it subscribes to PreferencesController:stateChange.
    • The AppStateController constructor is updated to super to the superclass.
    • AppStateController uses this.messagingSystem to refer to the messenger.
    • this.state is used to access state instead of this.store.getState.
    • this.update is used to update state instead of this.store.updateState.
    • AppStateController uses the messenger to emit the updateBadge event instead of the EventEmitter.
  • Supporting types exist.
    • The AppStateControllerState type exists and represents the current shape of the state object.
    • The AppStateControllerGetStateAction and AppStateControllerStateChangeEvent types exist.
    • A type for the AppStateController:badgeUpdated event exists.
    • The AppStateControllerActions and AppStateControllerEvents types exist.
    • The AllowedActions and AllowedEvents types exist.
    • The AppStateControllerMessenger type exists and expects KeyringController:qrKeyringStateChange, ApprovalController:addRequest, and ApprovalController:acceptRequest to be allowed.
    • AppStateControllerState exists and represents the current shape of the state object.
  • The tests are updated to follow suit.
    • The tests no longer pre-create an appStateController in a beforeEach.
    • Instead of passing a mock version of the messenger, the tests passes a real messenger to the AppStateController instance and use it for verification.
    • The tests verify changes in state for real (they do not merely test that updateState gets called).

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

@mcmire mcmire changed the title Convert AppStateController to TypeScript, and migrate to BaseController v2 Migrate AppStateController to BaseController v2 Jul 18, 2024
@kanthesha kanthesha self-assigned this Sep 26, 2024
@desi desi assigned mikesposito and unassigned kanthesha Nov 7, 2024
@cryptodev-2s cryptodev-2s self-assigned this Nov 27, 2024
github-merge-queue bot pushed a commit that referenced this issue Dec 4, 2024
…28784)

<!--
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 migrate `AppStateController` 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?
-->

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28784?quickstart=1)

## **Related issues**

Fixes: #25916

## **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
- [ ] I’ve included tests if applicable
- [ ] 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.
@metamaskbot metamaskbot added the release-12.10.0 Issue or pull request that will be included in release 12.10.0 label Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-12.10.0 Issue or pull request that will be included in release 12.10.0 team-wallet-framework
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants