@fabric-es/operator
Version:
Network operator
34 lines • 1.19 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getQueries = void 0;
const util_1 = __importDefault(require("util"));
const utils_1 = require("../utils");
const getQueries = (option) => async ({ asLocalhost } = { asLocalhost: true }) => {
let channel;
let gateway;
const logger = utils_1.getLogger({ name: '[operator] getQueries.js' });
const { connectionProfile, channelName, mspId, wallet, caAdmin, } = option;
try {
gateway = await utils_1.getGateway({
connectionProfile,
identity: caAdmin,
wallet,
asLocalhost,
});
const network = await gateway.getNetwork(channelName);
channel = network.getChannel();
}
catch (e) {
logger.error(util_1.default.format('fail to connect gateway, %j', e));
throw new Error(e);
}
return {
disconnect: () => gateway.disconnect(),
getMspid: () => mspId,
};
};
exports.getQueries = getQueries;
//# sourceMappingURL=getQueries.js.map