ibm-blockchain-js
Advanced tools
Comparing version 1.2.8 to 1.3.0
160
index.js
@@ -100,5 +100,2 @@ 'use strict'; | ||
// Step 2 - optional - only for secure networks | ||
if(options.network.users){ | ||
options.network.users = helper.filter_users(options.network.users); //only use the appropriate IDs filter out the rest | ||
} | ||
if(options.network.users && options.network.users.length > 0){ | ||
@@ -124,3 +121,3 @@ ibc.chaincode.details.users = options.network.users; | ||
ibc.chaincode.details.users = []; | ||
logger.log('[ibc-js] No membership users found after filtering, assuming this is a network w/o membership'); | ||
logger.log('[ibc-js] No membership users found, assuming this is a network w/o membership'); | ||
load_cc(); | ||
@@ -745,35 +742,19 @@ } | ||
var options = {}, body = {}; | ||
if(ibc.chaincode.details.version.indexOf('hyperledger/fabric/core/chaincode/shim') >= 0){ //hyperledger body format | ||
options = {path: '/chaincode'}; | ||
body = { | ||
jsonrpc: '2.0', | ||
method: 'deploy', | ||
params: { | ||
type: 1, | ||
chaincodeID:{ | ||
path: ibc.chaincode.details.git_url | ||
}, | ||
ctorMsg: { | ||
function: func, | ||
args: args | ||
}, | ||
secureContext: enrollId | ||
}, | ||
id: Date.now() | ||
}; | ||
} | ||
else{ //obc-peer body format | ||
options = {path: '/devops/deploy'}; | ||
body = { | ||
type: 'GOLANG', | ||
chaincodeID: { | ||
path: ibc.chaincode.details.git_url | ||
}, | ||
ctorMsg:{ | ||
'function': func, | ||
'args': args | ||
}, | ||
secureContext: enrollId | ||
}; | ||
} | ||
options = {path: '/chaincode'}; | ||
body = { | ||
jsonrpc: '2.0', | ||
method: 'deploy', | ||
params: { | ||
type: 1, | ||
chaincodeID:{ | ||
path: ibc.chaincode.details.git_url | ||
}, | ||
ctorMsg: { | ||
function: func, | ||
args: args | ||
}, | ||
secureContext: enrollId | ||
}, | ||
id: Date.now() | ||
}; | ||
@@ -912,38 +893,19 @@ // ---- Success ---- // | ||
var options = {}, body = {}; | ||
if(ibc.chaincode.details.version.indexOf('hyperledger/fabric/core/chaincode/shim') >= 0){ | ||
options = {path: '/chaincode'}; | ||
body = { | ||
jsonrpc: '2.0', | ||
method: 'invoke', | ||
params: { | ||
type: 1, | ||
chaincodeID:{ | ||
name: ibc.chaincode.details.deployed_name | ||
}, | ||
ctorMsg: { | ||
function: name, | ||
args: args | ||
}, | ||
secureContext: enrollId | ||
}, | ||
id: Date.now() | ||
}; | ||
} | ||
else{ | ||
options = {path: '/devops/invoke'}; | ||
body = { | ||
chaincodeSpec: { | ||
type: 'GOLANG', | ||
chaincodeID: { | ||
name: ibc.chaincode.details.deployed_name, | ||
}, | ||
ctorMsg: { | ||
function: name, | ||
args: args | ||
}, | ||
secureContext: enrollId | ||
} | ||
}; | ||
} | ||
options = {path: '/chaincode'}; | ||
body = { | ||
jsonrpc: '2.0', | ||
method: 'invoke', | ||
params: { | ||
type: 1, | ||
chaincodeID:{ | ||
name: ibc.chaincode.details.deployed_name | ||
}, | ||
ctorMsg: { | ||
function: name, | ||
args: args | ||
}, | ||
secureContext: enrollId | ||
}, | ||
id: Date.now() | ||
}; | ||
options.success = function(statusCode, data){ | ||
@@ -984,37 +946,19 @@ logger.log('[ibc-js]', name, ' - success:', data); | ||
if(ibc.chaincode.details.version.indexOf('hyperledger/fabric/core/chaincode/shim') >= 0){ | ||
options = {path: '/chaincode'}; | ||
body = { | ||
jsonrpc: '2.0', | ||
method: 'query', | ||
params: { | ||
type: 1, | ||
chaincodeID:{ | ||
name: ibc.chaincode.details.deployed_name | ||
}, | ||
ctorMsg: { | ||
function: name, | ||
args: args | ||
}, | ||
secureContext: enrollId | ||
}, | ||
id: Date.now() | ||
}; | ||
} | ||
else{ | ||
options = {path: '/devops/query'}; | ||
body = { | ||
chaincodeSpec: { | ||
type: 'GOLANG', | ||
chaincodeID: { | ||
name: ibc.chaincode.details.deployed_name, | ||
}, | ||
ctorMsg: { | ||
function: name, | ||
args: args | ||
}, | ||
secureContext: enrollId | ||
} | ||
}; | ||
} | ||
options = {path: '/chaincode'}; | ||
body = { | ||
jsonrpc: '2.0', | ||
method: 'query', | ||
params: { | ||
type: 1, | ||
chaincodeID:{ | ||
name: ibc.chaincode.details.deployed_name | ||
}, | ||
ctorMsg: { | ||
function: name, | ||
args: args | ||
}, | ||
secureContext: enrollId | ||
}, | ||
id: Date.now() | ||
}; | ||
@@ -1021,0 +965,0 @@ options.success = function(statusCode, data){ |
{ | ||
"name": "ibm-blockchain-js", | ||
"version": "1.2.8", | ||
"version": "1.3.0", | ||
"description": "A library for easily interacting with IBM Blockchain.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -188,3 +188,3 @@ *Are you looking for the Marbles app demo? That’s not here, head to the [marbles example](https://github.com/IBM-Blockchain/marbles)* | ||
- It will register the first peer with the first enrollId, the 2nd peer against the 2nd enrollId and so on. | ||
- This function only runs if valid users are found in options.network.users. A valid user is one that contains 'type_1'. | ||
- This function only runs if users are found in options.network.users. | ||
- Any errors in register will stop execution and run callback(err). | ||
@@ -549,3 +549,3 @@ 1. ibc.load_chaincode(options.chaincode, [callback]) | ||
"users": [{ | ||
"enrollId": "user_type1_xxx", | ||
"enrollId": "xxx", | ||
"enrollSecret": "xxx" | ||
@@ -562,10 +562,2 @@ }], | ||
*ibc.load() appears to ignore all of my users for secure context. Then it complains it found "No membership users" and never registers with a Peer!* | ||
- Correct behavior of `ibc.load()` is to remove any enrollIds that do not contain 'type_1' in their name. | ||
This is to conform to the OBC Peer spec of what enrollIds a dev's app should use. | ||
If this is not applicable for your network (ie you have a custom IBM Blockchain network) you can easily create your own version of `ibc.load()` for your needs. | ||
I would copy the code found in `ibc.load()` then modify it to fit your own needs. | ||
Everything important that `ibc.load()` calls is exposed in this module. | ||
*Do you have any examples that use this?* | ||
@@ -572,0 +564,0 @@ |
@@ -30,3 +30,5 @@ // Function testing the SDK | ||
"username": "user_type0_52737ec3c6", | ||
"secret": "4841d68d27" | ||
"secret": "4841d68d27", | ||
"enrollId":"user_type0_52737ec3c6", | ||
"enrollSecret":"4841d68d27" | ||
}] }, | ||
@@ -33,0 +35,0 @@ |
90678
1377
576