Skip to content
This repository was archived by the owner on Feb 9, 2021. It is now read-only.

Commit e40a745

Browse files
committed
Import release v0.10.1
This is a legacy import of the release originally managed in pure github. You may find the history of this release in the archives here: https://github.com/hyperledger-archives/fabric-chaintool/releases/tag/v0.10.1 Change-Id: I57fcb68c85ccf92b6eee4b57f97f41ddf0f59e2b Signed-off-by: Gregory Haskins <[email protected]>
1 parent 9a8948b commit e40a745

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+447
-585
lines changed

README.md

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ _chaintool_ is a toolchain to assist in various phases of [Hyperledger Fabric](h
88

99
### Why?
1010

11-
Current chaincode development is rather unstructured outside of the coarse-level callbacks for invoke or query passing a {function-name, argument-array} string-based tuple. The result of this is that input translation/validation is a manual, explicit, and likely fragile process in each chaincode function. Additionally, any potential chaincode consumer needs to study the chaincode source in order to ascertain its API.
11+
Current chaincode development is rather unstructured outside of the coarse-level callbacks for Invoke() passing opaque bytes. The result of this is that input translation/validation is a manual, explicit, and likely fragile process in each chaincode function. Additionally, any potential chaincode consumer needs to study the chaincode source in order to ascertain its API.
1212

1313
Consider that some chaincode applications may employ confidentiality to hide their source, while others may wish to employ alternative programming languages. This aside, chaincode deployment lifecycles may be long enough to require us to be aware of managing potential API incompatibilities between the chaincode and its clients. It starts to become clear that there are some advantages to allowing chaincode to express its API interfaces in a way that is independent from the underlying implementation/language and in a manner that supports some form of schema management.
1414

@@ -30,7 +30,7 @@ _chaintool_ provides some other benefits too, such as consistent language-neutra
3030

3131
```
3232
$ chaintool -h
33-
chaintool version: v0.7
33+
chaintool version: v0.10.1
3434
3535
Usage: chaintool [general-options] action [action-options]
3636
@@ -60,7 +60,7 @@ In all cases, you may obtain subcommand specific help by invoking "chaintool _$s
6060

6161
```
6262
$ chaintool package -h
63-
chaintool version: v0.7
63+
chaintool version: v0.10.1
6464
6565
Description: chaintool package - Package the chaincode into a CAR file for deployment
6666
@@ -210,7 +210,7 @@ The only core requirement is that both _chaintool_ and the chosen Hyperledger ne
210210

211211
#### Interface Declarations
212212

213-
Interfaces (as included in ./src/interfaces) may be in one or two categories: Provided or Consumed. _Provided_ means that the chaincode implements the interface and supports having clients or other chaincode invoke methods as declared. Likewise, _consumed_ indicates that the chaincode expects to perform inter-chaincode invoke/query operations to a disparate chaincode instance that provides the interface. It is perfectly fine (though perhaps uncommon) for a chaincode to both provide and consume a given interface (such as for proxy contracts which may accept operations in a polymorphic manner before passing operations on to a concrete instance).
213+
Interfaces (as included in ./src/interfaces) may be in one or two categories: Provided or Consumed. _Provided_ means that the chaincode implements the interface and supports having clients or other chaincode invoke methods as declared. Likewise, _consumed_ indicates that the chaincode expects to perform inter-chaincode invoke operations to a disparate chaincode instance that provides the interface. It is perfectly fine (though perhaps uncommon) for a chaincode to both provide and consume a given interface (such as for proxy contracts which may accept operations in a polymorphic manner before passing operations on to a concrete instance).
214214

215215
Both Provides and Consumes are expressed as an array of 1 or more entries. For example:
216216

@@ -273,20 +273,14 @@ message BalanceResult {
273273
int32 balance = 1;
274274
}
275275
276-
transactions {
276+
functions {
277277
void MakePayment(PaymentParams) = 1;
278278
void DeleteAccount(Entity) = 2;
279-
}
280-
281-
queries {
282-
BalanceResult CheckBalance(Entity) = 1;
279+
BalanceResult CheckBalance(Entity) = 3;
283280
}
284281
```
285282

286-
The _message_ definitions are almost 1:1 with protobuf grammar. The largest divergence is w.r.t. the _transactions_ and _queries_ sections. These two are similar to one another as well as to the notion of service/rpc in protobuf grammar. The reason we diverged is for a few different reasons:
287-
288-
- Chaincode has a strong delineation between and invoke and a query, and it was important for the parser to be able to understand the breakdown so that the proper code could be emitted
289-
- It was felt that the lack of "field indices" in the protobuf service/rpc grammar was a large shortcoming in ABI compatibility. Therefore, the grammar used here retains the notion of indices even for function calls.
283+
The _message_ definitions are almost 1:1 with protobuf grammar. The largest divergence is w.r.t. the _functions_ section. This section is similiar to the notion of service/rpc in protobuf grammar. We diverged from the protobuf/grpc grammar because it was felt that the lack of "field indices" was a large shortcoming in ABI compatibility. Therefore, the grammar used here retains the notion of indices even for function calls.
290284

291285
The main purpose of the grammar is to define RPC functions. For reasons of ABI stability, it was decided that all RPCs will have the following properties:
292286
- Be indexed (e.g. ABI depends on index stability, not function name)
@@ -316,23 +310,16 @@ message ChaincodeInput {
316310
317311
}
318312
```
319-
Chaintool deterministically maps transactions/queries declared within a CCI to an [encoded function name](#function-encoding), and expects the corresponding input parameter to be a base64 encoded protobuf message as the first and only arg string.
313+
Chaintool deterministically maps functions declared within a CCI to an [encoded function name](#function-encoding), and expects the corresponding input parameter to be a base64 encoded protobuf message as the first and only arg string.
320314

321315
Example:
322316
```
323-
{"function":"org.hyperledger.chaincode.example02/query/1","args":["CgNmb28="]}}
317+
{"function":"org.hyperledger.chaincode.example02/fcn/3","args":["CgNmb28="]}}
324318
```
325319

326320
#### Function Encoding
327321

328-
Function naming follows the convention *interface-name/method-type/method-index*. For instance, invoking *MakePayment* from our [example](./examples/example02/app/src/interfaces/org.hyperledger.chaincode.example02.cci) would be *org.hyperledger.chaintool.example02/txn/1*. Because its transaction #1 in the org.hyperledger.chaintool.example02 interface.
329-
330-
##### Method Types
331-
332-
There are two types of methods: transactions and queries. We therefore have two values in the function name that correspond to the underlying method type:
333-
334-
- "txn" - transactions
335-
- "query" - queries
322+
Function naming follows the convention *interface-name/method-type/method-index*. For instance, invoking *MakePayment* from our [example](./examples/example02/app/src/interfaces/org.hyperledger.chaincode.example02.cci) would be *org.hyperledger.chaintool.example02/fcn/1*. Because its function #1 in the org.hyperledger.chaintool.example02 interface.
336323

337324
### Output Protocol
338325

@@ -368,9 +355,9 @@ message PaymentParams {
368355
//
369356
// Available RPC functions exported by this interface
370357
//
371-
// void MakePayment(PaymentParams) -> org.hyperledger.chaincode.example02/txn/1
372-
// void DeleteAccount(Entity) -> org.hyperledger.chaincode.example02/txn/2
373-
// BalanceResult CheckBalance(Entity) -> org.hyperledger.chaincode.example02/query/1
358+
// void MakePayment(PaymentParams) -> org.hyperledger.chaincode.example02/fcn/1
359+
// void DeleteAccount(Entity) -> org.hyperledger.chaincode.example02/fcn/2
360+
// BalanceResult CheckBalance(Entity) -> org.hyperledger.chaincode.example02/fcn/3
374361
```
375362
## Metadata
376363

@@ -409,7 +396,7 @@ message Facts {
409396
repeated Fact facts = 1;
410397
}
411398
412-
queries {
399+
functions {
413400
Interfaces GetInterfaces(GetInterfacesParams) = 1;
414401
InterfaceDescriptor GetInterface(GetInterfaceParams) = 2;
415402
Facts GetFacts(GetFactsParams) = 3;

examples/example02/README.md

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,36 @@ This directory contains an implementation of the chaincode application called "e
1414
│   ├── appinit.cci
1515
│   └── org.hyperledger.chaincode.example02.cci
1616
└── client
17-
├── rest
18-
│   ├── cljs
19-
│   │   ├── Makefile
20-
│   │   ├── appinit.proto
21-
│   │   ├── org.hyperledger.chaincode.example02.proto
22-
│   │   ├── project.clj
23-
│   │   └── src
24-
│   │   └── example02
25-
│   │   ├── core.cljs
26-
│   │   ├── main.cljs
27-
│   │   └── rpc.cljs
28-
│   └── nodejs
29-
│   ├── appinit.proto
30-
│   ├── index.js
31-
│   ├── org.hyperledger.chaincode.example02.proto
32-
│   └── package.json
33-
└── sdk
34-
├── Makefile
17+
├── cljs
18+
│   ├── Makefile
19+
│   ├── appinit.proto
20+
│   ├── org.hyperledger.chaincode.example02.proto
21+
│   ├── project.clj
22+
│   └── src
23+
│   └── example02
24+
│   ├── core.cljs
25+
│   ├── hlc
26+
│   │   ├── core.cljs
27+
│   │   └── user.cljs
28+
│   ├── main.cljs
29+
│   ├── rpc.cljs
30+
│   └── util.cljs
31+
└── nodejs
3532
├── appinit.proto
33+
├── index.js
34+
├── util.js
3635
├── org.hyperledger.chaincode.example02.proto
37-
├── project.clj
38-
└── src
39-
└── example02
40-
├── core.cljs
41-
├── hlc
42-
│   ├── core.cljs
43-
│   └── user.cljs
44-
├── main.cljs
45-
├── rpc.cljs
46-
└── util.cljs
36+
└── package.json
4737
```
4838
* app - contains a org.hyperledger.chaincode.golang platform based chaincode application.
4939
* This is the code deployed to the blockchain
5040
* client - client applications for interacting with the chaincode application
51-
* rest - REST api based clients
52-
* nodejs - A simple demonstration of using nodejs+REST.
53-
* cljs - A complete client for example02 over REST written in ClojureScript
54-
* sdk - SDK based client, written in ClojureScript
41+
* nodejs - A simple demonstration of using nodejs.
42+
* cljs - A complete client for example02 written in ClojureScript
5543

5644
## Deploying and interacting with the example02
5745
### Step 1 - Fabric environment
58-
You will need a functioning peer that has chaintool v0.7 or higher available in the $PATH. You may check the version of chaintool you have with 'chaintool -h'. Once confirmed, start the peer with _peer node start_ as you normally would. It is advised to keep the configuration as simple as possible (1 VP, no security, noops consensus)
46+
You will need a functioning peer that has chaintool v0.10.1 or higher available in the $PATH. You may check the version of chaintool you have with 'chaintool -h'. Once confirmed, start the peer with _peer node start_ as you normally would. It is advised to keep the configuration as simple as possible (1 VP, no security, noops consensus)
5947

6048
### Step 2 - Package the chaincode application
6149
Run 'chaintool package' from the app folder, noting the CAR output path
@@ -82,11 +70,11 @@ Chaincode SHA3: f7026e0675b22a9d78b9f7f0cb97c93165bdefedc86de97f00e76b506c7
8270
#### Note:
8371
The _chaintool package_ command is designed to package for deployment, not development. If you started your node with _peer node start --peer-chaincodedev_, run _chaintool build_ instead. This is analogous to building non-chaintool chaincode using _go build_. The output will be placed in the _app/build/bin/_ directory.
8472
### Step 3 - Compile the client
85-
Run 'make' from the client/rest/cljs folder
73+
Run 'make' from the client/cljs folder
8674
```
8775
$ make
8876
lein npm install
89-
[email protected] /Users/ghaskins/sandbox/git/chaintool/examples/example02/client/rest/cljs
77+
[email protected] /Users/ghaskins/sandbox/git/chaintool/examples/example02/client/cljs
9078
9179
│ ├─┬ [email protected]
9280
│ │ ├── [email protected]

examples/example02/app/src/interfaces/org.hyperledger.chaincode.example02.cci

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ message BalanceResult {
1313
int32 balance = 1;
1414
}
1515

16-
transactions {
16+
functions {
1717
void MakePayment(PaymentParams) = 1;
1818
void DeleteAccount(Entity) = 2;
19+
BalanceResult CheckBalance(Entity) = 3;
1920
}
2021

21-
queries {
22-
BalanceResult CheckBalance(Entity) = 1;
23-
}
File renamed without changes.
File renamed without changes.

examples/example02/client/rest/cljs/org.hyperledger.chaincode.example02.proto renamed to examples/example02/client/cljs/protos/org.hyperledger.chaincode.example02.proto

File renamed without changes.

examples/example02/client/sdk/src/example02/core.cljs renamed to examples/example02/client/cljs/src/example02/core.cljs

File renamed without changes.

examples/example02/client/sdk/src/example02/hlc/core.cljs renamed to examples/example02/client/cljs/src/example02/hfc/core.cljs

File renamed without changes.

examples/example02/client/sdk/src/example02/hlc/user.cljs renamed to examples/example02/client/cljs/src/example02/hfc/user.cljs

File renamed without changes.

0 commit comments

Comments
 (0)