"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cGetTrieAccountHashesReqVersion = void 0;
exports.serializeGetTrieAccountHashesReq = serializeGetTrieAccountHashesReq;
exports.deserializeGetTrieAccountHashesReq = deserializeGetTrieAccountHashesReq;
const TypeIdentifierEnum_1 = require("./enum/TypeIdentifierEnum");
const Helpers_1 = require("./ajv/Helpers");
const AJVSchemaEnum_1 = require("./enum/AJVSchemaEnum");
exports.cGetTrieAccountHashesReqVersion = 1;
function serializeGetTrieAccountHashesReq(stream, req, root = false) {
    if (root) {
        stream.writeUInt16(TypeIdentifierEnum_1.TypeIdentifierEnum.cGetAccountTrieHashesReq);
    }
    stream.writeUInt8(exports.cGetTrieAccountHashesReqVersion);
    stream.writeUInt16(req.radixList.length);
    stream.writeString(req.radixList.join(','));
}
function deserializeGetTrieAccountHashesReq(stream) {
    const version = stream.readUInt8();
    if (version !== exports.cGetTrieAccountHashesReqVersion) {
        throw new Error(`Unsupported version for GetAccountTrieHashesReq: ${version}`);
    }
    const radixListLength = stream.readUInt16();
    let radixList = [];
    if (radixListLength > 0) {
        radixList = stream.readString().split(',');
    }
    const errors = (0, Helpers_1.verifyPayload)(AJVSchemaEnum_1.AJVSchemaEnum.GetTrieAccountHashesReq, {
        radixList,
    });
    if (errors && errors.length > 0) {
        throw new Error('Data validation error');
    }
    return {
        radixList,
    };
}
//# sourceMappingURL=GetTrieAccountHashesReq.js.map