1.2.7 • Published 6 years ago

fabric-node-cc-utils v1.2.7

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

fabric-node-cc-utils

Utils for fabric nodejs chaincode.

const { shim, Chaincode, parseCreator, CouchDbQueryResult } = require('fabric-node-cc-utils');

/*
  Extends your class from Chaincode.
  Override Init if you want do something in Init.
  Every function in the class can be called by queryByChaincode/sendTransactionProposal.
  Return value of function will be sent to client by shim.success, string/Buffer/Object type is acceptable.
  Exceptions will be sent to client by shim.error.
*/
class Example extends Chaincode {
  static async getId(stub) {
    return parseCreator(stub).subjectId;
  }

  async getIssuerId(stub) {
    return parseCreator(stub).issuerId;
  }

  async query(stub, args) {
    const q = args[0];
    const res = new CouchDbQueryResult(await stub.getQueryResult(q));
    return await res.toArray();
  }  
}

shim.start(new Example());
1.2.7

6 years ago

1.2.6

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago