@dojima-wallet/connection
Version:
Initialise and connection for layer 1&2 blockchain
135 lines (134 loc) • 4.67 kB
TypeScript
import { Balance, BaseChainClient, ChainClient, ChainClientParams, Fees, Network, Tx, TxHash, TxHistoryParams, TxParams, TxsPage } from "../client";
import { Address, Asset, BaseAmount } from "@dojima-wallet/utils";
import BigNumber from "bignumber.js";
import { CosmosSDKClient } from "./cosmos";
import { TxOfflineParams } from "./cosmos";
import { CosmosClientParams } from "./types";
/**
* Interface for custom Cosmos client
*/
export interface CosmosClient {
getSDKClient(): CosmosSDKClient;
}
/**
* Custom Cosmos client
*/
declare class Client extends BaseChainClient implements CosmosClient, ChainClient {
private sdkClient;
private clientUrls;
private chainIds;
/**
* Constructor
*
* Client has to be initialised with network type and phrase.
* It will throw an error if an invalid phrase has been passed.
*
* @param {ChainClientParams} params
*
* @throws {"Invalid phrase"} Thrown if the given phase is invalid.
*/
constructor({ network, phrase, clientUrls, chainIds, rootDerivationPaths, }: ChainClientParams & CosmosClientParams);
/**
* Updates current network.
*
* @param {Network} network
* @returns {void}
*/
setNetwork(network: Network): void;
/**
* Get the explorer url.
*
* @returns {string} The explorer url.
*/
getExplorerUrl(): string;
/**
* Get the explorer url for the given address.
*
* @param {Address} address
* @returns {string} The explorer url for the given address.
*/
getExplorerAddressUrl(address: Address): string;
/**
* Get the explorer url for the given transaction id.
*
* @param {string} txID
* @returns {string} The explorer url for the given transaction id.
*/
getExplorerTxUrl(txID: string): string;
/**
* @private
* Get private key.
*
* @returns {PrivKey} The private key generated from the given phrase
*
* @throws {"Phrase not set"}
* Throws an error if phrase has not been set before
* */
private getPrivateKey;
getSDKClient(): CosmosSDKClient;
/**
* Get the current address.
*
* @returns {Address} The current address.
*
* @throws {Error} Thrown if phrase has not been set before. A phrase is needed to create a wallet and to derive an address from it.
*/
getAddress(index?: number): string;
/**
* Validate the given address.
*
* @param {Address} address
* @returns {boolean} `true` or `false`
*/
validateAddress(address: Address): boolean;
/**
* Get the balance of a given address.
*
* @param {Address} address By default, it will return the balance of the current wallet. (optional)
* @param {Asset} asset If not set, it will return all assets available. (optional)
* @returns {Balance[]} The balance of the address.
*/
getBalance(address: Address, assets?: Asset[]): Promise<Balance[]>;
/**
* Get transaction history of a given address and asset with pagination options.
* If `asset` is not set, history will include `ATOM` txs only
* By default it will return the transaction history of the current wallet.
*
* @param {TxHistoryParams} params The options to get transaction history. (optional)
* @returns {TxsPage} The transaction history.
*/
getTransactions(params?: TxHistoryParams): Promise<TxsPage>;
/**
* Get the transaction details of a given transaction id. Supports `ATOM` txs only.
*
* @param {string} txId The transaction id.
* @returns {Tx} The transaction details of the given transaction id.
*/
getTransactionData(txId: string): Promise<Tx>;
/**
* Transfer balances.
*
* @param {TxParams} params The transfer options.
* @returns {TxHash} The transaction hash.
*/
transfer({ walletIndex, asset, amount, recipient, memo, gasLimit, feeAmount, }: TxParams & {
gasLimit?: BigNumber;
feeAmount?: BaseAmount;
}): Promise<TxHash>;
/**
* Transfer offline balances.
*
* @param {TxOfflineParams} params The transfer offline options.
* @returns {string} The signed transaction bytes.
*/
transferOffline({ walletIndex, asset, amount, recipient, memo, from_account_number, from_sequence, gasLimit, feeAmount, }: TxOfflineParams): Promise<string>;
/**
* Returns fees.
* It tries to get chain fees from HermesChain `inbound_addresses` first
* If it fails, it returns DEFAULT fees.
*
* @returns {Fees} Current fees
*/
getFees(): Promise<Fees>;
}
export { Client };