Skip to content
Open
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
8 changes: 8 additions & 0 deletions packages/multichain-account-service/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Wait for Snap platform to be ready before any wallet/group operations ([#7266](https://github.com/MetaMask/core/pull/7266))

### Changed

- **BREAKING:** Abstract method `SnapAccountProvider.createAccounts` has been renamed `runCreateAccounts` ([#7266](https://github.com/MetaMask/core/pull/7266))
- `SnapAccountProvider.createAccounts` is now implemented by `SnapAccountProvider` directly and automatically wait for the Snap platform to be ready before calling `runCreateAccounts`.
- **BREAKING:** Abstract method `SnapAccountProvider.discoverAccounts` has been renamed `runDiscoverAccounts` ([#7266](https://github.com/MetaMask/core/pull/7266))
- `SnapAccountProvider.discoverAccounts` is now implemented by `SnapAccountProvider` directly and automatically wait for the Snap platform to be ready before calling `runDiscoverAccounts`.
- Move peer dependencies for controller and service packages to direct dependencies ([#7209](https://github.com/MetaMask/core/pull/7209))
- The dependencies moved are:
- `@metamask/accounts-controller` (^35.0.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ export abstract class BaseBip44AccountProvider implements Bip44AccountProvider {

abstract getName(): string;

protected getAnyAccount(): Bip44Account<KeyringAccount> | undefined {
const anyAccount = this.messenger
.call(
// NOTE: Even though the name is misleading, this only fetches all internal
// accounts, including EVM and non-EVM. We might wanna change this action
// name once we fully support multichain accounts.
'AccountsController:listMultichainAccounts',
)
.find((account) => {
return isBip44Account(account) && this.isAccountCompatible(account);
});

// We cast here since `.find` will return a `InternalAccount | undefined`
// despite having the `isBip44Account` check.
return anyAccount as Bip44Account<KeyringAccount> | undefined;
}

#getAccounts(
filter: (account: KeyringAccount) => boolean = () => true,
): Bip44Account<KeyringAccount>[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ class MockBtcKeyring {
return account;
});
}
class MockBtcAccountProvider extends BtcAccountProvider {
override async ensureSnapPlatformIsReady(): Promise<void> {
// Override to avoid waiting during tests.
}
}

/**
* Sets up a BtcAccountProvider for testing.
Expand Down Expand Up @@ -153,7 +158,7 @@ function setup({
const multichainMessenger = getMultichainAccountServiceMessenger(messenger);
const provider = new AccountProviderWrapper(
multichainMessenger,
new BtcAccountProvider(multichainMessenger),
new MockBtcAccountProvider(multichainMessenger),
);

return {
Expand Down Expand Up @@ -348,7 +353,7 @@ describe('BtcAccountProvider', () => {

const multichainMessenger =
getMultichainAccountServiceMessenger(messenger);
const btcProvider = new BtcAccountProvider(
const btcProvider = new MockBtcAccountProvider(
multichainMessenger,
undefined,
mockTrace,
Expand Down Expand Up @@ -400,7 +405,7 @@ describe('BtcAccountProvider', () => {

const multichainMessenger =
getMultichainAccountServiceMessenger(messenger);
const btcProvider = new BtcAccountProvider(
const btcProvider = new MockBtcAccountProvider(
multichainMessenger,
undefined,
mockTrace,
Expand Down Expand Up @@ -433,7 +438,7 @@ describe('BtcAccountProvider', () => {

const multichainMessenger =
getMultichainAccountServiceMessenger(messenger);
const btcProvider = new BtcAccountProvider(
const btcProvider = new MockBtcAccountProvider(
multichainMessenger,
undefined,
mockTrace,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class BtcAccountProvider extends SnapAccountProvider {
);
}

async createAccounts({
async runCreateAccounts({
entropySource,
groupIndex: index,
}: {
Expand All @@ -77,7 +77,7 @@ export class BtcAccountProvider extends SnapAccountProvider {
});
}

async discoverAccounts({
async runDiscoverAccounts({
entropySource,
groupIndex,
}: {
Expand Down
Loading