/// <reference types="node" />
import Long from "long";
import { Message, Properties } from "protobufjs/light";
import { Instruction } from "../byzcoin";
import ByzCoinRPC from "../byzcoin/byzcoin-rpc";
import CoinInstance, { Coin } from "../byzcoin/contracts/coin-instance";
import DarcInstance from "../byzcoin/contracts/darc-instance";
import ValueInstance from "../byzcoin/contracts/value-instance";
import Instance, { InstanceID } from "../byzcoin/instance";
import { CalypsoWriteInstance } from "../calypso/calypso-instance";
import { LongTermSecret } from "../calypso/calypso-rpc";
import { IIdentity } from "../darc";
import Darc from "../darc/darc";
import Signer from "../darc/signer";
import ISigner from "../darc/signer";
import CredentialsInstance, { CredentialStruct } from "./credentials-instance";
import { PopPartyInstance } from "./pop-party-instance";
import { PopDesc } from "./proto";
import RoPaSciInstance from "./ro-pa-sci-instance";
export declare const SPAWNER_COIN: Buffer;
export default class SpawnerInstance extends Instance {
    private rpc;
    readonly costs: SpawnerStruct;
    static readonly contractID = "spawner";
    static readonly argumentCredential = "credential";
    static readonly argumentCredID = "credID";
    static readonly argumentDarc = "darc";
    static readonly argumentDarcID = "darcID";
    static readonly argumentCoinID = "coinID";
    static readonly argumentCoinName = "coinName";
    static readonly argumentCoinValue = "coinValue";
    /**
     * Spawn a spawner instance. It takes either an ICreateSpawner as single argument, or all the arguments
     * separated.
     *
     * @param params The ByzCoinRPC to use or an ICreateSpawner
     * @param darcID The darc instance ID
     * @param signers The list of signers
     * @param costs The different cost for new instances
     * @param beneficiary The beneficiary of the costs
     * @param preID Can be used to define the InstanceID of the credential
     */
    static spawn(params: ICreateSpawner | ByzCoinRPC, darcID?: InstanceID, signers?: Signer[], costs?: ICreateCost, beneficiary?: InstanceID, preID?: Buffer): Promise<SpawnerInstance>;
    /**
     * Initializes using an existing coinInstance from ByzCoin
     *
     * @param bc an initialized byzcoin RPC instance
     * @param iid the instance-ID of the spawn-instance
     * @param waitMatch how many times to wait for a match - useful if its called just after an addTransactionAndWait.
     * @param interval how long to wait between two attempts in waitMatch.
     */
    static fromByzcoin(bc: ByzCoinRPC, iid: InstanceID, waitMatch?: number, interval?: number): Promise<SpawnerInstance>;
    private struct;
    /**
     * Creates a new SpawnerInstance
     * @param rpc        The ByzCoinRPC instance
     * @param inst   A valid spawner instance
     */
    constructor(rpc: ByzCoinRPC, inst: Instance);
    /**
     * Update the data of this instance
     *
     * @returns a promise that resolves once the data is up-to-date
     */
    update(): Promise<SpawnerInstance>;
    /**
     * Create the instructions necessary to spawn one or more darcs. This is separated from the
     * spanDarcs method itself, so that a caller can create a bigger ClientTransaction with
     * multiple sets of instructions inside.
     *
     * @param coin where to take the coins from
     * @param darcs the darcs to create
     */
    spawnDarcInstructions(coin: CoinInstance, ...darcs: Darc[]): Instruction[];
    /**
     * Spawns one or more darc and returns an array of all the spawned darcs.
     *
     * @param coin      The coin instance to take coins from
     * @param signers   The signers for the transaction
     * @param darcs... All the darcs to spawn using the spawner. The coin instance must have enough
     * coins to pay for all darcs.
     * @returns a promise that resolves with the new array of the instantiated darc instances
     */
    spawnDarcs(coin: CoinInstance, signers: Signer[], ...darcs: Darc[]): Promise<DarcInstance[]>;
    /**
     * Creates all the necessary instruction to create a new coin - either with a 0 balance, or with
     * a given balance by the caller.
     *
     * @param coin where to take the coins to create the instance
     * @param darcID the responsible darc for the new coin
     * @param coinID the type of coin - must be the same as the `coin` in case of balance > 0
     * @param balance how many coins to transfer to the new coin
     */
    spawnCoinInstructions(coin: CoinInstance, darcID: InstanceID, coinID: Buffer, balance?: Long): Instruction[];
    /**
     * Create a coin instance for a given darc
     *
     * @param coin      The coin instance to take the coins from
     * @param signers   The signers for the transaction
     * @param darcID    The darc responsible for this coin
     * @param coinID    The instance-ID for the coin - will be calculated as sha256("coin" | coinID)
     * @param balance   The starting balance
     * @returns a promise that resolves with the new coin instance
     */
    spawnCoin(coin: CoinInstance, signers: Signer[], darcID: InstanceID, coinID: Buffer, balance?: Long): Promise<CoinInstance>;
    /**
     * Creates the instructions necessary to create a credential. This is separated from the spawnCredential
     * method, so that a caller can get the instructions separated and then put all the instructions
     * together in a big ClientTransaction.
     *
     * @param coin coin-instance to pay for the credential
     * @param darcID responsible darc for the credential
     * @param cred the credential structure
     * @param credID if given, used to calculate the iid of the credential, else the darcID will be used
     */
    spawnCredentialInstruction(coin: CoinInstance, darcID: Buffer, cred: CredentialStruct, credID?: Buffer): Instruction[];
    /**
     * Create a credential instance for the given darc
     *
     * @param coin      The coin instance to take coins from
     * @param signers   The signers for the transaction
     * @param darcID    The darc instance ID
     * @param cred      The starting credentials
     * @param credID    The instance-ID for this credential - will be calculated as sha256("credential" | credID)
     * @returns a promise that resolves with the new credential instance
     */
    spawnCredential(coin: CoinInstance, signers: ISigner[], darcID: Buffer, cred: CredentialStruct, credID?: Buffer): Promise<CredentialsInstance>;
    /**
     * Create a PoP party
     *
     * @param params structure of {coin, signers, orgs, desc, reward}
     * @returns a promise tha resolves with the new pop party instance
     */
    spawnPopParty(params: ICreatePopParty): Promise<PopPartyInstance>;
    /**
     * Create a Rock-Paper-scissors game instance
     *
     * @param params structure of {desc, coin, signers, stake, choice, fillup}
     * @returns a promise that resolves with the new instance
     */
    spawnRoPaSci(params: ICreateRoPaSci): Promise<RoPaSciInstance>;
    /**
     * Creates a new calypso write instance for a given key. The key will be encrypted under the
     * aggregated public key. This method creates both the darc that will be protecting the
     * calypsoWrite, as well as the calypsoWrite instance.
     *
     * @param coinInst this coin instance will pay for spawning the calypso write
     * @param signers allow the `invoke:coin.fetch` call on the coinInstance
     * @param lts the id of the long-term-secret that will re-encrypt the key
     * @param key the symmetric key that will be stored encrypted on-chain - not more than 31 bytes.
     * @param ident allowed to re-encrypt the symmetric key
     * @param data additionl data that will be stored AS-IS on chain! So it must be either encrypted using
     * the symmetric 'key', or meta data that is public.
     */
    spawnCalypsoWrite(coinInst: CoinInstance, signers: Signer[], lts: LongTermSecret, key: Buffer, ident: IIdentity[], data?: Buffer): Promise<CalypsoWriteInstance>;
    /**
     * Creates all the necessary instruction to create a new value - either with a 0 balance, or with
     * a given balance by the caller.
     *
     * @param coin where to take the coins to create the instance
     * @param darcID the responsible darc for the new coin
     * @param value the value to store in the instance
     */
    spawnValueInstructions(coin: CoinInstance, darcID: InstanceID, value: Buffer): Instruction[];
    /**
     * Create a value instance for a given darc
     *
     * @param coin      The coin instance to take the coins from
     * @param signers   The signers for the transaction
     * @param darcID    The darc responsible for this coin
     * @param value     The value to store in the instance
     * @returns a promise that resolves with the new coin instance
     */
    spawnValue(coin: CoinInstance, signers: Signer[], darcID: InstanceID, value: Buffer): Promise<ValueInstance>;
}
/**
 * Data of a spawner instance
 */
export declare class SpawnerStruct extends Message<SpawnerStruct> {
    /**
     * @see README#Message classes
     */
    static register(): void;
    readonly costDarc: Coin;
    readonly costCoin: Coin;
    readonly costCredential: Coin;
    readonly costParty: Coin;
    readonly costRoPaSci: Coin;
    readonly costCWrite: Coin;
    readonly costCRead: Coin;
    readonly costValue: Coin;
    readonly beneficiary: InstanceID;
    constructor(props?: Properties<SpawnerStruct>);
}
/**
 * Fields of the costs of a spawner instance
 */
export interface ICreateCost {
    costCRead: Long;
    costCWrite: Long;
    costCoin: Long;
    costCredential: Long;
    costDarc: Long;
    costParty: Long;
    costRoPaSci: Long;
    costValue: Long;
    [k: string]: Long;
}
/**
 * Parameters to create a spawner instance
 */
interface ICreateSpawner {
    bc: ByzCoinRPC;
    darcID: InstanceID;
    signers: Signer[];
    costs: ICreateCost;
    beneficiary: InstanceID;
    [k: string]: any;
}
/**
 * Parameters to create a rock-paper-scissors game
 */
interface ICreateRoPaSci {
    desc: string;
    coin: CoinInstance;
    signers: Signer[];
    stake: Long;
    choice: number;
    fillup: Buffer;
    calypso?: LongTermSecret;
    [k: string]: any;
}
/**
 * Parameters to create a pop party
 */
interface ICreatePopParty {
    coin: CoinInstance;
    signers: Signer[];
    orgs: InstanceID[];
    desc: PopDesc;
    reward: Long;
    [k: string]: any;
}
export {};
