import { StateParams, Delegation, MixNodeBond, MixNode, GatewayBond, Gateway, SendRequest } from "./types"; import { DirectSecp256k1HdWallet, EncodeObject } from "@cosmjs/proto-signing"; import { coin, Coin, coins, StdFee } from "@cosmjs/stargate"; import { ExecuteResult, InstantiateOptions, InstantiateResult, MigrateResult, UploadMeta, UploadResult } from "@cosmjs/cosmwasm-stargate"; import { CoinMap, displayAmountToNative, MappedCoin, nativeCoinToDisplay, printableBalance, printableCoin, nativeToPrintable } from "./currency"; import { nymGasLimits, nymGasPrice } from "./stargate-helper"; import { BroadcastTxSuccess } from "@cosmjs/stargate"; export declare const VALIDATOR_API_PORT = "8080"; export declare const VALIDATOR_API_GATEWAYS = "v1/gateways"; export declare const VALIDATOR_API_MIXNODES = "v1/mixnodes"; export { coins, coin }; export { Coin }; export { displayAmountToNative, nativeCoinToDisplay, printableCoin, printableBalance, nativeToPrintable, MappedCoin, CoinMap }; export { nymGasLimits, nymGasPrice }; export default class ValidatorClient { private readonly client; private readonly contractAddress; private readonly denom; private failedRequests; private gatewayCache; private mixNodesCache; private readonly prefix; urls: string[]; private constructor(); static connect(contractAddress: string, mnemonic: string, urls: string | string[], prefix: string): Promise; static connectForQuery(contractAddress: string, urls: string | string[], prefix: string): Promise; private static ensureArray; handleRequestFailure(error: Error): Promise; private changeValidator; static shuffleArray(arr: T[]): T[]; private static moveArrayHeadToBack; get address(): string; /** * TODO: re-enable this once we move back to client-side wallets running on people's machines * instead of the web wallet. * * Loads a named mnemonic from the system's keystore. * * @param keyPath the name of the key in the keystore * @returns the mnemonic as a string */ /** * Generates a random mnemonic, useful for creating new accounts. * @returns a fresh mnemonic. */ static randomMnemonic(): string; /** * @param mnemonic A mnemonic from which to generate a public/private keypair. * @returns the address for this client wallet */ static mnemonicToAddress(mnemonic: string, prefix: string): Promise; static buildWallet(mnemonic: string, prefix: string): Promise; getBalance(address: string): Promise; getStateParams(): Promise; /** * Get or refresh the list of mixnodes in the network. * * @returns an array containing all known `MixNodeBond`s. * * TODO: We will want to put this puppy on a timer, but for the moment we can * just get things strung together and refresh it manually. */ refreshMixNodes(): Promise; /** * Get or refresh the list of mixnodes in the network from validator-api * * @returns an array containing all known `MixNodeBond`s. * * TODO: We will want to put this puppy on a timer, but for the moment we can * just get things strung together and refresh it manually. */ refreshValidatorAPIMixNodes(): Promise; /** * Get mixnodes from the local client cache. * * @returns an array containing all `MixNodeBond`s in the client's local cache. */ getMixNodes(): MixNodeBond[]; /** * Generate a minimum gateway bond required to create a fresh mixnode. * * @returns a `Coin` instance containing minimum amount of coins to stake a gateway. */ minimumMixnodeBond(): Promise; /** * Announce a mixnode, paying a fee. */ bondMixnode(mixNode: MixNode, bond: Coin): Promise; /** * Unbond a mixnode, removing it from the network and reclaiming staked coins */ unbondMixnode(): Promise; /** * Delegates specified amount of stake to particular mixnode. * * @param mixIdentity identity of the node to which the delegation should be applied * @param amount desired amount of coins to delegate to the node */ delegateToMixnode(mixIdentity: string, amount: Coin): Promise; /** * Removes stake delegation from a particular mixnode. * * @param mixIdentity identity of the node from which the delegation should get removed */ removeMixnodeDelegation(mixIdentity: string): Promise; /** * Delegates specified amount of stake to particular gateway. * * @param gatewayIdentity identity of the gateway to which the delegation should be applied * @param amount desired amount of coins to delegate to the node */ delegateToGateway(gatewayIdentity: string, amount: Coin): Promise; /** * Removes stake delegation from a particular gateway. * * @param gatewayIdentity identity of the gateway from which the delegation should get removed */ removeGatewayDelegation(gatewayIdentity: string): Promise; /** * Checks whether there is already a bonded mixnode associated with this client's address */ ownsMixNode(): Promise; /** * Checks whether there is already a bonded gateway associated with this client's address */ ownsGateway(): Promise; /** * Get or refresh the list of gateways in the network. * * @returns an array containing all known `GatewayBond`s. * * TODO: Similarly to mixnode bonds, this should probably be put on a timer somewhere. */ refreshGateways(): Promise; /** * Get or refresh the list of gateways in the network from validator-api * * @returns an array containing all known `GatewayBond`s. * * TODO: Similarly to mixnode bonds, this should probably be put on a timer somewhere. */ refreshValidatorAPIGateways(): Promise; /** * Get gateways from the local client cache. * * @returns an array containing all `GatewayBond`s in the client's local cache. */ getGateways(): GatewayBond[]; /** * Generate a minimum gateway bond required to create a fresh gateway. * * @returns a `Coin` instance containing minimum amount of coins to stake a gateway. */ minimumGatewayBond(): Promise; /** * Announce a gateway, paying a fee. */ bondGateway(gateway: Gateway, bond: Coin): Promise; /** * Unbond a gateway, removing it from the network and reclaiming staked coins */ unbondGateway(): Promise; updateStateParams(newParams: StateParams): Promise; /** * Gets list of all delegations towards particular mixnode. * * @param mixIdentity identity of the node to which the delegation was sent */ getMixDelegations(mixIdentity: string): Promise; /** * Checks value of delegation of given client towards particular mixnode. * * @param mixIdentity identity of the node to which the delegation was sent * @param delegatorAddress address of the client who delegated the stake */ getMixDelegation(mixIdentity: string, delegatorAddress: string): Promise; /** * Gets list of all delegations towards particular gateway. * * @param gatewayIdentity identity of the gateway to which the delegation was sent */ getGatewayDelegations(gatewayIdentity: string): Promise; /** * Checks value of delegation of given client towards particular gateway. * * @param gatewayIdentity identity of the gateway to which the delegation was sent * @param delegatorAddress address of the client who delegated the stake */ getGatewayDelegation(gatewayIdentity: string, delegatorAddress: string): Promise; /** * Send funds from one address to another. */ send(senderAddress: string, recipientAddress: string, coins: readonly Coin[], memo?: string): Promise; /** * Send funds multiple times from one address to another in a single block. */ sendMultiple(senderAddress: string, data: SendRequest[], memo?: string): Promise; executeCustom(signerAddress: string, messages: readonly EncodeObject[], customFee: StdFee, memo?: string): Promise; upload(senderAddress: string, wasmCode: Uint8Array, meta?: UploadMeta, memo?: string): Promise; instantiate(senderAddress: string, codeId: number, initMsg: Record, label: string, options?: InstantiateOptions): Promise; migrate(senderAddress: string, contractAddress: string, codeId: number, migrateMsg: Record, memo?: string): Promise; }