Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ChaincodeResponse definition and add new response types (#413) #414

Merged
merged 2 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion apis/fabric-shim-api/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,21 @@ declare module 'fabric-shim-api' {

interface ChaincodeResponse {
status: number;
message: string;
message?: string;
payload?: Uint8Array;
}

interface SuccessResponse {
status: RESPONSE_CODE.OK;
message?: string;
payload: Uint8Array;
}

interface ErrorResponse {
status: RESPONSE_CODE.ERROR;
message: string;
payload?: Uint8Array;
}

interface ClientIdentity {
assertAttributeValue(attrName: string, attrValue: string): boolean;
Expand Down
12 changes: 8 additions & 4 deletions libraries/fabric-shim/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ declare module 'fabric-shim' {
import {
ChaincodeInterface,
ChaincodeProposal,
ErrorResponse,
SuccessResponse,
ChaincodeResponse,
ChaincodeStub as IChaincodeStub,
ClientIdentity as IClientIdentity,
Expand All @@ -26,6 +28,8 @@ declare module 'fabric-shim' {
export {
ChaincodeInterface,
ChaincodeProposal,
ErrorResponse,
SuccessResponse,
ChaincodeResponse,
Iterators,
QueryResponseMetadata,
Expand All @@ -35,16 +39,16 @@ declare module 'fabric-shim' {
Timestamp
}

export function error(msg: Uint8Array): ChaincodeResponse;
export function error(msg: string): ErrorResponse;
export function newLogger(name: string): Logger;
export function start(chaincode: ChaincodeInterface): any;
export function success(payload?: Uint8Array): ChaincodeResponse;
export function success(payload?: Uint8Array): SuccessResponse;

export class Shim {
static error(msg: Uint8Array): ChaincodeResponse;
static error(msg: string): ErrorResponse;
static newLogger(name: string): Logger;
static start(chaincode: ChaincodeInterface): any;
static success(payload?: Uint8Array): ChaincodeResponse;
static success(payload?: Uint8Array): SuccessResponse;
static server(chaincode: ChaincodeInterface, serverOpts: ChaincodeServerOpts): ChaincodeServer;
}

Expand Down
Loading