import { Log } from "./logs"; import { BroadcastMode, RestClient } from "./restclient"; import { Coin, CosmosSdkTx, JsonObject, PubKey, StdTx } from "./types"; export interface GetNonceResult { readonly accountNumber: number; readonly sequence: number; } export interface Account { /** Bech32 account address */ readonly address: string; readonly balance: ReadonlyArray; readonly pubkey: PubKey | undefined; readonly accountNumber: number; readonly sequence: number; } export interface PostTxResult { readonly logs: readonly Log[]; readonly rawLog: string; readonly data: any; /** Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex */ readonly transactionHash: string; } export interface SearchByIdQuery { readonly id: string; } export interface SearchByHeightQuery { readonly height: number; } export interface SearchBySentFromOrToQuery { readonly sentFromOrTo: string; } /** * This query type allows you to pass arbitrary key/value pairs to the backend. It is * more powerful and slightly lower level than the other search options. */ export interface SearchByTagsQuery { readonly tags: readonly { readonly key: string; readonly value: string; }[]; } export declare type SearchTxQuery = | SearchByIdQuery | SearchByHeightQuery | SearchBySentFromOrToQuery | SearchByTagsQuery; export interface SearchTxFilter { readonly minHeight?: number; readonly maxHeight?: number; } export interface Code { readonly id: number; /** Bech32 account address */ readonly creator: string; /** Hex-encoded sha256 hash of the code stored here */ readonly checksum: string; readonly source?: string; readonly builder?: string; } export interface CodeDetails extends Code { /** The original wasm bytes */ readonly data: Uint8Array; } export interface Contract { readonly address: string; readonly codeId: number; /** Bech32 account address */ readonly creator: string; readonly label: string; } export interface ContractDetails extends Contract { /** Argument passed on initialization of the contract */ readonly initMsg: object; } /** A transaction that is indexed as part of the transaction history */ export interface IndexedTx { readonly height: number; /** Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex */ readonly hash: string; /** Transaction execution error code. 0 on success. */ readonly code: number; readonly rawLog: string; readonly logs: readonly Log[]; readonly tx: CosmosSdkTx; /** The gas limit as set by the user */ readonly gasWanted?: number; /** The gas used by the execution */ readonly gasUsed?: number; /** An RFC 3339 time string like e.g. '2020-02-15T10:39:10.4696305Z' */ readonly timestamp: string; } export interface BlockHeader { readonly version: { readonly block: string; readonly app: string; }; readonly height: number; readonly chainId: string; /** An RFC 3339 time string like e.g. '2020-02-15T10:39:10.4696305Z' */ readonly time: string; } export interface Block { /** The ID is a hash of the block header (uppercase hex) */ readonly id: string; readonly header: BlockHeader; /** Array of raw transactions */ readonly txs: ReadonlyArray; } /** Use for testing only */ export interface PrivateCosmWasmClient { readonly restClient: RestClient; } export declare class CosmWasmClient { readonly restClient: RestClient; /** Any address the chain considers valid (valid bech32 with proper prefix) */ protected anyValidAddress: string | undefined; private readonly codesCache; private chainId; /** * Creates a new client to interact with a CosmWasm blockchain. * * This instance does a lot of caching. In order to benefit from that you should try to use one instance * for the lifetime of your application. When switching backends, a new instance must be created. * * @param apiUrl The URL of a Cosmos SDK light client daemon API (sometimes called REST server or REST API) * @param broadcastMode Defines at which point of the transaction processing the postTx method (i.e. transaction broadcasting) returns */ constructor(apiUrl: string, seed?: Uint8Array, broadcastMode?: BroadcastMode); getChainId(): Promise; getHeight(): Promise; /** * Returns a 32 byte upper-case hex transaction hash (typically used as the transaction ID) */ getIdentifier(tx: CosmosSdkTx): Promise; /** * Returns account number and sequence. * * Throws if the account does not exist on chain. * * @param address returns data for this address. When unset, the client's sender adddress is used. */ getNonce(address: string): Promise; getAccount(address: string): Promise; /** * Gets block header and meta * * @param height The height of the block. If undefined, the latest height is used. */ getBlock(height?: number): Promise; searchTx(query: SearchTxQuery, filter?: SearchTxFilter): Promise; postTx(tx: StdTx): Promise; getCodes(): Promise; getCodeDetails(codeId: number): Promise; getContracts(codeId: number): Promise; /** * Throws an error if no contract was found at the address */ getContract(address: string): Promise; /** * Makes a smart query on the contract, returns the parsed JSON document. * * Promise is rejected when contract does not exist. * Promise is rejected for invalid query format. * Promise is rejected for invalid response format. * * Note: addedParams allows for query string additions such as "&height=1234567" */ queryContractSmart( contractAddress: string, queryMsg: object, addedParams?: object, contractCodeHash?: string, ): Promise; private txsQuery; getCodeHashByCodeId(id: number): Promise; getCodeHashByContractAddr(addr: string): Promise; getNonceByTxId(txhash: string): Promise>; }