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

## [Unreleased]

### Changed

- **BREAKING:** Use new `createAccounts` options for `AccountsProvider.createAccounts` ([#462](https://github.com/MetaMask/accounts/pull/462))
- This will allow to use various ways of constructing accounts (e.g. multiple indexes at once).

## [0.12.0]

### Changed
Expand Down
26 changes: 15 additions & 11 deletions packages/account-api/src/api/provider.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';
import {
type CreateAccountOptions,
type EntropySourceId,
type KeyringAccount,
type KeyringCapabilities,
} from '@metamask/keyring-api';

import type { Bip44Account } from './bip44';

/**
* An account provider is reponsible of providing accounts to an account group.
*/
export type AccountProvider<Account extends KeyringAccount> = {
/**
* Capabilities supported by this provider.
*/
get capabilities(): KeyringCapabilities;

/**
* Gets an account for a given ID.
*
Expand All @@ -21,18 +31,12 @@ export type AccountProvider<Account extends KeyringAccount> = {
getAccounts: () => Account[];

/**
* Creates accounts for a given entropy source and a given group
* index.
* Creates accounts according to the given options.
*
* @param options - Options.
* @param options.entropySource - Entropy source to use.
* @param options.groupIndex - Group index to use.
* @param options - Create accounts options.
* @returns The list of created accounts.
*/
createAccounts: (options: {
entropySource: EntropySourceId;
groupIndex: number;
}) => Promise<Account[]>;
createAccounts: (options: CreateAccountOptions) => Promise<Account[]>;

/**
* Discover accounts for a given entropy source and a given group
Expand All @@ -54,7 +58,7 @@ export type AccountProvider<Account extends KeyringAccount> = {
/**
* A BIP-44 provider is a provider that can provide BIP-44 compatible accounts.
*
* Note: This is an alias for the `AccountProvider` type, but with a more specific
* NOTE: This is an alias for the `AccountProvider` type, but with a more specific
* type for the account.
*/
export type Bip44AccountProvider = AccountProvider<
Expand Down
Loading