diff --git a/packages/node-red-contrib-composer/README.md b/packages/node-red-contrib-composer/README.md index 1688bf7..50c1db9 100644 --- a/packages/node-red-contrib-composer/README.md +++ b/packages/node-red-contrib-composer/README.md @@ -16,7 +16,7 @@ In this example we will create a participant, the participant . 2. Create a `hyperledger-composer-out node` -3. Enter the `connection profile name`, `business network identifier`, `user Id`, and `user secret` on the `hyperledger-composer-out node`. +3. On `Composer Card` click the pencil top add a new config node. Specify the `card name`, or use the drop down to use one previous created. 4. Use an inject node and set it to use `JSON` and enter the following JSON @@ -33,8 +33,8 @@ A node red mid flow node that allows you to create, retrieve, update, or delete This example follows on from the above example. It will retrieve the participant that was created above. 1. Create a `hyperledger-composer-mid node` - - 2. Enter the `connection profile name`, `business network identifier`, `user Id`, and `user secret` on the `hyperledger-composer-mid node`. + + 2. On `Composer Card` click the pencil top add a new config node. Specify the `card name`, or use the drop down to use one previous created. 3. Use an `inject node` and set it to use JSON and enter the following JSON @@ -46,3 +46,5 @@ This example follows on from the above example. It will retrieve the participant ##Hyperledger-Composer-In A node red input node that subscribes to events from a blockchain + +1. On `Composer Card` click the pencil top add a new config node. Specify the `card name`, or use the drop down to use one previous created. diff --git a/packages/node-red-contrib-composer/nodes/hyperledger-composer-config.html b/packages/node-red-contrib-composer/nodes/hyperledger-composer-config.html index d54f007..714fe7b 100644 --- a/packages/node-red-contrib-composer/nodes/hyperledger-composer-config.html +++ b/packages/node-red-contrib-composer/nodes/hyperledger-composer-config.html @@ -2,34 +2,18 @@ RED.nodes.registerType('hyperledger-composer-config',{ category: 'config', defaults: { - connectionProfile: {value:"hlfv1",required:true}, - businessNetworkIdentifier: {value:"",required:true}, - userID: {value:"",required:true}, - userSecret: {value:"",required:true}, + cardName: {value:"",required:true} }, label: function() { - return this.connectionProfile+":"+this.businessNetworkIdentifier; + return this.cardName; } }); diff --git a/packages/node-red-contrib-composer/nodes/hyperledger-composer-config.js b/packages/node-red-contrib-composer/nodes/hyperledger-composer-config.js index 280546a..f26bdf3 100644 --- a/packages/node-red-contrib-composer/nodes/hyperledger-composer-config.js +++ b/packages/node-red-contrib-composer/nodes/hyperledger-composer-config.js @@ -1,10 +1,7 @@ module.exports = function(RED) { function HyperledgerComposerConfigNode(n) { RED.nodes.createNode(this,n); - this.connectionProfile = n.connectionProfile; - this.businessNetworkIdentifier = n.businessNetworkIdentifier; - this.userID = n.userID; - this.userSecret = n.userSecret; + this.cardName = n.cardName; } RED.nodes.registerType("hyperledger-composer-config",HyperledgerComposerConfigNode); -} \ No newline at end of file +}; diff --git a/packages/node-red-contrib-composer/nodes/hyperledger-composer.html b/packages/node-red-contrib-composer/nodes/hyperledger-composer.html index 82e2bed..638808a 100644 --- a/packages/node-red-contrib-composer/nodes/hyperledger-composer.html +++ b/packages/node-red-contrib-composer/nodes/hyperledger-composer.html @@ -21,8 +21,8 @@
- - + +
@@ -41,11 +41,11 @@
- - + +
- +
- - + +
@@ -85,7 +85,7 @@ paletteLabel: "Hyperledger Composer", defaults: { name: {value: ""}, - composerProfile: {value:"", type:"hyperledger-composer-config"}, + composerCard: {value:"", type:"hyperledger-composer-config"}, actionType: {value: "create"} }, @@ -110,7 +110,7 @@ paletteLabel: "Hyperledger Composer", defaults: { name: {value: ""}, - composerProfile: {value:"", type:"hyperledger-composer-config"}, + composerCard: {value:"", type:"hyperledger-composer-config"}, actionType: {value: "create"} }, inputs : 0, @@ -136,7 +136,7 @@ paletteLabel: "Hyperledger Composer", defaults: { name: {value: ""}, - composerProfile: {value:"", type:"hyperledger-composer-config"}, + composerCard: {value:"", type:"hyperledger-composer-config"}, actionType : {value : "create"}, resolve: {value:false}, }, diff --git a/packages/node-red-contrib-composer/nodes/hyperledger-composer.js b/packages/node-red-contrib-composer/nodes/hyperledger-composer.js index 22029ab..d6fa43f 100644 --- a/packages/node-red-contrib-composer/nodes/hyperledger-composer.js +++ b/packages/node-red-contrib-composer/nodes/hyperledger-composer.js @@ -24,7 +24,7 @@ module.exports = function (RED) { let connectionPromise; let businessNetworkConnection = new BusinessNetworkConnection(); - let connectionProfileName, businessNetworkIdentifier, userID, userSecret; + let cardName; let businessNetworkDefinition, serializer; let listener; @@ -38,15 +38,11 @@ module.exports = function (RED) { */ function connectInternal (node) { node.log('connectInternal'); - node.log('settings: connectionProfileName' + connectionProfileName + ' businessNetworkIdentifier ' + businessNetworkIdentifier + ' userID ' + userID + ' userSecret ' + userSecret); + node.log('settings: cardName' + cardName); connecting = true; connected = false; connectionPromise = businessNetworkConnection - .connect(connectionProfileName, - businessNetworkIdentifier, - userID, - userSecret - ) + .connect(cardName) .then((result) => { // setup some objects for this business network businessNetworkDefinition = result; @@ -203,7 +199,7 @@ module.exports = function (RED) { }) .then((result) => { node.log('got asset'); - if(resolve) { + if (resolve) { return result; } else { return serializer.toJSON(result); @@ -364,14 +360,8 @@ module.exports = function (RED) { function checkConfig (config) { return Promise.resolve().then(() => { - if (!config.connectionProfile) { - throw new Error('connection profile must be set'); - } else if (!config.businessNetworkIdentifier) { - throw new Error('business network identifier must be set'); - } else if (!config.userID) { - throw new Error('user ID must be set'); - } else if (!config.userSecret) { - throw new Error('user secret must be set'); + if (!config.cardName) { + throw new Error('card name must be set'); } return ''; @@ -408,14 +398,12 @@ module.exports = function (RED) { RED.nodes.createNode(node, config); node.on('input', function (msg) { - node.log('checking config'); - this.composer = RED.nodes.getNode(config.composerProfile); + node.log('config ' + config.composerCard); + this.composer = RED.nodes.getNode(config.composerCard); + node.log('checking config' + this.composer); checkConfig(this.composer) .then(() => { - connectionProfileName = this.composer.connectionProfile; - businessNetworkIdentifier = this.composer.businessNetworkIdentifier; - userID = this.composer.userID; - userSecret = this.composer.userSecret; + cardName = this.composer.cardName; node.log('checking payload'); return checkPayLoad(msg.payload, config.actionType); @@ -455,13 +443,10 @@ module.exports = function (RED) { node.on('input', function (msg) { node.log('checking config'); - this.composer = RED.nodes.getNode(config.composerProfile); + this.composer = RED.nodes.getNode(config.composerCard); checkConfig(this.composer) .then(() => { - connectionProfileName = this.composer.connectionProfile; - businessNetworkIdentifier = this.composer.businessNetworkIdentifier; - userID = this.composer.userID; - userSecret = this.composer.userSecret; + cardName = this.composer.cardName; return checkPayLoad(msg.payload, config.actionType); @@ -506,14 +491,11 @@ module.exports = function (RED) { function HyperledgerComposerInNode (config) { let node = this; RED.nodes.createNode(node, config); - this.composer = RED.nodes.getNode(config.composerProfile); + this.composer = RED.nodes.getNode(config.composerCard); node.log('checking config'); checkConfig(this.composer) .then(() => { - connectionProfileName = this.composer.connectionProfile; - businessNetworkIdentifier = this.composer.businessNetworkIdentifier; - userID = this.composer.userID; - userSecret = this.composer.userSecret; + cardName = this.composer.cardName; return subscribeToEvents(node); diff --git a/packages/node-red-contrib-composer/package.json b/packages/node-red-contrib-composer/package.json index 7f63538..74a1740 100644 --- a/packages/node-red-contrib-composer/package.json +++ b/packages/node-red-contrib-composer/package.json @@ -3,8 +3,8 @@ "version": "0.0.9", "description": "Hyperledger Composer nodes for node-red", "dependencies": { - "composer-client": "^0.14.0-0", - "composer-common": "^0.14.0-0" + "composer-client": "^0.15.0-0", + "composer-common": "^0.15.0-0" }, "devDependencies": { "eslint": "^3.5.0"