Options
All
  • Public
  • Public/Protected
  • All
Menu

Websocket client.

TODO: correlate request and response with id, so socket can be reused.

Hierarchy

  • WebsocketClient

Index

Constructors

constructor

  • new WebsocketClient(url?: string, debug?: boolean, autoClose?: boolean): WebsocketClient

Properties

autoClose

autoClose: boolean

promises

promises: Map<string, Deferred<any>>

sender

Methods

addNotifyListener

  • addNotifyListener(listener: function): void
  • Adds listener for Notify messages.

    Be careful to not set autoClose = true and close the websocket on your own.

    Parameters

    • listener: function

      Listener

        • (result: any): void
        • Parameters

          • result: any

          Returns void

    Returns void

close

  • close(): void

getAllowance

  • getAllowance(asset: string, from: Address, to: Address): Promise<any>

getBalance

  • getBalance(address: Address): Promise<any>

getBlock

  • getBlock(value: number | string): Promise<any>
  • Get block's info by block's height or hash. The result is hex encoded string.

    Parameters

    • value: number | string

      Block's height or hash

    Returns Promise<any>

getBlockHash

  • getBlockHash(height: number): Promise<any>

getBlockHeight

  • getBlockHeight(): Promise<any>

getBlockHeightByTxHash

  • getBlockHeightByTxHash(hash: string): Promise<any>

getBlockJson

  • getBlockJson(value: number | string): Promise<any>

getBlockTxsByHeight

  • getBlockTxsByHeight(height: number): Promise<any>
  • Return all transaction hash contained in the block corresponding to this height

    Parameters

    • height: number

      Height of the block

    Returns Promise<any>

getContract

  • getContract(hash: string): Promise<any>

getContractJson

  • getContractJson(hash: string): Promise<any>

getGasPrice

  • getGasPrice(): Promise<any>

getGrantOng

  • getGrantOng(address: Address): Promise<any>

getMempoolTxCount

  • getMempoolTxCount(): Promise<any>

getMempoolTxState

  • getMempoolTxState(txHash: string): Promise<any>

getMerkleProof

  • getMerkleProof(hash: string): Promise<any>

getNetworkId

  • getNetworkId(): Promise<any>

getNodeCount

  • getNodeCount(): Promise<any>

getRawTransaction

  • getRawTransaction(txHash: string): Promise<any>
  • Get raw transaction by transaction hash. The result is hex encoded transaction.

    Parameters

    • txHash: string

      Reversed transaction hash

    Returns Promise<any>

getRawTransactionJson

  • getRawTransactionJson(txHash: string): Promise<any>

getSmartCodeEvent

  • getSmartCodeEvent(value: number | string): Promise<any>
  • 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.

    Parameters

    • value: number | string

      Reversed transaction hash or block's height

    Returns Promise<any>

getStorage

  • getStorage(codeHash: string, key: string): Promise<any>
  • Get stored value in smart contract by contract's code hash and the key.

    Parameters

    • codeHash: string

      Contract's code hash

    • key: string

      Key of stored value

    Returns Promise<any>

getUnboundong

  • getUnboundong(address: Address): Promise<any>

getVersion

  • getVersion(): Promise<any>

Private notifyListener

  • notifyListener(result: any): void

Private send

  • send<T>(raw: T, close?: boolean): Promise<any>
  • Send msg to blockchain

    Type parameters

    • T: any

    Parameters

    • raw: T

      Message to send

    • Default value close: boolean = this.autoClose

      Automaticly close connection if also autoClose is specified

    Returns Promise<any>

sendHeartBeat

  • sendHeartBeat(): Promise<any>

sendRawTransaction

  • sendRawTransaction(hexData: string, preExec?: boolean, waitNotify?: boolean): Promise<any>
  • Send raw transaction

    Parameters

    • hexData: string

      Hex encoded data

    • Default value preExec: boolean = false

      Decides if it is a pre-executed transaction

    • Default value waitNotify: boolean = false

      Decides if client waits for notify from blockchain before closing

    Returns Promise<any>

sendSubscribe

  • sendSubscribe(subscribeEvent?: boolean, subscribeJsonBlock?: boolean, subscribeRawBlock?: boolean, subscribeBlockTxHashes?: boolean): Promise<any>
  • Send subscribe request

    Parameters

    • Default value subscribeEvent: boolean = false
    • Default value subscribeJsonBlock: boolean = false
    • Default value subscribeRawBlock: boolean = false
    • Default value subscribeBlockTxHashes: boolean = false

    Returns Promise<any>

Generated using TypeDoc