Socket
Socket
Sign inDemoInstall

fabric-shim

Package Overview
Dependencies
Maintainers
2
Versions
304
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fabric-shim - npm Package Compare versions

Comparing version 1.0.0-snapshot.5 to 1.0.0-snapshot.6

111

lib/handler.js

@@ -217,3 +217,3 @@ /*

stream.on('error', function (err) {
logger.debug('Chat stream with peer - on error: %j', err.stack ? err.stack : err);
logger.error('Chat stream with peer - on error: %j', err.stack ? err.stack : err);
stream.end();

@@ -235,3 +235,3 @@ });

handleGetState(key, txId) {
async handleGetState(key, txId) {
let msg = {

@@ -243,6 +243,6 @@ type: _serviceProto.ChaincodeMessage.Type.GET_STATE,

return this._askPeerAndListen(msg, 'GetState');
return await this._askPeerAndListen(msg, 'GetState');
}
handlePutState(key, value, txId) {
async handlePutState(key, value, txId) {
let payload = new _serviceProto.PutStateInfo();

@@ -258,6 +258,6 @@ payload.setKey(key);

return this._askPeerAndListen(msg, 'PutState');
return await this._askPeerAndListen(msg, 'PutState');
}
handleDeleteState(key, txId) {
async handleDeleteState(key, txId) {
let msg = {

@@ -269,6 +269,6 @@ type: _serviceProto.ChaincodeMessage.Type.DEL_STATE,

return this._askPeerAndListen(msg, 'DeleteState');
return await this._askPeerAndListen(msg, 'DeleteState');
}
handleGetStateByRange(startKey, endKey, txId) {
async handleGetStateByRange(startKey, endKey, txId) {
let payload = new _serviceProto.GetStateByRange();

@@ -284,6 +284,6 @@ payload.setStartKey(startKey);

return this._askPeerAndListen(msg, 'GetStateByRange');
return await this._askPeerAndListen(msg, 'GetStateByRange');
}
handleQueryStateNext(id, txId) {
async handleQueryStateNext(id, txId) {
let payload = new _serviceProto.QueryStateNext();

@@ -297,6 +297,6 @@ payload.setId(id);

};
return this._askPeerAndListen(msg, 'QueryStateNext');
return await this._askPeerAndListen(msg, 'QueryStateNext');
}
handleQueryStateClose(id, txId) {
async handleQueryStateClose(id, txId) {
let payload = new _serviceProto.QueryStateClose();

@@ -310,6 +310,6 @@ payload.setId(id);

};
return this._askPeerAndListen(msg, 'QueryStateClose');
return await this._askPeerAndListen(msg, 'QueryStateClose');
}
handleGetQueryResult(query, txId) {
async handleGetQueryResult(query, txId) {
let payload = new _serviceProto.GetQueryResult();

@@ -323,6 +323,6 @@ payload.setQuery(query);

};
return this._askPeerAndListen(msg, 'GetQueryResult');
return await this._askPeerAndListen(msg, 'GetQueryResult');
}
handleGetHistoryForKey(key, txId) {
async handleGetHistoryForKey(key, txId) {
let payload = new _serviceProto.GetHistoryForKey();

@@ -336,6 +336,6 @@ payload.setKey(key);

};
return this._askPeerAndListen(msg, 'GetHistoryForKey');
return await this._askPeerAndListen(msg, 'GetHistoryForKey');
}
handleInvokeChaincode(chaincodeName, args, txId) {
async handleInvokeChaincode(chaincodeName, args, txId) {
let payload = new _chaincodeProto.ChaincodeSpec();

@@ -358,10 +358,9 @@ let chaincodeId = new _chaincodeProto.ChaincodeID();

};
return this._askPeerAndListen(msg, 'InvokeChaincode')
.then((message) => {
// here the message type comes back as an enumeration value rather than a string
// so need to use the enumerated value
if (message.type === _serviceProto.ChaincodeMessage.Type.COMPLETED) {
return _responseProto.Response.decode(message.payload);
}
});
let message = await this._askPeerAndListen(msg, 'InvokeChaincode');
// here the message type comes back as an enumeration value rather than a string
// so need to use the enumerated value
if (message.type === _serviceProto.ChaincodeMessage.Type.COMPLETED) {
return _responseProto.Response.decode(message.payload);
}
}

@@ -402,3 +401,3 @@

function handleMessage(msg, client, action) {
async function handleMessage(msg, client, action) {
let nextStateMsg, input;

@@ -432,8 +431,8 @@ try {

if (stub) {
let promise, method;
let resp, method;
if (action === 'init') {
promise = client.chaincode.Init(stub);
resp = await client.chaincode.Init(stub);
method = 'Init';
} else {
promise = client.chaincode.Invoke(stub);
resp = await client.chaincode.Invoke(stub);
method = 'Invoke';

@@ -445,33 +444,31 @@ }

//unhandledPromiseRecection.
promise.then((resp) => {
logger.debug(util.format(
'[%s]Calling chaincode %s(), response status: %s',
shortTxid(msg.txid),
method,
resp.status));
logger.debug(util.format(
'[%s]Calling chaincode %s(), response status: %s',
shortTxid(msg.txid),
method,
resp.status));
if (resp.status >= Stub.RESPONSE_CODE.ERROR) {
let errMsg = util.format('[%s]Calling chaincode %s() returned error response [%s]. Sending ERROR message back to peer',
shortTxid(msg.txid), method, resp.message);
logger.error(errMsg);
if (resp.status >= Stub.RESPONSE_CODE.ERROR) {
let errMsg = util.format('[%s]Calling chaincode %s() returned error response [%s]. Sending ERROR message back to peer',
shortTxid(msg.txid), method, resp.message);
logger.error(errMsg);
nextStateMsg = {
type: _serviceProto.ChaincodeMessage.Type.ERROR,
payload: Buffer.from(errMsg),
txid: msg.txid
};
} else {
logger.info(util.format('[%s]Calling chaincode %s() succeeded. Sending COMPLETED message back to peer',
shortTxid(msg.txid), method));
nextStateMsg = {
type: _serviceProto.ChaincodeMessage.Type.ERROR,
payload: Buffer.from(errMsg),
txid: msg.txid
};
} else {
logger.info(util.format('[%s]Calling chaincode %s() succeeded. Sending COMPLETED message back to peer',
shortTxid(msg.txid), method));
nextStateMsg = {
type: _serviceProto.ChaincodeMessage.Type.COMPLETED,
payload: resp.toBuffer(),
txid: msg.txid,
chaincode_event: stub.chaincodeEvent
};
}
nextStateMsg = {
type: _serviceProto.ChaincodeMessage.Type.COMPLETED,
payload: resp.toBuffer(),
txid: msg.txid,
chaincode_event: stub.chaincodeEvent
};
}
client._stream.write(nextStateMsg);
});
client._stream.write(nextStateMsg);
}

@@ -478,0 +475,0 @@ } else {

@@ -36,4 +36,4 @@ 'use strict';

*/
close() {
return this.handler.handleQueryStateClose(this.response.id, this.txID);
async close() {
return await this.handler.handleQueryStateClose(this.response.id, this.txID);
}

@@ -75,6 +75,6 @@

*/
next() {
async next() {
// check to see if there are some results left in the current result set
if (this.currentLoc < this.response.results.length) {
return Promise.resolve(this._createAndEmitResult());
return this._createAndEmitResult();
}

@@ -84,12 +84,10 @@ else {

if (this.response.has_more) {
return this.handler.handleQueryStateNext(this.response.id, this.txID)
.then((response) => {
this.currentLoc = 0;
this.response = response;
return this._createAndEmitResult();
});
let response = await this.handler.handleQueryStateNext(this.response.id, this.txID);
this.currentLoc = 0;
this.response = response;
return this._createAndEmitResult();
}
// no more, just return EMCA spec defined response
this.emit('end', this);
return Promise.resolve({done: true});
return {done: true};
}

@@ -96,0 +94,0 @@

@@ -197,31 +197,31 @@ /*

getState(key) {
return this.handler.handleGetState(key, this.txId);
async getState(key) {
return await this.handler.handleGetState(key, this.txId);
}
putState(key, value) {
return this.handler.handlePutState(key, value, this.txId);
async putState(key, value) {
return await this.handler.handlePutState(key, value, this.txId);
}
deleteState(key) {
return this.handler.handleDeleteState(key, this.txId);
async deleteState(key) {
return await this.handler.handleDeleteState(key, this.txId);
}
getStateByRange(startKey, endKey) {
return this.handler.handleGetStateByRange(startKey, endKey, this.txId);
async getStateByRange(startKey, endKey) {
return await this.handler.handleGetStateByRange(startKey, endKey, this.txId);
}
getQueryResult(query) {
return this.handler.handleGetQueryResult(query, this.txId);
async getQueryResult(query) {
return await this.handler.handleGetQueryResult(query, this.txId);
}
getHistoryForKey(key) {
return this.handler.handleGetHistoryForKey(key, this.txId);
async getHistoryForKey(key) {
return await this.handler.handleGetHistoryForKey(key, this.txId);
}
invokeChaincode(chaincodeName, args, channel) {
async invokeChaincode(chaincodeName, args, channel) {
if (channel && channel.length > 0) {
chaincodeName = chaincodeName + '/' + channel;
}
return this.handler.handleInvokeChaincode(chaincodeName, args, this.txId);
return await this.handler.handleInvokeChaincode(chaincodeName, args, this.txId);
}

@@ -286,5 +286,5 @@

*/
getStateByPartialCompositeKey(objectType, attributes) {
async getStateByPartialCompositeKey(objectType, attributes) {
let partialCompositeKey = this.createCompositeKey(objectType, attributes);
return this.getStateByRange(partialCompositeKey, partialCompositeKey + MAX_UNICODE_RUNE_VALUE);
return await this.getStateByRange(partialCompositeKey, partialCompositeKey + MAX_UNICODE_RUNE_VALUE);
}

@@ -291,0 +291,0 @@ };

{
"name": "fabric-shim",
"version": "1.0.0-snapshot.5",
"version": "1.0.0-snapshot.6",
"description": "A node.js implementation of Hyperledger Fabric chaincode shim, to allow endorsing peers and user-provided chaincodes to communicate with each other",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc