"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cGetTxTimestampReqVersion = void 0;
exports.serializeGetTxTimestampReq = serializeGetTxTimestampReq;
exports.deserializeGetTxTimestampReq = deserializeGetTxTimestampReq;
const Helpers_1 = require("./ajv/Helpers");
const AJVSchemaEnum_1 = require("./enum/AJVSchemaEnum");
const TypeIdentifierEnum_1 = require("./enum/TypeIdentifierEnum");
exports.cGetTxTimestampReqVersion = 1;
function serializeGetTxTimestampReq(stream, obj, root = false) {
    const errors = (0, Helpers_1.verifyPayload)(AJVSchemaEnum_1.AJVSchemaEnum.GetTxTimestampReq, obj);
    if (errors && errors.length > 0) {
        throw new Error('Data validation error');
    }
    if (root) {
        stream.writeUInt16(TypeIdentifierEnum_1.TypeIdentifierEnum.cGetTxTimestampReq);
    }
    stream.writeUInt8(exports.cGetTxTimestampReqVersion);
    stream.writeString(obj.txId);
    stream.writeUInt32(obj.cycleCounter);
    stream.writeString(obj.cycleMarker);
}
function deserializeGetTxTimestampReq(stream) {
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    const version = stream.readUInt8();
    if (version > exports.cGetTxTimestampReqVersion) {
        throw new Error('GetTxTimestampReqVersion : Unsupported version');
    }
    // eslint-disable-next-line prefer-const
    let obj = {
        txId: stream.readString(),
        cycleCounter: stream.readUInt32(),
        cycleMarker: stream.readString(),
    };
    const errors = (0, Helpers_1.verifyPayload)(AJVSchemaEnum_1.AJVSchemaEnum.GetTxTimestampReq, obj);
    if (errors && errors.length > 0) {
        throw new Error('Data validation error');
    }
    return obj;
}
//# sourceMappingURL=GetTxTimestampReq.js.map