@siglesiasg/node-red-hyperledger-fabric-gateway
Version:
Hyperledger Fabric 2.x nodes for node-red with latest fabric-gateway library
33 lines • 1.8 kB
JavaScript
;
const node_red_utils_1 = require("../../libs/node-red-utils");
const connection_config_model_1 = require("../../models/connection-config.model");
const fabric_decoder_1 = require("./../../libs/fabric-decoder");
const fabric_functions_1 = require("./../../libs/fabric-functions");
const fabric_error_handler_1 = require("./../../libs/fabric-error-handler");
module.exports = (RED) => {
RED.nodes.registerType('fabric-channel-info', fabricChannelInfoNode);
function fabricChannelInfoNode(config) {
RED.nodes.createNode(this, config);
const connection = (0, connection_config_model_1.buildConnectionConfig)(RED, config);
const fabricChannelDef = (0, node_red_utils_1.getConfigValidate)(RED, config.channelSelector);
const chainInfoDecoder = (0, fabric_decoder_1.buildChannelInfoDecoder)();
this.debug('Fabric Get Channel Info Node Created');
this.status({ fill: 'green', shape: 'dot', text: 'Ready' });
this.on('input', async (msg, send, done) => {
try {
this.status({ fill: 'yellow', shape: 'dot', text: 'Querying...' });
await (0, fabric_functions_1.invokeChaincodeGeneric)(RED, this, msg, chainInfoDecoder, 'evaluate', connection, config.channelSelector, 'qscc', 'GetChainInfo', [fabricChannelDef.channel]);
this.status({ fill: 'green', shape: 'dot', text: 'Done' });
send(msg);
done();
}
catch (error) {
(0, fabric_error_handler_1.handleError)(this, done, error);
}
});
this.on('close', async (removed, done) => {
await fabric_functions_1.closeConnection.call(this, connection, done);
});
}
};
//# sourceMappingURL=fabric-channel-info.js.map