Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
feat(multichain-account-service): wait for Snap platform to be ready …
…before processing requests
  • Loading branch information
ccharly committed Nov 28, 2025
commit 05e75300c9cfe14f437ef5248e8e9553d2084ed8
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
Loading