-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-16147] Update Commercial Paper to work with v2 (#98)
Update the applications and scripts to use the new v2 SDKs and the new lifecycle Add in a basic script based on the readme.md that does a basic run of the scenario Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
- Loading branch information
Showing
35 changed files
with
669 additions
and
535 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
steps: | ||
- script: bash start.sh | ||
workingDirectory: basic-network | ||
displayName: Start Fabric | ||
- script: | | ||
./gradlew build | ||
workingDirectory: commercial-paper/organization/digibank/contract-java | ||
displayName: Build Java Contract | ||
- script: | | ||
docker-compose -f docker-compose.yml up -d cliDigiBank | ||
docker exec cliDigiBank peer lifecycle chaincode package cp.tar.gz --lang java --path /opt/gopath/src/github.com/contract-java/build/libs --label cp_0 | ||
docker exec cliDigiBank peer lifecycle chaincode install cp.tar.gz | ||
export PACKAGE_ID=$(docker exec cliDigiBank peer lifecycle chaincode queryinstalled 2>&1 | awk -F "[, ]+" '/Label: /{print $3}') | ||
docker exec cliDigiBank peer lifecycle chaincode approveformyorg --channelID mychannel --name papercontract -v 0 --package-id $PACKAGE_ID --sequence 1 --signature-policy "AND ('Org1MSP.member')" | ||
docker exec cliDigiBank peer lifecycle chaincode commit -o orderer.example.com:7050 --channelID mychannel --name papercontract -v 0 --sequence 1 --waitForEvent --signature-policy "AND ('Org1MSP.member')" | ||
docker exec cliDigiBank peer chaincode invoke -o orderer.example.com:7050 --channelID mychannel --name papercontract -c '{"Args":["org.papernet.commercialpaper:instantiate"]}' --waitForEvent | ||
workingDirectory: commercial-paper/organization/digibank/configuration/cli | ||
displayName: Setup Commercial Paper contract | ||
- script: retry -- npm install | ||
workingDirectory: commercial-paper/organization/magnetocorp/application | ||
displayName: Install Magnetocorp application | ||
- script: | | ||
set -ex | ||
node addToWallet.js | ||
node issue.js | ||
workingDirectory: commercial-paper/organization/magnetocorp/application | ||
displayName: Magnetocorp issue paper | ||
- script: retry -- npm install | ||
workingDirectory: commercial-paper/organization/digibank/application | ||
displayName: Install Digibank application | ||
- script: | | ||
set -ex | ||
node addToWallet.js | ||
node buy.js | ||
node redeem.js | ||
workingDirectory: commercial-paper/organization/digibank/application | ||
displayName: Digibank issue paper |
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,42 @@ | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
steps: | ||
- script: bash start.sh | ||
workingDirectory: basic-network | ||
displayName: Start Fabric | ||
- script: | | ||
docker-compose -f docker-compose.yml up -d cliMagnetoCorp | ||
docker exec cliMagnetoCorp peer lifecycle chaincode package cp.tar.gz --lang node --path /opt/gopath/src/github.com/contract --label cp_0 | ||
docker exec cliMagnetoCorp peer lifecycle chaincode install cp.tar.gz | ||
export PACKAGE_ID=$(docker exec cliMagnetoCorp peer lifecycle chaincode queryinstalled 2>&1 | awk -F "[, ]+" '/Label: /{print $3}') | ||
docker exec cliMagnetoCorp peer lifecycle chaincode approveformyorg --channelID mychannel --name papercontract -v 0 --package-id $PACKAGE_ID --sequence 1 --signature-policy "AND ('Org1MSP.member')" | ||
docker exec cliMagnetoCorp peer lifecycle chaincode commit -o orderer.example.com:7050 --channelID mychannel --name papercontract -v 0 --sequence 1 --waitForEvent --signature-policy "AND ('Org1MSP.member')" | ||
docker exec cliMagnetoCorp peer chaincode invoke -o orderer.example.com:7050 --channelID mychannel --name papercontract -c '{"Args":["org.papernet.commercialpaper:instantiate"]}' --waitForEvent | ||
workingDirectory: commercial-paper/organization/magnetocorp/configuration/cli | ||
displayName: Setup Commercial Paper contract | ||
- script: retry -- npm install | ||
workingDirectory: commercial-paper/organization/magnetocorp/application | ||
displayName: Install Magnetocorp application | ||
- script: | | ||
set -ex | ||
node addToWallet.js | ||
node issue.js | ||
workingDirectory: commercial-paper/organization/magnetocorp/application | ||
displayName: Magnetocorp issue paper | ||
- script: retry -- npm install | ||
workingDirectory: commercial-paper/organization/digibank/application | ||
displayName: Install Digibank application | ||
- script: | | ||
set -ex | ||
node addToWallet.js | ||
node buy.js | ||
node redeem.js | ||
workingDirectory: commercial-paper/organization/digibank/application | ||
displayName: Digibank issue paper |
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,41 @@ | ||
#!/bin/bash -e | ||
set -o pipefail | ||
|
||
echo "======== PULL DOCKER IMAGES ========" | ||
########################################################## | ||
REPO_URL=hyperledger-fabric.jfrog.io | ||
ORG_NAME="fabric" | ||
|
||
VERSION=2.0.0 | ||
ARCH="amd64" | ||
: ${STABLE_VERSION:=$VERSION-stable} | ||
STABLE_TAG=$ARCH-$STABLE_VERSION | ||
MASTER_TAG=$ARCH-stable | ||
|
||
echo "---------> STABLE_VERSION:" $STABLE_VERSION | ||
|
||
dockerTag() { | ||
for IMAGES in baseos peer orderer ca tools orderer ccenv javaenv nodeenv; do | ||
echo "Images: $IMAGES" | ||
echo | ||
docker pull $REPO_URL/$ORG_NAME-$IMAGES:$STABLE_TAG | ||
if [ $? != 0 ]; then | ||
echo "FAILED: Docker Pull Failed on $IMAGES" | ||
exit 1 | ||
fi | ||
docker tag $REPO_URL/$ORG_NAME-$IMAGES:$STABLE_TAG hyperledger/$ORG_NAME-$IMAGES | ||
docker tag $REPO_URL/$ORG_NAME-$IMAGES:$STABLE_TAG hyperledger/$ORG_NAME-$IMAGES:latest | ||
docker tag $REPO_URL/$ORG_NAME-$IMAGES:$STABLE_TAG hyperledger/$ORG_NAME-$IMAGES:$ARCH-$VERSION-stable | ||
docker tag $REPO_URL/$ORG_NAME-$IMAGES:$STABLE_TAG hyperledger/$ORG_NAME-$IMAGES:$ARCH-stable | ||
docker tag $REPO_URL/$ORG_NAME-$IMAGES:$STABLE_TAG hyperledger/$ORG_NAME-$IMAGES:$VERSION | ||
|
||
echo "Deleting docker images: $IMAGES" | ||
docker rmi -f $REPO_URL/$ORG_NAME-$IMAGES:$STABLE_TAG | ||
done | ||
} | ||
|
||
dockerTag | ||
|
||
echo | ||
docker images | ||
echo |
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 @@ | ||
cp.tar.gz |
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,59 @@ | ||
#!/bin/bash | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
set -ex | ||
|
||
function _exit(){ | ||
printf "Exiting:%s\n" "$1" | ||
exit -1 | ||
} | ||
|
||
# Where am I? | ||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" | ||
|
||
## Use this to remove anything existing on the basic network before starting | ||
# docker kill $(docker network inspect net_basic --format '{{json .Containers}}' | jq -r 'keys[]') && docker rm $(docker ps -aq) | ||
|
||
## Start the Fabric Network | ||
cd "${DIR}/basic-network" | ||
. ./start.sh | ||
|
||
docker ps | ||
|
||
## Run as MagnetoCorp | ||
# cd "${DIR}/commercial-paper/organization/magnetocorp/configuration/cli" | ||
# docker-compose -f docker-compose.yml up -d cliMagnetoCorp | ||
|
||
# docker exec cliMagnetoCorp peer lifecycle chaincode package cp.tar.gz --lang node --path /opt/gopath/src/github.com/contract --label cp_0 | ||
# docker exec cliMagnetoCorp peer lifecycle chaincode install cp.tar.gz | ||
# export PACKAGE_ID=$(docker exec cliMagnetoCorp peer lifecycle chaincode queryinstalled 2>&1 | awk -F "[, ]+" '/Label: /{print $3}') | ||
|
||
# docker exec cliMagnetoCorp peer lifecycle chaincode approveformyorg --channelID mychannel --name papercontract -v 0 --package-id $PACKAGE_ID --sequence 1 --signature-policy "AND ('Org1MSP.member')" | ||
# docker exec cliMagnetoCorp peer lifecycle chaincode commit -o orderer.example.com:7050 --channelID mychannel --name papercontract -v 0 --sequence 1 --waitForEvent --signature-policy "AND ('Org1MSP.member')" | ||
# docker exec cliMagnetoCorp peer chaincode invoke -o orderer.example.com:7050 --channelID mychannel --name papercontract -c '{"Args":["org.papernet.commercialpaper:instantiate"]}' --waitForEvent | ||
|
||
|
||
cd "${DIR}/commercial-paper/organization/digibank/configuration/cli" | ||
docker-compose -f docker-compose.yml up -d cliDigiBank | ||
CLI_CONTAINER=cliDigiBank | ||
docker exec ${CLI_CONTAINER} peer lifecycle chaincode package cp.tar.gz --lang java --path /opt/gopath/src/github.com/contract-java/build/libs --label cp_0 | ||
docker exec ${CLI_CONTAINER} peer lifecycle chaincode install cp.tar.gz | ||
export PACKAGE_ID=$(docker exec ${CLI_CONTAINER} peer lifecycle chaincode queryinstalled 2>&1 | awk -F "[, ]+" '/Label: /{print $3}') | ||
|
||
docker exec ${CLI_CONTAINER} peer lifecycle chaincode approveformyorg --channelID mychannel --name papercontract -v 0 --package-id $PACKAGE_ID --sequence 1 --signature-policy "AND ('Org1MSP.member')" | ||
docker exec ${CLI_CONTAINER} peer lifecycle chaincode commit -o orderer.example.com:7050 --channelID mychannel --name papercontract -v 0 --sequence 1 --waitForEvent --signature-policy "AND ('Org1MSP.member')" | ||
docker exec ${CLI_CONTAINER} peer chaincode invoke -o orderer.example.com:7050 --channelID mychannel --name papercontract -c '{"Args":["org.papernet.commercialpaper:instantiate"]}' --waitForEvent | ||
|
||
|
||
|
||
cd "${DIR}/commercial-paper/organization/magnetocorp/application" | ||
npm install | ||
node addToWallet.js | ||
node issue.js | ||
|
||
cd "${DIR}/commercial-paper/organization/digibank/application" | ||
npm install | ||
node addToWallet.js | ||
node buy.js | ||
node redeem.js |
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
Oops, something went wrong.