machinomy
Version:
Micropayments powered by Ethereum
32 lines (31 loc) • 2.09 kB
TypeScript
/// <reference types="@machinomy/types-web3" />
/// <reference types="@machinomy/types-truffle-contract" />
import * as Web3 from 'web3';
import { BigNumber } from 'bignumber.js';
import { TransactionResult } from 'truffle-contract';
import ChannelEthContract from './ChannelEthContract';
import ChannelTokenContract from './ChannelTokenContract';
import Signature from './Signature';
import ChannelId from './ChannelId';
import IChannelsDatabase from './storage/IChannelsDatabase';
import Payment from './payment';
export declare type Channel = [string, string, BigNumber, BigNumber, BigNumber];
export declare type ChannelWithTokenContract = [string, string, BigNumber, BigNumber, BigNumber, string];
export declare type ChannelFromContract = Channel | ChannelWithTokenContract | undefined;
export default class ChannelContract {
channelEthContract: ChannelEthContract;
channelTokenContract: ChannelTokenContract;
channelsDao: IChannelsDatabase;
constructor(web3: Web3, channelsDao: IChannelsDatabase, channelEthContract: ChannelEthContract, channelTokenContract: ChannelTokenContract);
open(sender: string, receiver: string, value: BigNumber, settlementPeriod: number | BigNumber, channelId?: ChannelId | string, tokenContract?: string): Promise<TransactionResult>;
claim(receiver: string, channelId: string, value: BigNumber, signature: Signature): Promise<TransactionResult>;
deposit(sender: string, channelId: string, value: BigNumber, tokenContract?: string): Promise<TransactionResult>;
getState(channelId: string): Promise<number>;
getSettlementPeriod(channelId: string): Promise<BigNumber>;
startSettle(account: string, channelId: string): Promise<TransactionResult>;
finishSettle(account: string, channelId: string): Promise<TransactionResult>;
paymentDigest(channelId: string, value: BigNumber): Promise<string>;
canClaim(payment: Payment): Promise<boolean>;
channelById(channelId: string): Promise<ChannelFromContract>;
getContractByChannelId(channelId: string): Promise<ChannelEthContract | ChannelTokenContract>;
}