import { Wallet, XrplNetwork } from 'xpring-common-js'; import { BigInteger } from 'big-integer'; import XrpClientDecorator from './xrp-client-decorator'; import TransactionStatus from './shared/transaction-status'; import XrpTransaction from './protobuf-wrappers/xrp-transaction'; import { GrpcNetworkClientInterface } from './network-clients/grpc-network-client-interface'; import SendXrpDetails from './shared/send-xrp-details'; import TransactionResult from './shared/transaction-result'; /** * DefaultXrpClient is a client for handling XRP payments on the XRPL. */ export default class DefaultXrpClient implements XrpClientDecorator { private readonly networkClient; readonly network: XrplNetwork; private coreXrplClient; /** * Create a new DefaultXrpClient. * * The DefaultXrpClient will use gRPC to communicate with the given endpoint. * * @param grpcUrl The URL of the gRPC instance to connect to. * @param network The network this XrpClient is connecting to. * @param forceWeb If `true`, then we will use the gRPC-Web client even when on Node. Defaults to false. This is mainly for testing and in the future will be removed when we have browser testing. */ static defaultXrpClientWithEndpoint(grpcUrl: string, network: XrplNetwork, forceWeb?: boolean): DefaultXrpClient; /** * Create a new DefaultXrpClient with a custom network client implementation. * * In general, clients should prefer to call `xrpClientWithEndpoint`. This constructor is provided to improve testability of this class. * * @param networkClient A network client which will manage remote RPCs to Rippled. * @param network The network this XrpClient is connecting to. */ constructor(networkClient: GrpcNetworkClientInterface, network: XrplNetwork); /** * Retrieve the balance for the given address. * * @param address The X-Address to retrieve a balance for. * @returns A `BigInteger` representing the number of drops of XRP in the account. */ getBalance(address: string): Promise; /** * Retrieve the transaction status for a Payment given transaction hash. * * Note: This method will only work for Payment type transactions which do not have the tf_partial_payment attribute set. * @see https://xrpl.org/payment.html#payment-flags * * @param transactionHash The hash of the transaction. * @returns The status of the given transaction. */ getPaymentStatus(transactionHash: string): Promise; /** * Send the given amount of XRP from the source wallet to the destination address. * * @param amount A `BigInteger`, number or numeric string representing the number of drops of XRP to send. * @param destinationAddress A destination address to send the drops to. * @param sender The wallet that XRP will be sent from and which will sign the request. * @returns A promise which resolves to a TransactionResult representing the pending outcome of the submitted transaction. */ sendXrp(amount: BigInteger | number | string, destinationAddress: string, sender: Wallet): Promise; /** * Send the given amount of XRP from the source wallet to the destination address, allowing * for additional details to be specified for use with supplementary features of the XRP ledger. * * @param sendXrpDetails - a wrapper object containing details for constructing a transaction. * @returns A promise which resolves to a TransactionResult representing the pending outcome of the submitted transaction. */ sendXrpWithDetails(sendXrpDetails: SendXrpDetails): Promise; /** * Check if an address exists on the XRP Ledger. * * @param address The address to check the existence of. * @returns A boolean if the account is on the ledger. */ accountExists(address: string): Promise; /** * Return the history of payments for the given account. * * Note: This method only works for payment type transactions, see: https://xrpl.org/payment.html * Note: This method only returns the history that is contained on the remote node, which may not contain a full history of the network. * * @param address: The address (account) for which to retrieve payment history. * @throws: An error if there was a problem communicating with the XRP Ledger. * @return: An array of transactions associated with the account. */ paymentHistory(address: string): Promise>; /** * Retrieve the payment transaction corresponding to the given transaction hash. * * Note: This method can return transactions that are not included in a fully validated ledger. * See the `validated` field to make this distinction. * * @param transactionHash The hash of the transaction to retrieve. * @throws An error if the transaction hash was invalid. * @returns An {@link XrpTransaction} object representing an XRP Ledger transaction. */ getPayment(transactionHash: string): Promise; /** * Enable Deposit Authorization for this XRPL account. * * @see https://xrpl.org/depositauth.html * * @param wallet The wallet associated with the XRPL account enabling Deposit Authorization and that will sign the request. * @returns A promise which resolves to a TransactionResult object that represents the result of this transaction. */ enableDepositAuth(wallet: Wallet): Promise; /** * Enables DepositPreauth and authorizes an XRPL account to send to this XRPL account. * * @see https://xrpl.org/depositpreauth.html * * @param xAddressToAuthorize The X-Address of the sender to enable DepositPreauth for. * @param wallet The wallet associated with the XRPL account enabling a deposit preauthorization and that will sign the request. */ authorizeSendingAccount(xAddressToAuthorize: string, wallet: Wallet): Promise; /** * Disables DepositPreauth and unauthorizes an XRPL account to send to this XRPL account. * * @see https://xrpl.org/depositpreauth.html * * @param xAddressToUnauthorize The X-Address of the sender to unauthorize. * @param wallet The wallet associated with the XRPL account revoking a deposit preauthorization, and that will sign the request. */ unauthorizeSendingAccount(xAddressToUnauthorize: string, wallet: Wallet): Promise; }