ibm-blockchain-js
Advanced tools
Comparing version 1.2.1 to 1.2.2
37
index.js
@@ -13,2 +13,3 @@ 'use strict'; | ||
var path = require('path'); | ||
var http = require('http'); | ||
var https = require('https'); | ||
@@ -197,3 +198,3 @@ var async = require('async'); | ||
var file = fs.createWriteStream(zip_dest); | ||
https.get(download_url, function(response) { | ||
var handleResponse = function(response) { //download a .zip of the repo | ||
response.pipe(file); | ||
@@ -210,7 +211,16 @@ file.on('finish', function() { | ||
}); | ||
}).on('error', function(err) { | ||
}; | ||
var handleError = function(err) { | ||
logger.error('! [ibc-js] Download error'); | ||
fs.unlink(zip_dest); //delete the file async | ||
if (cb) cb(helper.eFmt('doad_chaincode() download error', 500, err.message), ibc.chaincode); | ||
}); | ||
}; | ||
var protocol = download_url.split('://')[0]; | ||
if(protocol === 'https') { //choose http or https | ||
https.get(download_url, handleResponse).on('error', handleError); | ||
} | ||
else{ | ||
http.get(download_url, handleResponse).on('error', handleError); | ||
} | ||
} | ||
@@ -222,3 +232,3 @@ | ||
try{ | ||
var zip = new AdmZip(zip_dest); | ||
var zip = new AdmZip(zip_dest); //unzip the zip we downloaded | ||
zip.extractAllTo(unzip_dest, /*overwrite*/true); | ||
@@ -268,3 +278,3 @@ } | ||
if(!found_invoke){ //warning no run/invoke functions | ||
logger.wartn('! [ibc-js] Warning - did not find any invoke functions in chaincode\'s "Invoke()", building a generic "invoke"'); | ||
logger.warn('! [ibc-js] Warning - did not find any invoke functions in chaincode\'s "Invoke()", building a generic "invoke"'); | ||
build_invoke_func('invoke'); //this will make chaincode.invoke.invokce(args) | ||
@@ -435,3 +445,3 @@ } | ||
var errors = []; | ||
ibc.chaincode.details.options = {quiet: true, timeout: 60000, tls: true}; //defaults | ||
ibc.chaincode.details.options = {quiet: true, timeout: 60000, tls: true}; //defaults | ||
@@ -545,3 +555,2 @@ if(!arrayPeers || arrayPeers.constructor !== Array) errors.push('network input arg should be array of peer objects'); | ||
else { | ||
//logger.log(' - saved ', dest); | ||
if(cb) cb(null, null); | ||
@@ -598,7 +607,7 @@ } | ||
function read(args, enrollId, cb){ | ||
if(typeof enrollId === 'function'){ //if cb is in 2nd param use known enrollId | ||
if(typeof enrollId === 'function'){ //if cb is in 2nd param use known enrollId | ||
cb = enrollId; | ||
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollID; | ||
} | ||
if(enrollId == null) { //if enrollId not provided, use known valid one | ||
if(enrollId == null) { //if enrollId not provided, use known valid one | ||
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollID; | ||
@@ -725,7 +734,7 @@ } | ||
function deploy(func, args, deploy_options, enrollId, cb){ | ||
if(typeof enrollId === 'function'){ //if cb is in 2nd param use known enrollId | ||
if(typeof enrollId === 'function'){ //if cb is in 2nd param use known enrollId | ||
cb = enrollId; | ||
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollID; | ||
} | ||
if(enrollId == null) { //if enrollId not provided, use known valid one | ||
if(enrollId == null) { //if enrollId not provided, use known valid one | ||
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollID; | ||
@@ -736,3 +745,3 @@ } | ||
logger.log('[ibc-js] \tfunction:', func, ', arg:', args); | ||
logger.log('\n\n\t Waiting...'); //this can take awhile | ||
logger.log('\n\n\t Waiting...'); //this can take awhile | ||
@@ -781,2 +790,4 @@ var options = {}, body = {}; | ||
if(ibc.chaincode.details.deployed_name.length < 32) ibc.chaincode.details.deployed_name = ''; //doesnt look right, let code below catch error | ||
if(ibc.chaincode.details.deployed_name === ''){ | ||
@@ -1029,2 +1040,2 @@ logger.error('\n\n\t deploy resp error - there is no chaincode hash name in response:', data); | ||
module.exports = ibc; | ||
module.exports = ibc; |
{ | ||
"name": "ibm-blockchain-js", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "A library for easily interacting with IBM Blockchain.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90572
1408
4