@metamask/eth-ledger-bridge-keyring
Version:
A MetaMask compatible keyring, for ledger hardware wallets
98 lines • 3.54 kB
text/typescript
import type { Bip44Account } from "@metamask/account-api";
import type { KeyringAccount, EntropySourceId } from "@metamask/keyring-api";
import type { CreateAccountOptions, Keyring } from "@metamask/keyring-api/v2";
import { EthKeyringWrapper } from "@metamask/keyring-sdk/v2";
import type { AccountId, EthKeyring } from "@metamask/keyring-utils";
import type { GetAppNameAndVersionResponse, LedgerBridge, LedgerBridgeOptions } from "../ledger-bridge.cjs";
import type { AccountPage, LedgerKeyring as LegacyLedgerKeyring } from "../ledger-keyring.cjs";
/**
* Concrete {@link Keyring} adapter for {@link LedgerKeyring}.
*
* This wrapper exposes the accounts and signing capabilities of the legacy
* Ledger keyring via the unified V2 interface.
*
* All Ledger keyring accounts are BIP-44 derived from the device.
*/
export type LedgerKeyringOptions = {
legacyKeyring: LegacyLedgerKeyring;
entropySource: EntropySourceId;
};
type LedgerKeyringAsEthKeyring = LegacyLedgerKeyring & EthKeyring;
export declare class LedgerKeyring extends EthKeyringWrapper<LedgerKeyringAsEthKeyring, Bip44Account<KeyringAccount>> implements Keyring {
#private;
readonly entropySource: EntropySourceId;
constructor(options: LedgerKeyringOptions);
getAccounts(): Promise<Bip44Account<KeyringAccount>[]>;
createAccounts(options: CreateAccountOptions): Promise<Bip44Account<KeyringAccount>[]>;
/**
* Delete an account from the keyring.
*
* @param accountId - The account ID to delete.
*/
deleteAccount(accountId: AccountId): Promise<void>;
/**
* @returns The current derivation path used by the inner keyring.
*/
get hdPath(): string;
/**
* @returns The bridge instance used by the inner keyring to communicate
* with the device.
*/
get bridge(): LedgerBridge<LedgerBridgeOptions>;
/**
* @returns The device ID for the paired Ledger device.
*/
getDeviceId(): string;
/**
* Set the device ID for the paired Ledger device.
*
* @param deviceId - The device ID to set.
*/
setDeviceId(deviceId: string): void;
/**
* Set the derivation path on the inner keyring.
*
* @param hdPath - The derivation path to set.
*/
setHdPath(hdPath: string): void;
/**
* Fetch the first page of candidate addresses from the device.
*
* @returns The first page of accounts.
*/
getFirstPage(): Promise<AccountPage>;
/**
* Fetch the next page of candidate addresses from the device.
*
* @returns The next page of accounts.
*/
getNextPage(): Promise<AccountPage>;
/**
* Fetch the previous page of candidate addresses from the device.
*
* @returns The previous page of accounts.
*/
getPreviousPage(): Promise<AccountPage>;
/**
* Clear the inner keyring's device-pairing state and accounts, and reset
* the V2 account registry to keep them in sync.
*/
forgetDevice(): Promise<void>;
/**
* @returns Whether the inner keyring has an unlocked HD key.
*/
isUnlocked(): boolean;
/**
* Attempt to open the Ethereum app on the connected Ledger device.
*
* @returns Whether the app was opened.
*/
attemptMakeApp(): Promise<boolean>;
/**
* @returns The app name and version currently running on the connected
* Ledger device.
*/
getAppNameAndVersion(): Promise<GetAppNameAndVersionResponse>;
}
export {};
//# sourceMappingURL=ledger-keyring.d.cts.map