Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
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
Loading