@metamask/eth-ledger-bridge-keyring
Version:
A MetaMask compatible keyring, for ledger hardware wallets
84 lines • 3.31 kB
text/typescript
import { type TypedTransaction } from "@ethereumjs/tx";
import type { MessageTypes, TypedMessage } from "@metamask/eth-sig-util";
import { SignTypedDataVersion } from "@metamask/eth-sig-util";
import type { Keyring } from "@metamask/keyring-utils";
import { Hex } from "@metamask/utils";
import type OldEthJsTransaction from "ethereumjs-tx";
import HDKey from "hdkey";
import { LedgerBridge, LedgerBridgeOptions } from "./ledger-bridge.mjs";
declare enum NetworkApiUrls {
Ropsten = "https://api-ropsten.etherscan.io",
Kovan = "https://api-kovan.etherscan.io",
Rinkeby = "https://api-rinkeby.etherscan.io",
Mainnet = "https://api.etherscan.io"
}
export type AccountPageEntry = {
address: string;
balance: number | null;
index: number;
};
export type AccountPage = AccountPageEntry[];
export type AccountDetails = {
index?: number;
bip44?: boolean;
hdPath?: string;
};
export type LedgerBridgeKeyringOptions = {
hdPath: string;
accounts: Hex[];
deviceId: string;
accountDetails: Readonly<Record<Hex, AccountDetails>>;
accountIndexes: Readonly<Record<Hex, number>>;
implementFullBIP44: boolean;
};
export type LedgerKeyringSerializedState = Partial<LedgerBridgeKeyringOptions>;
export declare class LedgerKeyring implements Keyring {
#private;
static type: string;
deviceId: string;
readonly type: string;
page: number;
perPage: number;
unlockedAccount: number;
accounts: readonly Hex[];
accountDetails: Record<string, AccountDetails>;
hdk: HDKey;
hdPath: string;
paths: Record<string, number>;
network: NetworkApiUrls;
implementFullBIP44: boolean;
bridge: LedgerBridge<LedgerBridgeOptions>;
constructor({ bridge }: {
bridge: LedgerBridge<LedgerBridgeOptions>;
});
init(): Promise<void>;
destroy(): Promise<void>;
serialize(): Promise<Omit<LedgerKeyringSerializedState, 'accountIndexes'>>;
deserialize(opts: LedgerKeyringSerializedState): Promise<void>;
setDeviceId(deviceId: string): void;
getDeviceId(): string;
isUnlocked(): boolean;
isConnected(): boolean;
setAccountToUnlock(index: number): void;
setHdPath(hdPath: string): void;
unlock(hdPath?: string, updateHdk?: boolean): Promise<Hex>;
addAccounts(amount: number): Promise<Hex[]>;
getName(): string;
getFirstPage(): Promise<AccountPage>;
getNextPage(): Promise<AccountPage>;
getPreviousPage(): Promise<AccountPage>;
getAccounts(): Promise<Hex[]>;
removeAccount(address: string): void;
attemptMakeApp(): Promise<boolean>;
updateTransportMethod(transportType: string): Promise<boolean>;
signTransaction(address: Hex, tx: TypedTransaction | OldEthJsTransaction): Promise<TypedTransaction | OldEthJsTransaction>;
signMessage(withAccount: Hex, data: string): Promise<string>;
signPersonalMessage(withAccount: Hex, message: string): Promise<string>;
unlockAccountByAddress(address: Hex): Promise<string | undefined>;
signTypedData<Version extends SignTypedDataVersion.V4, Types extends MessageTypes, Options extends {
version?: Version;
}>(withAccount: Hex, data: TypedMessage<Types>, options?: Options): Promise<string>;
forgetDevice(): void;
}
export {};
//# sourceMappingURL=ledger-keyring.d.mts.map