@siglesiasg/node-red-hyperledger-fabric-gateway
Version:
Hyperledger Fabric 2.x nodes for node-red with latest fabric-gateway library
32 lines • 1.61 kB
JavaScript
;
const fabric_functions_1 = require("../../libs/fabric-functions");
const fabric_decoder_1 = require("./../../libs/fabric-decoder");
const fabric_functions_2 = require("./../../libs/fabric-functions");
const connection_config_model_1 = require("./../../models/connection-config.model");
const fabric_error_handler_1 = require("./../../libs/fabric-error-handler");
module.exports = (RED) => {
RED.nodes.registerType('fabric-cc-evaluate', fabricCCEvaluateNode);
function fabricCCEvaluateNode(config) {
RED.nodes.createNode(this, config);
const connection = (0, connection_config_model_1.buildConnectionConfig)(RED, config);
const genericDecoder = (0, fabric_decoder_1.buildGenericDecoder)();
this.debug('Fabric Generic 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: 'Evaluating...' });
await (0, fabric_functions_1.invokeChaincode)(RED, this, msg, genericDecoder, 'evaluate', connection, config);
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_2.closeConnection.call(this, connection, done);
});
}
};
//# sourceMappingURL=fabric-cc-evaluate.js.map