raiden-ts
Version:
Raiden Light Client Typescript/Javascript SDK
86 lines (85 loc) • 4.48 kB
TypeScript
import type { Observable } from 'rxjs';
import type { RaidenAction } from '../../actions';
import { raidenConfigUpdate, raidenSynced } from '../../actions';
import type { RaidenState } from '../../state';
import type { RaidenEpicDeps } from '../../types';
import { blockStale, blockTime, contractSettleTimeout, newBlock } from '../actions';
/**
* Emits raidenSynced when all init$ tasks got completed
*
* @param action$ - Observable of RaidenActions
* @param state$ - Observable of RaidenStates
* @param deps - Epics dependencies
* @param deps.init$ - Init$ subject
* @returns Observable of raidenSynced actions
*/
export declare function initEpic({}: Observable<RaidenAction>, state$: Observable<RaidenState>, { init$ }: RaidenEpicDeps): Observable<raidenSynced>;
/**
* Fetch current blockNumber, register for new block events and emit newBlock actions
*
* @param action$ - Observable of RaidenActions
* @param state$ - Observable of RaidenStates
* @param deps - RaidenEpicDeps members
* @param deps.provider - Eth provider
* @param deps.init$ - Observable which completes when initial sync is done
* @returns Observable of newBlock actions
*/
export declare function initNewBlockEpic(action$: Observable<RaidenAction>, {}: Observable<RaidenState>, { provider, init$ }: RaidenEpicDeps): Observable<newBlock>;
/**
* Fetch and calculate average blockTime every fetchEach=20, across maxSize=5 requests,
* i.e. moving average of 20*5=100 last blocks
*
* @param action$ - Observable of RaidenActions
* @param state$ - Observable of RaidenStates
* @param deps - RaidenEpicDeps members
* @param deps.getBlockTimestamp - Block timestamp (cached) getter function
* @param deps.log - Logger instance
* @returns Observable of blockTime actions
*/
export declare function blockTimeEpic(action$: Observable<RaidenAction>, {}: Observable<RaidenState>, { log, getBlockTimestamp }: RaidenEpicDeps): Observable<blockTime>;
/**
* Monitors provider for staleness. A provider is considered stale when it doesn't emit new blocks
* on either 2 * httpTimeout or the average time for 3 blocks.
*
* @param action$ - Observable of RaidenActions
* @param state$ - Observable of RaidenStates
* @param deps - RaidenEpicDeps members
* @param deps.config$ - Config observable
* @param deps.latest$ - Latest observable
* @param deps.init$ - Init observable
* @returns Observable of blockStale actions
*/
export declare function blockStaleEpic({}: Observable<RaidenAction>, state$: Observable<RaidenState>, { latest$, config$, init$ }: RaidenEpicDeps): Observable<blockStale>;
/**
* Fetch settleTimeout from contract once
*
* @param action$ - Observable of RaidenActions
* @param state$ - Observable of RaidenStates
* @param deps - RaidenEpicDeps members
* @param deps.log - Logger instance
* @param deps.registryContract - TokenNetworkRegistry instance
* @param deps.config$ - Config observable
* @param deps.init$ - Observable of sync tasks
* @returns Observable of contractSettleTimeout actions
*/
export declare function contractSettleTimeoutEpic({}: Observable<RaidenAction>, state$: Observable<RaidenState>, { log, registryContract, config$, init$ }: RaidenEpicDeps): Observable<contractSettleTimeout | raidenConfigUpdate>;
/**
* Process new blocks and re-emit confirmed or removed actions
*
* Events can also be confirmed by `fromEthersEvent + map(logToContractEvent)` combination.
* Notice that this epic does not know how to parse a tx log to update an action which payload was
* composed of values which can change upon reorgs. It only checks if given txHash is still present
* on the blockchain. `fromEthersEvent` can usually emit unconfirmed events multiple times to
* update/replace the pendingTxs action if needed, and also should emit the confirmed action with
* proper values; therefore, one should only relay on this epic to confirm an action if there's
* nothing critical depending on values in it's payload which can change upon reorgs.
*
* @param action$ - Observable of RaidenActions
* @param state$ - Observable of RaidenStates
* @param deps - RaidenEpicDeps members
* @param deps.config$ - Config observable
* @param deps.provider - Eth provider
* @param deps.latest$ - Latest observable
* @returns Observable of confirmed or removed actions
*/
export declare function confirmationEpic({}: Observable<RaidenAction>, state$: Observable<RaidenState>, { config$, provider, latest$ }: RaidenEpicDeps): Observable<RaidenAction>;