Skip to content

feat: add clearSate to accounts-controller - #9799

Merged
gantunesr merged 4 commits into
mainfrom
gar/feat/accounts-controller/clear-state
Aug 7, 2026
Merged

feat: add clearSate to accounts-controller#9799
gantunesr merged 4 commits into
mainfrom
gar/feat/accounts-controller/clear-state

Conversation

@gantunesr

@gantunesr gantunesr commented Aug 6, 2026

Copy link
Copy Markdown
Member

Explanation

Add a clearState method to the accounts-controller allowing callers to delete the current state and reset it to the default one.

References

Related to https://consensyssoftware.atlassian.net/browse/MUL-2050

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Clearing account controller state removes all accounts and selection until keyring/sync repopulates it; misuse or missing coordination with other controllers could briefly break account UX.

Overview
Adds clearState on AccountsController so callers can wipe in-memory account state (empty accounts, no selection, empty accountIdByAddress) back to defaults—same idea as AccountTreeController:clearState, for flows like full wallet reset (MUL-2050).

The former private defaultState is replaced by an exported getDefaultAccountsControllerState() used by the constructor and clearState. The method is registered on the messenger as AccountsController:clearState, with types and package exports updated. Tests cover direct calls, idempotent empty state, and messenger invocation.

Reviewed by Cursor Bugbot for commit 84e410a. Bugbot is set up for automated code reviews on this repo. Configure here.

@gantunesr

Copy link
Copy Markdown
Member Author

@metamaskbot publish-preview

@gantunesr
gantunesr marked this pull request as ready for review August 7, 2026 14:45
@gantunesr
gantunesr requested review from a team as code owners August 7, 2026 14:45

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1f2cff7. Configure here.

Comment thread packages/accounts-controller/src/AccountsController.ts
ccharly
ccharly previously approved these changes Aug 7, 2026
@gantunesr
gantunesr enabled auto-merge August 7, 2026 15:03
@ccharly
ccharly disabled auto-merge August 7, 2026 15:06
@gantunesr
gantunesr enabled auto-merge August 7, 2026 15:14
@gantunesr
gantunesr added this pull request to the merge queue Aug 7, 2026
Merged via the queue into main with commit eb0ac0b Aug 7, 2026
168 checks passed
@gantunesr
gantunesr deleted the gar/feat/accounts-controller/clear-state branch August 7, 2026 15:22
@cursor cursor Bot mentioned this pull request Aug 7, 2026
4 tasks
pull Bot pushed a commit to Reality2byte/core that referenced this pull request Aug 7, 2026
## Explanation

<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:

* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?
* If your primary goal was to update one package but you found you had
to update another one along the way, why did you do so?
* If you had to upgrade a dependency, why did you do so?
-->

Minor release of:

- `@metamask/accounts-controller`

## References

<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?

For example:

* Fixes #12345
* Related to #67890
-->

## Checklist

- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Release-only dependency alignment for a minor accounts-controller add
(`clearState`); wide touch surface but no behavioral changes introduced
in this PR’s diff.
> 
> **Overview**
> **Monorepo release 1183.0.0** that ships
**`@metamask/accounts-controller` 39.1.0** and aligns dependents on
`^39.1.0`.
> 
> The accounts-controller minor release (documented in its changelog for
this bump) adds **`clearState`** / **`AccountsController:clearState`**
to reset internal account state to defaults and exports
**`getDefaultAccountsControllerState`**
([MetaMask#9799](MetaMask#9799)). This PR itself is
version, changelog, `package.json`, and **`yarn.lock`** updates across
packages such as `wallet`, `assets-controller`,
`transaction-controller`, bridge controllers, and multichain packages—no
new controller logic in the diff.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
89eecf4. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants