/// <reference types="node" />
import { BehaviorSubject } from "rxjs";
import { ByzCoinRPC, Instance, InstanceID } from "../../../byzcoin";
import { Darc, IIdentity, Rules } from "../../../darc";
import { TransactionBuilder } from "..";
/**
 * Used in DarcBS.evolve for chosing which parts of the DARC to evolve.
 */
export interface IDarcAttr {
    description?: Buffer;
    rules?: Rules;
}
/**
 * Update rules given an action and an identity. If it's an InstanceID, it will
 * be interpreted as darc:instanceID.
 */
export declare type IRule = [string, IIdentity | InstanceID];
/**
 * DarcStruct holds a darc together with the corresponding instance. This instance can be used to
 * get the version.
 */
export declare class DarcStruct extends Darc {
    readonly inst: Instance;
    constructor(inst: Instance);
}
/**
 * Holds a list of DARCs that will be updated individually, and whenever the list changes.
 */
export declare class DarcInsts extends BehaviorSubject<DarcInst[]> {
    /**
     * Retrieves an eventually changing list of darcs from ByzCoin.
     *
     * @param bc of an initialized ByzCoinRPC instance
     * @param idsBS
     */
    static retrieve(bc: ByzCoinRPC, idsBS: BehaviorSubject<InstanceID[]> | InstanceID[]): Promise<DarcInsts>;
    constructor(sbs: BehaviorSubject<DarcInst[]>);
}
/**
 * A DarcBS class represents a darc on byzcoin. It has methods to modify the darc by
 * adding and removing rules, as well as to change the description.
 */
export declare class DarcInst extends BehaviorSubject<DarcStruct> {
    /**
     * Retrieves a DarcBS from ByzCoin given an InstanceID.
     *
     * @param bc of an initialized ByzCoinRPC instance
     * @param darcID a fixed InstanceID representing the baseID of the darc to retrieve
     * @return a DarcBS or undefined if something went wrong (no Darc at that ID)
     */
    static retrieve(bc: ByzCoinRPC, darcID: InstanceID): Promise<DarcInst>;
    constructor(darc: BehaviorSubject<DarcStruct>);
    /**
     * Creates an instruction in the transaction with either an update of the description and/or an update
     * of the rules.
     *
     * @param tx where the instruction will be appended to
     * @param updates contains a description update and/or rules to be merged
     * @param unrestricted if true, will create an unrestricted evolve that allows to create new rules
     * @return the new DARC as it will appear on ByzCoin if the transaction is accepted
     */
    evolve(tx: TransactionBuilder, updates: IDarcAttr, unrestricted?: boolean): Darc;
    /**
     * Sets the description of the DARC.
     *
     * @param tx where the instruction will be appended to
     * @param description of the new DARC
     * @return the new DARC as it will appear on ByzCoin if the transaction is accepted
     */
    setDescription(tx: TransactionBuilder, description: Buffer): Darc;
    /**
     * Creates a new darc by overwriting existing rules.
     * A darc with a rule for `invoke:darc.evolve_unrestricted` can also accept new rules
     *
     * @param tx where the instruction will be appended to
     * @param newRules is a map of action to expression
     * @return the new DARC as it will appear on ByzCoin if the transaction is accepted
     */
    setRules(tx: TransactionBuilder, ...newRules: IRule[]): Darc;
    /**
     * Adds a sign and evolve element to the DARC with an OR expression
     *
     * @param tx where the instruction will be appended to
     * @param addRules is a map of actions to identities that will be ORed with the existing expression.
     * @return the new DARC as it will appear on ByzCoin if the transaction is accepted
     */
    addToRules(tx: TransactionBuilder, ...addRules: IRule[]): Darc;
    /**
     * Removes an identity in the sign and/or evolve expression. The expressions need to be pure
     * OR expressions, else this will fail.
     *
     * @param tx where the instruction will be appended to
     * @param rmRules is a map of actions to identities that will be removed from existing rules.
     * @return the new DARC as it will appear on ByzCoin if the transaction is accepted
     */
    rmFromRules(tx: TransactionBuilder, ...rmRules: IRule[]): Darc;
    /**
     * Creates the instruction necessary to spawn a new coin using this darc.
     *
     * @param tx where the instruction will be appended to
     * @param name of the coin
     * @param preHash used to calculate the ID of the coin, if given
     */
    spawnCoin(tx: TransactionBuilder, name: Buffer, preHash?: Buffer): InstanceID;
    /**
     * Spawns a new darc. The current darc must have a `spawn:darc` rule.
     *
     * @param tx where the instruction will be appended to
     * @param newDarc to be spawned
     */
    spawnDarc(tx: TransactionBuilder, newDarc: Darc): void;
}
