Skip to content

feat(account-tree-controller): add get/set account group methods - #9739

Open
hmalik88 wants to merge 17 commits into
mainfrom
hm/add-account-group-methods
Open

feat(account-tree-controller): add get/set account group methods#9739
hmalik88 wants to merge 17 commits into
mainfrom
hm/add-account-group-methods

Conversation

@hmalik88

@hmalik88 hmalik88 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Explanation

Added getAccountFromSelectedAccountGroup and setSelectedAccountGroupByAccountId methods

References

N/A

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
Changes how the selected account is synced to AccountsController and introduces APIs that drive account/group selection; behavior is well-tested but affects core wallet selection paths.

Overview
Adds getAccountFromSelectedAccountGroup and setSelectedAccountGroupByAccountId on AccountTreeController, exposed via messenger actions and package exports, with changelog and broad unit tests.

getAccountFromSelectedAccountGroup is intended as the group-based replacement for AccountsController:getSelectedAccount / getSelectedMultichainAccount. Without a chain ID it applies the existing EVM-priority pick (first EVM in the group, else first account). With an optional CAIP-2 chainId it returns the first account in the selected group whose scopes match, validates the chain ID, and returns undefined when nothing matches.

setSelectedAccountGroupByAccountId resolves the account’s group from the internal tree map and delegates to setSelectedAccountGroup, throwing if the account is not in the tree.

Internal selection logic is refactored: #getDefaultAccountFromAccountGroupId becomes #getAccountFromAccountGroupId, returning a full InternalAccount instead of an ID. #setSelectedAccountGroup now forwards accountToSelect.id to AccountsController:setSelectedAccount (previously passed the account object).

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

@hmalik88
hmalik88 marked this pull request as ready for review July 31, 2026 14:13
@hmalik88
hmalik88 requested review from a team as code owners July 31, 2026 14:14
@hmalik88
hmalik88 temporarily deployed to default-branch July 31, 2026 14:14 — with GitHub Actions Inactive

@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 2 potential issues.

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 36886ae. Configure here.

Comment thread packages/account-tree-controller/src/index.ts
Comment thread packages/account-tree-controller/src/AccountTreeController.ts
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