From e1d1951c5b62c2b240259e9fb9b3120eb4dc0085 Mon Sep 17 00:00:00 2001 From: NIKHIL E GUPTA Date: Wed, 29 Apr 2020 20:15:38 -0400 Subject: [PATCH] Remove file transfer files from commercial paper Signed-off-by: NIKHIL E GUPTA --- .../commercial-paper/azure-pipelines-go.yml | 14 ++--- .../commercial-paper/azure-pipelines-java.yml | 15 ++--- .../azure-pipelines-javascript.yml | 15 ++--- commercial-paper/README.md | 18 +++--- commercial-paper/network-clean.sh | 7 ++- .../digibank/application/addToWallet.js | 55 ------------------- .../magnetocorp/application/addToWallet.js | 55 ------------------- 7 files changed, 37 insertions(+), 142 deletions(-) delete mode 100644 commercial-paper/organization/digibank/application/addToWallet.js delete mode 100644 commercial-paper/organization/magnetocorp/application/addToWallet.js diff --git a/ci/templates/commercial-paper/azure-pipelines-go.yml b/ci/templates/commercial-paper/azure-pipelines-go.yml index 9008cf46..2e80c524 100644 --- a/ci/templates/commercial-paper/azure-pipelines-go.yml +++ b/ci/templates/commercial-paper/azure-pipelines-go.yml @@ -18,9 +18,9 @@ steps: displayName: Vendor DigiBank Dependencies - script: | - ./network.sh up createChannel -s couchdb -i ${FABRIC_VERSION} # FABRIC_VERSION is set in ci/azure-pipelines.yml + ./network.sh up createChannel -ca -s couchdb -i ${FABRIC_VERSION} # FABRIC_VERSION is set in ci/azure-pipelines.yml - # Copy the connection profiles so they are in the correct organizations. + # Copy the connection profiles so they are in the correct organizations. cp "./organizations/peerOrganizations/org1.example.com/connection-org1.yaml" "../commercial-paper/organization/digibank/gateway/" cp "./organizations/peerOrganizations/org2.example.com/connection-org2.yaml" "../commercial-paper/organization/magnetocorp/gateway/" workingDirectory: test-network @@ -41,7 +41,7 @@ steps: --sequence 1 \ --tls \ --cafile $ORDERER_CA - + peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name papercontract -v 0 --sequence 1 workingDirectory: commercial-paper/organization/magnetocorp displayName: Setup Commercial Paper Contract @@ -61,7 +61,7 @@ steps: --sequence 1 \ --tls \ --cafile $ORDERER_CA - + peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name papercontract -v 0 --sequence 1 peer lifecycle chaincode commit -o localhost:7050 \ @@ -70,7 +70,7 @@ steps: --ordererTLSHostnameOverride orderer.example.com \ --channelID mychannel --name papercontract -v 0 \ --sequence 1 \ - --tls --cafile $ORDERER_CA --waitForEvent + --tls --cafile $ORDERER_CA --waitForEvent workingDirectory: commercial-paper/organization/digibank displayName: Setup Commercial Paper Contract @@ -80,7 +80,7 @@ steps: displayName: Install Magnetocorp Application - script: | set -ex - node addToWallet.js + node enrollUser.js node issue.js workingDirectory: commercial-paper/organization/magnetocorp/application displayName: MagnetoCorp Issue Paper @@ -90,7 +90,7 @@ steps: displayName: Install DigiBank Application - script: | set -ex - node addToWallet.js + node enrollUser.js node buy.js node redeem.js workingDirectory: commercial-paper/organization/digibank/application diff --git a/ci/templates/commercial-paper/azure-pipelines-java.yml b/ci/templates/commercial-paper/azure-pipelines-java.yml index 28d8e1d1..cdfd46d5 100644 --- a/ci/templates/commercial-paper/azure-pipelines-java.yml +++ b/ci/templates/commercial-paper/azure-pipelines-java.yml @@ -13,11 +13,12 @@ steps: displayName: Build MagnetoCorp Java Contract - script: | - ./network.sh up createChannel -s couchdb -i ${FABRIC_VERSION} # FABRIC_VERSION is set in ci/azure-pipelines.yml + ./network.sh up createChannel -ca -s couchdb -i ${FABRIC_VERSION} # FABRIC_VERSION is set in ci/azure-pipelines.yml - # Copy the connection profiles so they are in the correct organizations. + # Copy the connection profiles so they are in the correct organizations. cp "./organizations/peerOrganizations/org1.example.com/connection-org1.yaml" "../commercial-paper/organization/digibank/gateway/" cp "./organizations/peerOrganizations/org2.example.com/connection-org2.yaml" "../commercial-paper/organization/magnetocorp/gateway/" + workingDirectory: test-network displayName: Start Fabric - script: | @@ -36,7 +37,7 @@ steps: --sequence 1 \ --tls \ --cafile $ORDERER_CA - + peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name papercontract -v 0 --sequence 1 workingDirectory: commercial-paper/organization/magnetocorp displayName: Setup Commercial Paper Contract @@ -56,7 +57,7 @@ steps: --sequence 1 \ --tls \ --cafile $ORDERER_CA - + peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name papercontract -v 0 --sequence 1 peer lifecycle chaincode commit -o localhost:7050 \ @@ -65,7 +66,7 @@ steps: --ordererTLSHostnameOverride orderer.example.com \ --channelID mychannel --name papercontract -v 0 \ --sequence 1 \ - --tls --cafile $ORDERER_CA --waitForEvent + --tls --cafile $ORDERER_CA --waitForEvent workingDirectory: commercial-paper/organization/digibank displayName: Setup Commercial Paper Contract @@ -75,7 +76,7 @@ steps: displayName: Install MagnetoCorp Application - script: | set -ex - node addToWallet.js + node enrollUser.js node issue.js workingDirectory: commercial-paper/organization/magnetocorp/application displayName: MagnetoCorp Issue Paper @@ -85,7 +86,7 @@ steps: displayName: Install DigiBank Application - script: | set -ex - node addToWallet.js + node enrollUser.js node buy.js node redeem.js workingDirectory: commercial-paper/organization/digibank/application diff --git a/ci/templates/commercial-paper/azure-pipelines-javascript.yml b/ci/templates/commercial-paper/azure-pipelines-javascript.yml index b4f2df26..452c0c8c 100644 --- a/ci/templates/commercial-paper/azure-pipelines-javascript.yml +++ b/ci/templates/commercial-paper/azure-pipelines-javascript.yml @@ -4,11 +4,12 @@ steps: - script: | - ./network.sh up createChannel -s couchdb -i ${FABRIC_VERSION} # FABRIC_VERSION is set in ci/azure-pipelines.yml + ./network.sh up createChannel -ca -s couchdb -i ${FABRIC_VERSION} # FABRIC_VERSION is set in ci/azure-pipelines.yml - # Copy the connection profiles so they are in the correct organizations. + # Copy the connection profiles so they are in the correct organizations. cp "./organizations/peerOrganizations/org1.example.com/connection-org1.yaml" "../commercial-paper/organization/digibank/gateway/" cp "./organizations/peerOrganizations/org2.example.com/connection-org2.yaml" "../commercial-paper/organization/magnetocorp/gateway/" + workingDirectory: test-network displayName: Start Fabric - script: | @@ -27,7 +28,7 @@ steps: --sequence 1 \ --tls \ --cafile $ORDERER_CA - + peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name papercontract -v 0 --sequence 1 workingDirectory: commercial-paper/organization/magnetocorp displayName: Setup Commercial Paper Contract @@ -47,7 +48,7 @@ steps: --sequence 1 \ --tls \ --cafile $ORDERER_CA - + peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name papercontract -v 0 --sequence 1 peer lifecycle chaincode commit -o localhost:7050 \ @@ -56,7 +57,7 @@ steps: --ordererTLSHostnameOverride orderer.example.com \ --channelID mychannel --name papercontract -v 0 \ --sequence 1 \ - --tls --cafile $ORDERER_CA --waitForEvent + --tls --cafile $ORDERER_CA --waitForEvent workingDirectory: commercial-paper/organization/digibank displayName: Setup Commercial Paper Contract @@ -65,7 +66,7 @@ steps: displayName: Install MagnetoCorp Application - script: | set -ex - node addToWallet.js + node enrollUser.js node issue.js workingDirectory: commercial-paper/organization/magnetocorp/application displayName: MagnetoCorp Issue Paper @@ -75,7 +76,7 @@ steps: displayName: Install DigiBank Application - script: | set -ex - node addToWallet.js + node enrollUser.js node buy.js node redeem.js workingDirectory: commercial-paper/organization/digibank/application diff --git a/commercial-paper/README.md b/commercial-paper/README.md index 4aa6056c..e6e9bb82 100644 --- a/commercial-paper/README.md +++ b/commercial-paper/README.md @@ -21,7 +21,7 @@ This `README.md` file is in the `commercial-paper` directory, the source code fo 1) Start the Hyperledger Fabric infrastructure - The 'test-network' will be used - this has two organizations 'org1' and 'org2' DigiBank will be org1, and MagnetoCorp will be org2. + The 'test-network' will be used - this has two organizations 'org1' and 'org2' DigiBank will be org1, and MagnetoCorp will be org2. 2) Install and Instantiate the Contracts @@ -43,7 +43,7 @@ You will need a machine with the following You will need to install the peer cli binaries and this fabric-samples repository available. For more information [Install the Samples, Binaries and Docker Images](https://hyperledger-fabric.readthedocs.io/en/latest/install.html) in the Hyperledger Fabric documentation. -It is advised to have 3 console windows open; one to monitor the infrastructure and one each for MagnetoCorp and DigiBank. Once you've cloned the fabric-samples - change to the commercial-paper directory in each window. +It is advised to have 3 console windows open; one to monitor the infrastructure and one each for MagnetoCorp and DigiBank. Once you've cloned the fabric-samples - change to the commercial-paper directory in each window. ``` cd fabric-samples/commercial-paper @@ -85,7 +85,7 @@ cd fabric-samples/commercial-paper/organization/digibank ### Deploy the smart contract to the channel -You need to perform similar operations for both organizations. For different contract languages the steps are very similar. The steps for JavaScript are shown first, with the details of different languages afterwards. +You need to perform similar operations for both organizations. For different contract languages the steps are very similar. The steps for JavaScript are shown first, with the details of different languages afterwards. **For a JavaScript Contract** @@ -109,7 +109,7 @@ peer lifecycle chaincode approveformyorg --orderer localhost:7050 --ordererTLSH --sequence 1 \ --tls \ --cafile $ORDERER_CA - + peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name papercontract -v 0 --sequence 1 ``` @@ -149,7 +149,7 @@ peer lifecycle chaincode commit -o localhost:7050 \ --ordererTLSHostnameOverride orderer.example.com \ --channelID mychannel --name papercontract -v 0 \ --sequence 1 \ - --tls --cafile $ORDERER_CA --waitForEvent + --tls --cafile $ORDERER_CA --waitForEvent ``` @@ -229,7 +229,7 @@ This is running as *MagnetoCorp* These commands are to be run in the *Add the Identity to be used* ``` -node addToWallet.js +node enrollUser.js # or java -cp target/commercial-paper-0.0.1-SNAPSHOT.jar org.magnetocorp.AddToWallet ``` @@ -244,7 +244,7 @@ java -cp target/commercial-paper-0.0.1-SNAPSHOT.jar org.magnetocorp.Issue ### Buy and Redeem the paper -This is running as *Digibank*; +This is running as *Digibank*; You can now run the applications to buy and redeem the paper. Change to either the `commercial-paper/organization/digibank/application` directory or `commercial-paper/organization/digibank/application-java` @@ -252,7 +252,7 @@ You can now run the applications to buy and redeem the paper. Change to either t *Add the Identity to be used* ``` -node addToWallet.js +node enrollUser.js # or java -cp target/commercial-paper-0.0.1-SNAPSHOT.jar org.digibank.AddToWallet ``` @@ -277,5 +277,5 @@ java -cp target/commercial-paper-0.0.1-SNAPSHOT.jar org.digibank.Redeem When you are finished using the Fabric test network and the commercial paper smart contract and applications, you can use the following command to clean up the network: ``` -./network-clean.sh +./network-clean.sh ``` diff --git a/commercial-paper/network-clean.sh b/commercial-paper/network-clean.sh index 5fe6c087..47434b6b 100755 --- a/commercial-paper/network-clean.sh +++ b/commercial-paper/network-clean.sh @@ -16,11 +16,14 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" export FABRIC_CFG_PATH="${DIR}/../config" -cd "${DIR}/../test-network/" +pushd "${DIR}/../test-network/" docker kill cliDigiBank cliMagnetoCorp logspout || true ./network.sh down +popd + +rm -rf organization/magnetocorp/identity/ +rm -rf organization/digibank/identity/ # remove any stopped containers docker rm $(docker ps -aq) - diff --git a/commercial-paper/organization/digibank/application/addToWallet.js b/commercial-paper/organization/digibank/application/addToWallet.js deleted file mode 100644 index 9517e393..00000000 --- a/commercial-paper/organization/digibank/application/addToWallet.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright IBM Corp. All Rights Reserved. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -'use strict'; - -// Bring key classes into scope, most importantly Fabric SDK network class -const fs = require('fs'); -const { Wallets } = require('fabric-network'); -const path = require('path'); - -const fixtures = path.resolve(__dirname, '../../../../test-network'); - -async function main() { - - // Main try/catch block - try { - - // A wallet stores a collection of identities - const wallet = await Wallets.newFileSystemWallet('../identity/user/balaji/wallet'); - - // Identity to credentials to be stored in the wallet - const credPath = path.join(fixtures, '/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com'); - const certificate = fs.readFileSync(path.join(credPath, '/msp/signcerts/User1@org1.example.com-cert.pem')).toString(); - const privateKey = fs.readFileSync(path.join(credPath, '/msp/keystore/priv_sk')).toString(); - - // Load credentials into wallet - const identityLabel = 'balaji'; - - const identity = { - credentials: { - certificate, - privateKey - }, - mspId: 'Org1MSP', - type: 'X.509' - } - - await wallet.put(identityLabel, identity); - - } catch (error) { - console.log(`Error adding to wallet. ${error}`); - console.log(error.stack); - } -} - -main().then(() => { - console.log('done'); -}).catch((e) => { - console.log(e); - console.log(e.stack); - process.exit(-1); -}); diff --git a/commercial-paper/organization/magnetocorp/application/addToWallet.js b/commercial-paper/organization/magnetocorp/application/addToWallet.js deleted file mode 100644 index eb491238..00000000 --- a/commercial-paper/organization/magnetocorp/application/addToWallet.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright IBM Corp. All Rights Reserved. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -'use strict'; - -// Bring key classes into scope, most importantly Fabric SDK network class -const fs = require('fs'); -const { Wallets } = require('fabric-network'); -const path = require('path'); - -const fixtures = path.resolve(__dirname, '../../../../test-network'); - -async function main() { - - // Main try/catch block - try { - // A wallet stores a collection of identities - const wallet = await Wallets.newFileSystemWallet('../identity/user/isabella/wallet'); - - // Identity to credentials to be stored in the wallet - const credPath = path.join(fixtures, '/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com'); - const certificate = fs.readFileSync(path.join(credPath, '/msp/signcerts/User1@org2.example.com-cert.pem')).toString(); - const privateKey = fs.readFileSync(path.join(credPath, '/msp/keystore/priv_sk')).toString(); - - // Load credentials into wallet - const identityLabel = 'isabella'; - - const identity = { - credentials: { - certificate, - privateKey - }, - mspId: 'Org2MSP', - type: 'X.509' - } - - - await wallet.put(identityLabel,identity); - - } catch (error) { - console.log(`Error adding to wallet. ${error}`); - console.log(error.stack); - } -} - -main().then(() => { - console.log('done'); -}).catch((e) => { - console.log(e); - console.log(e.stack); - process.exit(-1); -});