UNPKG

raiden-ts

Version:

Raiden Light Client Typescript/Javascript SDK

149 lines (148 loc) 5.94 kB
import type { BigNumber } from '@ethersproject/bignumber'; import * as t from 'io-ts'; import { Address, Hash, Secret } from '../utils/types'; export declare const Direction: { readonly SENT: "sent"; readonly RECEIVED: "received"; }; export declare type Direction = typeof Direction[keyof typeof Direction]; export declare const DirectionC: t.KeyofC<{ sent: string; received: string; }>; /** * This struct holds the relevant messages exchanged in a transfer * The transfer state is defined by the exchanged messages */ declare const _TransferState: t.ReadonlyC<t.IntersectionC<[t.TypeC<{ _id: t.StringC; channel: t.StringC; direction: t.KeyofC<{ sent: string; received: string; }>; secrethash: import("../utils/types").HexStringC<32>; expiration: t.NumberC; /** -> outgoing locked transfer */ transfer: import("../utils/types").TimedC<import("../utils/types").SignedC<import("../messages/types").LockedTransferC>>; fee: import("../utils/types").IntC<32>; partner: import("../utils/types").AddressC; cleared: t.NumberC; }>, t.PartialC<{ /** Transfer secret, if known */ secret: import("../utils/types").HexStringC<32>; /** Set iff secret got registered on-chain on a block before transfer expiration */ secretRegistered: import("../utils/types").TimedC<t.TypeC<{ txHash: import("../utils/types").HexStringC<32>; txBlock: t.NumberC; }>>; /** <- incoming processed for locked transfer */ transferProcessed: import("../utils/types").TimedC<import("../utils/types").SignedC<import("../messages/types").ProcessedC>>; /** !! channel was closed !! */ channelClosed: import("../utils/types").TimedC<t.TypeC<{ txHash: import("../utils/types").HexStringC<32>; txBlock: t.NumberC; }>>; /** channel was settled */ channelSettled: import("../utils/types").TimedC<t.TypeC<{ txHash: import("../utils/types").HexStringC<32>; txBlock: t.NumberC; }>>; /** * <- incoming secret request from target * If this is set, it means the target requested the secret, not necessarily with a valid * amount (an invalid amount < value == lock - fee, means transfer failed) */ secretRequest: import("../utils/types").TimedC<import("../utils/types").SignedC<import("../messages/types").SecretRequestC>>; /** * -> outgoing secret reveal to target * If this is set, it means the secret was revealed (so transfer succeeded, even if it didn't * complete yet) */ secretReveal: import("../utils/types").TimedC<import("../utils/types").SignedC<import("../messages/types").SecretRevealC>>; /** * -> outgoing unlock to recipient * If this is set, it means the Unlock was sent (even if partner didn't acknowledge it yet) */ unlock: import("../utils/types").TimedC<import("../utils/types").SignedC<import("../messages/types").UnlockC>>; /** * -> outgoing lock expired (if so) * If this is set, transfer failed, and we expired the lock (retrieving the locked amount). * Transfer failed may not have completed yet, e.g. waiting for LockExpired's Processed reply */ expired: import("../utils/types").TimedC<import("../utils/types").SignedC<import("../messages/types").LockExpiredC>>; /** * <- incoming processed for Unlock message * If this is set, the protocol completed by the transfer succeeding and partner * acknowledging validity of our off-chain unlock */ unlockProcessed: import("../utils/types").TimedC<import("../utils/types").SignedC<import("../messages/types").ProcessedC>>; /** * <- incoming processed for LockExpired message * If this is set, the protocol completed by the transfer failing and partner acknowledging * this transfer can't be claimed anymore */ expiredProcessed: import("../utils/types").TimedC<import("../utils/types").SignedC<import("../messages/types").ProcessedC>>; }>]>>; export interface TransferState extends t.TypeOf<typeof _TransferState> { } export interface TransferStateC extends t.Type<TransferState, t.OutputOf<typeof _TransferState>> { } export declare const TransferState: TransferStateC; export declare enum RaidenTransferStatus { pending = "PENDING", received = "RECEIVED", closed = "CLOSED", requested = "REQUESTED", revealed = "REVEALED", registered = "REGISTERED", unlocking = "UNLOCKING", expiring = "EXPIRING", unlocked = "UNLOCKED", expired = "EXPIRED" } /** * Public exposed transfers interface (Raiden.transfers$) * * This should be only used as a public view of the internal transfer state */ export interface RaidenTransfer { key: string; secrethash: Hash; direction: 'sent' | 'received'; status: RaidenTransferStatus; initiator: Address; partner: Address; target: Address; metadata: unknown; paymentId: BigNumber; chainId: number; token: Address; tokenNetwork: Address; channelId: BigNumber; value: BigNumber; fee: BigNumber; amount: BigNumber; expiration: number; startedAt: Date; changedAt: Date; /** * Set as soon as known if transfer did happen or fail (even if still there're pending actions) * undefined=pending, true=success, false=failed */ success: boolean | undefined; /** * True if transfer did complete, i.e. nothing else left to be done for it * False if transfer still has pending actions (even if success status is already known) */ completed: boolean; secret?: Secret; } export declare const RevealedSecret: t.IntersectionC<[t.TypeC<{ secret: import("../utils/types").HexStringC<32>; amount: import("../utils/types").UIntC<32>; }>, t.PartialC<{ payment_identifier: import("../utils/types").UIntC<8>; }>]>; export declare type RevealedSecret = t.TypeOf<typeof RevealedSecret>; export {};