import { AccountData, AminoSignResponse, StdSignDoc } from "@cosmjs/amino"; import { SignDoc } from "cosmjs-types/cosmos/tx/v1beta1/tx"; import { DirectSignResponse } from "@cosmjs/proto-signing"; import { Observer } from "../utils"; import { Signer, SigningMode } from "./signer"; /** * Enum that represents the connection status of a PrivateKeyProvider. */ export declare enum PrivateKeyProviderStatus { NotConnected = 0, Connecting = 1, Connected = 2, Disconnecting = 3 } /** * Enum that represents the supported key types. */ export declare enum PrivateKeyType { Secp256k1 = 0 } /** * Interface representing a private key. */ export interface PrivateKey { type: PrivateKeyType; key: Uint8Array; } /** * Class that represents a secp256k1 key provider. */ export declare abstract class PrivateKeyProvider { private observerManager; protected keyProviderStatus: PrivateKeyProviderStatus; addStatusListener(observer: Observer): void; removeStatusListener(observer: Observer): void; protected updateStatus(newStatus: PrivateKeyProviderStatus): void; protected assertConnected(): void; get status(): PrivateKeyProviderStatus; /** * Connects to the Secp256k1 key provider. */ abstract connect(): Promise; /** * Disconnects from the Secp256k1 key provider. */ abstract disconnect(): Promise; /** * Gets the Secp256k1 private key. * If the key provider is not connected this function should throw an error. */ abstract getPrivateKey(): Promise; } /** * Implementation of PrivateKeyProvider that provides a private key * from an in memory private key. */ export declare class Secp256k1KeyProvider extends PrivateKeyProvider { private readonly privateKey; /** * Default constructor. * @param privateKey - Hex encoded private key, or raw private key bytes. */ constructor(privateKey: string | Uint8Array); connect(): Promise; disconnect(): Promise; getPrivateKey(): Promise; } /** * Options to customize some parameters of PrivateKeySigner. */ export interface PrivateKeySignerOptions { /** * Prefix used to generate the bech32 address. */ prefix?: string; } /** * Signer that uses a private key provided from a PrivateKeyProvider * to sign a transaction. */ export declare class PrivateKeySigner extends Signer { private keyProviderStatusListener; private keyProvider; private readonly signMode; private readonly prefix; private currentAccount?; private _privateKey?; private aminoSigner?; private directSigner?; /** * Build the signer from a secp256k1 private key. * @param privateKey - Hex encoded private key, or raw private key bytes. * @param signingMode - Hex encoded private key, or raw private key bytes. * @param options - Signer options. */ static fromSecp256k1(privateKey: string | Uint8Array, signingMode: SigningMode, options?: PrivateKeySignerOptions): PrivateKeySigner; /** * Build the signer with a randomly generated secp256k1 private key. * @param signingMode - Signer sign mode, this can be {@link SigningMode.AMINO} * or {@link SigningMode.DIRECT}. * @param options - Signer options. */ static generate(signMode: SigningMode, options?: PrivateKeySignerOptions): PrivateKeySigner; constructor(provider: PrivateKeyProvider, signingMode: SigningMode, options?: PrivateKeySignerOptions); private clearSessionFields; connect(): Promise; disconnect(): Promise; getAccounts(): Promise; getCurrentAccount(): Promise; signAmino(signerAddress: string, signDoc: StdSignDoc): Promise; signDirect(signerAddress: string, signDoc: SignDoc): Promise; get signingMode(): SigningMode; get privateKey(): PrivateKey; private static keyProviderStatusToSignerStatus; }