UNPKG

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

Version:

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

32 lines 1.6 kB
"use strict"; const fabric_functions_1 = require("../../libs/fabric-functions"); const fabric_decoder_1 = require("./../../libs/fabric-decoder"); const fabric_error_handler_1 = require("./../../libs/fabric-error-handler"); const fabric_functions_2 = require("./../../libs/fabric-functions"); const connection_config_model_1 = require("./../../models/connection-config.model"); module.exports = (RED) => { RED.nodes.registerType('fabric-cc-submit', fabricCCSubmitNode); function fabricCCSubmitNode(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, 'submit', 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-submit.js.map