UNPKG

@siglesiasg/node-red-hyperledger-fabric-gateway

Version:

Hyperledger Fabric 2.x nodes for node-red with latest fabric-gateway library

31 lines 1.54 kB
"use strict"; const fabric_functions_1 = require("../../libs/fabric-functions"); const connection_config_model_1 = require("../../models/connection-config.model"); const fabric_decoder_1 = require("./../../libs/fabric-decoder"); const fabric_error_handler_1 = require("./../../libs/fabric-error-handler"); module.exports = (RED) => { RED.nodes.registerType('fabric-cc-generic', fabricGenericNode); function fabricGenericNode(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: 'Querying...' }); await (0, fabric_functions_1.invokeChaincode)(RED, this, msg, genericDecoder, config.actionType, 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_1.closeConnection.call(this, connection, done); }); } }; //# sourceMappingURL=fabric-cc-generic.js.map