UNPKG

@metamask/account-api

Version:
1 lines 1.97 kB
{"version":3,"file":"provider.mjs","sourceRoot":"","sources":["../../src/api/provider.ts"],"names":[],"mappings":"","sourcesContent":["import type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\n\nimport type { Bip44Account } from './bip44';\n\n/**\n * An account provider is reponsible of providing accounts to an account group.\n */\nexport type AccountProvider<Account extends KeyringAccount> = {\n /**\n * Gets an account for a given ID.\n *\n * @returns An account, or undefined if not found.\n */\n getAccount: (id: Account['id']) => Account | undefined;\n\n /**\n * Gets all accounts for this provider.\n *\n * @returns A list of all account for this provider.\n */\n getAccounts: () => Account[];\n\n /**\n * Creates accounts for a given entropy source and a given group\n * index.\n *\n * @param options - Options.\n * @param options.entropySource - Entropy source to use.\n * @param options.groupIndex - Group index to use.\n * @returns The list of created accounts.\n */\n createAccounts: (options: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }) => Promise<Account[]>;\n\n /**\n * Discover accounts for a given entropy source and a given group\n * index.\n *\n * NOTE: This method needs to also create the discovered accounts.\n *\n * @param options - Options.\n * @param options.entropySource - Entropy source to use.\n * @param options.groupIndex - Group index to use.\n * @returns The list of discovered and created accounts.\n */\n discoverAccounts: (options: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }) => Promise<Account[]>;\n};\n\n/**\n * A BIP-44 provider is a provider that can provide BIP-44 compatible accounts.\n *\n * Note: This is an alias for the `AccountProvider` type, but with a more specific\n * type for the account.\n */\nexport type Bip44AccountProvider = AccountProvider<\n Bip44Account<KeyringAccount>\n>;\n"]}