import { AccountData, DirectSignResponse, OfflineDirectSigner } from "@cosmjs/proto-signing"; import { AminoSignResponse, StdSignDoc, OfflineAminoSigner } from "@cosmjs/amino"; import { SignDoc } from "cosmjs-types/cosmos/tx/v1beta1/tx"; import { Observer } from "../utils/observermanager"; /** * Represents the various signing modes that can be supported by signers. */ export declare enum SigningMode { AMINO = 0, DIRECT = 1 } /** * Represents the possible status of a Signer. */ export declare enum SignerStatus { NotConnected = 0, Connecting = 1, Connected = 2, Disconnecting = 3 } /** * Represents a generic method that receives updates for new Signer status values. */ export type SignerObserver = Observer; /** * Represents a remote signer. */ export declare abstract class Signer implements OfflineDirectSigner, OfflineAminoSigner { private signerStatus; private observerManager; /** * Builds a new Signer instance. * @param status - Initial signer status. * @protected */ protected constructor(status: SignerStatus); /** * Updates the signer status and notifies the observers. * @param newStatus - The new signer status. * @protected */ protected updateStatus(newStatus: SignerStatus): void; /** * Checks if the signer is connected and if not throws a SignerNotConnected exception. * @protected */ protected assertConnected(): void; /** * Adds an observer that will be called each time the signer changes state. * @param observer - The observer to be called. */ addStatusListener(observer: SignerObserver): void; /** * Removes an observer so that it will not be called when the status changes. * @param observer - The observer to be removed. */ removeStatusListener(observer: SignerObserver): void; /** * Gets the current signer status. */ get status(): SignerStatus; /** * Tells whether the signer is connected or not. */ get isConnected(): boolean; /** * Returns the signing mode supported by the signer. */ abstract get signingMode(): SigningMode; /** * Connects the signer. * If the signer is already connected no actions will be performed. */ abstract connect(): Promise; /** * Disconnect the signer. * If the signer is already disconnect no actions will be performed. */ abstract disconnect(): Promise; /** * Gets the account selected by the user as the account to be used, or `undefined` if no account * has been selected yet. */ abstract getCurrentAccount(): Promise; /** * Gets all the accounts managed by the signer. * * NOTE: In some signer implementations, this method might execute asynchronously. * This means the returned promise might never complete. */ abstract getAccounts(): Promise; /** * Implements OfflineDirectSigner. */ abstract signDirect(signerAddress: string, signDoc: SignDoc): Promise; /** * Implements OfflineAminoSigner. */ abstract signAmino(signerAddress: string, signDoc: StdSignDoc): Promise; }