Skip to content

Commit e424f6b

Browse files
committed
Merge remote-tracking branch 'origin/main' into hm/add-keyring-actions
2 parents 632dd68 + dfd2a80 commit e424f6b

File tree

7 files changed

+61
-2
lines changed

7 files changed

+61
-2
lines changed

packages/accounts-controller/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add a `getAccounts` method (and its associated action) that is the plural version of `getAccount` ([#6927](https://github.com/MetaMask/core/pull/6927))
13+
- This method is added to primarily be consumed in the `MultichainAccountService`.
14+
1015
### Changed
1116

1217
- Bump `@metamask/base-controller` from `^8.4.1` to `^8.4.2` ([#6917](https://github.com/MetaMask/core/pull/6917))

packages/accounts-controller/src/AccountsController.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2777,6 +2777,30 @@ describe('AccountsController', () => {
27772777
});
27782778
});
27792779

2780+
describe('getAccounts', () => {
2781+
it('returns a list of accounts based on the given account IDs', () => {
2782+
const { accountsController } = setupAccountsController({
2783+
initialState: {
2784+
internalAccounts: {
2785+
accounts: {
2786+
[mockAccount.id]: mockAccount,
2787+
[mockAccount2.id]: mockAccount2,
2788+
[mockAccount3.id]: mockAccount3,
2789+
},
2790+
selectedAccount: mockAccount.id,
2791+
},
2792+
},
2793+
});
2794+
2795+
const result = accountsController.getAccounts([
2796+
mockAccount.id,
2797+
mockAccount3.id,
2798+
]);
2799+
2800+
expect(result).toStrictEqual([mockAccount, mockAccount3]);
2801+
});
2802+
});
2803+
27802804
describe('getSelectedAccount', () => {
27812805
it.each([
27822806
{

packages/accounts-controller/src/AccountsController.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ export type AccountsControllerGetAccountAction = {
124124
handler: AccountsController['getAccount'];
125125
};
126126

127+
export type AccountsControllerGetAccountsAction = {
128+
type: `${typeof controllerName}:getAccounts`;
129+
handler: AccountsController['getAccounts'];
130+
};
131+
127132
export type AccountsControllerUpdateAccountMetadataAction = {
128133
type: `${typeof controllerName}:updateAccountMetadata`;
129134
handler: AccountsController['updateAccountMetadata'];
@@ -145,6 +150,7 @@ export type AccountsControllerActions =
145150
| AccountsControllerGetSelectedAccountAction
146151
| AccountsControllerGetNextAvailableAccountNameAction
147152
| AccountsControllerGetAccountAction
153+
| AccountsControllerGetAccountsAction
148154
| AccountsControllerGetSelectedMultichainAccountAction
149155
| AccountsControllerUpdateAccountMetadataAction;
150156

@@ -303,6 +309,16 @@ export class AccountsController extends BaseController<
303309
return this.state.internalAccounts.accounts[accountId];
304310
}
305311

312+
/**
313+
* Returns the internal account objects for the given account IDs, if they exist.
314+
*
315+
* @param accountIds - The IDs of the accounts to retrieve.
316+
* @returns The internal account objects, or undefined if the account(s) do not exist.
317+
*/
318+
getAccounts(accountIds: string[]): (InternalAccount | undefined)[] {
319+
return accountIds.map((accountId) => this.getAccount(accountId));
320+
}
321+
306322
/**
307323
* Returns an array of all evm internal accounts.
308324
*
@@ -1305,6 +1321,11 @@ export class AccountsController extends BaseController<
13051321
this.getAccount.bind(this),
13061322
);
13071323

1324+
this.messagingSystem.registerActionHandler(
1325+
`AccountsController:getAccounts`,
1326+
this.getAccounts.bind(this),
1327+
);
1328+
13081329
this.messagingSystem.registerActionHandler(
13091330
`AccountsController:updateAccountMetadata`,
13101331
this.updateAccountMetadata.bind(this),

packages/accounts-controller/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export type {
1313
AccountsControllerGetAccountByAddressAction,
1414
AccountsControllerGetNextAvailableAccountNameAction,
1515
AccountsControllerGetAccountAction,
16+
AccountsControllerGetAccountsAction,
1617
AccountsControllerUpdateAccountMetadataAction,
1718
AllowedActions,
1819
AccountsControllerActions,

packages/assets-controllers/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add `Monad Mainnet` into `SUPPORTED_NETWORKS_ACCOUNTS_API_V4`
13+
14+
### Fixed
15+
16+
- Fix incorrect balance scan contract address for `Monad Mainnet`
17+
- Remove `Monad Mainnet` in `SINGLE_CALL_BALANCES_ADDRESS_BY_CHAINID` ([#6929](https://github.com/MetaMask/core/pull/6929))
18+
1019
## [83.0.0]
1120

1221
### Changed

packages/assets-controllers/src/AssetsContractController.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ export const SINGLE_CALL_BALANCES_ADDRESS_BY_CHAINID = {
7474
'0x6aa75276052d96696134252587894ef5ffa520af',
7575
[SupportedTokenDetectionNetworks.moonriver]:
7676
'0x6aa75276052d96696134252587894ef5ffa520af',
77-
[SupportedTokenDetectionNetworks.monad_mainnet]:
78-
'0xC856736BFe4DcB217F6678Ff2C4D7A7939B29A88',
7977
} as const satisfies Record<Hex, string>;
8078

8179
export const STAKING_CONTRACT_ADDRESS_BY_CHAINID = {

packages/assets-controllers/src/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ export const SUPPORTED_NETWORKS_ACCOUNTS_API_V4 = [
1515
'0xa4b1', // 42161
1616
'0x82750', // 534352
1717
'0x531', // 1329
18+
'0x8f', // 143
1819
];

0 commit comments

Comments
 (0)