@metamask/eth-ledger-bridge-keyring
Version:
A MetaMask compatible keyring, for ledger hardware wallets
108 lines • 4.72 kB
text/typescript
import type Transport from "@ledgerhq/hw-transport";
import { GetPublicKeyParams, GetPublicKeyResponse, LedgerBridge, LedgerSignMessageParams, LedgerSignMessageResponse, LedgerSignTransactionParams, LedgerSignTransactionResponse, LedgerSignTypedDataParams, LedgerSignTypedDataResponse } from "./ledger-bridge.mjs";
import { TransportMiddleware } from "./ledger-transport-middleware.mjs";
import { GetAppNameAndVersionResponse, LedgerMobileBridgeOptions } from "./type.mjs";
export type MobileBridge = LedgerBridge<LedgerMobileBridgeOptions> & {
getAppNameAndVersion(): Promise<GetAppNameAndVersionResponse>;
openEthApp(): Promise<void>;
closeApps(): Promise<void>;
};
/**
* LedgerMobileBridge is a bridge between the LedgerKeyring and the LedgerTransportMiddleware.
*/
export declare class LedgerMobileBridge implements MobileBridge {
#private;
isDeviceConnected: boolean;
constructor(transportMiddleware: TransportMiddleware, opts?: LedgerMobileBridgeOptions);
/**
* Method to initializes the keyring.
* Mobile ledger doesnt not require init.
*
* @returns A promise that will resolve once the bridge is initialized.
*/
init(): Promise<void>;
/**
* Method to destroy the keyring.
* It will dispose the transportmiddleware and set isDeviceConnected to false.
*/
destroy(): Promise<void>;
/**
* Method to sign a string Message.
* Sending the string message to the device and returning the signed message.
*
* @param params - An object contains hdPath and message.
* @param params.hdPath - The BIP 32 path of the account.
* @param params.message - The message to sign.
* @returns Retrieve v, r, s from the signed message.
*/
deviceSignMessage({ hdPath, message, }: LedgerSignMessageParams): Promise<LedgerSignMessageResponse>;
/**
* Method to sign a EIP712 Message.
* Sending the typed data message to the device and returning the signed message.
*
* @param params - An object contains hdPath, domainSeparatorHex and hashStructMessageHex.
* @param params.hdPath - The BIP 32 path of the account.
* @param params.message - The EIP712 message to sign.
* @returns Retrieve v, r, s from the signed message.
*/
deviceSignTypedData({ hdPath, message, }: LedgerSignTypedDataParams): Promise<LedgerSignTypedDataResponse>;
/**
* Method to sign a transaction
* Sending the hexadecimal transaction message to the device and returning the signed transaction.
*
* @param params - An object contains tx, hdPath.
* @param params.tx - The raw ethereum transaction in hexadecimal to sign.
* @param params.hdPath - The BIP 32 path of the account.
* @returns Retrieve v, r, s from the signed transaction.
*/
deviceSignTransaction({ tx, hdPath, }: LedgerSignTransactionParams): Promise<LedgerSignTransactionResponse>;
/**
* Method to retrieve the ethereum address for a given BIP 32 path.
*
* @param params - An object contains hdPath.
* @param params.hdPath - The BIP 32 path of the account.
* @returns An object contains publicKey, address and chainCode.
*/
getPublicKey({ hdPath, }: GetPublicKeyParams): Promise<GetPublicKeyResponse>;
/**
* Method to retrieve the current configuration.
*
* @returns Retrieve current configuration.
*/
getOptions(): Promise<LedgerMobileBridgeOptions>;
/**
* Method to set the current configuration.
*
* @param opts - An configuration object.
*/
setOptions(opts: LedgerMobileBridgeOptions): Promise<void>;
/**
* Method to set the transport object to communicate with the device.
*
* @param transport - The communication interface with the Ledger hardware wallet. There are different kind of transports based on the technology (channels like U2F, HID, Bluetooth, Webusb).
* @returns Retrieve boolean.
*/
updateTransportMethod(transport: Transport): Promise<boolean>;
/**
* Method to init eth app object on ledger device.
* This method is not supported on mobile.
*/
attemptMakeApp(): Promise<boolean>;
/**
* Method to open ethereum application on ledger device.
*
*/
openEthApp(): Promise<void>;
/**
* Method to close all running application on ledger device.
*
*/
closeApps(): Promise<void>;
/**
* Method to retrieve the name and version of the running application in ledger device.
*
* @returns An object contains appName and version.
*/
getAppNameAndVersion(): Promise<GetAppNameAndVersionResponse>;
}
//# sourceMappingURL=ledger-mobile-bridge.d.mts.map