import BigNumber from 'bignumber.js';
import { Context, TransactionQueue } from "../internal";
import { Identity, ProcedureAuthorizationStatus, ProcedureOpts } from "../types";
import { MapMaybePostTransactionValue, MaybePostTransactionValue, PolymeshTx, PostTransactionValueArray, ProcedureAuthorization, ResolverFunctionArray } from "../types/internal";
interface AddTransactionOptsBase<Values extends unknown[]> {
    fee?: BigNumber;
    resolvers?: ResolverFunctionArray<Values>;
    isCritical?: boolean;
    paidForBy?: Identity;
}
interface AddBatchTransactionOpts<Values extends unknown[], Args extends unknown[]> extends AddTransactionOptsBase<Values> {
    groupByFn?: (obj: MapMaybePostTransactionValue<Args>) => string;
}
interface AddTransactionOpts<Values extends unknown[]> extends AddTransactionOptsBase<Values> {
    batchSize?: number;
}
/**
 * @hidden
 *
 * Represents an operation performed on the Polymesh blockchain.
 * A Procedure can be prepared to yield a [[TransactionQueue]] that can be run
 */
export declare class Procedure<Args extends unknown = void, ReturnValue extends unknown = void, Storage extends unknown = Record<string, unknown>> {
    private prepareTransactions;
    private getAuthorization;
    private prepareStorage;
    private transactions;
    private _storage;
    private _context;
    /**
     * @hidden
     *
     * @param prepareTransactions - function that prepares the transaction queue
     * @param getAuthorization - can be a ProcedureAuthorization object or a function that returns a ProcedureAuthorization object
     */
    constructor(prepareTransactions: (this: Procedure<Args, ReturnValue, Storage>, args: Args) => Promise<MaybePostTransactionValue<ReturnValue>>, getAuthorization?: ProcedureAuthorization | ((this: Procedure<Args, ReturnValue, Storage>, args: Args) => Promise<ProcedureAuthorization> | ProcedureAuthorization), prepareStorage?: (this: Procedure<Args, ReturnValue, Storage>, args: Args) => Promise<Storage> | Storage);
    /**
     * @hidden
     * Set the context and storage (if not already set), return the Context
     */
    private setup;
    /**
     * @hidden
     * Reset the procedure
     */
    private cleanup;
    /**
     * @hidden
     */
    private _checkAuthorization;
    /**
     * Check if the current user has sufficient authorization to run the procedure
     *
     * @param args - procedure arguments
     */
    checkAuthorization(args: Args, context: Context, opts?: ProcedureOpts): Promise<ProcedureAuthorizationStatus>;
    /**
     * Build a [[TransactionQueue]] that can be run
     *
     * @param args.args - arguments required to prepare the queue
     * @param args.transformer - optional function that transforms the Procedure result
     * @param context - context in which the resulting queue will run
     * @param opts.signer - address that will be used as a signer for this procedure
     *   (it must have already been added to the keyring)
     */
    prepare<QueueReturnType>(args: {
        args: Args;
        transformer?: (value: ReturnValue) => QueueReturnType | Promise<QueueReturnType>;
    }, context: Context, opts?: ProcedureOpts): Promise<TransactionQueue<ReturnValue, QueueReturnType>>;
    /**
     * Appends a transaction into the TransactionQueue's queue. This defines
     *   what will be run by the TransactionQueue when it is started.
     *
     * @param tx - a transaction that will be run in the Procedure's TransactionQueue
     * @param options.fee - value in POLYX of the transaction (should only be set manually in special cases, otherwise it is fetched automatically from the chain)
     * @param options.resolvers - asynchronous callbacks used to return runtime data after
     *   the added transaction has finished successfully
     * @param options.isCritical - whether this transaction failing should make the entire queue fail or not. Defaults to true
     * @param options.signer - address or keyring pair of the account that will sign this transaction. Defaults to the current pair in the context
     * @param options.batchSize - amount of elements in the batch (this is only used for certain transactions whose fees depend on the size of the arg list, like `asset.addDocuments`)
     * @param options.paidForBy - third party Identity that will pay for the transaction fees
     * @param args - arguments to be passed to the transaction method
     *
     * @returns an array of [[PostTransactionValue]]. Each element corresponds to whatever is returned by one of the resolver functions passed as options
     */
    addTransaction<TxArgs extends unknown[], Values extends unknown[] = []>(transaction: PolymeshTx<TxArgs>, options: AddTransactionOpts<Values>, ...args: MapMaybePostTransactionValue<TxArgs>): PostTransactionValueArray<Values>;
    /**
     * Appends a Procedure into this Procedure's queue. This defines
     *   what will be run by the Transaction Queue when it is started.
     *
     * @param proc - a Procedure that will be run as part of this Procedure's Transaction Queue
     * @param args - arguments to be passed to the procedure
     *
     * @returns whichever value is returned by the passed Procedure
     */
    addProcedure<ProcArgs extends unknown, R extends unknown, S extends unknown>(procedure: Procedure<ProcArgs, R, S>, args: ProcArgs): Promise<MaybePostTransactionValue<R>>;
    addProcedure<R extends unknown, S extends unknown>(procedure: Procedure<void, R, S>): Promise<MaybePostTransactionValue<R>>;
    /**
     * Appends a batch of transactions into the TransactionQueue's queue. This defines
     *   what will be run by the TransactionQueue when it is started
     *
     * @note if the argument list is too large, they will be separated into multiple batch transactions
     *
     * @param tx - a transaction that will be run in the Procedure's TransactionQueue
     * @param options.fee - value in POLYX of the transaction (should only be set manually in special cases, otherwise it is fetched automatically from the chain)
     * @param options.resolvers - asynchronous callbacks used to return runtime data after
     *   the added transaction has finished successfully
     * @param options.isCritical - whether this transaction failing should make the entire queue fail or not. Defaults to true
     * @param options.signer - address or keyring pair of the account that will sign this transaction. Defaults to the current pair in the context
     * @param options.paidByThirdParty - if the transaction fees will be paid by a third party. Defaults to false
     * @param options.groupByFn - function that establishes how to group the arguments in case the list is too large and they must be separated internally
     * @param args - arguments to be passed to each method in the batch
     *
     * @returns an array of [[PostTransactionValue]]. Each element corresponds to whatever is returned by one of the resolver functions passed as options.
     *   If the batch is separated into smaller batches, resolvers will be run on the last batch
     */
    addBatchTransaction<TxArgs extends unknown[], Values extends unknown[] = []>(transaction: PolymeshTx<TxArgs>, options: AddBatchTransactionOpts<Values, TxArgs>, args: MapMaybePostTransactionValue<TxArgs>[]): PostTransactionValueArray<Values>;
    /**
     * internal data container. Used to store common fetched/processed data that is
     *   used by both `prepareTransactions` and `checkAuthorization`
     */
    get storage(): Storage;
    /**
     * contains the data services, current account, etc. In short, the *context* in which
     *   the Procedure is being run
     */
    get context(): Context;
}
export {};
//# sourceMappingURL=Procedure.d.ts.map