import { AccountStore, ContractLoader, Logger, LoggerOptions } from '@evan.network/dbcp';
import * as BigNumber from 'bignumber.js';
/**
 * parameters for Payments constructor
 */
export interface PaymentOptions extends LoggerOptions {
    executor: any;
    accountStore: AccountStore;
    contractLoader: ContractLoader;
    web3: any;
}
/**
 * Paymentchannel proof data type
 */
export interface MicroProof {
    /**
     * Balance value
     */
    balance: BigNumber;
    /**
     * Balance signature
     */
    sig?: string;
}
/**
 * Payment channel state data blueprint
 */
export interface MicroChannel {
    /**
     * Sender/client's account address
     */
    account: string;
    /**
     * Receiver/server's account address
     */
    receiver: string;
    /**
     * Open channel block number
     */
    block: number;
    /**
     * Current balance proof
     */
    proof: MicroProof;
    /**
     * Next balance proof, persisted with confirmPayment
     */
    next_proof?: MicroProof;
    /**
     * Cooperative close signature from receiver
     */
    closing_sig?: string;
}
/**
 * getChannelInfo result
 */
export interface MicroChannelInfo {
    /**
     * Current channel state, one of 'opened', 'closed' or 'settled'
     */
    state: string;
    /**
     * Block of current state (opened=open block number,
     * closed=channel close requested block number, settled=settlement block number)
     */
    block: number;
    /**
     * Current channel deposited sum
     */
    deposit: BigNumber;
    /**
     * Value already taken from the channel
     */
    withdrawn: BigNumber;
}
/**
 * class for instantiating/managing/settling payment channels to/from a given accountId
 *
 * @class      Payments (name)
 */
export declare class Payments extends Logger {
    options: PaymentOptions;
    /**
     * Currently set channel info. May be loaded through [[loadStoredChannel]],
     * [[loadChannelFromBlockchain]], or stored and set manually with [[setChannel]]
     */
    channel: MicroChannel;
    channelManager: any;
    startBlock: any;
    challenge: any;
    constructor(options: any);
    /**
     * Close current channel
     *
     * Optional parameter is signed cooperative close from receiver, if available.
     * If cooperative close was successful, channel is already settled after this
     * method is resolved.
     * Else, it enters 'closed' state, and should be settled after settlement
     * period, configured in contract.
     *
     * @param closingSig  Cooperative-close signature from receiver
     * @returns  Promise to closing tx hash
     */
    closeChannel(closingSig?: string): Promise<void>;
    /**
     * Persists next_proof to proof
     *
     * This method must be used after successful payment request,
     * or right after signNewProof is resolved,
     * if implementation don't care for request status
     */
    confirmPayment(proof: MicroProof): void;
    /**
     * Get channel details such as current state (one of opened, closed or
     * settled), block in which it was set and current deposited amount
     *
     * @param channel  Channel to get info from. Default to channel
     * @returns Promise to MicroChannelInfo data
     */
    getChannelInfo(channel?: MicroChannel): Promise<MicroChannelInfo>;
    /**
     * Get contract's configured challenge's period
     *
     * As it calls the contract method, can be used for validating that
     * contract's address has code in current network
     *
     * @returns  Promise to challenge period number, in blocks
     */
    getChallengePeriod(): Promise<number>;
    /**
     * Ask user for signing a channel balance
     *
     * Notice it's the final balance, not the increment, and that the new
     * balance is set in next_proof, requiring a
     * confirmPayment call to persist it, after successful
     * request.
     * Implementation can choose to call confirmPayment right after this call
     * resolves, assuming request will be successful after payment is signed.
     * Tries to use eth_signTypedData (from EIP712), tries to use personal sign
     * if it fails.
     *
     * @param proof  Balance proof to be signed
     * @returns  Promise to signature
     */
    getClosingSig(account: string): Promise<string>;
    /**
     * Health check for currently configured channel info
     *
     * @param channel  Channel to test. Default to channel
     * @returns  True if channel is valid, false otherwise
     */
    isChannelValid(channel?: MicroChannel): boolean;
    /**
     * Ask user for signing a payment, which is previous balance incremented of
     * amount.
     *
     * Warnings from signNewProof applies
     *
     * @param amount  Amount to increment in current balance
     * @returns  Promise to signature
     */
    incrementBalanceAndSign(amount: BigNumber | string): Promise<MicroProof>;
    /**
     * Scan the blockchain for an open channel, and load it with 0 balance
     *
     * The 0 balance may be overwritten with setBalance if
     * server replies with a updated balance on first request.
     * It should ask user for signing the zero-balance proof
     * Throws/reject if no open channel was found
     *
     * @param account  Sender/client's account address
     * @param receiver  Receiver/server's account address
     * @returns  Promise to channel info, if a channel was found
     */
    loadChannelFromBlockchain(account: string, receiver: string): Promise<MicroChannel>;
    /**
     * Open a channel for account to receiver, depositing some eve on it
     *
     * Replaces current channel data
     *
     * @param account  Sender/client's account address
     * @param receiver  Receiver/server's account address
     * @param deposit  Tokens to be initially deposited in the channel (in Wei)
     * @returns  Promise to MicroChannel info object
     */
    openChannel(account: string, receiver: string, deposit: BigNumber | string): Promise<MicroChannel>;
    /**
     * sets a new channelmanager contract to the current instanct
     *
     * @param      {string}  channelManager  the new channelmanager address
     */
    setChannelManager(channelManager: string): void;
    /**
     * Set [[channel]] info
     *
     * Can be used to externally [re]store an externally persisted channel info
     *
     * @param channel  Channel info to be set
     */
    setChannel(channel: MicroChannel): void;
    /**
     * If channel was not cooperatively closed, and after settlement period,
     * this function settles the channel, distributing the tokens to sender and
     * receiver.
     *
     * @returns  Promise resolved when done
     */
    settleChannel(): Promise<void>;
    /**
     * Ask user for signing a channel balance
     *
     * Notice it's the final balance, not the increment, and that the new
     * balance is set in [[MicroChannel.next_proof]], requiring a
     * [[confirmPayment]] call to persist it, after successful
     * request.
     * Implementation can choose to call confirmPayment right after this call
     * resolves, assuming request will be successful after payment is signed.
     * Tries to use eth_signTypedData (from EIP712), tries to use personal sign
     * if it fails.
     *
     * @param proof  Balance proof to be signed
     * @returns  Promise to signature
     */
    signNewProof(proof?: MicroProof): Promise<MicroProof>;
    /**
     * Ask user for signing a string with (personal|eth)_sign
     *
     * @param msg  Data to be signed
     * @returns Promise to signature
     */
    signMessage(msg: string): Promise<string>;
    /**
    * Top up current channel, by depositing some [more] tokens to it
    *
    * Should work with both ERC20/ERC223 tokens
    *
    * @param deposit  Tokens to be deposited in the channel
    * @returns  Promise to tx hash
    */
    /**
     * Top up current channel, by depositing some [more] EVE to it
     *
     * @param      {BigNumber|string}  deposit  amount  to topup channel
     * @return     {Promise<void>}  resolved when done
     */
    topUpChannel(deposit: BigNumber | string): Promise<void>;
    /**
     * converts a input string to a bigNumber.js object
     *
     * @param      {string}  input  to converted string
     */
    toBigNumber(input: string): any;
    private getClosingProofSignatureParams();
    private getBalanceProofSignatureParams(proof);
}
