"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deserializeRequestTxAndStateReq = exports.serializeRequestTxAndStateReq = exports.cRequestTxAndStateReqVersion = void 0;
const TypeIdentifierEnum_1 = require("./enum/TypeIdentifierEnum");
exports.cRequestTxAndStateReqVersion = 1;
function serializeRequestTxAndStateReq(stream, obj, root = false) {
    if (root) {
        stream.writeUInt16(TypeIdentifierEnum_1.TypeIdentifierEnum.cRequestTxAndStateReq);
    }
    stream.writeUInt8(exports.cRequestTxAndStateReqVersion);
    stream.writeString(obj.txid);
    stream.writeUInt32(obj.accountIds.length);
    for (const accountId of obj.accountIds) {
        stream.writeString(accountId);
    }
    stream.writeUInt8(obj.includeAppReceiptData ? 1 : 0);
}
exports.serializeRequestTxAndStateReq = serializeRequestTxAndStateReq;
function deserializeRequestTxAndStateReq(stream) {
    const version = stream.readUInt8();
    if (version > exports.cRequestTxAndStateReqVersion) {
        throw new Error('cRequestTxAndStateReqVersion version mismatch');
    }
    const txid = stream.readString();
    const accountIdsLength = stream.readUInt32();
    const accountIds = [];
    for (let i = 0; i < accountIdsLength; i++) {
        accountIds.push(stream.readString());
    }
    let includeAppReceiptData = false;
    if (stream.readUInt8() === 1) {
        // Check if appReceiptData is requested
        includeAppReceiptData = true;
    }
    return {
        txid,
        accountIds,
        includeAppReceiptData,
    };
}
exports.deserializeRequestTxAndStateReq = deserializeRequestTxAndStateReq;
//# sourceMappingURL=RequestTxAndStateReq.js.map