UNPKG

raiden-ts

Version:

Raiden Light Client Typescript/Javascript SDK

157 lines (156 loc) 8.18 kB
import type { Network } from '@ethersproject/networks'; import * as t from 'io-ts'; import type { Observable } from 'rxjs'; /** * A Raiden configuration object with required and optional params from [[PartialRaidenConfig]]. * * Notice partial/undefined values are special: when a raidenConfigUpdate is called with an * undefined value, it won't be set, as they can't be [re]stored in the JSON state, but instead * means it'll be *reset* to the default value; therefore, if a partial value has a defined * default, it can't be unset; if you want to support "empty" values, use null, empty string or * other falsy serializable types, and/or ensure it never gets a default * * - matrixServerLookup - Matrix server URL to fetch existing matrix servers from. * After intializing a [[Raiden]] instance, the matrix server can't be changed later on. * - revealTimeout - Timeout for secrets to be revealed (in seconds) * - expiryFactor - Multiply revealTimeout to get how far in the future transfer expiration should be * - httpTimeout - Used in http fetch requests * - additionalServices - Array of extra services URLs (or addresses, if URL set on SecretRegistry) * - pfsMode - One of 'disabled' (disables PFS usage and notifications), 'auto' (notifies all of * registered and additionalServices, picks cheapest for transfers without explicit pfs), * or 'onlyAdditional' (notifies all, but pick first responding from additionalServices only). * - pfsSafetyMargin - Safety margin to be added to fees received from PFS. Either a fee * multiplier, or a [fee, amount] pair ofmultipliers. Use `1.1` to add a 10% over estimated fee * margin, or `[0.03, 0.0005]` to add a 3% over fee plus 0.05% over amount. * - pfsMaxPaths - Limit number of paths requested from PFS for a route. * - pfsMaxFee - Maximum fee we're willing to pay a PFS for a route (in SVT/RDN wei) * - pfsIouTimeout - Number of seconds to timeout an IOU to a PFS. * - confirmationBlocks - How many blocks to wait before considering a transaction as confirmed * - monitoringReward - Reward to be paid to MS, in SVT/RDN; use Zero or null to disable * - logger - String specifying the console log level of redux-logger. Use '' to silence. * - caps - Own transport capabilities overrides. Set to null to disable all, including defaults * - fallbackIceServers - STUN servers to be used as a fallback for WebRTC * - rateToSvt - Exchange rate between tokens and SVT, in wei: e.g. rate[TKN]=2e18 => 1TKN = 2SVT * - pollingInterval - Interval at which to poll ETH provider for new blocks/events (milliseconds) * Honored only at start time * - minimumAllowance - Minimum value to call `approve` on tokens; default to MaxUint256, so * approving tokens should be needed only once, trusting TokenNetwork's & UDC contracts; * Set to Zero to fallback to approving the strictly needed deposit amounts * - autoSettle - Whether to channelSettle.request settleable channels automatically * - autoUDCWithdraw - Whether to udcWithdraw.request planned withdraws automatically * - mediationFees - deps.mediationFeeCalculator config. It's typed as unknown because it'll be * validated and decoded by [[FeeModel.decodeConfig]]. * - encryptSecret - Whether to send secret encrypted to target by default on transfers * - matrixServer? - Specify a matrix server to use. * - subkey? - When using subkey, this sets the behavior when { subkey } option isn't explicitly * set in on-chain method calls. false (default) = use main key; true = use subkey * - gasPriceFactor - Multiplier to be applied over base estimated/average gasPrice; * post-EPI1559 (London), this gets applied only to `maxPriorityFeePerGas`, or eth-node's * `eth_gasPrice` returned value; default does nothing and let provider guess (e.g. Metamask); * default ethers `maxPriorityFeePerGas` is 2.5 Gwei */ export declare const RaidenConfig: t.ReadonlyC<t.IntersectionC<[t.TypeC<{ matrixServerLookup: t.StringC; revealTimeout: t.NumberC; expiryFactor: t.NumberC; httpTimeout: t.NumberC; additionalServices: t.ReadonlyArrayC<t.UnionC<[import("./utils/types").AddressC, t.StringC]>>; pfsMode: t.KeyofC<{ disabled: string; auto: string; onlyAdditional: string; }>; pfsSafetyMargin: t.UnionC<[t.NumberC, t.TupleC<[t.NumberC, t.NumberC]>]>; pfsMaxPaths: t.NumberC; pfsMaxFee: import("./utils/types").UIntC<32>; pfsIouTimeout: t.NumberC; confirmationBlocks: t.NumberC; monitoringReward: t.UnionC<[t.NullC, import("./utils/types").UIntC<32>]>; logger: t.KeyofC<{ "": null; trace: null; debug: null; info: null; warn: null; error: null; }>; caps: t.UnionC<[t.NullC, t.ReadonlyC<t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.StringC, t.NumberC, t.BooleanC, t.NullC]>, t.ArrayC<t.UnionC<[t.StringC, t.NumberC, t.BooleanC, t.NullC]>>]>>>]>; fallbackIceServers: t.ArrayC<t.TypeC<{ urls: t.UnionC<[t.StringC, t.ArrayC<t.StringC>]>; }>>; rateToSvt: t.RecordC<t.StringC, import("./utils/types").UIntC<32>>; pollingInterval: t.NumberC; minimumAllowance: import("./utils/types").UIntC<32>; autoSettle: t.BooleanC; autoUDCWithdraw: t.BooleanC; mediationFees: t.UnknownC; encryptSecret: t.BooleanC; }>, t.PartialC<{ matrixServer: t.StringC; subkey: t.BooleanC; gasPriceFactor: t.UnionC<[t.NumberC, t.NullC]>; }>]>>; export interface RaidenConfig extends t.TypeOf<typeof RaidenConfig> { } export declare const PartialRaidenConfig: t.ReadonlyC<t.ExactC<t.PartialC<{ matrixServer: t.StringC; subkey: t.BooleanC; gasPriceFactor: t.UnionC<[t.NumberC, t.NullC]>; matrixServerLookup: t.StringC; revealTimeout: t.NumberC; expiryFactor: t.NumberC; httpTimeout: t.NumberC; additionalServices: t.ReadonlyArrayC<t.UnionC<[import("./utils/types").AddressC, t.StringC]>>; pfsMode: t.KeyofC<{ disabled: string; auto: string; onlyAdditional: string; }>; pfsSafetyMargin: t.UnionC<[t.NumberC, t.TupleC<[t.NumberC, t.NumberC]>]>; pfsMaxPaths: t.NumberC; pfsMaxFee: import("./utils/types").UIntC<32>; pfsIouTimeout: t.NumberC; confirmationBlocks: t.NumberC; monitoringReward: t.UnionC<[t.NullC, import("./utils/types").UIntC<32>]>; logger: t.KeyofC<{ "": null; trace: null; debug: null; info: null; warn: null; error: null; }>; caps: t.UnionC<[t.NullC, t.ReadonlyC<t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.StringC, t.NumberC, t.BooleanC, t.NullC]>, t.ArrayC<t.UnionC<[t.StringC, t.NumberC, t.BooleanC, t.NullC]>>]>>>]>; fallbackIceServers: t.ArrayC<t.TypeC<{ urls: t.UnionC<[t.StringC, t.ArrayC<t.StringC>]>; }>>; rateToSvt: t.RecordC<t.StringC, import("./utils/types").UIntC<32>>; pollingInterval: t.NumberC; minimumAllowance: import("./utils/types").UIntC<32>; autoSettle: t.BooleanC; autoUDCWithdraw: t.BooleanC; mediationFees: t.UnknownC; encryptSecret: t.BooleanC; }>>>; export interface PartialRaidenConfig extends t.TypeOf<typeof PartialRaidenConfig> { } /** * Create a RaidenConfig from some common options * * @param obj - Object containing common parameters for config * @param obj.network - ether's Network object for the current blockchain * @param overwrites - Overwrites values from default config * @returns A full config object */ export declare function makeDefaultConfig({ network }: { network: Network; }, overwrites?: PartialRaidenConfig): RaidenConfig; /** * A function which returns an Iterable of intervals based on parameters in config$ * By default, it returns an iterable which, on every iterator call, will return a new * exponentialBackoff iterator ranging from config.pollingInterval to 2 * config.httpTimeout * * @param config$ - Config-like observable, emiting objects with pollingInterval & httpTimeout * @returns Iterable (resettable) of intervals */ export declare function intervalFromConfig(config$: Observable<Pick<RaidenConfig, 'pollingInterval' | 'httpTimeout'>>): Iterable<number> & Iterator<number>;