raiden-ts
Version:
Raiden Light Client Typescript/Javascript SDK
61 lines (60 loc) • 3.25 kB
TypeScript
import type { Observable } from 'rxjs';
import type { RaidenAction } from '../../actions';
import { raidenShutdown } from '../../actions';
import type { RaidenState } from '../../state';
import type { RaidenEpicDeps } from '../../types';
import { channelClose, channelDeposit, channelMonitored, channelOpen, channelSettle, channelWithdrawn, tokenMonitored } from '../actions';
/**
* If state.tokens is empty (usually only on first run), scan registry and token networks for
* registered TokenNetworks of interest (ones which has/had channels with us) and monitors them.
* Otherwise, just emit tokenMonitored actions for all previously monitored TokenNetworks
*
* @param action$ - Observable of RaidenActions
* @param state$ - Observable of RaidenStates
* @param deps - RaidenEpicDeps members
* @param deps.address - Our address
* @param deps.provider - Eth provider
* @param deps.registryContract - TokenNetworkRegistry contract instance
* @param deps.contractsInfo - Contracts info mapping
* @param deps.init$ - Init$ tasks subject
* @returns Observable of tokenMonitored actions
*/
export declare function initTokensRegistryEpic(action$: Observable<RaidenAction>, state$: Observable<RaidenState>, deps: RaidenEpicDeps): Observable<tokenMonitored>;
/**
* Monitor provider to ensure account continues to be available and network stays the same
*
* @param action$ - Observable of RaidenActions
* @param state$ - Observable of RaidenStates
* @param deps - RaidenEpicDeps members
* @param deps.address - Our address
* @param deps.network - Current network
* @param deps.provider - Eth provider
* @param deps.main - Main account
* @returns Observable of raidenShutdown actions
*/
export declare function initMonitorProviderEpic(action$: Observable<RaidenAction>, {}: Observable<RaidenState>, { address, main, network, provider }: RaidenEpicDeps): Observable<raidenShutdown>;
/**
* Listen TokenNetwork contract for channel Events
* Currently monitored events:
* - ChannelOpened, fires a channelopen.success action
* - ChannelNewDeposit, fires a channelDeposit.success action
* - ChannelWithdraw, fires a channelWithdrawn action
* - ChannelClosedEvent, fires a channelClose.success action
* - ChannelSettledEvent, fires a channelSettle.success action
* Also emits tokenMonitored to tell we're monitoring a tokenNetwork, with its [fromBlock, toBlock]
* ranges of fetched pastEvents
*
* @param action$ - Observable of RaidenActions
* @param state$ - Observable of RaidenStates
* @param deps - RaidenEpicDeps members
* @returns Observable of channelOpen.success,channelDeposit.success,channelClose.success,
* channelSettle.success actions
*/
export declare function channelEventsEpic(action$: Observable<RaidenAction>, {}: Observable<RaidenState>, deps: RaidenEpicDeps): Observable<tokenMonitored | channelOpen.success | channelDeposit.success | channelWithdrawn | channelClose.success | channelSettle.success>;
/**
* Emit channelMonitored action for channels on state
*
* @param state$ - Observable of RaidenStates
* @returns Observable of channelMonitored actions
*/
export declare function channelMonitoredEpic({}: Observable<RaidenAction>, state$: Observable<RaidenState>): Observable<channelMonitored>;