UNPKG

@metamask/multichain-account-service

Version:
128 lines 5.22 kB
import type { Bip44Account } from "@metamask/account-api"; import type { AccountProvider } from "@metamask/account-api"; import type { EntropySourceId, KeyringAccount } from "@metamask/keyring-api"; import type { MultichainAccountGroup } from "./MultichainAccountGroup.mjs"; import { MultichainAccountWallet } from "./MultichainAccountWallet.mjs"; import type { MultichainAccountServiceMessenger } from "./types.mjs"; export declare const serviceName = "MultichainAccountService"; /** * The options that {@link MultichainAccountService} takes. */ type MultichainAccountServiceOptions<Account extends Bip44Account<KeyringAccount>> = { messenger: MultichainAccountServiceMessenger; providers?: AccountProvider<Account>[]; }; /** Reverse mapping object used to map account IDs and their wallet/multichain account. */ type AccountContext<Account extends Bip44Account<KeyringAccount>> = { wallet: MultichainAccountWallet<Account>; group: MultichainAccountGroup<Account>; }; /** * Service to expose multichain accounts capabilities. */ export declare class MultichainAccountService { #private; /** * The name of the service. */ name: typeof serviceName; /** * Constructs a new MultichainAccountService. * * @param options - The options. * @param options.messenger - The messenger suited to this * MultichainAccountService. * @param options.providers - Optional list of account * providers. */ constructor({ messenger, providers, }: MultichainAccountServiceOptions<Bip44Account<KeyringAccount>>); /** * Initialize the service and constructs the internal reprensentation of * multichain accounts and wallets. */ init(): void; /** * Gets the account's context which contains its multichain wallet and * multichain account group references. * * @param id - Account ID. * @returns The account context if any, undefined otherwise. */ getAccountContext(id: KeyringAccount['id']): AccountContext<Bip44Account<KeyringAccount>> | undefined; /** * Gets a reference to the multichain account wallet matching this entropy source. * * @param options - Options. * @param options.entropySource - The entropy source of the multichain account. * @throws If none multichain account match this entropy. * @returns A reference to the multichain account wallet. */ getMultichainAccountWallet({ entropySource, }: { entropySource: EntropySourceId; }): MultichainAccountWallet<Bip44Account<KeyringAccount>>; /** * Gets an array of all multichain account wallets. * * @returns An array of all multichain account wallets. */ getMultichainAccountWallets(): MultichainAccountWallet<Bip44Account<KeyringAccount>>[]; /** * Gets a reference to the multichain account group matching this entropy source * and a group index. * * @param options - Options. * @param options.entropySource - The entropy source of the multichain account. * @param options.groupIndex - The group index of the multichain account. * @throws If none multichain account match this entropy source and group index. * @returns A reference to the multichain account. */ getMultichainAccountGroup({ entropySource, groupIndex, }: { entropySource: EntropySourceId; groupIndex: number; }): MultichainAccountGroup<Bip44Account<KeyringAccount>>; /** * Gets all multichain account groups for a given entropy source. * * @param options - Options. * @param options.entropySource - The entropy source to query. * @throws If no multichain accounts match this entropy source. * @returns A list of all multichain accounts. */ getMultichainAccountGroups({ entropySource, }: { entropySource: EntropySourceId; }): MultichainAccountGroup<Bip44Account<KeyringAccount>>[]; /** * Creates the next multichain account group. * * @param options - Options. * @param options.entropySource - The wallet's entropy source. * @returns The next multichain account group. */ createNextMultichainAccountGroup({ entropySource, }: { entropySource: EntropySourceId; }): Promise<MultichainAccountGroup<Bip44Account<KeyringAccount>>>; /** * Creates a multichain account group. * * @param options - Options. * @param options.groupIndex - The group index to use. * @param options.entropySource - The wallet's entropy source. * @returns The multichain account group for this group index. */ createMultichainAccountGroup({ groupIndex, entropySource, }: { groupIndex: number; entropySource: EntropySourceId; }): Promise<MultichainAccountGroup<Bip44Account<KeyringAccount>>>; /** * Align all multichain account wallets. */ alignWallets(): Promise<void>; /** * Align a specific multichain account wallet. * * @param entropySource - The entropy source of the multichain account wallet. */ alignWallet(entropySource: EntropySourceId): Promise<void>; } export {}; //# sourceMappingURL=MultichainAccountService.d.mts.map