machinomy
Version:
Micropayments powered by Ethereum
31 lines (30 loc) • 1.56 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 Signature from './Signature';
import { Unidirectional } from '@machinomy/contracts';
import ChannelId from './ChannelId';
declare type Raw = [string, // sender
string, // receiver
BigNumber, // value
BigNumber, // settlingPeriod
BigNumber];
export default class ChannelEthContract {
contract: Promise<Unidirectional.Contract>;
private web3;
private cache;
constructor(web3: Web3, ttl: number);
open(sender: string, receiver: string, price: BigNumber, settlementPeriod: number | BigNumber, channelId?: ChannelId | string): Promise<TransactionResult>;
claim(receiver: string, channelId: string, value: BigNumber, signature: Signature): Promise<TransactionResult>;
deposit(sender: string, channelId: string, value: BigNumber): 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(channelId: string, payment: BigNumber, receiver: string, signature: Signature): Promise<boolean>;
channelById(channelId: string): Promise<Raw | undefined>;
}
export {};