import type { TypedTransaction, TypedTxData } from "@ethereumjs/tx"; import type { MessageTypes, TypedMessage } from "@metamask/eth-sig-util"; import type { Hex } from "@metamask/utils"; import type { QrKeyringBridge, SerializedUR } from "./qr-keyring.cjs"; export declare const SUPPORTED_UR_TYPE: { CRYPTO_HDKEY: string; CRYPTO_ACCOUNT: string; ETH_SIGNATURE: string; }; export declare enum DeviceMode { HD = "hd", ACCOUNT = "account" } /** * Common details for the device source, which can be either a CryptoAccount or CryptoHDKey. */ export type CommonDeviceDetails = { /** * Value take out from the device note field, if available. */ keyringAccount: string; /** * The name of the device */ name: string; /** * The device fingerprint, hex-encoded */ xfp: string; /** * Indexes of the accounts derived from the device * in the form of a map from address to index */ indexes: Record; }; /** * Details for the HD mode of the Device. This mode derives * accounts from a root public key (xpub) and a derivation path. */ export type HDModeDeviceDetails = { /** * The device mode is HD, indicating that it derives accounts from a * root public key (xpub) and a derivation path. */ keyringMode: DeviceMode.HD; /** * The xpub of the HD key */ xpub: string; /** * The derivation path of the HD key */ hdPath: string; /** * The path used to derive child accounts */ childrenPath: string; }; /** * Details for the Account mode of the Device. This mode derives * accounts from a set of addresses and their corresponding paths. */ export type AccountModeDeviceDetails = { /** * The device mode is ACCOUNT, indicating that it derives accounts from * a set of addresses and their corresponding paths. */ keyringMode: DeviceMode.ACCOUNT; /** * The derivation paths for each hex-encoded address in the device */ paths: Record; }; /** * An address with its corresponding index. */ export type IndexedAddress = { address: Hex; index: number; }; /** * The details of the source CryptoAccount or CryptoHDKey * that the Device uses to derive accounts. */ export type DeviceDetails = CommonDeviceDetails & (HDModeDeviceDetails | AccountModeDeviceDetails); export type DeviceOptions = { /** * The requestScan function to scan the QR code */ requestScan: QrKeyringBridge['requestScan']; /** * The source of the device, which can be of type `DeviceDetails`, * `string`, or `SerializedUR`. * * When a `string` or `SerializedUR` is provided, the Device will * initialize itself from the UR. */ source: DeviceDetails | string | SerializedUR; }; export declare class Device { #private; /** * Create a new Device instance. * * @param options - The options for the Device, including the requestScan function * and the source of the device details. * @param options.requestScan - The function to request a scan of the QR code. * @param options.source - The source of the device details, which can be a * UR string, a `SerializedUR`, or a `DeviceDetails` object. */ constructor({ requestScan, source }: DeviceOptions); /** * Derive an address from the source at a given index * * @param index - The index to derive the address from * @returns The derived address in hex format * @throws Will throw an error if the source is not initialized */ addressFromIndex(index: number): Hex; /** * Retrieve the path of an address derived from the source. * * @param address - The address to retrieve the path for * @returns The path of the address */ pathFromAddress(address: Hex): string; /** * Get a page of addresses derived from the source. * * @param page - The page number to retrieve * @param pageSize - The number of addresses per page * @returns An array of IndexedAddress objects, each containing the address and its index * @throws Will throw an error if the source is not initialized */ getAddressesPage(page: number, pageSize?: number): IndexedAddress[]; /** * Retrieve the details of the paired device. * * @returns Thea paired device details */ getDeviceDetails(): DeviceDetails; /** * Sign a transaction. This is equivalent to the `eth_signTransaction` * Ethereum JSON-RPC method. See the Ethereum JSON-RPC API documentation for * more details. * * @param address - The address of the account to use for signing. * @param transaction - The transaction to sign. * @returns The signed transaction. */ signTransaction(address: Hex, transaction: TypedTransaction): Promise; /** * Sign a message. This is equivalent to the `eth_signTypedData` v4 Ethereum * JSON-RPC method. * * @param address - The address of the account to use for signing. * @param data - The data to sign. * @returns The signed message. */ signTypedData(address: Hex, data: TypedMessage): Promise; /** * Sign a message. This is equivalent to the `eth_sign` Ethereum JSON-RPC * method, which is exposed by MetaMask as the method `personal_sign`. See * the Ethereum JSON-RPC API documentation for more details. * * For more information about this method and why we call it `personal_sign`, * see the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}. * * @param address - The address of the account to use for signing. * @param message - The message to sign. * @returns The signed message. */ signPersonalMessage(address: Hex, message: Hex): Promise; } //# sourceMappingURL=device.d.cts.map