UNPKG

@xchainjs/xchain-radix

Version:

Custom Radix client and utilities used by XChainJS clients

121 lines (120 loc) 5.11 kB
/// <reference types="node" /> import { Curve, PrivateKey } from '@radixdlt/radix-engine-toolkit'; import { AssetInfo, BaseXChainClient, Fees, Network, PreparedTx, TxHistoryParams, XChainClientParams } from '@xchainjs/xchain-client'; import { Address, TokenAsset } from '@xchainjs/xchain-util'; import { RadixSpecificClient } from './radix-client'; import { Balance, Tx, TxParams, TxsPage } from './types/radix'; /** * Custom Radix client */ export default class Client extends BaseXChainClient { private radixSpecificClient; private curve; constructor({ network, phrase, rootDerivationPaths, feeBounds, curve, }: XChainClientParams & { curve?: Curve; }); get radixClient(): RadixSpecificClient; setNetwork(network: Network): void; /** * Get an estimated fee for a test transaction that involves sending * XRD from one account to another * * @returns {Fee} An estimated fee */ getFees(): Promise<Fees>; getRadixNetwork(): number; getPrivateKey(index: number): Buffer; getRadixPrivateKey(index: number): PrivateKey; /** * Get the address for a given account. * @deprecated Use getAddressAsync instead. */ getAddress(): string; /** * Get the current address asynchronously for a given account. * @returns {Address} A promise resolving to the current address. * A phrase is needed to create a wallet and to derive an address from it. */ getAddressAsync(index?: number): Promise<string>; /** * Get the explorer URL based on the network. * * @returns {string} The explorer URL based on the network. */ getExplorerUrl(): string; /** * Get the explorer URL for a given account address based on the network. * @param {Address} address The address to generate the explorer URL for. * @returns {string} The explorer URL for the given address. */ getExplorerAddressUrl(address: Address): string; /** * Get the explorer URL for a given transaction ID based on the network. * @param {string} txID The transaction ID to generate the explorer URL for. * @returns {string} The explorer URL for the given transaction ID. */ getExplorerTxUrl(txID: string): string; /** * Validate the given address. * @param {Address} address The address to validate. * @returns {boolean} `true` if the address is valid, `false` otherwise. */ validateAddressAsync(address: string): Promise<boolean>; validateAddress(address: string): boolean; /** * Retrieves the balances of a given address. * @param {Address} address - The address to retrieve the balance for. * @param {Asset[]} assets - Assets to retrieve the balance for (optional). * @returns {Promise<Balance[]>} An array containing the balance of the address. */ getBalance(address: Address, assets?: TokenAsset[]): Promise<Balance[]>; /** * Get transaction history of a given address with pagination options. * @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. * This method uses LTSRadixEngineToolkit.Transaction.summarizeTransaction * to convert a transaction hex to a transaction summary. If the transaction was not built with * the SimpleTransactionBuilder, the method will fail to get the transaction data * @param {string} txId The transaction id. * @returns {Tx} The transaction details of the given transaction id. */ getTransactionData(txId: string): Promise<Tx>; /** * Helper function to convert a transaction in hex, returned by the gateway to a Tx type * @param transaction_hex - The raw_hex returned by the gateway for a transaction id * @param confirmed_at - The confirmed_at date for the transaction * @param intent_hash - The transaction intent hash * @returns a transaction in Tx type */ convertTransactionFromHex(transaction_hex: string, intent_hash: string, confirmed_at: Date): Promise<Tx>; /** * Creates a transaction using the SimpleTransactionBuilder, signs it with the * private key and returns the signed hex * @param params - The transactions params * @returns A signed transaction hex */ transfer(params: TxParams): Promise<string>; /** * Submits a transaction * @param txHex - The transaction hex build with the transfer method * @returns - The response from the gateway */ broadcastTx(txHex: string): Promise<string>; /** * Prepares a transaction to be used by the transfer method * It will include a non signed transaction * @param params - The transaction params * @returns a PreparedTx */ prepareTx(params: TxParams): Promise<PreparedTx>; /** * Get asset information. * @returns Asset information. */ getAssetInfo(): AssetInfo; } export { Client };