Comments (3)
Definitely you are correct that the error function should take a string parameter: error(msg: string): ErrorResponse
.
The only slight concern is that the ChaincodeResponse returned from the ChaincodeInterface methods really can be anything that fits the shape:
interface ChaincodeResponse {
status: number;
message?: string;
payload? Uint8Array;
}
However, this is really an implementation detail only affecting the low-level shim API for developing chaincode, and the values that actually make sense better fit your type definitions.
Please feel free to open a PR to modify the types as you've described.
from fabric-chaincode-node.
I agree. Perhaps the TypeScript types would be better defined like this?
interface SuccessResponse {
status: RESPONSE_CODE.OK;
message?: string;
payload: Uint8Array;
}
interface ErrorResponse {
status: RESPONSE_CODE.ERROR;
message: string;
payload?: Uint8Array;
}
type ChaincodeResponse = SuccessResponse | ErrorResponse;
export class Shim {
static error(msg: Uint8Array): ErrorResponse;
static success(payload?: Uint8Array): SuccessResponse;
// ...
}
So any fix can properly address your issue, I'm interested to know the impact of this typing mismatch on your use of the API.
from fabric-chaincode-node.
I think the fix could be the following:
interface SuccessResponse { // <- message is unnecessary for SuccessResponse
status: ChaincodeStub.RESPONSE_CODE.OK;
payload: Uint8Array;
}
interface ErrorResponse { // <- payload is unnecessary for ErrorResponse
status: ChaincodeStub.RESPONSE_CODE.ERROR;
message: string;
}
type ChaincodeResponse = SuccessResponse | ErrorResponse;
export class Shim {
static error(msg: string): ErrorResponse; // <- this should be string instead of Uint8Array
static success(payload?: Uint8Array): SuccessResponse;
// ...
}
I was writing test cases for my chain code and discovered the issue. Do you think we can make a pull request?
from fabric-chaincode-node.
Related Issues (20)
- iterator of getHistoryForKey() sdk method is not returning the txId and timestamp HOT 1
- StateBasedEndorsement Policy is missing the nOutOf.. HOT 2
- Port the FullStackApplication Tests to use as a Functional Test HOT 1
- Transition the FV tests to use Microfab HOT 1
- Chaincode does not start due to missing dependency in fabric-shim
- Published release v2.5.3 not tagged as latest HOT 1
- ChaincodeMessageHandler calls non-existent cancel() function on stream
- Wrong getTxTimestamp
- TypeError on chaincode start with fabric-shim >=2.5.1
- Use Node 20
- Fix minor TypeScript issues
- Fix "Cannot find module" errors in TypeScript test files
- Add ESLint TypeScript support
- Document how to start node chaincode as a service, including how to set grpc parameters HOT 2
- Scheduled vulnerability scan
- jsdocs are not getting published HOT 4
- Publish unstable / snapshot packages on every change
- Update @grpc/grpc-js HOT 3
- help me.. im a korean student HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fabric-chaincode-node.