@metamask/eth-ledger-bridge-keyring
Version:
A MetaMask compatible keyring, for ledger hardware wallets
117 lines • 5.5 kB
text/typescript
import type Transport from "@ledgerhq/hw-transport";
import { AppConfigurationResponse, GetAppNameAndVersionResponse, GetPublicKeyParams, GetPublicKeyResponse, LedgerBridge, LedgerSignDelegationAuthorizationParams, LedgerSignDelegationAuthorizationResponse, LedgerSignMessageParams, LedgerSignMessageResponse, LedgerSignTransactionParams, LedgerSignTransactionResponse, LedgerSignTypedDataParams, LedgerSignTypedDataResponse } from "./ledger-bridge.cjs";
import { TransportMiddleware } from "./ledger-transport-middleware.cjs";
import { LedgerMobileBridgeOptions } from "./type.cjs";
export type MobileBridge = LedgerBridge<LedgerMobileBridgeOptions> & {
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>;
deviceSignDelegationAuthorization({ hdPath, chainId, contractAddress, nonce, }: LedgerSignDelegationAuthorizationParams): Promise<LedgerSignDelegationAuthorizationResponse>;
/**
* Method to sign a transaction
* Sending the hexadecimal transaction message to the device and returning the signed transaction.
*
* Tries clear-signing first. If resolution fails (e.g. no Ledger plugin for the chain or contract),
* falls back to blind signing via `signTransaction(..., null)` unless the user rejected on the device.
*
* @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>;
/**
* Method to retrieve the current configuration of the Ethereum application on the Ledger device.
*
* @returns An object containing the application configuration including blind signing support, ERC20 provisioning status, Stark support, and version.
*/
getAppConfiguration(): Promise<AppConfigurationResponse>;
}
//# sourceMappingURL=ledger-mobile-bridge.d.cts.map