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

Commit 6916021

Browse files
erin-hughesawjh-ibm
authored andcommitted
Adding the letters of credit sample app (again) (#139)
* Moving to fresh branch to address DCO issue Signed-off-by: Erin Hughes <[email protected]> Updating to final bank names (#45) Signed-off-by: Erin Hughes <[email protected]> Implemented alert for when Bob's balance increases Signed-off-by: Erin Hughes <[email protected]> First wave of css tweaks Signed-off-by: Erin Hughes <[email protected]> Second wave of css changes Signed-off-by: Erin Hughes <[email protected]> Further styling changes, addition of status bar, bug fixes Signed-off-by: Erin Hughes <[email protected]> Swapping currencies and exchange rates Signed-off-by: Erin Hughes <[email protected]> Tutorial updates from feedback (#52) * tutorial contents Signed-off-by: awjh-ibm <[email protected]> * updating tutorial against feedback Signed-off-by: awjh-ibm <[email protected]> Updating IBAN to refelct change in countries (#53) Signed-off-by: Erin Hughes <[email protected]> update installer ready for release (#54) Signed-off-by: awjh-ibm <[email protected]> Allow network version changing in installer (#55) * allow for network version change Signed-off-by: awjh-ibm <[email protected]> * acme -> example Signed-off-by: awjh-ibm <[email protected]> * Tweaks to prepare for release Signed-off-by: Erin Hughes <[email protected]>
1 parent 515b257 commit 6916021

Some content is hidden

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

69 files changed

+5791
-1
lines changed

.travis/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ git ls-remote
6666
docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}"
6767

6868
# This is the list of Docker images to build.
69-
export DOCKER_IMAGES="vehicle-manufacture-car-builder vehicle-manufacture-manufacturing vehicle-manufacture-vda"
69+
export DOCKER_IMAGES="vehicle-manufacture-car-builder vehicle-manufacture-manufacturing vehicle-manufacture-vda letters-of-credit"
7070

7171
# Push the code to npm.
7272
if [ -z "${TRAVIS_TAG}" ]; then
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (https://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# Typescript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
60+
# production folder
61+
dist/
62+
63+
# composer stuff
64+
*.card
65+
66+
# install stuff
67+
fabric-tools
68+
loc-stage
69+
.loc-card-store
70+
letters-of-credit-network.bna
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM node:8-alpine
2+
ENV NPM_CONFIG_LOGLEVEL warn
3+
ENV PORT 6001
4+
RUN mkdir -p /usr/src/app
5+
WORKDIR /usr/src/app
6+
COPY package.json /usr/src/app/
7+
RUN apk add --no-cache git && \
8+
npm install --production -g pm2 && \
9+
npm install --production && \
10+
npm cache clean --force && \
11+
apk del git
12+
COPY . /usr/src/app/
13+
EXPOSE 6001
14+
CMD [ "pm2-docker", "npm", "--", "start" ]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Letter of Credit Sample Application
2+
3+
To deploy this application, run the provided install script by using the following command:
4+
5+
`./installers/install.sh`
6+
7+
This will open the tutorial and the four banking tabs that make up the application, as well as Playground and the REST server.
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
#!/bin/bash
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
# REMOVE EXISTING REST SERVER, PLAYGROUND ETC
15+
docker rm -f $(docker ps -a | grep hyperledger/* | awk '{ print $1 }')
16+
17+
docker pull hyperledger/composer-playground:latest
18+
docker pull hyperledger/composer-cli:latest
19+
docker pull hyperledger/composer-rest-server:latest
20+
docker pull hyperledger/letters-of-credit:latest
21+
22+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
23+
24+
# GET AND SETUP FABRIC
25+
rm -rf $DIR/fabric-tools
26+
mkdir $DIR/fabric-tools
27+
chmod 777 $DIR/fabric-tools
28+
cd $DIR/fabric-tools
29+
30+
curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.tar.gz
31+
tar -xvf $DIR/fabric-tools/fabric-dev-servers.tar.gz
32+
$DIR/fabric-tools/startFabric.sh
33+
34+
cd $DIR
35+
36+
# CREATE LOCATION FOR LOCAL CARD STORE
37+
rm -rf $(pwd)/.loc-card-store
38+
mkdir $(pwd)/.loc-card-store
39+
chmod 777 $(pwd)/.loc-card-store
40+
41+
# CREATE CONNECTION PROFILE
42+
rm -fr $(pwd)/loc-stage
43+
mkdir $(pwd)/loc-stage
44+
chmod 777 $(pwd)/loc-stage
45+
echo '{
46+
"name": "hlfv1",
47+
"version": "1.0.0",
48+
"client": {
49+
"organization": "Org1",
50+
"connection": {
51+
"timeout": {
52+
"peer": {
53+
"endorser": "300",
54+
"eventHub": "300",
55+
"eventReg": "300"
56+
},
57+
"orderer": "300"
58+
}
59+
}
60+
},
61+
"orderers": {
62+
"orderer.example.com": {
63+
"url": "grpc://orderer.example.com:7050",
64+
"grpcOptions": {}
65+
}
66+
},
67+
"peers": {
68+
"peer0.org1.example.com": {
69+
"url": "grpc://peer0.org1.example.com:7051",
70+
"eventUrl": "grpc://peer0.org1.example.com:7053",
71+
"grpcOptions": {},
72+
"endorsingPeer": true,
73+
"chaincodeQuery": true,
74+
"ledgerQuery": true,
75+
"eventSource": true
76+
}
77+
},
78+
"channels": {
79+
"composerchannel": {
80+
"orderers": ["orderer.example.com"],
81+
"peers": {
82+
"peer0.org1.example.com": {}
83+
}
84+
}
85+
},
86+
"certificateAuthorities": {
87+
"ca.org1.example.com": {
88+
"url": "http://ca.org1.example.com:7054",
89+
"caName": "ca.org1.example.com"
90+
}
91+
},
92+
"organizations": {
93+
"Org1": {
94+
"mspid": "Org1MSP",
95+
"peers": ["peer0.org1.example.com"],
96+
"certificateAuthorities": ["ca.org1.example.com"]
97+
}
98+
},
99+
"x-type": "hlfv1",
100+
"x-commitTimeout": 100
101+
}' > $(pwd)/loc-stage/connection.json
102+
103+
# CREATE PEER ADMIN CARD AND IMPORT
104+
docker run \
105+
--rm \
106+
--network composer_default \
107+
-v $(pwd)/.loc-card-store:/home/composer/.composer \
108+
-v $(pwd)/loc-stage:/home/composer/loc-stage \
109+
-v $(pwd)/fabric-tools/fabric-scripts/hlfv1/composer/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp:/home/composer/PeerAdmin \
110+
hyperledger/composer-cli:latest \
111+
card create -p loc-stage/connection.json -u PeerAdmin -r PeerAdmin -r ChannelAdmin -f /home/composer/loc-stage/PeerAdmin.card -c PeerAdmin/signcerts/[email protected] -k PeerAdmin/keystore/114aab0e76bf0c78308f89efc4b8c9423e31568da0c340ca187a9b17aa9a4457_sk
112+
113+
docker run \
114+
--rm \
115+
--network composer_default \
116+
-v $(pwd)/.loc-card-store:/home/composer/.composer \
117+
-v $(pwd)/loc-stage:/home/composer/loc-stage \
118+
-v $(pwd)/fabric-tools/fabric-scripts/hlfv1/composer/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp:/home/composer/PeerAdmin \
119+
hyperledger/composer-cli:latest \
120+
card import -f /home/composer/loc-stage/PeerAdmin.card
121+
122+
# START PLAYGROUND
123+
docker run \
124+
-d \
125+
--network composer_default \
126+
--name composer \
127+
-v $(pwd)/.loc-card-store:/home/composer/.composer \
128+
-p 8080:8080 \
129+
hyperledger/composer-playground:latest
130+
131+
# WAIT FOR PLAYGROUND TO WAKE UP
132+
sleep 5
133+
134+
# GET THE BNA
135+
ROOT=$DIR/..
136+
cd $ROOT
137+
npm install
138+
cd $DIR
139+
cp $ROOT/node_modules/letters-of-credit-network/dist/letters-of-credit-network.bna letters-of-credit-network.bna
140+
141+
# INSTALL THE BNA
142+
docker run \
143+
--rm \
144+
--network composer_default \
145+
-v $(pwd)/letters-of-credit-network.bna:/home/composer/letters-of-credit-network.bna \
146+
-v $(pwd)/loc-stage:/home/composer/loc-stage \
147+
-v $(pwd)/.loc-card-store:/home/composer/.composer \
148+
hyperledger/composer-cli:latest \
149+
network install -c PeerAdmin@hlfv1 -a letters-of-credit-network.bna
150+
151+
NETWORK_VERSION=$(grep -o '"version": *"[^"]*"' $ROOT/node_modules/letters-of-credit-network/package.json | grep -o '[0-9]\.[0-9]\.[0-9]')
152+
153+
# START THE BNA
154+
docker run \
155+
--rm \
156+
--network composer_default \
157+
-v $(pwd)/letters-of-credit-network.bna:/home/composer/letters-of-credit-network.bna \
158+
-v $(pwd)/loc-stage:/home/composer/loc-stage \
159+
-v $(pwd)/.loc-card-store:/home/composer/.composer \
160+
hyperledger/composer-cli:latest \
161+
network start -n letters-of-credit-network -V $NETWORK_VERSION -c PeerAdmin@hlfv1 -A admin -S adminpw -f /home/composer/loc-stage/bnaadmin.card
162+
163+
docker run \
164+
--rm \
165+
--network composer_default \
166+
-v $(pwd)/loc-stage:/home/composer/loc-stage \
167+
-v $(pwd)/.loc-card-store:/home/composer/.composer \
168+
hyperledger/composer-cli:latest \
169+
card import -f /home/composer/loc-stage/bnaadmin.card
170+
171+
# CREATE THE NEEDED PARTICIPANTS
172+
docker run \
173+
--rm \
174+
--network composer_default \
175+
-v $(pwd)/.loc-card-store:/home/composer/.composer \
176+
hyperledger/composer-cli:latest \
177+
transaction submit -c admin@letters-of-credit-network -d '{"$class": "org.example.loc.CreateDemoParticipants"}'
178+
179+
# SET CORRECT PERMISSIONS
180+
docker exec \
181+
composer \
182+
find /home/composer/.composer -name "*" -exec chmod 777 {} \;
183+
184+
# START THE REST SERVER
185+
docker run \
186+
-d \
187+
--network composer_default \
188+
--name rest \
189+
-v $(pwd)/.loc-card-store:/home/composer/.composer \
190+
-e COMPOSER_CARD=admin@letters-of-credit-network \
191+
-e COMPOSER_NAMESPACES=never \
192+
-p 3000:3000 \
193+
hyperledger/composer-rest-server:latest
194+
195+
#WAIT FOR REST SERVER TO WAKE UP
196+
sleep 10
197+
198+
# START THE LOC APPLICATION
199+
docker run \
200+
-d \
201+
--network composer_default \
202+
--name vda \
203+
-e REACT_APP_REST_SERVER_CONFIG='{"webSocketURL": "ws://localhost:3000", "httpURL": "http://localhost:3000/api"}' \
204+
-p 6001:6001 \
205+
hyperledger/letters-of-credit:latest
206+
207+
#WAIT FOR REACT SERVER TO WAKE UP
208+
sleep 10
209+
210+
# OPEN THE APPLICATION
211+
URLS="http://localhost:6001/tutorial http://localhost:6001/alice http://localhost:6001/matias http://localhost:6001/ella http://localhost:6001/bob http://localhost:8080 http://localhost:3000/explorer/"
212+
case "$(uname)" in
213+
"Darwin") open ${URLS}
214+
;;
215+
"Linux") if [ -n "$BROWSER" ] ; then
216+
$BROWSER http://localhost:6001/tutorial http://localhost:6001/alice http://localhost:6001/matias http://localhost:6001/ella http://localhost:6001/bob http://localhost:8080 http://localhost:3000/explorer/
217+
elif which x-www-browser > /dev/null ; then
218+
nohup x-www-browser ${URLS} < /dev/null > /dev/null 2>&1 &
219+
elif which xdg-open > /dev/null ; then
220+
for URL in ${URLS} ; do
221+
xdg-open ${URL}
222+
done
223+
elif which gnome-open > /dev/null ; then
224+
gnome-open http://localhost:6001/tutorial http://localhost:6001/alice http://localhost:6001/matias http://localhost:6001/ella http://localhost:6001/bob http://localhost:8080 http://localhost:3000/explorer/
225+
else
226+
echo "Could not detect web browser to use - please launch Application and Composer Playground URL using your chosen browser ie: <browser executable name> http://localhost:8080 or set your BROWSER variable to the browser launcher in your PATH"
227+
fi
228+
;;
229+
*) echo "Playground not launched - this OS is currently not supported "
230+
;;
231+
esac
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "letters-of-credit",
3+
"version": "0.0.7",
4+
"private": true,
5+
"author": "Erin Hughes, Hannah Rayner, Nikola Ignatov, Jackson Ross, Andrew Hurt",
6+
"dependencies": {
7+
"axios": "^0.18.0",
8+
"letters-of-credit-network": "^0.2.4",
9+
"react": "^16.2.0",
10+
"react-dom": "^16.2.0",
11+
"react-redux": "^5.0.7",
12+
"react-router-dom": "^4.2.2",
13+
"react-scripts": "1.1.1",
14+
"react-stepper-horizontal": "^1.0.10",
15+
"react-toggle": "^4.0.2",
16+
"redux": "^3.7.2"
17+
},
18+
"scripts": {
19+
"start": "react-scripts start",
20+
"build": "react-scripts build",
21+
"test": "react-scripts test --env=jsdom",
22+
"eject": "react-scripts eject",
23+
"deployNetwork": "composer runtime install --card PeerAdmin@hlfv1 --businessNetworkName letters-of-credit-network && composer network start --card PeerAdmin@hlfv1 --networkAdmin admin --networkAdminEnrollSecret adminpw --archiveFile *.bna --file networkadmin.card && composer-rest-server -c admin@letters-of-credit-network -n never -w true && composer-rest-server -c admin@letters-of-credit-network -n never -w true"
24+
},
25+
"devDependencies": {
26+
"gulp": "^3.9.1",
27+
"gulp-sass": "^3.2.1"
28+
}
29+
}
14.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)