Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/account-tree-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- **BREAKING:** Use `:getSelectedMultichainAccount` instead of `:getSelectedAccount` to compute currently selected account group ([#6608](https://github.com/MetaMask/core/pull/6608))
- Coming from the old account model, a non-EVM account could have been selected and the lastly selected EVM account might not be using the same group index.
- Bump `@metamask/utils` from `^11.4.2` to `^11.8.0` ([#6588](https://github.com/MetaMask/core/pull/6588))

### Removed

- Remove use of `:getSelectedAccount` action ([#6608](https://github.com/MetaMask/core/pull/6608))

## [0.15.1]

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function getAccountTreeControllerMessenger(
allowedActions: [
'AccountsController:listMultichainAccounts',
'AccountsController:getAccount',
'AccountsController:getSelectedAccount',
'AccountsController:getSelectedMultichainAccount',
'AccountsController:setSelectedAccount',
'UserStorageController:getState',
'UserStorageController:performGetStorage',
Expand Down Expand Up @@ -305,7 +305,7 @@ function setup({
AccountsController: {
accounts: InternalAccount[];
listMultichainAccounts: jest.Mock;
getSelectedAccount: jest.Mock;
getSelectedMultichainAccount: jest.Mock;
getAccount: jest.Mock;
};
UserStorageController: {
Expand All @@ -329,7 +329,7 @@ function setup({
accounts,
listMultichainAccounts: jest.fn(),
getAccount: jest.fn(),
getSelectedAccount: jest.fn(),
getSelectedMultichainAccount: jest.fn(),
},
UserStorageController: {
getState: jest.fn(),
Expand Down Expand Up @@ -366,13 +366,13 @@ function setup({
mocks.AccountsController.getAccount,
);

// Mock AccountsController:getSelectedAccount to return the first account
mocks.AccountsController.getSelectedAccount.mockImplementation(
// Mock AccountsController:getSelectedMultichainAccount to return the first account
mocks.AccountsController.getSelectedMultichainAccount.mockImplementation(
() => accounts[0] || MOCK_HD_ACCOUNT_1,
);
messenger.registerActionHandler(
'AccountsController:getSelectedAccount',
mocks.AccountsController.getSelectedAccount,
'AccountsController:getSelectedMultichainAccount',
mocks.AccountsController.getSelectedMultichainAccount,
);

// Mock AccountsController:setSelectedAccount
Expand Down Expand Up @@ -750,7 +750,7 @@ describe('AccountTreeController', () => {
keyrings: [MOCK_HD_KEYRING_1],
});

mocks.AccountsController.getSelectedAccount.mockImplementation(
mocks.AccountsController.getSelectedMultichainAccount.mockImplementation(
() => MOCK_HD_ACCOUNT_1,
);

Expand All @@ -767,7 +767,7 @@ describe('AccountTreeController', () => {

mocks.AccountsController.accounts = [MOCK_HD_ACCOUNT_2];
mocks.KeyringController.keyrings = [MOCK_HD_KEYRING_2];
mocks.AccountsController.getSelectedAccount.mockImplementation(
mocks.AccountsController.getSelectedMultichainAccount.mockImplementation(
() => MOCK_HD_ACCOUNT_2,
);

Expand Down Expand Up @@ -1554,10 +1554,10 @@ describe('AccountTreeController', () => {

// Unregister existing handler and register new one BEFORE init
messenger.unregisterActionHandler(
'AccountsController:getSelectedAccount',
'AccountsController:getSelectedMultichainAccount',
);
messenger.registerActionHandler(
'AccountsController:getSelectedAccount',
'AccountsController:getSelectedMultichainAccount',
() => EMPTY_ACCOUNT_MOCK,
);

Expand All @@ -1581,17 +1581,17 @@ describe('AccountTreeController', () => {
keyrings: [MOCK_HD_KEYRING_1, MOCK_HD_KEYRING_2],
});

// Mock getSelectedAccount to return an account not in the tree BEFORE init
// Mock getSelectedMultichainAccount to return an account not in the tree BEFORE init
const unknownAccount: InternalAccount = {
...MOCK_HD_ACCOUNT_1,
id: 'unknown-account-id',
};

messenger.unregisterActionHandler(
'AccountsController:getSelectedAccount',
'AccountsController:getSelectedMultichainAccount',
);
messenger.registerActionHandler(
'AccountsController:getSelectedAccount',
'AccountsController:getSelectedMultichainAccount',
() => unknownAccount,
);

Expand All @@ -1609,18 +1609,18 @@ describe('AccountTreeController', () => {
expect(controller.getSelectedAccountGroup()).toBe(expectedGroupId1);
});

it('returns empty string when no wallets exist and getSelectedAccount returns EMPTY_ACCOUNT', () => {
it('returns empty string when no wallets exist and getSelectedMultichainAccount returns EMPTY_ACCOUNT', () => {
const { controller, messenger } = setup({
accounts: [],
keyrings: [],
});

// Mock getSelectedAccount to return EMPTY_ACCOUNT_MOCK (id is '') BEFORE init
// Mock getSelectedMultichainAccount to return EMPTY_ACCOUNT_MOCK (id is '') BEFORE init
messenger.unregisterActionHandler(
'AccountsController:getSelectedAccount',
'AccountsController:getSelectedMultichainAccount',
);
messenger.registerActionHandler(
'AccountsController:getSelectedAccount',
'AccountsController:getSelectedMultichainAccount',
() => EMPTY_ACCOUNT_MOCK,
);

Expand Down Expand Up @@ -2813,7 +2813,7 @@ describe('AccountTreeController', () => {
keyrings: [MOCK_HD_KEYRING_1],
});

mocks.AccountsController.getSelectedAccount.mockImplementation(
mocks.AccountsController.getSelectedMultichainAccount.mockImplementation(
() => MOCK_HD_ACCOUNT_1,
);

Expand Down Expand Up @@ -2842,7 +2842,7 @@ describe('AccountTreeController', () => {
keyrings: [MOCK_HD_KEYRING_1],
});

mocks.AccountsController.getSelectedAccount.mockImplementation(
mocks.AccountsController.getSelectedMultichainAccount.mockImplementation(
() => MOCK_HD_ACCOUNT_1,
);

Expand All @@ -2865,7 +2865,7 @@ describe('AccountTreeController', () => {

mocks.AccountsController.accounts = [MOCK_HD_ACCOUNT_2];
mocks.KeyringController.keyrings = [MOCK_HD_KEYRING_2];
mocks.AccountsController.getSelectedAccount.mockImplementation(
mocks.AccountsController.getSelectedMultichainAccount.mockImplementation(
() => MOCK_HD_ACCOUNT_2,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ export class AccountTreeController extends BaseController<
[walletId: AccountWalletId]: AccountWalletObject;
}): AccountGroupId | '' {
const selectedAccount = this.messagingSystem.call(
'AccountsController:getSelectedAccount',
'AccountsController:getSelectedMultichainAccount',
);
if (selectedAccount && selectedAccount.id) {
const accountMapping = this.#accountIdToContext.get(selectedAccount.id);
Expand Down
2 changes: 1 addition & 1 deletion packages/account-tree-controller/src/rule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function getAccountTreeControllerMessenger(
allowedActions: [
'AccountsController:listMultichainAccounts',
'AccountsController:getAccount',
'AccountsController:getSelectedAccount',
'AccountsController:getSelectedMultichainAccount',
'AccountsController:setSelectedAccount',
'KeyringController:getState',
'SnapController:get',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function getAccountTreeControllerMessenger(
allowedActions: [
'AccountsController:listMultichainAccounts',
'AccountsController:getAccount',
'AccountsController:getSelectedAccount',
'AccountsController:getSelectedMultichainAccount',
'AccountsController:setSelectedAccount',
'KeyringController:getState',
'SnapController:get',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('keyring', () => {
allowedActions: [
'AccountsController:listMultichainAccounts',
'AccountsController:getAccount',
'AccountsController:getSelectedAccount',
'AccountsController:getSelectedMultichainAccount',
'AccountsController:setSelectedAccount',
'KeyringController:getState',
'SnapController:get',
Expand Down
2 changes: 1 addition & 1 deletion packages/account-tree-controller/src/rules/snap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function getAccountTreeControllerMessenger(
allowedActions: [
'AccountsController:listMultichainAccounts',
'AccountsController:getAccount',
'AccountsController:getSelectedAccount',
'AccountsController:getSelectedMultichainAccount',
'AccountsController:setSelectedAccount',
'KeyringController:getState',
'SnapController:get',
Expand Down
4 changes: 2 additions & 2 deletions packages/account-tree-controller/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
AccountsControllerAccountAddedEvent,
AccountsControllerAccountRemovedEvent,
AccountsControllerGetAccountAction,
AccountsControllerGetSelectedAccountAction,
AccountsControllerGetSelectedMultichainAccountAction,
AccountsControllerListMultichainAccountsAction,
AccountsControllerSelectedAccountChangeEvent,
AccountsControllerSetSelectedAccountAction,
Expand Down Expand Up @@ -115,7 +115,7 @@ export type AccountTreeControllerSetAccountGroupPinnedAction = {

export type AllowedActions =
| AccountsControllerGetAccountAction
| AccountsControllerGetSelectedAccountAction
| AccountsControllerGetSelectedMultichainAccountAction
| AccountsControllerListMultichainAccountsAction
| AccountsControllerSetSelectedAccountAction
| KeyringControllerGetStateAction
Expand Down
Loading