UNPKG

raiden-api-sdk

Version:

SDK for interacting with the Raiden API

65 lines (64 loc) 2.48 kB
import { PaymentReceipt as PaymentReceiptS, PaymentEvent as PaymentEventS } from 'raiden-swagger-sdk'; import { Observable } from 'rxjs'; import { Configuration, PaymentsApi } from './apis'; export interface Token { /** * The address of the token */ address: string; /** * The amount you want to pay */ amount: number; } /** * Creates an object used to initiate a payment * * @param address - The address of the token * @param amount - The amount you want to pay */ export declare function NewToken(address: string, amount: number): Token; export declare enum PaymentEventEventEnum { EventPaymentReceivedSuccess = "EventPaymentReceivedSuccess", EventPaymentSentSuccess = "EventPaymentSentSuccess", EventPaymentSentFailed = "EventPaymentSentFailed" } export interface PaymentReceipt extends PaymentReceiptS { } export interface PaymentEvent extends PaymentEventS { event: PaymentEventEventEnum; } export declare class Payments { private readonly paymentsApi; static create(config?: Configuration): Payments; constructor(paymentsApi: PaymentsApi); /** * Initiate a payment * * @remarks * The request will only return once the payment either succeeded or failed. * * A payment can fail due to the expiration of a lock, the target being offline, * channels on the path to the target not having enough `settleTimeout` and * `revealTimeout` in order to allow the payment to be propagated safely, not enough funds etc. * @param token - Payment details * @param to - Address of the recipient * @param identifier - Identifier of the payment * * @since 0.100.3 * @throws {@link RaidenAPIError} * @see {@link https://raiden-network.readthedocs.io/en/latest/rest_api.html#post--api-(version)-payments-(token_address)-(target_address)} */ initiate(token: Readonly<Token>, to: string, identifier?: number): Observable<Readonly<PaymentReceipt>>; /** * Payment History * * @param tokenAddress - The token you want history for * @param targetAddress - The target address you want history for * * @since 0.100.3 * @throws {@link RaidenAPIError} * @see {@link https://raiden-network.readthedocs.io/en/latest/rest_api.html#get--api-v1-payments-(token_address)-(target_address)} */ history(tokenAddress?: string, targetAddress?: string): Observable<ReadonlyArray<Readonly<PaymentEvent>>>; }