Tradehub.Protocol (Tradehub v0.1.7) View Source

This module provides a set of functionalities to retreive information from the tradehub protocol.

Link to this section Summary

Functions

Get the block time in format HH:MM:SS.ZZZZZZ.

Requests latest blocks or specific blocks that match the requested parameters.

Requests delegation rewards of the given account

Get external transfers (both withdraws and deposits) of an account from other blockchains.

Requests Cosmos RPC status endpoint

Get total of available balances of token on the chain.

Get a transaction by providing a hash

Requests available transaction types on Tradehub

Get all validators, includes active, unbonding, and unbonded validators.

Link to this section Functions

Specs

block_time() :: {:ok, String.t()} | {:error, HTTPoison.Error.t()}

Get the block time in format HH:MM:SS.ZZZZZZ.

Examples

iex> Tradehub.Protocol.block_time
Link to this function

blocks(before_id \\ nil, after_id \\ nil, order_by \\ nil, proposer \\ nil, limit \\ nil)

View Source

Specs

blocks(nil, nil, nil, nil, nil) ::
  {:ok, [Tradehub.block()]} | {:error, HTTPoison.Error.t()}
blocks(integer(), integer(), String.t(), String.t(), integer()) ::
  {:ok, [Tradehub.block()]} | {:error, HTTPoison.Error.t()}

Requests latest blocks or specific blocks that match the requested parameters.

Parameters

  • before_id: before block height
  • after_id: after block height
  • order_by: not specified yet
  • proposer: tradehub validator consensus starting with swthvalcons1 on mainnet and tswthvalcons1 on testnet
  • limit: limit the responded result, values greater than 200 have no effect and a maximum of 200 results are returned.

Examples

iex> Tradehub.Protocol.blocks
Link to this function

delegation_rewards(account)

View Source

Specs

delegation_rewards(String.t()) ::
  {:ok, Tradehub.delegation_rewards()} | {:error, HTTPoison.Error.t()}

Requests delegation rewards of the given account

Examples

iex> Tradehub.Protocol.delegation_rewards("swth1945upvdn2p2sgq7muyhfmygn3fu740jw9l73du")
Link to this function

external_transfers(account)

View Source

Specs

external_transfers(String.t()) ::
  {:ok, [Tradehub.transfer_record()]} | {:error, HTTPoison.Error.t()}

Get external transfers (both withdraws and deposits) of an account from other blockchains.

Examples

iex> Tradehub.Protocol.external_transfers("swth1qlue2pat9cxx2s5xqrv0ashs475n9va963h4hz")

Specs

status() :: {:ok, Tradehub.protocol_status()} | {:error, HTTPoison.Error.t()}

Requests Cosmos RPC status endpoint

Examples

iex> Tradehub.Protocol.status

Specs

total_balances() ::
  {:ok, [Tradehub.protocol_balance()]} | {:error, HTTPoison.Error.t()}

Get total of available balances of token on the chain.

Examples

iex> Tradehub.Protocol.total_balances

Specs

transaction(String.t()) ::
  {:ok, Tradehub.transaction()} | {:error, HTTPoison.Error.t()}

Get a transaction by providing a hash

Examples

iex> Tradehub.Protocol.transaction("A93BEAC075562D4B6031262BDDE8B9A720346A54D8570A881E3671FEB6E6EFD4")

Specs

transaction_types() :: {:ok, [String.t()]} | {:error, HTTPoison.Error.t()}

Requests available transaction types on Tradehub

Examples

iex> Tradehub.Protocol.transaction_types
Link to this function

transactions(address \\ nil, msg_type \\ nil, height \\ nil, start_block \\ nil, end_block \\ nil, before_id \\ nil, after_id \\ nil, order_by \\ nil, limit \\ nil)

View Source

Specs

transactions(nil, nil, nil, nil, nil, nil, nil, nil, nil) ::
  {:ok, [Tradehub.transaction()]} | {:error, HTTPoison.Error.t()}
transactions(
  String.t(),
  String.t(),
  String.t(),
  String.t(),
  String.t(),
  String.t(),
  String.t(),
  String.t(),
  String.t()
) :: {:ok, [Tradehub.transaction()]} | {:error, HTTPoison.Error.t()}

Requests latest transactions or filtered transactions based on the filter params.

Parameters

  • address: tradehub switcheo address starts with swth1 on mainnet and tswth1 on testnet.
  • msg_type: filtered by msg_type, allowed values can be fetch with Tradehub.Protocol.transaction_types
  • height: filter transactions at a specific height
  • start_block: filter transactions after block
  • end_block: filter transactions before block
  • before_id: filter transactions before id
  • after_id: filter transactions after id
  • order_by: TODO
  • limit: limit by 200, values above 200 have no effects.

Examples

iex> Tradehub.Protocol.transactions

Specs

validators() :: {:ok, [Tradehub.validator()]} | {:error, HTTPoison.Error.t()}

Get all validators, includes active, unbonding, and unbonded validators.

Examples

iex> Tradehub.Protocol.validators