JSPM

@test-xchain/xchain-thorchain

0.19.5
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q25063F
  • License MIT

Custom Thorchain client and utilities used by XChainJS clients

Package Exports

  • @test-xchain/xchain-thorchain

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@test-xchain/xchain-thorchain) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@test-xchain/xchain-thorchain

Thorchain Module for XChainJS Clients

Installation

yarn add @test-xchain/xchain-thorchain

Following peer dependencies have to be installed into your project. These are not included in @test-xchain/xchain-thorchain.

yarn add @test-xchain/xchain-client @test-xchain/xchain-crypto @test-xchain/xchain-util @test-xchain/xchain-cosmos axios cosmos-client

Important note: Make sure to install same version of cosmos-client as xchain-thorchain is using (currently cosmos-client@0.39.2 ). In other case things might break.

Thorchain Client Testing

yarn install
yarn test

Service Providers

This package uses the following service providers:

Function Service Notes
Balances Cosmos RPC https://cosmos.network/rpc/v0.37.9 (GET /bank/balances/{address})
Transaction history Tendermint RPC https://docs.tendermint.com/master/rpc/#/Info/tx_search
Transaction details by hash Cosmos RPC https://cosmos.network/rpc/v0.37.9 (GET /txs/{hash})
Transaction broadcast Cosmos RPC https://cosmos.network/rpc/v0.37.9 (POST /txs)
Explorer Thorchain.net https://thorchain.net

Rate limits: No

Examples

// import `xchain-thorchain`
import { Client } from '@test-xchain/xchain-thorchain'

// Create a `Client`
const client = new Client({ network: Network.Testnet, phrase: 'my secret phrase' })

// get address
const address = client.getAddress()
console.log('address:', client.getAddress()) // address: tthor13gym97tmw3axj3hpewdggy2cr288d3qffr8skg

// get balances
const balances = await client.getBalance(address)
console.log('balances:', balances[0].amount.amount().toString()) // balance: 6968080395099

// get transactions
const txs = await client.getTransactions({ address })
console.log('txs total:', txs.total) // txs total: 100

// get transaction details
const tx = await client.getTransactionData('any-tx-hash', address)
console.log('tx asset:', tx.asset) // tx asset: { chain: 'THOR', symbol: 'RUNE', ticker: 'RUNE' }

For more examples check out tests in ./__tests__/client.test.ts