import { AccountLinesResponse, GatewayBalancesResponse, StatusResponse, TransactionResponse, AccountOffersResponse, RipplePathFindResponse, SourceCurrency } from '../shared/rippled-web-socket-schema'; import IssuedCurrency from '../shared/issued-currency'; /** * A network client for interacting with the rippled WebSocket API. * @see https://xrpl.org/rippled-api.html */ export default class WebSocketNetworkClient { private handleErrorMessage; private readonly socket; private accountCallbacks; private messageCallbacks; private waiting; private idNumber; /** * Create a new WebSocketNetworkClient. * * @param webSocketUrl The URL of the rippled node to query. * @see https://xrpl.org/monitor-incoming-payments-with-websocket.html */ constructor(webSocketUrl: string, handleErrorMessage: (message: string) => void); /** * Properly handles incoming transactions from the websocket. * * @param data The websocket response received from the websocket. */ private handleTransaction; /** * Sends an API request over the websocket connection. * @see https://xrpl.org/monitor-incoming-payments-with-websocket.html * * @param request The object to send over the websocket. * @returns The API response from the websocket. */ private sendApiRequest; /** * Subscribes for notification about every validated transaction that affects the given account. * @see https://xrpl.org/subscribe.html * * @param account The account from which to subscribe to incoming transactions, encoded as a classic address. * @param callback The function called whenever a new transaction is received. * @returns The response from the websocket confirming the subscription. */ subscribeToAccount(account: string, callback: (data: TransactionResponse) => void): Promise; /** * Unsubscribes from notifications about every validated transaction that affects the given account. * @see https://xrpl.org/unsubscribe.html * * @param account The account from which to unsubscribe from incoming transactions, encoded as a classic address. * @returns The response from the websocket confirming the unsubscription. */ unsubscribeFromAccount(account: string): Promise; /** * Submits an account_lines request to the rippled WebSocket API. * @see https://xrpl.org/account_lines.html * * @param account The XRPL account to query for trust lines. */ getAccountLines(account: string, peerAccount?: string): Promise; /** * Submits a gateway_balances request to the rippled WebSocket API. * @see https://xrpl.org/gateway_balances.html * * @param account The XRPL account for which to retrieve issued currency balances. * @param addressesToExclude (Optional) An array of operational address to exclude from the balances issued. * @see https://xrpl.org/issuing-and-operational-addresses.html */ getGatewayBalances(account: string, addressesToExclude?: Array): Promise; /** * Submits an account_offers request to the rippled WebSocket API. * @see https://xrpl.org/account_offers.html * * @param account The XRPL account for which to retrieve a list of outstanding offers. */ getAccountOffers(account: string): Promise; /** * Submits a ripple_path_find request to the rippled WebSocket API. * @see https://xrpl.org/ripple_path_find.html * * @param sourceAccount The XRPL account at the start of the desired path, as a classic address. * @param destinationAccount The XRPL account at the end of the desired path, as a classic address. * @param destinationAmount The currency amount that the destination account would receive in a transaction * (-1 if the path should deliver as much as possible). * @param sendMax The currency amount that would be spent in the transaction (cannot be used with sourceCurrencies). * @param sourceCurrencies An array of currencies that the source account might want to spend (cannot be used with sendMax). */ findRipplePath(sourceAccount: string, destinationAccount: string, destinationAmount: string | IssuedCurrency, sendMax?: string | IssuedCurrency, sourceCurrencies?: SourceCurrency[]): Promise; /** * Closes the socket. */ close(): void; }