import { Address } from '../../crypto/address'; import { Deferred } from './deferred'; import { WebsocketSender } from './websocketSender'; /** * Websocket client. * * TODO: correlate request and response with id, so socket can be reused. */ export declare class WebsocketClient { sender: WebsocketSender; autoClose: boolean; promises: Map>; constructor(url?: string, debug?: boolean, autoClose?: boolean); /** * Send heart beat request */ sendHeartBeat(): Promise; /** * Send subscribe request * @param subscribeEvent * @param subscribeJsonBlock * @param subscribeRawBlock * @param subscribeBlockTxHashes */ sendSubscribe(subscribeEvent?: boolean, subscribeJsonBlock?: boolean, subscribeRawBlock?: boolean, subscribeBlockTxHashes?: boolean): Promise; /** * Send raw transaction * @param hexData Hex encoded data * @param preExec Decides if it is a pre-executed transaction * @param waitNotify Decides if client waits for notify from blockchain before closing */ sendRawTransaction(hexData: string, preExec?: boolean, waitNotify?: boolean): Promise; /** * Get raw transaction by transaction hash. * The result is hex encoded transaction. * @param txHash Reversed transaction hash */ getRawTransaction(txHash: string): Promise; /** * Get transaction info by transaction hash. * The result is json. * @param txHash Reversed transaction hash */ getRawTransactionJson(txHash: string): Promise; /** Deprecated * Get the generation time for each block. * If the blockchain node runs in vbft, the result is null. */ /** * Get Nodes count */ getNodeCount(): Promise; /** * Get current block height */ getBlockHeight(): Promise; /** * Get block's info by block's height or hash. * The result is hex encoded string. * @param value Block's height or hash */ getBlock(value: number | string): Promise; /** * Get block's info by block's height or hash. * The result is json. * @param value Block's height or hash */ getBlockJson(value: number | string): Promise; /** * Get the balance of some address. * The result contains ONT and ONG. * @param address Address */ getBalance(address: Address): Promise; /** * Get the balance of some address. * The result contains ONT and ONG. * @param address Address */ getBalanceV2(address: Address): Promise; /** * Get unbound ong of this address * The result contains ONG. * @param address Address */ getUnboundong(address: Address): Promise; /** * Get contract info by code hash. * The result is hex encoded string. * @param hash Contract's code hash. */ getContract(hash: string): Promise; /** * Get contract's info by code hash * The result is json. * @param hash Contract's code hash */ getContractJson(hash: string): Promise; /** * Get smart conde event by transaction hash or block's height. * If parameter is transaction hash, the result is the event of that transaction. * If parameter is block's height, the result is all the events of that block. * @param value Reversed transaction hash or block's height */ getSmartCodeEvent(value: number | string): Promise; /** * Get block's height by transaction hash * @param hash Reversed transaction hash */ getBlockHeightByTxHash(hash: string): Promise; /** * Get stored value in smart contract by contract's code hash and the key. * @param codeHash Contract's code hash * @param key Key of stored value */ getStorage(codeHash: string, key: string): Promise; /** * Get merkle proof by transaction hash. * @param hash Reversed transaction hash */ getMerkleProof(hash: string): Promise; /** * Get allowanece * @param asset Asset's type.Only ONT and ONG supported. * @param from Address of allowance's sender. * @param to Address of allowance's receiver. */ getAllowance(asset: string, from: Address, to: Address): Promise; /** * Get allowanece * @param asset Asset's type.Only ONT and ONG supported. * @param from Address of allowance's sender. * @param to Address of allowance's receiver. */ getAllowanceV2(asset: string, from: Address, to: Address): Promise; /** * Get block hash by block height * @param height Height of the block */ getBlockHash(height: number): Promise; /** * Return all transaction hash contained in the block corresponding to this height * @param height Height of the block */ getBlockTxsByHeight(height: number): Promise; /** * Return the state of transaction locate in memory */ getGasPrice(): Promise; /** * Get grant ong * @param address Address */ getGrantOng(address: Address): Promise; /** * Query the transaction count in the memory pool */ getMempoolTxCount(): Promise; /** * Query the transaction state in the memory pool */ getMempoolTxState(txHash: string): Promise; /** * Get the version information of the node */ getVersion(): Promise; /** * Get the network id */ getNetworkId(): Promise; /** * Adds listener for Notify messages. * * Be careful to not set autoClose = true and close the websocket on your own. * @param listener Listener */ addNotifyListener(listener: (result: any) => void): void; /** * Close the websocket manually. */ close(): void; /** * Send msg to blockchain * @param raw Message to send * @param close Automaticly close connection if also autoClose is specified */ private send; private notifyListener; }