"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deserializeGetTrieHashesReq = exports.serializeGetTrieHashesReq = void 0;
const TypeIdentifierEnum_1 = require("./enum/TypeIdentifierEnum");
const Helpers_1 = require("./ajv/Helpers");
const AJVSchemaEnum_1 = require("./enum/AJVSchemaEnum");
const cGetTrieHashesReqVersion = 1;
function serializeGetTrieHashesReq(stream, request, root = false) {
    if (root) {
        stream.writeUInt16(TypeIdentifierEnum_1.TypeIdentifierEnum.cGetTrieHashesReq);
    }
    stream.writeUInt8(cGetTrieHashesReqVersion);
    stream.writeUInt32(request.radixList.length);
    for (const radix of request.radixList) {
        stream.writeString(radix);
    }
}
exports.serializeGetTrieHashesReq = serializeGetTrieHashesReq;
function deserializeGetTrieHashesReq(stream) {
    const version = stream.readUInt8();
    if (version > cGetTrieHashesReqVersion) {
        throw new Error('Unsupported version in deserializeGetTrieHashesReq');
    }
    const length = stream.readUInt32();
    const radixList = [];
    for (let i = 0; i < length; i++) {
        radixList.push(stream.readString());
    }
    const errors = (0, Helpers_1.verifyPayload)(AJVSchemaEnum_1.AJVSchemaEnum.GetTrieHashesReq, { radixList });
    if (errors && errors.length > 0) {
        throw new Error('AJV: GetTrieHashesReq validation error');
    }
    return { radixList };
}
exports.deserializeGetTrieHashesReq = deserializeGetTrieHashesReq;
//# sourceMappingURL=GetTrieHashesReq.js.map