import { DfsInterface, KeyProviderInterface } from '@evan.network/dbcp';
import { BaseContract, BaseContractOptions } from '../base-contract/base-contract';
import { CryptoProvider } from '../../encryption/crypto-provider';
import { Sharing } from '../sharing';
export interface Answer {
    data: any;
    hash: string;
    owner: string;
    created: number;
    parent: number;
}
export interface AnswerResult {
    [index: number]: Answer;
}
export interface Call {
    data: any;
    hash: string;
    owner: string;
    created: number;
    answerCount: number;
    sharing: string;
}
export interface CallResult {
    [index: number]: Call;
}
/**
 * options for ServiceContract constructor
 */
export interface ServiceContractOptions extends BaseContractOptions {
    cryptoProvider: CryptoProvider;
    dfs: DfsInterface;
    keyProvider: KeyProviderInterface;
    sharing: Sharing;
    web3: any;
    defaultCryptoAlgo?: string;
}
/**
 * helper class for ServiceContracts
 *
 * @class      ServiceContract (name)
 */
export declare class ServiceContract extends BaseContract {
    options: ServiceContractOptions;
    private readonly encodingUnencrypted;
    private readonly encodingEncrypted;
    private readonly encodingUnencryptedHash;
    private readonly cryptoAlgorithHashes;
    private serviceDefinition;
    constructor(optionsInput: ServiceContractOptions);
    /**
     * adds list of accounts to a calls sharings list
     *
     * @param      {any|string}     contract   contract instance or contract id
     * @param      {string}         accountId  account id of sharing user
     * @param      {number}         callId     id of the call to extend sharings for
     * @param      {string[]}       to         list of account ids
     * @return     {Promise<void>}  resolved when done
     */
    addToCallSharing(contract: any | string, accountId: string, callId: number, to: string[], hashKey?: string, contentKey?: string, section?: string): Promise<void>;
    /**
     * create and initialize new contract
     *
     * @param      {string}        accountId             owner of the new contract and transaction
     *                                                   executor
     * @param      {string}        businessCenterDomain  ENS domain name of the business center
     * @param      {any}           service               service definition
     * @param      {string}        descriptionDfsHash    bytes32 hash of DBCP description
     * @return     {Promise<any>}  contract instance
     */
    create(accountId: string, businessCenterDomain: string, service: any, descriptionDfsHash?: string): Promise<any>;
    /**
     * retrieve a single answer
     *
     * @param      {any|string}    contract     smart contract instance or contract ID
     * @param      {string}        accountId    Ethereum account ID
     * @param      {number}        callId       index of the call to which the answer was created
     * @param      {number}        answerIndex  index of the answer in the call (starts from 0 for
     *                                          every call)
     * @return     {Promise<any>}  the answer
     */
    getAnswer(contract: any | string, accountId: string, callId: number, answerIndex: number): Promise<any>;
    /**
     * retrieves number of answers for a given call
     *
     * @param      {any|string}       contract  smart contract instance or contract ID
     * @param      {number}           callId    call index
     * @return     {Promise<number>}  number of answers
     */
    getAnswerCount(contract: any | string, callId: number): Promise<number>;
    /**
     * gets answers for a given call
     *
     * @param      {any|string}      contract   smart contract instance or contract ID
     * @param      {string}          accountId  Ethereum account ID
     * @param      {number}          callId     index of the call to which the answer was created
     * @param      {number}          count      number of elements to retrieve
     * @param      {number}          offset     skip this many elements
     * @param      {boolean}         reverse    retrieve last elements first
     * @return     {Promise<any[]>}  the calls
     */
    getAnswers(contract: any | string, accountId: string, callId: number, count?: number, offset?: number, reverse?: boolean): Promise<AnswerResult>;
    /**
     * get a call from a contract
     *
     * @param      {any|string}    contract   smart contract instance or contract ID
     * @param      {string}        accountId  Ethereum account ID
     * @param      {number}        callId  index of the call to retrieve
     * @return     {Promise<any>}  the call
     */
    getCall(contract: any | string, accountId: string, callId: number): Promise<any>;
    /**
      * get all calls from a contract
      *
      * @param      {any|string}      contract   smart contract instance or contract ID
      * @param      {string}          accountId  Ethereum account ID
      * @param      {number}          count      number of elements to retrieve
      * @param      {number}          offset     skip this many elements
      * @param      {boolean}         reverse    retrieve last elements first
      * @return     {Promise<any>}  the calls
      */
    getCalls(contract: any | string, accountId: string, count?: number, offset?: number, reverse?: boolean): Promise<CallResult>;
    /**
     * get number of calls of a contract
     *
     * @param      {any|string}  contract  smart contract instance or contract ID
     * @return     {Promise<number>}      number of calls
     */
    getCallCount(contract: any | string): Promise<number>;
    /**
     * gets the owner/creator of a call
     *
     * @param      {any|string}       contract  contract instance or id
     * @param      {number}           callId    id of a call
     * @return     {Promise<string>}  account id of call owner
     */
    getCallOwner(contract: any | string, callId: number): Promise<string>;
    /**
     * gets the service of a service contract
     *
     * @param      {any|string}       contract   smart contract instance or contract ID
     * @param      {string}           accountId  Ethereum account ID
     * @return     {Promise<string>}  service description
     */
    getService(contract: any | string, accountId: string): Promise<string>;
    /**
     * send answer to service contract call
     *
     * @param      {any|string}     contract    smart contract instance or contract ID
     * @param      {string}         accountId   Ethereum account ID
     * @param      {any}            answer      answer to send
     * @param      {number}         callId      index of the call to which the answer was created
     * @param      {string}         callAuthor  Ethereum account ID of the creator of the initial call
     * @return     {Promise<number>}  resolved when done
     */
    sendAnswer(contract: any | string, accountId: string, answer: any, callId: number, callAuthor: string, callParent?: string): Promise<number>;
    /**
     * send a call to a service
     *
     * @param      {any|string}       contract   smart contract instance or contract ID
     * @param      {string}           accountId  Ethereum account ID
     * @param      {any}              call       call to send
     * @return     {Promise<number>}  returns id of new call
     */
    sendCall(contract: any | string, accountId: string, call: any, to?: string[]): Promise<number>;
    /**
     * set service description
     *
     * @param      {any|string}     contract              smart contract instance or contract ID
     * @param      {string}         accountId             Ethereum account ID
     * @param      {any}            service               service to set
     * @param      {string}         businessCenterDomain  domain of the business the service contract
     *                                                    belongs to
     * @param      {bool}           skipValidation        (optional) skip validation of service
     *                                                    definition, validation is enabled by default
     * @return     {Promise<void>}  resolved when done
     */
    setService(contract: any | string, accountId: string, service: any, businessCenterDomain: string, skipValidation?: any): Promise<void>;
    /**
     * decrypt message; returns null if unable to decyrypt
     *
     * @param      {string}           toDecrypt     message to decrypt
     * @param      {any}              contract      contract the message belongs to
     * @param      {string}           accountId     account, that decrypts
     * @param      {string}           propertyName  name of the property to decrypt
     * @param      {string}           callId        (optional) if a call, id of the call to decrypt
     * @return     {Promise<string>}  decrypted message or null (if unable to decyrypt)
     */
    private decrypt;
    /**
     * decrypt input hash, return decrypted hash; returns null if unable to decyrypt
     *
     * @param      {string}        toDecrypt  data to decrypt
     * @param      {any}           contract   contract instance or contract id
     * @param      {string}        accountId  account id that decrypts the data
     * @param      {string}        callId     (optional) if a call should be decrypted, id of the call
     * @return     {Promise<any>}  decrypted envelope or null (if unable to decyrypt)
     */
    private decryptHash;
    /**
     * encrypt message
     *
     * @param      {string}           toEncrypt     message to encrypt
     * @param      {any}              contract      contract to encrypt message for
     * @param      {string}           from          encrypting account
     * @param      {string}           propertyName  property, that is encrypted
     * @param      {number}           block         current block
     * @param      {to}               to            (optional) target of message (if encrypting a
     *                                              call, target is none (no specific ENCRYPTION
     *                                              target, keys wrapped in multi sharings))
     * @param      {Buffer}           key           (optional) key to use, if no key is provided,
     *                                              sharings is used to look for a key
     * @return     {Promise<string>}  stringified {Envelope}
     */
    private encrypt;
    /**
     * encrypt incoming hash
     *
     * @param      {string}           toEncrypt  hash to encrypt
     * @param      {any}              contract   contract to encrypt data for
     * @param      {string}           accountId  encrypting account
     * @param      {Buffer}           key        key to use (if no key is provided, use key from
     *                                           sharings)
     * @return     {Promise<string>}  encrypted envelope or hash as string
     */
    private encryptHash;
    /**
     * gets calls or answers from service contract
     *
     * @param      {any}           serviceContract  smart contract instance or contract ID
     * @param      {string}        type             'calls' or 'answers'
     * @param      {number}        callId           id of parent call (if retrieving answers) or null
     * @param      {number}        count            number of items to retrieve
     * @param      {number}        offset           skip this many entries
     * @param      {boolean}       reverse          fetch entries, starting with last entry
     * @return     {Promise<any>}  object with result info
     */
    private getEntries;
    /**
     * convert number bytes32 string
     *
     * @param      {number}  number  number to convert
     * @return     {string}  bytes32 string with '0x' prefix
     */
    private numberToBytes32;
}
