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

Commit

Permalink
Adding the letters of credit sample app (again) (#139)
Browse files Browse the repository at this point in the history
* Moving to fresh branch to address DCO issue

Signed-off-by: Erin Hughes <Erin.Hughes@ibm.com>

Updating to final bank names (#45)

Signed-off-by: Erin Hughes <Erin.Hughes@ibm.com>

Implemented alert for when Bob's balance increases

Signed-off-by: Erin Hughes <Erin.Hughes@ibm.com>

First wave of css tweaks

Signed-off-by: Erin Hughes <Erin.Hughes@ibm.com>

Second wave of css changes

Signed-off-by: Erin Hughes <Erin.Hughes@ibm.com>

Further styling changes, addition of status bar, bug fixes

Signed-off-by: Erin Hughes <Erin.Hughes@ibm.com>

Swapping currencies and exchange rates

Signed-off-by: Erin Hughes <Erin.Hughes@ibm.com>

Tutorial updates from feedback (#52)

* tutorial contents

Signed-off-by: awjh-ibm <andrew.hurt1@ibm.com>

* updating tutorial against feedback

Signed-off-by: awjh-ibm <andrew.hurt1@ibm.com>

Updating IBAN to refelct change in countries (#53)

Signed-off-by: Erin Hughes <Erin.Hughes@ibm.com>

update installer ready for release (#54)

Signed-off-by: awjh-ibm <andrew.hurt1@ibm.com>

Allow network version changing in installer (#55)

* allow for network version change

Signed-off-by: awjh-ibm <andrew.hurt1@ibm.com>

* acme -> example

Signed-off-by: awjh-ibm <andrew.hurt1@ibm.com>

* Tweaks to prepare for release

Signed-off-by: Erin Hughes <Erin.Hughes@ibm.com>
  • Loading branch information
erin-hughes authored and awjh-ibm committed May 31, 2018
1 parent 515b257 commit 6916021
Show file tree
Hide file tree
Showing 69 changed files with 5,791 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis/deploy.sh
Expand Up @@ -66,7 +66,7 @@ git ls-remote
docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}"

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

# Push the code to npm.
if [ -z "${TRAVIS_TAG}" ]; then
Expand Down
70 changes: 70 additions & 0 deletions packages/letters-of-credit/.gitignore
@@ -0,0 +1,70 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# production folder
dist/

# composer stuff
*.card

# install stuff
fabric-tools
loc-stage
.loc-card-store
letters-of-credit-network.bna
14 changes: 14 additions & 0 deletions packages/letters-of-credit/Dockerfile
@@ -0,0 +1,14 @@
FROM node:8-alpine
ENV NPM_CONFIG_LOGLEVEL warn
ENV PORT 6001
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN apk add --no-cache git && \
npm install --production -g pm2 && \
npm install --production && \
npm cache clean --force && \
apk del git
COPY . /usr/src/app/
EXPOSE 6001
CMD [ "pm2-docker", "npm", "--", "start" ]
7 changes: 7 additions & 0 deletions packages/letters-of-credit/README.md
@@ -0,0 +1,7 @@
## Letter of Credit Sample Application

To deploy this application, run the provided install script by using the following command:

`./installers/install.sh`

This will open the tutorial and the four banking tabs that make up the application, as well as Playground and the REST server.
231 changes: 231 additions & 0 deletions packages/letters-of-credit/installer/install.sh
@@ -0,0 +1,231 @@
#!/bin/bash
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# REMOVE EXISTING REST SERVER, PLAYGROUND ETC
docker rm -f $(docker ps -a | grep hyperledger/* | awk '{ print $1 }')

docker pull hyperledger/composer-playground:latest
docker pull hyperledger/composer-cli:latest
docker pull hyperledger/composer-rest-server:latest
docker pull hyperledger/letters-of-credit:latest

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# GET AND SETUP FABRIC
rm -rf $DIR/fabric-tools
mkdir $DIR/fabric-tools
chmod 777 $DIR/fabric-tools
cd $DIR/fabric-tools

curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.tar.gz
tar -xvf $DIR/fabric-tools/fabric-dev-servers.tar.gz
$DIR/fabric-tools/startFabric.sh

cd $DIR

# CREATE LOCATION FOR LOCAL CARD STORE
rm -rf $(pwd)/.loc-card-store
mkdir $(pwd)/.loc-card-store
chmod 777 $(pwd)/.loc-card-store

# CREATE CONNECTION PROFILE
rm -fr $(pwd)/loc-stage
mkdir $(pwd)/loc-stage
chmod 777 $(pwd)/loc-stage
echo '{
"name": "hlfv1",
"version": "1.0.0",
"client": {
"organization": "Org1",
"connection": {
"timeout": {
"peer": {
"endorser": "300",
"eventHub": "300",
"eventReg": "300"
},
"orderer": "300"
}
}
},
"orderers": {
"orderer.example.com": {
"url": "grpc://orderer.example.com:7050",
"grpcOptions": {}
}
},
"peers": {
"peer0.org1.example.com": {
"url": "grpc://peer0.org1.example.com:7051",
"eventUrl": "grpc://peer0.org1.example.com:7053",
"grpcOptions": {},
"endorsingPeer": true,
"chaincodeQuery": true,
"ledgerQuery": true,
"eventSource": true
}
},
"channels": {
"composerchannel": {
"orderers": ["orderer.example.com"],
"peers": {
"peer0.org1.example.com": {}
}
}
},
"certificateAuthorities": {
"ca.org1.example.com": {
"url": "http://ca.org1.example.com:7054",
"caName": "ca.org1.example.com"
}
},
"organizations": {
"Org1": {
"mspid": "Org1MSP",
"peers": ["peer0.org1.example.com"],
"certificateAuthorities": ["ca.org1.example.com"]
}
},
"x-type": "hlfv1",
"x-commitTimeout": 100
}' > $(pwd)/loc-stage/connection.json

# CREATE PEER ADMIN CARD AND IMPORT
docker run \
--rm \
--network composer_default \
-v $(pwd)/.loc-card-store:/home/composer/.composer \
-v $(pwd)/loc-stage:/home/composer/loc-stage \
-v $(pwd)/fabric-tools/fabric-scripts/hlfv1/composer/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp:/home/composer/PeerAdmin \
hyperledger/composer-cli:latest \
card create -p loc-stage/connection.json -u PeerAdmin -r PeerAdmin -r ChannelAdmin -f /home/composer/loc-stage/PeerAdmin.card -c PeerAdmin/signcerts/Admin@org1.example.com-cert.pem -k PeerAdmin/keystore/114aab0e76bf0c78308f89efc4b8c9423e31568da0c340ca187a9b17aa9a4457_sk

docker run \
--rm \
--network composer_default \
-v $(pwd)/.loc-card-store:/home/composer/.composer \
-v $(pwd)/loc-stage:/home/composer/loc-stage \
-v $(pwd)/fabric-tools/fabric-scripts/hlfv1/composer/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp:/home/composer/PeerAdmin \
hyperledger/composer-cli:latest \
card import -f /home/composer/loc-stage/PeerAdmin.card

# START PLAYGROUND
docker run \
-d \
--network composer_default \
--name composer \
-v $(pwd)/.loc-card-store:/home/composer/.composer \
-p 8080:8080 \
hyperledger/composer-playground:latest

# WAIT FOR PLAYGROUND TO WAKE UP
sleep 5

# GET THE BNA
ROOT=$DIR/..
cd $ROOT
npm install
cd $DIR
cp $ROOT/node_modules/letters-of-credit-network/dist/letters-of-credit-network.bna letters-of-credit-network.bna

# INSTALL THE BNA
docker run \
--rm \
--network composer_default \
-v $(pwd)/letters-of-credit-network.bna:/home/composer/letters-of-credit-network.bna \
-v $(pwd)/loc-stage:/home/composer/loc-stage \
-v $(pwd)/.loc-card-store:/home/composer/.composer \
hyperledger/composer-cli:latest \
network install -c PeerAdmin@hlfv1 -a letters-of-credit-network.bna

NETWORK_VERSION=$(grep -o '"version": *"[^"]*"' $ROOT/node_modules/letters-of-credit-network/package.json | grep -o '[0-9]\.[0-9]\.[0-9]')

# START THE BNA
docker run \
--rm \
--network composer_default \
-v $(pwd)/letters-of-credit-network.bna:/home/composer/letters-of-credit-network.bna \
-v $(pwd)/loc-stage:/home/composer/loc-stage \
-v $(pwd)/.loc-card-store:/home/composer/.composer \
hyperledger/composer-cli:latest \
network start -n letters-of-credit-network -V $NETWORK_VERSION -c PeerAdmin@hlfv1 -A admin -S adminpw -f /home/composer/loc-stage/bnaadmin.card

docker run \
--rm \
--network composer_default \
-v $(pwd)/loc-stage:/home/composer/loc-stage \
-v $(pwd)/.loc-card-store:/home/composer/.composer \
hyperledger/composer-cli:latest \
card import -f /home/composer/loc-stage/bnaadmin.card

# CREATE THE NEEDED PARTICIPANTS
docker run \
--rm \
--network composer_default \
-v $(pwd)/.loc-card-store:/home/composer/.composer \
hyperledger/composer-cli:latest \
transaction submit -c admin@letters-of-credit-network -d '{"$class": "org.example.loc.CreateDemoParticipants"}'

# SET CORRECT PERMISSIONS
docker exec \
composer \
find /home/composer/.composer -name "*" -exec chmod 777 {} \;

# START THE REST SERVER
docker run \
-d \
--network composer_default \
--name rest \
-v $(pwd)/.loc-card-store:/home/composer/.composer \
-e COMPOSER_CARD=admin@letters-of-credit-network \
-e COMPOSER_NAMESPACES=never \
-p 3000:3000 \
hyperledger/composer-rest-server:latest

#WAIT FOR REST SERVER TO WAKE UP
sleep 10

# START THE LOC APPLICATION
docker run \
-d \
--network composer_default \
--name vda \
-e REACT_APP_REST_SERVER_CONFIG='{"webSocketURL": "ws://localhost:3000", "httpURL": "http://localhost:3000/api"}' \
-p 6001:6001 \
hyperledger/letters-of-credit:latest

#WAIT FOR REACT SERVER TO WAKE UP
sleep 10

# OPEN THE APPLICATION
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/"
case "$(uname)" in
"Darwin") open ${URLS}
;;
"Linux") if [ -n "$BROWSER" ] ; then
$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/
elif which x-www-browser > /dev/null ; then
nohup x-www-browser ${URLS} < /dev/null > /dev/null 2>&1 &
elif which xdg-open > /dev/null ; then
for URL in ${URLS} ; do
xdg-open ${URL}
done
elif which gnome-open > /dev/null ; then
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/
else
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"
fi
;;
*) echo "Playground not launched - this OS is currently not supported "
;;
esac
29 changes: 29 additions & 0 deletions packages/letters-of-credit/package.json
@@ -0,0 +1,29 @@
{
"name": "letters-of-credit",
"version": "0.0.7",
"private": true,
"author": "Erin Hughes, Hannah Rayner, Nikola Ignatov, Jackson Ross, Andrew Hurt",
"dependencies": {
"axios": "^0.18.0",
"letters-of-credit-network": "^0.2.4",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-redux": "^5.0.7",
"react-router-dom": "^4.2.2",
"react-scripts": "1.1.1",
"react-stepper-horizontal": "^1.0.10",
"react-toggle": "^4.0.2",
"redux": "^3.7.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"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"
},
"devDependencies": {
"gulp": "^3.9.1",
"gulp-sass": "^3.2.1"
}
}
Binary file added packages/letters-of-credit/public/favicon.ico
Binary file not shown.

0 comments on commit 6916021

Please sign in to comment.