Skip to content

Commit dedf498

Browse files
authored
feat: revert changes to AccountProvider and add Bip44AccountProvider type alias (#361)
What is the current state of things and why does it need to change? 1. It was determined that `AccountProviderType` doesn't work well with the concept of a custom provider. We wanted to let the `MultichainAccountWallet` orchestrate the discovery so it was determined it would be better to keep the function signature as is for `discoverAndCreateAccounts`. 2. Writing `AccountProvider<Bip44Account<KeyringAccount>>` is a mouthful. What is the solution your changes offer and how does it work? 1. Remove the `AccountProviderType` enum, revert the changes made to `AccountProvider`. 2. Write a type alias: `Bip44AccountProvider`.
1 parent cd03860 commit dedf498

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

packages/account-api/src/api/provider.test.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

packages/account-api/src/api/provider.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
import type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';
22

3-
export enum AccountProviderType {
4-
Evm = 'Evm',
5-
Solana = 'Solana',
6-
Btc = 'Btc',
7-
}
3+
import type { Bip44Account } from './bip44';
84

95
/**
106
* An account provider is reponsible of providing accounts to an account group.
117
*/
128
export type AccountProvider<Account extends KeyringAccount> = {
13-
/**
14-
* The type of the provider.
15-
*/
16-
providerType: AccountProviderType;
179
/**
1810
* Gets an account for a given ID.
1911
*
@@ -43,15 +35,28 @@ export type AccountProvider<Account extends KeyringAccount> = {
4335
}) => Promise<Account[]>;
4436

4537
/**
46-
* Discover accounts for a given entropy source.
38+
* Discover accounts for a given entropy source and a given group
39+
* index.
4740
*
4841
* NOTE: This method needs to also create the discovered accounts.
4942
*
5043
* @param options - Options.
5144
* @param options.entropySource - Entropy source to use.
45+
* @param options.groupIndex - Group index to use.
5246
* @returns The list of discovered and created accounts.
5347
*/
5448
discoverAndCreateAccounts: (options: {
5549
entropySource: EntropySourceId;
50+
groupIndex: number;
5651
}) => Promise<Account[]>;
5752
};
53+
54+
/**
55+
* A BIP-44 provider is a provider that can provide BIP-44 compatible accounts.
56+
*
57+
* Note: This is an alias for the `AccountProvider` type, but with a more specific
58+
* type for the account.
59+
*/
60+
export type Bip44AccountProvider = AccountProvider<
61+
Bip44Account<KeyringAccount>
62+
>;

0 commit comments

Comments
 (0)