@xchainjs/xchain-thorchain
Version:
Custom Thorchain client and utilities used by XChainJS clients
116 lines (115 loc) • 4.23 kB
TypeScript
/**
* Import necessary modules and types for the Thorchain client.
*/
import { StdFee } from '@cosmjs/amino';
import { AssetInfo, Network, PreparedTx, TxHash, TxParams } from '@xchainjs/xchain-client';
import { Client as CosmosSDKClient, CosmosSdkClientParams, MsgTypes } from '@xchainjs/xchain-cosmos-sdk';
import { Address } from '@xchainjs/xchain-util';
import { CompatibleAsset, DepositParam, DepositTx, TxOfflineParams } from './types';
/**
* Interface for custom Thorchain client
*/
export interface ThorchainClient {
deposit(params: DepositParam): Promise<TxHash>;
getDepositTransaction(txId: string): Promise<DepositTx>;
transferOffline(params: TxOfflineParams): Promise<string>;
}
/**
* Thorchain client params to instantiate the Thorchain client
*/
export type ThorchainClientParams = Partial<CosmosSdkClientParams>;
/**
* Thorchain base client
*/
export declare abstract class Client extends CosmosSDKClient implements ThorchainClient {
/**
* Thorchain client constructor
*
* @param {ThorchainClientParams} config Optional - Client configuration. If it is not set, default values will be used
*/
constructor(config?: ThorchainClientParams);
/**
* Get address prefix by network
* @param {Network} network The network of which return the prefix
* @returns the address prefix
*/
protected getPrefix(network: Network): string;
/**
* Get client native asset
*
* @returns {AssetInfo} Thorchain native asset
*/
getAssetInfo(): AssetInfo;
/**
* Returns the number of the decimals of known assets
*
* @param {CompatibleAsset} asset - Asset of which return the number of decimals
* @returns {number} the number of decimals of the assets
*/
getAssetDecimals(asset: CompatibleAsset): number;
/**
* Get the explorer url.
*
* @returns {string} The explorer url for thorchain based on the current network.
*/
getExplorerUrl(): string;
/**
* Get the explorer url for the given address.
*
* @param {Address} address The address for which to get the explorer URL.
* @returns {string} The explorer url for the given address.
*/
getExplorerAddressUrl(address: string): string;
/**
* Get the explorer url for the given transaction id.
*
* @param {string} txID The transaction ID for which to get the explorer URL.
* @returns {string} The explorer url for the given transaction id.
*/
getExplorerTxUrl(txID: string): string;
/**
* Get Asset from denomination
*
* @param {string} denom The denomination for which to get the asset.
* @returns {CompatibleAsset|null} The asset of the given denomination.
*/
assetFromDenom(denom: string): CompatibleAsset | null;
/**
* Get denomination from Asset
*
* @param {CompatibleAsset} asset The asset for which to get the denomination.
* @returns {string} The denomination of the given asset.
*/
getDenom(asset: CompatibleAsset): string | null;
/**
* Prepare transfer transaction.
*
* @param {TxParams&Address} params The transfer options.
* @returns {PreparedTx} The raw unsigned transaction.
*/
prepareTx({ sender, recipient, asset, amount, memo, }: TxParams & {
sender: Address;
}): Promise<PreparedTx>;
/**
* Get deposit transaction
*
* @deprecated Use getTransactionData instead
* @param {string} txId The transaction ID for which to get the deposit transaction
*/
getDepositTransaction(txId: string): Promise<DepositTx>;
/**
* Get the message type url by type used by the cosmos-sdk client to make certain actions
*
* @param {MsgTypes} msgType The message type of which return the type url
* @returns {string} the type url of the message
*/
protected getMsgTypeUrlByType(msgType: MsgTypes): string;
/**
* Returns the standard fee used by the client
*
* @returns {StdFee} the standard fee
*/
protected getStandardFee(): StdFee;
abstract deposit(params: DepositParam): Promise<string>;
abstract transferOffline(params: TxOfflineParams): Promise<string>;
}