import type { TypedTransaction, TypedTxData } from "@ethereumjs/tx"; import type { TypedMessage, MessageTypes } from "@metamask/eth-sig-util"; import type { Keyring } from "@metamask/keyring-utils"; import type { Hex } from "@metamask/utils"; import { DeviceMode } from "./device.cjs"; import type { DeviceDetails, IndexedAddress } from "./device.cjs"; export declare const QR_KEYRING_TYPE = "QR Hardware Wallet Device"; export declare enum QrScanRequestType { /** * Request a scan for a QR code containing a UR * with information related to a hardware wallet. */ PAIR = "pair", /** * Request a scan for a QR code containing a * UR-encoded transaction signature. */ SIGN = "sign" } export type QrSignatureRequest = { requestId: string; payload: SerializedUR; requestTitle?: string; requestDescription?: string; }; export type QrScanRequest = { type: QrScanRequestType; request?: QrSignatureRequest; }; export type SerializedUR = { type: string; cbor: string; }; export type QrKeyringBridge = { requestScan: (request: QrScanRequest) => Promise; }; export type QrKeyringOptions = { ur?: string; bridge: QrKeyringBridge; }; /** * The state of the QrKeyring * * @property accounts - The accounts in the QrKeyring */ export type SerializedQrKeyringState = { version?: number; accounts?: string[]; currentAccount?: number; } & ({ initialized?: false; } | ({ initialized: true; } & DeviceDetails)); /** * Returns the default serialized state of the QrKeyring. * * @returns The default serialized state. */ export declare const getDefaultSerializedQrKeyringState: () => SerializedQrKeyringState; export declare class QrKeyring implements Keyring { #private; static type: string; readonly type = "QR Hardware Wallet Device"; readonly bridge: QrKeyringBridge; constructor(options: QrKeyringOptions); /** * Serializes the QrKeyring state * * @returns The serialized state */ serialize(): Promise; /** * Deserializes the QrKeyring state * * @param state - The serialized state to deserialize */ deserialize(state: SerializedQrKeyringState): Promise; /** * Get the derivation path for a given address. * * @param address - The address to get the derivation path for. * @returns The derivation path for the address, or undefined if the device * is not paired or the address is not found. */ getPathFromAddress(address: Hex): string | undefined; /** * Adds accounts to the QrKeyring * * @param accountsToAdd - The number of accounts to add * @returns The accounts added */ addAccounts(accountsToAdd: number): Promise; /** * Gets the accounts in the QrKeyring * * @returns The accounts in the QrKeyring */ getAccounts(): Promise; /** * Remove an account from the keyring * * @param address - The address of the account to remove */ removeAccount(address: Hex): void; /** * Pair a QR-based Hardware Device from a CBOR encoded UR to the QrKeyring * * @param ur - The CBOR encoded UR */ pairDevice(ur: string | SerializedUR): void; /** * Sets the next account index to unlock * * @param index - The index of the account to unlock */ setAccountToUnlock(index: number): void; /** * Get the name of the paired device or the keyring type * if unavailable. * * @returns The name of the paired device or the keyring type. */ getName(): string; /** * Get the mode of the paired device. * * @returns The device mode, or undefined if no device is paired. */ getMode(): DeviceMode | undefined; /** * Fetch the first page of accounts. If the keyring is not currently initialized, * it will trigger a scan request to initialize it. * * @returns The first page of accounts as an array of Hex strings. */ getFirstPage(): Promise; /** * Fetch the next page of accounts. If the keyring is not currently initialized, * it will trigger a scan request to initialize it. * * @returns The next page of accounts as an array of IndexedAddress objects. */ getNextPage(): Promise; /** * Fetch the previous page of accounts. If the keyring is not currently initialized, * it will trigger a scan request to initialize it. * * @returns The previous page of accounts as an array of IndexedAddress objects. */ getPreviousPage(): Promise; /** * Fetch the current page of accounts. If the keyring is not currently initialized, * it will trigger a scan request to initialize it. * * @returns The current page of accounts as an array of IndexedAddress objects. */ getCurrentPage(): Promise; /** * Clear the keyring state and forget any paired device or accounts. */ forgetDevice(): Promise; /** * 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=qr-keyring.d.cts.map