"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeGetAppliedVoteResp = serializeGetAppliedVoteResp;
exports.deserializeGetAppliedVoteResp = deserializeGetAppliedVoteResp;
const AJVSchemaEnum_1 = require("./enum/AJVSchemaEnum");
const AppliedVote_1 = require("./AppliedVote");
const TypeIdentifierEnum_1 = require("./enum/TypeIdentifierEnum");
const Helpers_1 = require("./ajv/Helpers");
const cGetAppliedVoteRespVersion = 1;
function serializeGetAppliedVoteResp(stream, obj, root = false) {
    if (root) {
        stream.writeUInt16(TypeIdentifierEnum_1.TypeIdentifierEnum.cGetAppliedVoteResp);
    }
    stream.writeUInt8(cGetAppliedVoteRespVersion);
    stream.writeString(obj.txId);
    (0, AppliedVote_1.serializeAppliedVote)(stream, obj.appliedVote); // Serialize AppliedVote object
    stream.writeString(obj.appliedVoteHash);
}
function deserializeGetAppliedVoteResp(stream) {
    const version = stream.readUInt8();
    if (version > cGetAppliedVoteRespVersion) {
        throw new Error('GetAppliedVoteResp version mismatch');
    }
    const txId = stream.readString();
    const appliedVote = (0, AppliedVote_1.deserializeAppliedVote)(stream); // Deserialize AppliedVote object
    const appliedVoteHash = stream.readString();
    const result = {
        txId,
        appliedVote,
        appliedVoteHash,
    };
    const errors = (0, Helpers_1.verifyPayload)(AJVSchemaEnum_1.AJVSchemaEnum.GetAppliedVoteResp, result);
    if (errors && errors.length > 0) {
        throw new Error(`AJV: validation error -> ${errors.join(', ')}`);
    }
    return result;
}
//# sourceMappingURL=GetAppliedVoteResp.js.map