wearetheledger / fabric-node-chaincode-utils Goto Github PK
View Code? Open in Web Editor NEWUtilities for writing and testing hyperledger Fabric nodejs chaincode
Home Page: https://theledger.be
License: MIT License
Utilities for writing and testing hyperledger Fabric nodejs chaincode
Home Page: https://theledger.be
License: MIT License
stubHelper.getClientIdentity().getAttributeValue('siteName');
stubHelper.generateUUID('333BBB');
createdAt: stubHelper.getTxDate().getTime();
Hi all,
unfortunately, I can no longer build the project because of different assignment issues.
Same happens if I only checkout the project (v2.x) and run npm run build
.
`
node_modules/@theledger/fabric-shim-types/index.d.ts:29:18 - error TS2300: Duplicate identifier 'ClientIdentity'.
29 export class ClientIdentity {
~~~~~~~~~~~~~~
node_modules/fabric-shim/types/index.d.ts:31:18 - error TS2300: Duplicate identifier 'ClientIdentity'.
31 export class ClientIdentity {
~~~~~~~~~~~~~~
node_modules/fabric-shim/types/index.d.ts:128:19 - error TS2320: Interface 'HistoryQueryIterator' cannot simultaneously extend types 'CommonIterator' and 'Iterator'.
Named property 'close' of types 'CommonIterator' and 'Iterator' are not identical.
128 interface HistoryQueryIterator extends CommonIterator {
~~~~~~~~~~~~~~~~~~~~
node_modules/fabric-shim/types/index.d.ts:132:19 - error TS2320: Interface 'StateQueryIterator' cannot simultaneously extend types 'CommonIterator' and 'Iterator'.
Named property 'close' of types 'CommonIterator' and 'Iterator' are not identical.
132 interface StateQueryIterator extends CommonIterator {
~~~~~~~~~~~~~~~~~~
Type '() => 'fabric-shim'.ChaincodeProposal.SignedProposal' is not assignable to type '() => 'fabric-shim'.SignedProposal'.
Type ''fabric-shim'.ChaincodeProposal.SignedProposal' is not assignable to type ''fabric-shim'.SignedProposal'.
Property 'proposal' is missing in type 'SignedProposal'.
44 async Init(stub: Stub): Promise {
~~~~
src/Chaincode.ts:65:11 - error TS2416: Property 'Invoke' in type 'Chaincode' is not assignable to the same property in base type 'ChaincodeInterface'.
Type '(stub: Stub) => Promise' is not assignable to type '{ (stub: ChaincodeStub): Promise; (stub: Stub): Promise; }'.
Types of parameters 'stub' and 'stub' are incompatible.
Type 'ChaincodeStub' is not assignable to type 'Stub'.
65 async Invoke(stub: Stub): Promise {
~~~~~~
src/StubHelper.ts:49:35 - error TS2345: Argument of type 'Stub' is not assignable to a parameter of type 'ChaincodeStub'.
Property 'getStateByRangeWithPagination' is missing in type 'Stub'.
49 return new ClientIdentity(this.stub);
~~~~~~~~~
`
I already have tried to figure out the issue by checking and dependency version but without success :-(.
Any idea what is going on?
Excuse me, I have some questions.
I am using your typescript package to develop fabric application.
I face some problems about gerQueryResultAsList.
here is part of my code to test limit and skip:
const Data = stubHelper.getQueryResultAsList({
"selector": {"Frequency": "Daily"},"limit":2,"skip":0
});
test sort:
const Data = stubHelper.getQueryResultAsList({
"selector": {"Frequency": "Daily"},"limit":2,"skip":1,"sort": {"Name": "desc"},"fields": ["name"]
})
Hello,
I use @theledger/fabric-chaincode-utils to write my chaincode,
and do stubHelper.putState(verifiedArgs.key, myObject).
I have a json object with a empty value, like:
{
name: 'HOME',
firstname: 'John',
foo: '',
age: 30
}
When I want to do channel.sendTransactionProposal() I got a error "Calling chaincode Invoke() returned error response [undefined]. Sending ERROR message back to peer"
How It is possible to put/send a json with some empty values?
Thanks by advance ๐
I have tried to test the library on a modified version of fabcar example and deployed on HLF 1.3.
When calling a chaincode function using the StubHelper.generateUUID method, I got the following issue:
message: 'this.stub.getTxTimestamp(...).toDate is not a function'
Any idea ??
node_modules/@theledger/fabric-chaincode-utils/dist/Chaincode.d.ts:28:5 - error TS2416: Property 'Init' in type 'Chaincode' is not assignable to the same property in base type 'ChaincodeInterface'.
Type '(stub: Stub) => Promise' is not assignable to type '{ (stub: Stub): Promise; (stub: ChaincodeStub): Promise; }'.
Types of parameters 'stub' and 'stub' are incompatible.
Type 'ChaincodeStub' is not assignable to type 'Stub'.
Types of property 'getSignedProposal' are incompatible.
Type '() => import("fabric-shim").ChaincodeProposal.SignedProposal' is not assignable to type '() => import("fabric-shim").SignedProposal'.
Property 'proposal' is missing in type 'import("fabric-shim").ChaincodeProposal.SignedProposal' but required in type 'import("fabric-shim").SignedProposal'.
28 Init(stub: Stub): Promise;
~~~~
node_modules/@theledger/fabric-shim-types/index.d.ts:53:9
53 proposal: Proposal;
~~~~~~~~
'proposal' is declared here.
node_modules/@theledger/fabric-chaincode-utils/dist/Chaincode.d.ts:38:5 - error TS2416: Property 'Invoke' in type 'Chaincode' is not assignable to the same property in base type 'ChaincodeInterface'.
Type '(stub: Stub) => Promise' is not assignable to type '{ (stub: Stub): Promise; (stub: ChaincodeStub): Promise; }'.
Types of parameters 'stub' and 'stub' are incompatible.
Type 'ChaincodeStub' is not assignable to type 'Stub'.
38 Invoke(stub: Stub): Promise;
~~~~~~
node_modules/@theledger/fabric-shim-types/index.d.ts:29:18 - error TS2300: Duplicate identifier 'ClientIdentity'.
29 export class ClientIdentity {
~~~~~~~~~~~~~~
node_modules/fabric-shim/types/index.d.ts:31:18
31 export class ClientIdentity {
~~~~~~~~~~~~~~
'ClientIdentity' was also declared here.
node_modules/@theledger/fabric-shim-types/index.d.ts:95:10 - error TS2300: Duplicate identifier 'ChaincodeResponse'.
95 type ChaincodeResponse = {
~~~~~~~~~~~~~~~~~
node_modules/fabric-shim/types/index.d.ts:13:15
13 interface ChaincodeResponse {
~~~~~~~~~~~~~~~~~
'ChaincodeResponse' was also declared here.
node_modules/@theledger/fabric-shim-types/index.d.ts:207:19 - error TS2320: Interface 'HistoryQueryIterator' cannot simultaneously extend types 'Iterator' and 'CommonIterator'.
Named property 'close' of types 'Iterator' and 'CommonIterator' are not identical.
207 interface HistoryQueryIterator extends Iterator {
~~~~~~~~~~~~~~~~~~~~
node_modules/@theledger/fabric-shim-types/index.d.ts:211:19 - error TS2320: Interface 'StateQueryIterator' cannot simultaneously extend types 'Iterator' and 'CommonIterator'.
Named property 'close' of types 'Iterator' and 'CommonIterator' are not identical.
211 interface StateQueryIterator extends Iterator {
~~~~~~~~~~~~~~~~~~
node_modules/fabric-shim/types/index.d.ts:13:15 - error TS2300: Duplicate identifier 'ChaincodeResponse'.
13 interface ChaincodeResponse {
~~~~~~~~~~~~~~~~~
node_modules/@theledger/fabric-shim-types/index.d.ts:95:10
95 type ChaincodeResponse = {
~~~~~~~~~~~~~~~~~
'ChaincodeResponse' was also declared here.
node_modules/fabric-shim/types/index.d.ts:31:18 - error TS2300: Duplicate identifier 'ClientIdentity'.
31 export class ClientIdentity {
~~~~~~~~~~~~~~
node_modules/@theledger/fabric-shim-types/index.d.ts:29:18
29 export class ClientIdentity {
~~~~~~~~~~~~~~
'ClientIdentity' was also declared here.
src/index.ts:6:12 - error TS2345: Argument of type 'MyChaincode' is not assignable to parameter of type 'ChaincodeInterface'.
Types of property 'Init' are incompatible.
Type '(stub: Stub) => Promise' is not assignable to type '{ (stub: Stub): Promise; (stub: ChaincodeStub): Promise; }'.
6 shim.start(new MyChaincode());
~~~~~~~~~~~~~~~~~
Found 9 errors.
When making a call to StubHelper.prototype.getQueryResultAsList
using Fabric 1.4 (haven't tested with other versions) and @theledger/[email protected], the iterator response is not an actual iterator, but an object containing an iterator as a prop.
This produces the error TypeError: iterator.next is not a function
Hi all, thanks for sharing this library. It is very useful.
I was trying to send appropriate HTTP status codes for some errors in my smart contract chaincode.
Whenever I do throw new NotFoundError('data.not.found');
, I get:
{ "statusCode": 500, "error": "Internal Server Error", "message": "Error: transaction returned with failure: {\"name\":\"Error\",\"status\":500,\"message\":\"data.not.found\"}" }
I get the same HTTP 500 error messages even when I use new ChaincodeError('message', <any HTTP status>);
What am I doing wrong?
Is there any plan to support fabric 1.4 ?
Do you plan to upgrade the package to version 1.3.0 of fabric-shim?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.