Skip to content

Commit a1a90a0

Browse files
committed
Merge branch 'main' into cryptodev-2s/messenger/core-backend
2 parents b7ebc18 + e4f2a09 commit a1a90a0

File tree

144 files changed

+5813
-479
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+5813
-479
lines changed

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ npmMinimalAgeGate: 4320 # 3 days (in minutes)
2424
# regardless of their publish age.
2525
npmPreapprovedPackages:
2626
- "@metamask/*"
27+
- "@metamask-previews/*"
2728
- "@lavamoat/*"

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ linkStyle default opacity:0.5
201201
chain_agnostic_permission --> permission_controller;
202202
composable_controller --> base_controller;
203203
composable_controller --> json_rpc_engine;
204-
core_backend --> base_controller;
205204
core_backend --> controller_utils;
205+
core_backend --> messenger;
206206
core_backend --> profile_sync_controller;
207207
core_backend --> accounts_controller;
208208
core_backend --> keyring_controller;
@@ -216,6 +216,7 @@ linkStyle default opacity:0.5
216216
earn_controller --> transaction_controller;
217217
eip_5792_middleware --> transaction_controller;
218218
eip_5792_middleware --> keyring_controller;
219+
eip_7702_internal_rpc_middleware --> controller_utils;
219220
eip1193_permission_middleware --> chain_agnostic_permission;
220221
eip1193_permission_middleware --> controller_utils;
221222
eip1193_permission_middleware --> json_rpc_engine;

eslint-warning-thresholds.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,6 @@
287287
"packages/gas-fee-controller/src/determineGasFeeCalculations.ts": {
288288
"jsdoc/tag-lines": 4
289289
},
290-
"packages/json-rpc-engine/src/JsonRpcEngine.test.ts": {
291-
"jest/no-conditional-in-test": 2
292-
},
293-
"packages/json-rpc-engine/src/JsonRpcEngine.ts": {
294-
"@typescript-eslint/prefer-promise-reject-errors": 2
295-
},
296290
"packages/json-rpc-middleware-stream/src/index.test.ts": {
297291
"@typescript-eslint/prefer-promise-reject-errors": 3,
298292
"no-empty-function": 1

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@metamask/core-monorepo",
3-
"version": "638.0.0",
3+
"version": "641.0.0",
44
"private": true,
55
"description": "Monorepo for packages shared between MetaMask clients",
66
"repository": {

packages/account-tree-controller/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@
5757
},
5858
"devDependencies": {
5959
"@metamask/account-api": "^0.12.0",
60-
"@metamask/accounts-controller": "^33.1.1",
60+
"@metamask/accounts-controller": "^33.2.0",
6161
"@metamask/auto-changelog": "^3.4.4",
6262
"@metamask/keyring-api": "^21.0.0",
63-
"@metamask/keyring-controller": "^23.1.1",
64-
"@metamask/multichain-account-service": "^1.6.1",
65-
"@metamask/profile-sync-controller": "^25.1.1",
63+
"@metamask/keyring-controller": "^23.2.0",
64+
"@metamask/multichain-account-service": "^1.6.2",
65+
"@metamask/profile-sync-controller": "^25.1.2",
6666
"@metamask/providers": "^22.1.0",
6767
"@metamask/snaps-controllers": "^14.0.1",
6868
"@types/jest": "^27.4.1",

packages/accounts-controller/CHANGELOG.md

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

88
## [Unreleased]
99

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

1219
- Bump `@metamask/base-controller` from `^8.4.1` to `^8.4.2` ([#6917](https://github.com/MetaMask/core/pull/6917))
@@ -631,7 +638,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
631638

632639
- Initial release ([#1637](https://github.com/MetaMask/core/pull/1637))
633640

634-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@33.1.1...HEAD
641+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@33.2.0...HEAD
642+
[33.2.0]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@33.1.1...@metamask/accounts-controller@33.2.0
635643
[33.1.1]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@33.1.0...@metamask/accounts-controller@33.1.1
636644
[33.1.0]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@33.0.0...@metamask/accounts-controller@33.1.0
637645
[33.0.0]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@32.0.2...@metamask/accounts-controller@33.0.0

packages/accounts-controller/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@metamask/accounts-controller",
3-
"version": "33.1.1",
3+
"version": "33.2.0",
44
"description": "Manages internal accounts",
55
"keywords": [
66
"MetaMask",
@@ -66,8 +66,8 @@
6666
"devDependencies": {
6767
"@metamask/auto-changelog": "^3.4.4",
6868
"@metamask/controller-utils": "^11.14.1",
69-
"@metamask/keyring-controller": "^23.1.1",
70-
"@metamask/network-controller": "^24.3.0",
69+
"@metamask/keyring-controller": "^23.2.0",
70+
"@metamask/network-controller": "^24.3.1",
7171
"@metamask/providers": "^22.1.0",
7272
"@metamask/snaps-controllers": "^14.0.1",
7373
"@types/jest": "^27.4.1",

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,

0 commit comments

Comments
 (0)