-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-16527] Split fabric-shim into API and impl
Pull the API definition - currently a TypeScript ambient declaration file - into it's own module named fabric-shim-api. This way, users of the contract API or shim API can depend upon it without having to depend on the shim implementation as well. Signed-off-by: Simon Stone <sstone1@uk.ibm.com> Change-Id: I46bb973862431b63a3664b1af937d3e8ec32251f
- Loading branch information
Showing
15 changed files
with
328 additions
and
11,990 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* | ||
# Copyright IBM Corp. All Rights Reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
*/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "fabric-shim-api", | ||
"version": "2.0.0-snapshot", | ||
"tag": "unstable", | ||
"description": "A node.js API of Hyperledger Fabric chaincode shim, to allow endorsing peers and user-provided chaincodes to communicate with each other", | ||
"main": "index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/hyperledger/fabric-chaincode-node" | ||
}, | ||
"keywords": [ | ||
"fabric-shim", | ||
"Hyperledger Fabric", | ||
"Fabric Shim" | ||
], | ||
"engines": { | ||
"node": "10.15.2", | ||
"npm": "^6.4.1" | ||
}, | ||
"types": "./types/index.d.ts", | ||
"license": "Apache-2.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
/* | ||
Copyright 2018 IBM All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
declare module 'fabric-shim-api' { | ||
|
||
interface Timestamp { | ||
seconds: number; | ||
nanos: number; | ||
} | ||
|
||
interface ChaincodeResponse { | ||
status: number; | ||
message: string; | ||
payload: Uint8Array; | ||
} | ||
|
||
interface ClientIdentity { | ||
assertAttributeValue(attrName: string, attrValue: string): boolean; | ||
getAttributeValue(attrName: string): string | null; | ||
getID(): string; | ||
getIDBytes(): Uint8Array; | ||
getMSPID(): string; | ||
} | ||
|
||
interface SerializedIdentity { | ||
mspid: string; | ||
idBytes: Uint8Array; | ||
} | ||
|
||
interface QueryResponseMetadata { | ||
fetchedRecordsCount: number; | ||
bookmark: string; | ||
} | ||
|
||
interface StateQueryResponse<T> { | ||
iterator: T; | ||
metadata: QueryResponseMetadata; | ||
} | ||
|
||
enum RESPONSE_CODE { | ||
OK = 200, | ||
ERRORTHRESHOLD = 400, | ||
ERROR = 500 | ||
} | ||
|
||
interface ChaincodeStub { | ||
getArgs(): string[]; | ||
getStringArgs(): string[]; | ||
getFunctionAndParameters(): { params: string[], fcn: string }; | ||
|
||
getTxID(): string; | ||
getChannelID(): string; | ||
getCreator(): SerializedIdentity; | ||
getTransient(): Map<string, Uint8Array>; | ||
|
||
getSignedProposal(): ChaincodeProposal.SignedProposal; | ||
getTxTimestamp(): Timestamp; | ||
getBinding(): string; | ||
|
||
getState(key: string): Promise<Uint8Array>; | ||
putState(key: string, value: Uint8Array): Promise<void>; | ||
deleteState(key: string): Promise<void>; | ||
setStateValidationParameter(key: string, ep: Uint8Array): Promise<void>; | ||
getStateValidationParameter(key: string): Promise<Uint8Array>; | ||
getStateByRange(startKey: string, endKey: string): Promise<Iterators.StateQueryIterator> & AsyncIterable<Iterators.KV>; | ||
getStateByRangeWithPagination(startKey: string, endKey: string, pageSize: number, bookmark?: string): Promise<StateQueryResponse<Iterators.StateQueryIterator>> & AsyncIterable<Iterators.KV>; | ||
getStateByPartialCompositeKey(objectType: string, attributes: string[]): Promise<Iterators.StateQueryIterator> & AsyncIterable<Iterators.KV>; | ||
getStateByPartialCompositeKeyWithPagination(objectType: string, attributes: string[], pageSize: number, bookmark?: string): Promise<StateQueryResponse<Iterators.StateQueryIterator>> & AsyncIterable<Iterators.KV>; | ||
|
||
getQueryResult(query: string): Promise<Iterators.StateQueryIterator> & AsyncIterable<Iterators.KV>; | ||
getQueryResultWithPagination(query: string, pageSize: number, bookmark?: string): Promise<StateQueryResponse<Iterators.StateQueryIterator>> & AsyncIterable<Iterators.KV>; | ||
getHistoryForKey(key: string): Promise<Iterators.HistoryQueryIterator> & AsyncIterable<Iterators.KeyModification>; | ||
|
||
invokeChaincode(chaincodeName: string, args: string[], channel: string): Promise<ChaincodeResponse>; | ||
setEvent(name: string, payload: Uint8Array): void; | ||
|
||
createCompositeKey(objectType: string, attributes: string[]): string; | ||
splitCompositeKey(compositeKey: string): SplitCompositekey; | ||
|
||
getPrivateData(collection: string, key: string): Promise<Uint8Array>; | ||
getPrivateDataHash(collection: string, key: string): Promise<Uint8Array>; | ||
putPrivateData(collection: string, key: string, value: Uint8Array): Promise<void>; | ||
deletePrivateData(collection: string, key: string): Promise<void>; | ||
setPrivateDataValidationParameter(collection: string, key: string, ep: Uint8Array): Promise<void>; | ||
getPrivateDataValidationParameter(collection: string, key: string): Promise<Uint8Array>; | ||
getPrivateDataByRange(collection: string, startKey: string, endKey: string): Promise<Iterators.StateQueryIterator> & AsyncIterable<Iterators.KV>; | ||
getPrivateDataByPartialCompositeKey(collection: string, objectType: string, attributes: string[]): Promise<Iterators.StateQueryIterator> & AsyncIterable<Iterators.KV>; | ||
getPrivateDataQueryResult(collection: string, query: string): Promise<Iterators.StateQueryIterator> & AsyncIterable<Iterators.KV>; | ||
} | ||
|
||
interface SplitCompositekey { | ||
objectType: string; | ||
attributes: string[]; | ||
} | ||
|
||
interface ChaincodeInterface { | ||
Init(stub: ChaincodeStub): Promise<ChaincodeResponse>; | ||
Invoke(stub: ChaincodeStub): Promise<ChaincodeResponse>; | ||
} | ||
|
||
namespace Iterators { | ||
|
||
interface CommonIterator<T> { | ||
close(): Promise<void>; | ||
next(): Promise<NextResult<T>>; | ||
} | ||
|
||
interface NextResult<T> { | ||
value: T; | ||
done: boolean; | ||
} | ||
|
||
type HistoryQueryIterator = CommonIterator<KeyModification>; | ||
type StateQueryIterator = CommonIterator<KV>; | ||
|
||
interface NextKeyModificationResult { | ||
value: KeyModification; | ||
done: boolean; | ||
} | ||
|
||
interface KV { | ||
namespace: string; | ||
key: string; | ||
value: Uint8Array; | ||
} | ||
|
||
interface KeyModification { | ||
isDelete: boolean; | ||
value: Uint8Array; | ||
timestamp: Timestamp; | ||
txId: string; | ||
} | ||
} | ||
|
||
namespace ChaincodeProposal { | ||
interface SignedProposal { | ||
proposal: Proposal; | ||
signature: Uint8Array; | ||
} | ||
|
||
interface Proposal { | ||
header: Header; | ||
payload: ChaincodeProposalPayload; | ||
} | ||
|
||
interface Header { | ||
channelHeader: ChannelHeader; | ||
signatureHeader: SignatureHeader; | ||
} | ||
|
||
interface ChannelHeader { | ||
type: HeaderType; | ||
version: number; | ||
timestamp: Timestamp; | ||
channelId: string; | ||
txId: string; | ||
epoch: number; | ||
extension: Uint8Array; | ||
tlsCertHash: Uint8Array; | ||
} | ||
|
||
interface SignatureHeader { | ||
creator: SerializedIdentity; | ||
nonce: Uint8Array; | ||
} | ||
|
||
interface ChaincodeProposalPayload { | ||
input: Uint8Array; | ||
transientMap: Map<string, Uint8Array>; | ||
} | ||
|
||
enum HeaderType { | ||
MESSAGE = 0, | ||
CONFIG = 1, | ||
CONFIG_UPDATE = 2, | ||
ENDORSER_TRANSACTION = 3, | ||
ORDERER_TRANSACTION = 4, | ||
DELIVER_SEEK_INFO = 5, | ||
CHAINCODE_PACKAGE = 6, | ||
PEER_ADMIN_OPERATION = 8 | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
Copyright 2018 IBM All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
{ | ||
"compilerOptions": { | ||
"removeComments": false, | ||
"preserveConstEnums": true, | ||
"sourceMap": true, | ||
"declaration": true, | ||
"noImplicitAny": true, | ||
"noImplicitReturns": true, | ||
"noImplicitThis": true, | ||
"suppressImplicitAnyIndexErrors": true, | ||
"moduleResolution": "node", | ||
"module": "commonjs", | ||
"target": "es6", | ||
"outDir": "dist", | ||
"baseUrl": ".", | ||
"paths": { | ||
"*": [ | ||
"node_modules/*" | ||
] | ||
}, | ||
"lib": [ | ||
"esnext" | ||
] | ||
}, | ||
"files": [ | ||
"index.d.ts" | ||
], | ||
"formatCodeOptions": { | ||
"indentSize": 2, | ||
"tabSize": 2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.