UNPKG

raiden-ts

Version:

Raiden Light Client Typescript/Javascript SDK

46 lines 1.66 kB
import { AddressZero, HashZero, Zero } from '@ethersproject/constants'; import * as t from 'io-ts'; import { LocksrootZero, SignatureZero } from '../constants'; import { Address, Hash, templateLiteral, UInt } from '../utils/types'; export const ChannelKey = templateLiteral(/^0x[0-9a-fA-F]{40}@0x[0-9a-fA-F]{40}$/); export const ChannelUniqueKey = templateLiteral(/^0x[0-9a-fA-F]{40}@0x[0-9a-fA-F]{40}#\d+$/); // Represents a HashTime-Locked amount in a channel export const Lock = t.intersection([ t.type({ amount: UInt(32), expiration: UInt(32), secrethash: Hash, }), t.partial({ registered: t.literal(true) }), ], 'Lock'); /** * Balance Proof constructed from an EnvelopeMessage * Either produced by us or received from the partner, the BPs are generated from the messages * because BP signature requires the hash of the message, for authentication of data not included * nor relevant for the smartcontract/BP itself, but so for the peers (e.g. payment_id) */ const _BalanceProof = t.readonly(t.type({ // channel data chainId: UInt(32), tokenNetworkAddress: Address, channelId: UInt(32), // balance proof data nonce: UInt(8), transferredAmount: UInt(32), lockedAmount: UInt(32), locksroot: Hash, additionalHash: Hash, })); export const BalanceProof = _BalanceProof; export const BalanceProofZero = { chainId: Zero, tokenNetworkAddress: AddressZero, channelId: Zero, nonce: Zero, transferredAmount: Zero, lockedAmount: Zero, locksroot: LocksrootZero, additionalHash: HashZero, signature: SignatureZero, }; //# sourceMappingURL=types.js.map