-
-
Notifications
You must be signed in to change notification settings - Fork 251
refactor(multichain-account-service): Improved performance across package classes and improved error messages #6654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 53 commits
aa318fe
17e855f
924a679
be8b2f7
b49f7b4
a261e1e
6104131
c45f612
acf36e0
ce3cef4
891fa50
83060d6
01096bf
4c2e582
43972f8
7cec854
f05e6da
e325c77
6c5b86e
7d805ef
6b6e776
33e5e34
f4d79c0
350aa93
ce322e0
31a6d71
4c485a6
c82de17
7d6e76a
2d55dbd
b8a87ff
92d1c3a
8dedd1a
11cc131
d28a324
f308e9f
8bc1237
19cfdf3
82fece8
c812a82
91aa52e
4b19ed5
5bcaa53
c12435a
e9ab58d
521a71b
1162348
31f0193
7128b55
0c9324c
6b15c2d
0ec9181
98db5d3
98d6373
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -20,7 +20,7 @@ | |||||||||||||
import { SnapStatus } from '@metamask/snaps-utils'; | ||||||||||||||
import type { CaipChainId } from '@metamask/utils'; | ||||||||||||||
import type { V4Options } from 'uuid'; | ||||||||||||||
import * as uuid from 'uuid'; | ||||||||||||||
|
||||||||||||||
import type { | ||||||||||||||
AccountsControllerActions, | ||||||||||||||
|
@@ -2777,6 +2777,26 @@ | |||||||||||||
}); | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
describe('getAccounts', () => { | ||||||||||||||
it('returns a list of accounts based on the given account IDs', () => { | ||||||||||||||
const { accountsController } = setupAccountsController({ | ||||||||||||||
initialState: { | ||||||||||||||
internalAccounts: { | ||||||||||||||
accounts: { | ||||||||||||||
[mockAccount.id]: mockAccount, | ||||||||||||||
[mockAccount2.id]: mockAccount2, | ||||||||||||||
}, | ||||||||||||||
selectedAccount: mockAccount.id, | ||||||||||||||
}, | ||||||||||||||
}, | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
const result = accountsController.getAccounts([mockAccount.id]); | ||||||||||||||
|
||||||||||||||
expect(result).toStrictEqual([mockAccount]); | ||||||||||||||
Comment on lines
+2794
to
+2796
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe use multiple accounts instead?
Suggested change
|
||||||||||||||
}); | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
describe('getSelectedAccount', () => { | ||||||||||||||
it.each([ | ||||||||||||||
{ | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably also split this from this PR. For similar reasons (see my other comment about |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||||
|
||||||
## [Unreleased] | ||||||
|
||||||
### Added | ||||||
|
||||||
- Add actions for `createNewVaultAndKeychain` and `createNewVaultAndRestore` ([#6654](https://github.com/MetaMask/core/pull/6708)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
- These actions are meant to to be consumed by the `MultichainAccountService` in its `createMultichainAccountWallet` method. | ||||||
|
||||||
## [23.1.1] | ||||||
|
||||||
### Changed | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe those change should be splitted in another PR. The main reason would be that we would need to first release the But I think we don't allow minor bump for peer dep... We might want to check with the |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||||
|
||||||
## [Unreleased] | ||||||
|
||||||
### Added | ||||||
|
||||||
- **BREAKING** A performance refactor was made around all the classes in this package ([#6654](https://github.com/MetaMask/core/pull/6708)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
- Add logic in the `createMultichainAccountWallet` method in `MultichainAccountService` so that it can handle all entry points: importing an SRP, recovering a vault and creating a new vault. | ||||||
- Add a `getAccountIds` method which returns all the account ids pertaining to a group. | ||||||
- Add an `addAccounts` method on the `BaseBip44AccountProvider` class which keeps track of all the account IDs that pertain to it. | ||||||
|
||||||
### Changed | ||||||
|
||||||
- **BREAKING** A performance refactor was made around all the classes in this package ([#6654](https://github.com/MetaMask/core/pull/6708)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
- The `MultichainAccountService` is refactored to construct a top level service state for its `init` function, this state is passed down to the `MultichainAccountWallet` and `MultichainAccountGroup` classes in slices for them to construct their internal states. | ||||||
- Additional state is generated at the entry points where it needs to be updated i.e. `createMultichainAccountGroup`, `discoverAccounts` and `alignAccounts`. | ||||||
- We no longer prevent group creation if some providers' `createAccounts` calls fail during group creation, only if they all fail. | ||||||
- The `getAccounts` method in the `BaseBip44AccountProvider` class no longer relies on fetching the entire list of internal accounts from the `AccountsController`, instead it gets the specific accounts that it stores in its internal accounts list. | ||||||
- The `EvmAccountProvider` no longer fetches from the `AccountController` to get an account for its ID, we deterministically get the associated account ID through `getUUIDFromAddressOfNormalAccount`. | ||||||
- The `EvmAccountProvider` now uses the `getAccount` method from the `AccountsController` when fetching an account after account creation as it is more efficient. | ||||||
|
||||||
### Removed | ||||||
|
||||||
- **BREAKING** A performance refactor was made around all the classes in this package ([#6654](https://github.com/MetaMask/core/pull/6708)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
- Remove `#handleOnAccountAdded` and `#handleOnAccountRemoved` methods in `MultichainAccountService` due to internal state being updated within the service. | ||||||
- Remove `getAccountContext` (and associated map) in the `MultichainAccountService` as the service no longer uses that method. | ||||||
- Remove the `sync` method in favor of the sole `init` method for both `MultichainAccountWallet` and `MultichainAccountGroup`. | ||||||
|
||||||
## [1.6.1] | ||||||
|
||||||
### Changed | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.