"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const long_1 = tslib_1.__importDefault(require("long"));
const light_1 = require("protobufjs/light");
const __1 = require("..");
const darc_1 = tslib_1.__importDefault(require("../../darc/darc"));
const proto_1 = require("../../network/proto");
const protobuf_1 = require("../../protobuf");
const skipblock_1 = require("../../skipchain/skipblock");
const proof_1 = tslib_1.__importStar(require("../proof"));
/**
 * Request to create a byzcoin skipchain
 */
class CreateGenesisBlock extends light_1.Message {
    constructor(props) {
        super(props);
        this.darcContractIDs = this.darcContractIDs || [];
        /* Protobuf aliases */
        Object.defineProperty(this, "genesisdarc", {
            get() {
                return this.genesisDarc;
            },
            set(value) {
                this.genesisDarc = value;
            },
        });
        Object.defineProperty(this, "blockinterval", {
            get() {
                return this.blockInterval;
            },
            set(value) {
                this.blockInterval = value;
            },
        });
        Object.defineProperty(this, "maxblocksize", {
            get() {
                return this.maxBlockSize;
            },
            set(value) {
                this.maxBlockSize = value;
            },
        });
        Object.defineProperty(this, "darccontractids", {
            get() {
                return this.darcContractIDs;
            },
            set(value) {
                this.darcContractIDs = value;
            },
        });
    }
    /**
     * @see README#Message classes
     */
    static register() {
        protobuf_1.registerMessage("CreateGenesisBlock", CreateGenesisBlock, proto_1.Roster, darc_1.default);
    }
}
exports.CreateGenesisBlock = CreateGenesisBlock;
/**
 * Response of a request to create byzcoin skipchain
 */
class CreateGenesisBlockResponse extends light_1.Message {
    /**
     * @see README#Message classes
     */
    static register() {
        protobuf_1.registerMessage("CreateGenesisBlockResponse", CreateGenesisBlockResponse, skipblock_1.SkipBlock);
    }
}
exports.CreateGenesisBlockResponse = CreateGenesisBlockResponse;
/**
 * Request to get the proof of presence/absence of a given key
 */
class GetProof extends light_1.Message {
    /**
     * @see README#Message classes
     */
    static register() {
        protobuf_1.registerMessage("GetProof", GetProof);
    }
}
exports.GetProof = GetProof;
/**
 * Response of a proof request
 */
class GetProofResponse extends light_1.Message {
    /**
     * @see README#Message classes
     */
    static register() {
        protobuf_1.registerMessage("GetProofResponse", GetProofResponse, proof_1.default);
    }
}
exports.GetProofResponse = GetProofResponse;
/**
 * Request to add a transaction
 */
class AddTxRequest extends light_1.Message {
    constructor(props) {
        super(props);
        /* Protobuf aliases */
        Object.defineProperty(this, "skipchainid", {
            get() {
                return this.skipchainID;
            },
            set(value) {
                this.skipchainID = value;
            },
        });
    }
    /**
     * @see README#Message classes
     */
    static register() {
        protobuf_1.registerMessage("AddTxRequest", AddTxRequest, __1.ClientTransaction);
    }
}
exports.AddTxRequest = AddTxRequest;
/**
 * Response of a request to add a transaction
 */
class AddTxResponse extends light_1.Message {
    /**
     * @see README#Message classes
     */
    static register() {
        protobuf_1.registerMessage("AddTxResponse", AddTxResponse);
    }
}
exports.AddTxResponse = AddTxResponse;
/**
 * Request to get the current counters for given signers
 */
class GetSignerCounters extends light_1.Message {
    constructor(props) {
        super(props);
        this.signerIDs = this.signerIDs || [];
        /* Protobuf aliases */
        Object.defineProperty(this, "signerids", {
            get() {
                return this.signerIDs;
            },
            set(value) {
                this.signerIDs = value;
            },
        });
        Object.defineProperty(this, "skipchainid", {
            get() {
                return this.skipchainID;
            },
            set(value) {
                this.skipchainID = value;
            },
        });
    }
    /**
     * @see README#Message classes
     */
    static register() {
        protobuf_1.registerMessage("GetSignerCounters", GetSignerCounters);
    }
}
exports.GetSignerCounters = GetSignerCounters;
/**
 * Response of a counter request in the same order as the signers array
 */
class GetSignerCountersResponse extends light_1.Message {
    constructor(props) {
        super(props);
        this.counters = this.counters || [];
    }
    /**
     * @see README#Message classes
     */
    static register() {
        protobuf_1.registerMessage("GetSignerCountersResponse", GetSignerCountersResponse);
    }
}
exports.GetSignerCountersResponse = GetSignerCountersResponse;
/**
 * Holds an instanceID and it's latest known version.
 */
class IDVersion extends light_1.Message {
    static register() {
        protobuf_1.registerMessage("IDVersion", IDVersion);
    }
}
exports.IDVersion = IDVersion;
/**
 * Requests a set of proofs that will be returned in a single message.
 * The reply will only hold proofs for instances that have a higher version than the ones given here.
 */
class GetUpdatesRequest extends light_1.Message {
    static register() {
        protobuf_1.registerMessage("GetUpdatesRequest", GetUpdatesRequest, IDVersion);
    }
}
exports.GetUpdatesRequest = GetUpdatesRequest;
// send all instances with version 0, even those that are not updated.
GetUpdatesRequest.sendVersion0 = long_1.default.fromNumber(1);
// send proofs for missing instances. If not present, missing instances are ignored.
GetUpdatesRequest.sendMissingProofs = long_1.default.fromNumber(2);
/**
 * The requested proofs
 */
class GetUpdatesReply extends light_1.Message {
    static register() {
        protobuf_1.registerMessage("GetUpdatesReply", GetUpdatesReply, proof_1.InclusionProof, skipblock_1.ForwardLink, skipblock_1.SkipBlock);
    }
}
exports.GetUpdatesReply = GetUpdatesReply;
/**
 * Request information about a specific version of an instance. The node might not have this version in its cache,
 * so it might return an error.
 */
class GetInstanceVersion extends light_1.Message {
    static register() {
        protobuf_1.registerMessage("GetInstanceVersion", GetInstanceVersion);
    }
}
exports.GetInstanceVersion = GetInstanceVersion;
/**
 * Request the latest version of this instance. The difference with this and GetProof is that it doesn't return a
 * full proof, but it includes the block where this instance has been created or modified.
 */
class GetLastInstanceVersion extends light_1.Message {
    static register() {
        protobuf_1.registerMessage("GetLastInstanceVersion", GetLastInstanceVersion);
    }
}
exports.GetLastInstanceVersion = GetLastInstanceVersion;
/**
 * Returns the StateChangeBody and the block index where this instance has been created or modified. Contrary to
 * GetProof, this does not return a full proof that can be verified by the client. For this, the client has to
 * either request the block itself, or ask for a GetProof to get the latest version of the instance.
 */
class GetInstanceVersionResponse extends light_1.Message {
    static register() {
        protobuf_1.registerMessage("GetInstanceVersionResponse", GetInstanceVersionResponse, proof_1.StateChangeBody);
    }
}
exports.GetInstanceVersionResponse = GetInstanceVersionResponse;
/**
 * Requests all known versions of a given instance. The nodes only hold a certain amount of versions, so this might
 * not go back all the way to the version where the instance has been created.
 */
class GetAllInstanceVersion extends light_1.Message {
    static register() {
        protobuf_1.registerMessage("GetAllInstanceVersion", GetAllInstanceVersion);
    }
}
exports.GetAllInstanceVersion = GetAllInstanceVersion;
/**
 * Reply holding all known versions of this instance.
 */
class GetAllInstanceVersionResponse extends light_1.Message {
    static register() {
        protobuf_1.registerMessage("GetAllInstanceVersionResponse", GetAllInstanceVersionResponse, GetInstanceVersionResponse);
    }
}
exports.GetAllInstanceVersionResponse = GetAllInstanceVersionResponse;
CreateGenesisBlock.register();
CreateGenesisBlockResponse.register();
GetProof.register();
GetProofResponse.register();
AddTxRequest.register();
AddTxResponse.register();
GetSignerCounters.register();
GetSignerCountersResponse.register();
GetUpdatesRequest.register();
GetUpdatesReply.register();
GetInstanceVersion.register();
GetLastInstanceVersion.register();
GetInstanceVersionResponse.register();
GetAllInstanceVersion.register();
GetAllInstanceVersionResponse.register();
