UNPKG

raiden-api-sdk

Version:

SDK for interacting with the Raiden API

70 lines (69 loc) 2.48 kB
import { Connection as ConnectionS } from 'raiden-swagger-sdk'; import { Observable } from 'rxjs'; import { Configuration, ConnectionsApi } from './apis'; export interface Connection extends ConnectionS { } export interface Connections { [key: string]: Readonly<Connection>; } export interface DepositAllocation { /** * Number of channels to open proactively. * * @defaultValue 3 */ initialChannelTarget: number; /** * Fraction of funds that will be used to join channels * opened by other participants. * * @defaultValue 0.4 */ joinableFundsTarget: number; } export declare type ClosedChannelAddress = string; export declare class TokenNetworks { private readonly connectionsApi; static create(config?: Configuration): TokenNetworks; constructor(connectionsApi: ConnectionsApi); /** * Joined Token Networks * * @remarks * Each key is a token address for which you have open channels. * * @since 0.100.3 * @throws {@link RaidenAPIError} * @see {@link https://raiden-network.readthedocs.io/en/latest/rest_api.html#get--api-(version)-connections} */ findAll(): Observable<Connections>; /** * Automatically join a token network. * * @remarks * The request will only return once all blockchain calls * for opening and/or depositing to a channel have completed. * * @param tokenAddress - Token address of the respective token network * @param funds - The amount of funds you want to deposit * @param allocation - Allocation of funds for each channel in the network * * @since 0.100.3 * @throws {@link RaidenAPIError} * @see {@link https://raiden-network.readthedocs.io/en/latest/rest_api.html#put--api-(version)-connections-(token_address)} */ join(tokenAddress: string, funds: number, allocation?: DepositAllocation): Observable<void>; /** * Leave a token network * * @remarks * The request will only return once all blockchain calls * for closing/settling a channel have completed. * @param tokenAddress - Token address of the respective token network * * @since 0.100.3 * @throws {@link RaidenAPIError} * @see {@link https://raiden-network.readthedocs.io/en/latest/rest_api.html#delete--api-(version)-connections-(token_address)} */ leave(tokenAddress: string): Observable<ReadonlyArray<ClosedChannelAddress>>; }