mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-23 01:55:10 +00:00
Remove file transfer files from commercial paper
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
This commit is contained in:
parent
cda88df4f6
commit
e1d1951c5b
7 changed files with 37 additions and 142 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
```
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
|
|
@ -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);
|
||||
});
|
||||
Loading…
Reference in a new issue