Skip to content

Commit

Permalink
Fix ChaincodeResponse definition and add new response types (#413) (#414
Browse files Browse the repository at this point in the history
)

Signed-off-by: Jerrylum <[email protected]>
  • Loading branch information
Jerrylum authored Mar 10, 2024
1 parent 6126c09 commit 2d94982
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
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

0 comments on commit 2d94982

Please sign in to comment.