machinomy
Version:
Micropayments powered by Ethereum
32 lines (31 loc) • 1.69 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 * as contracts from '@machinomy/contracts';
import Signature from './Signature';
import ChannelId from './ChannelId';
declare type RawChannel = [string, // sender
string, // receiver
BigNumber, // value
BigNumber, // settlingPeriod
BigNumber, // settlingUntil
string];
export default class ChannelTokenContract {
contract: Promise<contracts.TokenUnidirectional.Contract>;
private cache;
private web3;
constructor(web3: Web3, ttl: number);
open(sender: string, receiver: string, value: BigNumber | number, settlementPeriod: number | BigNumber, tokenContract: string, channelId?: ChannelId | 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, tokenContract: string): Promise<string>;
canClaim(channelId: string, payment: BigNumber, receiver: string, signature: Signature): Promise<boolean>;
channelById(channelId: string): Promise<RawChannel | undefined>;
}
export {};