/// <reference types="node" />
import Long from "long";
import { Message, Properties } from "protobufjs/light";
import IdentityWrapper, { IIdentity } from "../darc/identity-wrapper";
import Signer from "../darc/signer";
import { IBeautifierSchema } from "./beautifier";
import { InstanceID } from "./instance";
export interface ICounterUpdater {
    getSignerCounters(signers: IIdentity[], increment: number): Promise<Long[]>;
    updateCachedCounters(signers: IIdentity[]): Promise<Long[]>;
    getNextCounter(signer: IIdentity): Long;
}
/**
 * List of instructions to send to a byzcoin chain
 */
export declare class ClientTransaction extends Message<ClientTransaction> {
    /**
     * @see README#Message classes
     */
    static register(): void;
    /**
     * Create a transaction from the list of instructions.
     * @param version   Version of the ByzCoin protocol
     * @param instrs    List of instructions
     */
    static make(version: number, ...instrs: Instruction[]): ClientTransaction;
    readonly instructions: Instruction[];
    /**
     * @deprecated Use the static function make to create transactions compatible with
     * latest versions of the ByzCoin protocol.
     */
    constructor(props?: Properties<ClientTransaction>);
    /**
     * Sign the hash of the instructions using the list of signers
     * @param signers List of signers
     */
    signWith(signers: Signer[][]): void;
    /**
     * Fetch the counters and update the instructions accordingly
     * @param rpc       The RPC to use to fetch
     * @param signers   List of signers
     */
    updateCounters(rpc: ICounterUpdater, signers: IIdentity[][]): Promise<void>;
    updateCountersAndSign(rpc: ICounterUpdater, signers: Signer[][]): Promise<void>;
    /**
     * Hash the instructions' hash
     * @returns a buffer of the hash
     */
    hash(): Buffer;
}
declare type InstructionType = 0 | 1 | 2;
/**
 * An instruction represents one action
 */
export declare class Instruction extends Message<Instruction> {
    /**
     * Get the type of the instruction
     * @returns the type as a number
     */
    readonly type: InstructionType;
    static readonly typeSpawn = 0;
    static readonly typeInvoke = 1;
    static readonly typeDelete = 2;
    /**
     * @see README#Message classes
     */
    static register(): void;
    /**
     * Helper to create a spawn instruction
     * @param iid           The instance ID
     * @param contractID    The contract name
     * @param args          Arguments for the instruction
     * @returns the instruction
     */
    static createSpawn(iid: Buffer, contractID: string, args: Argument[]): Instruction;
    /**
     * Helper to create a invoke instruction
     * @param iid           The instance ID
     * @param contractID    The contract name
     * @param command       The command to invoke
     * @param args          The list of arguments
     * @returns the instruction
     */
    static createInvoke(iid: Buffer, contractID: string, command: string, args: Argument[]): Instruction;
    /**
     * Helper to create a delete instruction
     * @param iid           The instance ID
     * @param contractID    The contract name
     * @returns the instruction
     */
    static createDelete(iid: Buffer, contractID: string): Instruction;
    readonly spawn: Spawn;
    readonly invoke: Invoke;
    readonly delete: Delete;
    readonly instanceID: InstanceID;
    readonly signerCounter: Long[];
    readonly signerIdentities: IdentityWrapper[];
    readonly signatures: Buffer[];
    constructor(props?: Properties<Instruction>);
    /**
     * Use the signers to make a signature of the hash
     * @param ctxHash The client transaction hash
     * @param signers The list of signers
     */
    signWith(ctxHash: Buffer, signers: Signer[]): void;
    /**
     * Set the signer counters and identities
     * @param counters      List of counters
     * @param identities    List of identities
     */
    setCounters(counters: Long[], identities: IdentityWrapper[]): void;
    /**
     * Fetch and update the counters
     * @param rpc       the RPC to use to fetch
     * @param signers   the list of signers
     */
    updateCounters(rpc: ICounterUpdater, signers: IIdentity[]): Promise<void>;
    /**
     * Hash the instruction
     * @returns a buffer of the hash
     */
    hash(): Buffer;
    /**
     * Get the unique identifier of the instruction
     * @returns the id as a buffer
     */
    deriveId(what?: string): Buffer;
    /**
     * Returns the instance ID of the new instance to be spawned. If the argument 'arg' exists, it is used to
     * calculate a client-defined ID. If the argument 'arg' doesn't exist, the normal deriveId is used.
     * It throws an error if the instruction is not of type spawn.
     *
     * @param what to be used if arg is not given
     * @param arg holding the pre-image of the instanceID
     */
    deriveIdArg(what?: string, arg?: string): InstanceID;
    /**
     * Return a general-purpose json representation of an instruction that is
     * contracts aware, ie. knows how to render specific contracts arguments. It
     * returns the following status:
     *
     * 0: the default hex representation is used
     * 1: has been specifically interpreted
     *
     * The JSON has the following structure:
     *
     *  {
     *      status: 0 | 1
     *      type: "spawn|invoke|delete",
     *      contract: "config|darc|..."
     *      args: [
     *          {
     *              "name": "<NAME>",
     *              "value": "<VALUE>",    // Arg value or its summary
     *              "full": "<FULL VALUE>" // Optional. useful if the argument
     *                                     // have a very long representation.
     *          }
     *          ...
     *      ]
     *  }
     *
     */
    beautify(): IBeautifierSchema;
    protected hashForVersion(version: number): Buffer;
}
/**
 * Argument of an instruction
 */
export declare class Argument extends Message<Argument> {
    /**
     * @see README#Message classes
     */
    static register(): void;
    readonly name: string;
    readonly value: Buffer;
    constructor(props?: Properties<Argument>);
}
/**
 * Spawn instruction that will create instances
 */
export declare class Spawn extends Message<Spawn> {
    /**
     * @see README#Message classes
     */
    static register(): void;
    readonly args: Argument[];
    readonly contractID: string;
    constructor(props?: Properties<Spawn>);
}
/**
 * Invoke instruction that will update an existing instance
 */
export declare class Invoke extends Message<Invoke> {
    /**
     * @see README#Message classes
     */
    static register(): void;
    readonly command: string;
    readonly args: Argument[];
    readonly contractID: string;
    constructor(props?: Properties<Invoke>);
}
/**
 * Delete instruction that will delete an instance
 */
export declare class Delete extends Message<Delete> {
    /**
     * @see README#Message classes
     */
    static register(): void;
    readonly contractID: string;
    constructor(props?: Properties<Delete>);
}
export {};
