"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cApoptosisProposalReqVersion = void 0;
exports.serializeApoptosisProposalReq = serializeApoptosisProposalReq;
exports.deserializeApoptosisProposalReq = deserializeApoptosisProposalReq;
const Helpers_1 = require("./ajv/Helpers");
const AJVSchemaEnum_1 = require("./enum/AJVSchemaEnum");
const TypeIdentifierEnum_1 = require("./enum/TypeIdentifierEnum");
exports.cApoptosisProposalReqVersion = 1;
function serializeApoptosisProposalReq(stream, obj, root = false) {
    if (root) {
        stream.writeUInt16(TypeIdentifierEnum_1.TypeIdentifierEnum.cApoptosisProposalReq);
    }
    stream.writeUInt8(exports.cApoptosisProposalReqVersion);
    stream.writeString(obj.id);
    stream.writeUInt32(obj.when);
}
function deserializeApoptosisProposalReq(stream) {
    const version = stream.readUInt8();
    if (version > exports.cApoptosisProposalReqVersion) {
        throw new Error('ApoptosisProposalReq version mismatch');
    }
    const id = stream.readString();
    const when = stream.readUInt32();
    const obj = {
        id,
        when,
    };
    const errors = (0, Helpers_1.verifyPayload)(AJVSchemaEnum_1.AJVSchemaEnum.ApoptosisProposalReq, obj);
    if (errors && errors.length > 0) {
        throw new Error('Data validation error');
    }
    return obj;
}
//# sourceMappingURL=ApoptosisProposalReq.js.map