Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit 8d36db4

Browse files
author
Dave Kelsey
authored
Fix digital prop app (#111)
* fix all the problems and move to node 8 syntax Signed-off-by: Dave Kelsey <[email protected]> * fix code bug and update readme to support 0.17 Signed-off-by: Dave Kelsey <[email protected]> * updates based on review Signed-off-by: Dave Kelsey <[email protected]>
1 parent 046b541 commit 8d36db4

File tree

13 files changed

+230
-364
lines changed

13 files changed

+230
-364
lines changed

Diff for: packages/digitalproperty-app/CmdOrder.png

-23.6 KB
Binary file not shown.

Diff for: packages/digitalproperty-app/Dockerfile

-2
This file was deleted.

Diff for: packages/digitalproperty-app/README.md

+38-22
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,39 @@ This sample application should be run against a v1.0 Hyperledger Fabric (and whi
88

99
These scripts use Node v6, and bash, which are Hyperledger Composer dependencies. Choose a directory that you wish to have the setup scripts within.
1010

11-
1. In a directory of your choice (will assume `~/fabric-tools`) get the zip file that contains the tools. There are both .zip and .tar.gz formats
11+
1. In a directory of your choice (will assume `~/fabric-tools`) get the zip file that contains the tools. There are both .tar.gz and .zip formats
1212
```
1313
$ mkdir ~/fabric-tools && cd ~/fabric-tools
14-
$ curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.zip
15-
$ unzip fabric-dev-servers.zip
14+
$ curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.tar.gz
15+
$ tar xvzf fabric-dev-servers.tar.gz
16+
1617
```
1718

1819
```
1920
$ mkdir ~/fabric-tools && cd ~/fabric-tools
20-
$ curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.tar.gz
21-
$ tar xvzf fabric-dev-servers.tar.gz
21+
$ curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.zip
22+
$ unzip fabric-dev-servers.zip
23+
```
2224

25+
**IMPORTANT** if you are running this sample application using Hyperledger composer version 0.17 or higher then you need to be using Hyperledger fabric 1.1. To ensure this you must ensure you set the version to 1.1 as follows
26+
27+
```
28+
$ export FABRIC_VERSION=hlfv11
29+
```
30+
If you have been using composer version 0.16 then you will need to clear out your file system card store as cards in there are not compatible with 0.17. The quickest way to do this is
31+
```
32+
$ rm -fr $HOME/.composer
2333
```
2434

25-
2. If this is the first time you've run this tutorial, you'll need to download the fabric first. If you have already downloaded a set of Fabric images then first start the fabric (see below), and create a Composer profile. Make sure you don't have a previous network (digitalproperty-network) docker container left running as 'legacy' - remove legacy containers as necessary using `docker rm`). After that, you can then choose to stop the fabric, and start it again later. Alternatively, to completely clean up, you can 'teardown' the Fabric and the Composer profile / sample credentials (see more below).
35+
2. If this is the first time you've run this tutorial, you'll need to download the fabric first. If you have already downloaded a set of Fabric images then first start the fabric (see below), and create a Composer business network card. Make sure you don't have a previous network (digitalproperty-network) docker container left running as 'legacy' - remove legacy containers as necessary using `docker rm`). After that, you can then choose to stop the fabric, and start it again later. Alternatively, to completely clean up, you can 'teardown' the Fabric (see more below).
2636

2737
All the scripts will be in the directory `~/fabric-tools` you created above. A typical sequence for Hyperledger Composer startup would be:
2838

2939
```
3040
$ cd ~/fabric-tools
3141
$ ./downloadFabric.sh
3242
$ ./startFabric.sh
33-
$ ./createComposerProfile.sh
43+
$ ./createPeerAdminCard.sh
3444
```
3545

3646
Then at the end of your development session
@@ -70,14 +80,15 @@ By default, this 'start' script will pause for 15 seconds to let Fabric start -
7080
$ export FABRIC_START_TIMEOUT=30
7181
```
7282

73-
### Create Composer Profile
83+
### Create Composer Business network card
84+
This will create a business network card and import it into the card store. This card provides the ability to install and start business networks on the hyperledger fabric network.
7485

7586
Issue this command from the `fabric-tools` directory
7687
```
77-
$ ./createComposerProfile.sh
88+
$ ./createPeerAdminCard.sh
7889
```
7990

80-
Note: this create a Hyperledger Composer profile specifically to connect to the development fabric you've already started.
91+
Note: this create a Hyperledger Composer business network card specifically to connect to the development fabric you've already started.
8192

8293
### Teardown Fabric (when you want to 'clean' up and start afresh)
8394

@@ -86,14 +97,6 @@ Issue from the `fabric-tools` directory
8697
$ ./teardownFabric.sh
8798
```
8899

89-
90-
### Command Ordering
91-
92-
This diagram should to clarify the order in which the scripts can be run.
93-
94-
![](CmdOrder.png).
95-
96-
97100
# Step 2: Getting the Hyperledger Composer sample application (the Digital Property CLI sample application) up and running
98101

99102
1. Make sure you've started Fabric as in Step 1 above. For example, If this is your first time for example
@@ -102,7 +105,7 @@ This diagram should to clarify the order in which the scripts can be run.
102105
$ cd ~/fabric-tools
103106
$ ./downloadFabric.sh
104107
$ ./startFabric.sh
105-
$ ./createComposerProfile.sh
108+
$ ./createPeerAdminCard.sh
106109
```
107110

108111
2. Clone the sample application into a directory of your choice - BUT not the same directory as in Step 1. (Assume `~/github')
@@ -113,6 +116,22 @@ $ cd composer-sample-applications
113116
$
114117
```
115118

119+
**IMPORTANT** if you are using Composer 0.17 or higher and thus Hyperledger Fabric 1.1, then you need to change the application to use the correct version of Composer. To do this open the file `packages/digitalproperty-app/package.json` and change all the references to composer dependencies from `^0.16.3` to `^0.17.2` eg.
120+
```
121+
"dependencies": {
122+
"cli-table": "^0.3.1",
123+
"composer-cli": "^0.17.2",
124+
"composer-client": "^0.17.2",
125+
"digitalproperty-network": "^0.1.2",
126+
"jsonfile": "^2.4.0",
127+
"lodash": "^4.17.4",
128+
"prettyjson": "^1.2.1",
129+
"sprintf-js": "^1.0.3",
130+
"winston": "^2.3.0",
131+
"yargs": "^6.5.0"
132+
},
133+
```
134+
116135
OPTIONAL: To see a summary of all the sample applications, there's a simple command that will show summary details of the sample applications available in this repository. A useful information node.js script has been created to show the available sample applications - note you will need to run `npm install` from the current directory (takes about 5-10 mins) before running this command.
117136
```
118137
$ node ~/github/composer-sample-applications/info.js
@@ -130,6 +149,3 @@ $ npm run deployNetwork
130149
```
131150
$ npm test
132151
```
133-
134-
135-

Diff for: packages/digitalproperty-app/cli.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ winston.loggers.add('application', {
3232
const LOG = winston.loggers.get('application');
3333

3434
LOG.info('Hyperledger Composer: Digital Property console application');
35-
try{
36-
require('yargs')
37-
.usage ('node cli.js <participant> <action>')
38-
.commandDir('lib/cmds')
39-
.demand(1,'Please specify a partipant, for example: digitalproperty landregistry <action>')
40-
.help()
41-
.strict()
42-
.recommendCommands()
43-
.epilogue('For more information visit us at https://hyperledger.github.io/composer')
44-
.argv;
45-
} catch (err){
35+
try {
36+
require('yargs')
37+
.usage ('node cli.js <participant> <action>')
38+
.commandDir('lib/cmds')
39+
.demand(1,'Please specify a partipant, for example: digitalproperty landregistry <action>')
40+
.help()
41+
.strict()
42+
.recommendCommands()
43+
.epilogue('For more information visit us at https://hyperledger.github.io/composer')
44+
.argv;
45+
} catch (err) {
4646
console.log(err);
4747
}

Diff for: packages/digitalproperty-app/config/default.json

-5
This file was deleted.

Diff for: packages/digitalproperty-app/config/hlfv0.6.json

-8
This file was deleted.

Diff for: packages/digitalproperty-app/config/playground.json

-8
This file was deleted.

Diff for: packages/digitalproperty-app/lib/cmds/landregistry_cmds/addDefaultTitles.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ exports.command = 'bootstrap';
2222
exports.desc = 'Add a set of default land titiles';
2323
exports.builder = {};
2424

25-
exports.handler = function (argv) {
25+
exports.handler = async function (argv) {
2626
LOG.info('Adding default land titles to the asset registry');
27-
return LandRegistry.addDefaultCmd(argv)
28-
.then(() => {
29-
LOG.info ('Command completed successfully.');
30-
process.exit(0);
31-
})
32-
.catch((error) => {
33-
LOG.error(error+ '\nCommand failed.');
34-
process.exit(1);
35-
});
27+
try {
28+
await LandRegistry.addDefaultCmd(argv);
29+
LOG.info ('Command completed successfully.');
30+
process.exit(0);
31+
} catch(error) {
32+
LOG.error(error+ '\nCommand failed.');
33+
process.exit(1);
34+
}
3635
};

Diff for: packages/digitalproperty-app/lib/cmds/landregistry_cmds/listTitles.js

+10-16
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,14 @@ const LOG = winston.loggers.get('application');
2222
exports.command = 'list';
2323
exports.desc = 'Lists all the land titles held in the Land Regsitry';
2424
exports.builder = {};
25-
exports.handler = function (argv) {
26-
27-
28-
return LandRegistry.listCmd(argv)
29-
.then(() => {
30-
LOG.info('Command completed successfully.');
31-
process.exit(0);
32-
})
33-
.catch((error) => {
34-
LOG.error(error+ '\nCommand failed.');
35-
process.exit(1);
36-
});
37-
38-
39-
40-
25+
exports.handler = async function (argv) {
26+
27+
try {
28+
await LandRegistry.listCmd(argv);
29+
LOG.info('Command completed successfully.');
30+
process.exit(0);
31+
} catch(error) {
32+
LOG.error(error+ '\nCommand failed.');
33+
process.exit(1);
34+
}
4135
};

Diff for: packages/digitalproperty-app/lib/cmds/landregistry_cmds/listen.js

+6-12
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,12 @@ const LOG = winston.loggers.get('application');
2222
exports.command = 'listen';
2323
exports.desc = 'Listen for all events';
2424
exports.builder = {};
25-
exports.handler = function (argv) {
25+
exports.handler = async function (argv) {
2626

27-
28-
return LandRegistry.listen(argv)
29-
.then(() => {
30-
LOG.info('Command completed successfully.');
31-
})
32-
.catch((error) => {
27+
try {
28+
await LandRegistry.listen(argv);
29+
LOG.info('Command completed successfully.');
30+
} catch(error) {
3331
LOG.error(error+ '\nCommand failed.');
34-
});
35-
36-
37-
38-
32+
}
3933
};

Diff for: packages/digitalproperty-app/lib/cmds/landregistry_cmds/submit.js

+10-16
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,14 @@ const LOG = winston.loggers.get('application');
2222
exports.command = 'submit';
2323
exports.desc = 'Updates a fixed title in the regsitry';
2424
exports.builder = {};
25-
exports.handler = function (argv) {
26-
27-
28-
return LandRegistry.submitCmd(argv)
29-
.then(() => {
30-
LOG.info('Command completed successfully.');
31-
process.exit(0);
32-
})
33-
.catch((error) => {
34-
LOG.error(error+ '\nCommand failed.');
35-
process.exit(1);
36-
});
37-
38-
39-
40-
25+
exports.handler = async function (argv) {
26+
27+
try {
28+
await LandRegistry.submitCmd(argv);
29+
LOG.info('Command completed successfully.');
30+
process.exit(0);
31+
} catch(error) {
32+
LOG.error(error+ '\nCommand failed.');
33+
process.exit(1);
34+
}
4135
};

0 commit comments

Comments
 (0)