{"size": 3180, "ext": "js", "max_stars_repo_path": "hyperledger-fabric-sdk/node_modules/fabric-network/lib/impl/event/privateblockeventfactory.js", "max_stars_repo_name": "amandeep4272/securing-electronic-patient-records", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "hyperledger-fabric-sdk/node_modules/fabric-network/lib/impl/event/privateblockeventfactory.js", "max_issues_repo_name": "amandeep4272/securing-electronic-patient-records", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "hyperledger-fabric-sdk/node_modules/fabric-network/lib/impl/event/privateblockeventfactory.js", "max_forks_repo_name": "amandeep4272/securing-electronic-patient-records", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 48.1818181818, "max_line_length": 145, "alphanum_fraction": 0.7216981132}
"use strict";
/*
 * Copyright 2020 IBM All Rights Reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.newPrivateBlockEvent = void 0;
const gatewayutils_1 = require("../gatewayutils");
const fullblockeventfactory_1 = require("./fullblockeventfactory");
const fullcontracteventfactory_1 = require("./fullcontracteventfactory");
const fulltransactioneventfactory_1 = require("./fulltransactioneventfactory");
const util = __importStar(require("util"));
function newPrivateBlockEvent(eventInfo) {
    const privateData = eventInfo.privateData;
    if (!privateData) {
        throw new Error('No private data found: ' + util.inspect(eventInfo));
    }
    const fullBlockEvent = (0, fullblockeventfactory_1.newFullBlockEvent)(eventInfo);
    const privateBlockEvent = {
        blockNumber: fullBlockEvent.blockNumber,
        blockData: fullBlockEvent.blockData,
        getTransactionEvents: (0, gatewayutils_1.cachedResult)(() => newPrivateTransactionEvents(privateBlockEvent, privateData))
    };
    return Object.freeze(privateBlockEvent);
}
exports.newPrivateBlockEvent = newPrivateBlockEvent;
function newPrivateTransactionEvents(blockEvent, privateData) {
    return (0, fulltransactioneventfactory_1.getTransactionEnvelopeIndexes)(blockEvent.blockData)
        .map((index) => newPrivateTransactionEvent(blockEvent, index, privateData[index]));
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function newPrivateTransactionEvent(blockEvent, index, privateData) {
    const fullTransactionEvent = (0, fulltransactioneventfactory_1.newFullTransactionEvent)(blockEvent, index);
    const privateTransactionEvent = {
        transactionId: fullTransactionEvent.transactionId,
        status: fullTransactionEvent.status,
        transactionData: fullTransactionEvent.transactionData,
        isValid: fullTransactionEvent.isValid,
        // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
        privateData,
        getBlockEvent: () => blockEvent,
        getContractEvents: (0, gatewayutils_1.cachedResult)(() => (0, fullcontracteventfactory_1.newFullContractEvents)(privateTransactionEvent))
    };
    return Object.freeze(privateTransactionEvent);
}
//# sourceMappingURL=privateblockeventfactory.js.map