UNPKG

eth-onekey-bridge-keyring

Version:
87 lines 3.17 kB
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 type { Hex } from "@metamask/utils"; import type { ConnectSettings } from "@onekeyfe/hd-core"; import HDKey from "hdkey"; import type { OneKeyBridge } from "./onekey-bridge.mjs"; export type AccountDetails = { index?: number; hdPath: string; passphraseState?: string | undefined; }; export type AccountPageEntry = { address: string; balance: number | null; index: number; }; export type AccountPage = AccountPageEntry[]; export type OneKeyControllerOptions = { hdPath?: string; accounts?: Hex[]; accountDetails?: Readonly<Record<string, AccountDetails>>; page?: number; passphraseState?: string; }; export type OneKeyControllerState = { hdPath: string; accounts: string[]; accountDetails: Record<string, AccountDetails>; page: number; passphraseState?: string; }; export declare class OneKeyKeyring implements Keyring { #private; readonly type: string; static type: string; page: number; perPage: number; unlockedAccount: number; hdk: HDKey; accounts: readonly Hex[]; accountDetails: Record<string, AccountDetails>; passphraseState: string | undefined; hdPath: string; readonly bridge: OneKeyBridge; constructor({ bridge }: { bridge: OneKeyBridge; }); init(): Promise<void>; destroy(): Promise<void>; serialize(): Promise<OneKeyControllerState>; deserialize(state: OneKeyControllerOptions): Promise<void>; getModel(): string | undefined; setAccountToUnlock(index: number): void; setHdPath(hdPath: string): void; lock(): void; isUnlocked(): boolean; unlock(): Promise<string>; addAccounts(numberOfAccounts?: number): Promise<Hex[]>; getName(): string; getFirstPage(): Promise<AccountPage>; getNextPage(): Promise<AccountPage>; getPreviousPage(): Promise<AccountPage>; getAccounts(): Promise<Hex[]>; removeAccount(address: string): void; updateTransportMethod(transportType: ConnectSettings['env']): Promise<void>; /** * Signs a transaction using OneKey. * * Accepts either an ethereumjs-tx or @ethereumjs/tx transaction, and returns * the same type. * * @param address - Hex string address. * @param tx - Instance of either new-style or old-style ethereumjs transaction. * @returns The signed transaction, an instance of either new-style or old-style * ethereumjs transaction. */ signTransaction(address: Hex, tx: TypedTransaction): Promise<TypedTransaction>; signMessage(withAccount: string, data: string): Promise<string>; signPersonalMessage(withAccount: string, message: string): Promise<string>; signTypedData<Types extends MessageTypes>(address: string, data: TypedMessage<Types>, { version }: { version?: SignTypedDataVersion; }): Promise<string>; forgetDevice(): void; } //# sourceMappingURL=onekey-keyring.d.mts.map