raiden-ts
Version:
Raiden Light Client Typescript/Javascript SDK
126 lines (125 loc) • 4.87 kB
TypeScript
import type { BigNumber } from '@ethersproject/bignumber';
import * as t from 'io-ts';
import type { Int } from '../utils/types';
import { Address, UInt } from '../utils/types';
export declare enum ChannelState {
open = "open",
closing = "closing",
closed = "closed",
settleable = "settleable",
settling = "settling",
settled = "settled"
}
/**
* Contains info of each side of a channel
*/
declare const _ChannelEnd: t.ReadonlyC<t.TypeC<{
address: import("../utils/types").AddressC;
deposit: import("../utils/types").UIntC<32>;
withdraw: import("../utils/types").UIntC<32>;
locks: t.ReadonlyArrayC<t.IntersectionC<[t.TypeC<{
amount: import("../utils/types").UIntC<32>;
expiration: import("../utils/types").UIntC<32>;
secrethash: import("../utils/types").HexStringC<32>;
}>, t.PartialC<{
registered: t.LiteralC<true>;
}>]>>;
balanceProof: import("../utils/types").SignedC<import("./types").BalanceProofC>;
pendingWithdraws: t.ReadonlyArrayC<t.UnionC<[import("../utils/types").SignedC<import("../messages").WithdrawRequestC>, import("../utils/types").SignedC<import("../messages").WithdrawConfirmationC>, import("../utils/types").SignedC<import("../messages").WithdrawExpiredC>]>>;
nextNonce: import("../utils/types").UIntC<8>;
}>>;
export interface ChannelEnd extends t.TypeOf<typeof _ChannelEnd> {
}
export interface ChannelEndC extends t.Type<ChannelEnd, t.OutputOf<typeof _ChannelEnd>> {
}
export declare const ChannelEnd: ChannelEndC;
export declare const Channel: t.IntersectionC<[t.ReadonlyC<t.TypeC<{
_id: t.RefinementType<t.StringC, `0x${string}@0x${string}#${number}`, string, unknown>;
id: t.NumberC;
token: import("../utils/types").AddressC;
tokenNetwork: import("../utils/types").AddressC;
isFirstParticipant: t.BooleanC;
openBlock: t.NumberC;
own: ChannelEndC;
partner: ChannelEndC;
}>>, t.UnionC<[t.ReadonlyC<t.TypeC<{
state: t.UnionC<[t.LiteralC<ChannelState.open>, t.LiteralC<ChannelState.closing>]>;
}>>, t.IntersectionC<[t.ReadonlyC<t.TypeC<{
closeBlock: t.NumberC;
closeParticipant: import("../utils/types").AddressC;
}>>, t.UnionC<[t.ReadonlyC<t.TypeC<{
state: t.UnionC<[t.LiteralC<ChannelState.closed>, t.LiteralC<ChannelState.settleable>, t.LiteralC<ChannelState.settling>]>;
}>>, t.ReadonlyC<t.TypeC<{
state: t.LiteralC<ChannelState.settled>;
settleBlock: t.NumberC;
}>>]>]>]>]>;
export declare type Channel = t.TypeOf<typeof Channel>;
export interface ChannelBalances {
ownDeposit: UInt<32>;
ownWithdraw: UInt<32>;
ownTransferred: UInt<32>;
ownLocked: UInt<32>;
ownBalance: Int<32>;
ownCapacity: UInt<32>;
ownOnchainUnlocked: UInt<32>;
ownUnlocked: UInt<32>;
ownTotalWithdrawable: UInt<32>;
ownWithdrawable: UInt<32>;
partnerDeposit: UInt<32>;
partnerWithdraw: UInt<32>;
partnerTransferred: UInt<32>;
partnerLocked: UInt<32>;
partnerBalance: Int<32>;
partnerCapacity: UInt<32>;
partnerOnchainUnlocked: UInt<32>;
partnerUnlocked: UInt<32>;
partnerTotalWithdrawable: UInt<32>;
partnerWithdrawable: UInt<32>;
totalCapacity: UInt<32>;
}
/**
* Public exposed channels interface (Raiden.channels$)
*
* This should be only used as a public view of the internal channel state
* It contains some details about channel's current state, and some balances.
* Most relevant are:
* - state: one of 'open', 'closing', 'closed', 'settleable' or 'settling'
* - id: channel identifier
* - token: ERC20 token contract address
* - tokenNetwork: TokenNetwork contract address
* - openBlock: block number in which channel was opened
* - closeBlock: block in which channel got closed
* - partner: partner's address
* - balance: how much was sent (negative) plus received on this channel from partner
* - capacity: how much still can be transferred through this channel; increases with deposit
* - Balances [for each property, prefixed with either 'own' or 'partner']:
* - Deposit: on-chain totalDeposit
* - Withdraw: on-chain totalWithdraw
* - Unlocked: how much was received and unlocked on this channel's end
* - Locked: how much is still locked off-chain on this channel's end
* - Balance: received minus sent off-chain
* - Capacity: channel end's liquidity
* - Withdrawable: amount which can still be withdrawn
*/
export interface RaidenChannel extends ChannelBalances {
state: ChannelState;
id: number;
token: Address;
tokenNetwork: Address;
openBlock: number;
closeBlock?: number;
partner: Address;
balance: BigNumber;
capacity: BigNumber;
}
/**
* Public exposed aggregated channels mapping
*
* token => partner => RaidenChannel
*/
export interface RaidenChannels {
[token: string]: {
[partner: string]: RaidenChannel;
};
}
export {};