[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>
This commit is contained in:
Matthew B White 2020-01-14 16:44:31 +00:00 committed by Simon Stone
parent 6d9fd6f7e1
commit 4c2a0a4a49
35 changed files with 667 additions and 533 deletions

View file

@ -47,5 +47,25 @@ jobs:
- template: install-deps.yml
- template: install-fabric.yml
- template: fabcar-typescript.yml
- job: commercialpaper_javascript
displayName: CommercialPaper (JavaScript)
pool:
vmImage: ubuntu-18.04
dependsOn: []
timeoutInMinutes: 60
steps:
- template: install-deps.yml
- template: install-fabric.yml
- template: commercialpaper-javascript.yml
- job: commercialpaper_java
displayName: CommercialPaper (Java)
pool:
vmImage: ubuntu-18.04
dependsOn: []
timeoutInMinutes: 60
steps:
- template: install-deps.yml
- template: install-fabric.yml
- template: commercialpaper-java.yml

View file

@ -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

View file

@ -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

41
ci/getDockerImages.sh Executable file
View file

@ -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

View file

@ -17,13 +17,5 @@ steps:
cd /usr/local
sudo tar xzvf /tmp/hyperledger-fabric-ca-latest-linux-amd64.latest-SNAPSHOT.tar.gz
displayName: Download Fabric CA CLI
- script: |
set -ex
for i in baseos ca ccenv javaenv nodeenv peer orderer tools; do
docker pull nexus3.hyperledger.org:10001/hyperledger/fabric-$i:amd64-2.0.0-stable
docker tag nexus3.hyperledger.org:10001/hyperledger/fabric-$i:amd64-2.0.0-stable hyperledger/fabric-$i:amd64-2.0.0-stable
docker tag nexus3.hyperledger.org:10001/hyperledger/fabric-$i:amd64-2.0.0-stable hyperledger/fabric-$i:amd64-2.0.0
docker tag nexus3.hyperledger.org:10001/hyperledger/fabric-$i:amd64-2.0.0-stable hyperledger/fabric-$i:2.0.0
docker tag nexus3.hyperledger.org:10001/hyperledger/fabric-$i:amd64-2.0.0-stable hyperledger/fabric-$i:latest
done
- script: bash ci/getDockerImages.sh
displayName: Pull Fabric Docker images

1
commercial-paper/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
cp.tar.gz

View file

@ -1,7 +1,7 @@
# Commercial Paper Tutorial
This folder contains the code for an introductory tutorial to Smart Contract development. It is based around the scenario of Commercial Paper.
The full tutorial, including full scenario details and line by line code walkthroughs is in the [Hyperledger Fabric documentation](https://hyperledger-fabric.readthedocs.io/en/release-1.4/tutorial/commercial_paper.html).
The full tutorial, including full scenario details and line by line code walkthroughs is in the [Hyperledger Fabric documentation](https://hyperledger-fabric.readthedocs.io/en/latest/tutorial/commercial_paper.html).
## Scenario
@ -9,7 +9,7 @@ In this tutorial two organizations, MagnetoCorp and DigiBank, trade commercial p
Once youve set up a basic network, youll act as Isabella, an employee of MagnetoCorp, who will issue a commercial paper on its behalf. Youll then switch hats to take the role of Balaji, an employee of DigiBank, who will buy this commercial paper, hold it for a period of time, and then redeem it with MagnetoCorp for a small profit.
![](https://hyperledger-fabric.readthedocs.io/en/release-1.4/_images/commercial_paper.diagram.1.png)
![](https://hyperledger-fabric.readthedocs.io/en/latest/_images/commercial_paper.diagram.1.png)
## Quick Start
@ -34,7 +34,7 @@ You are strongly advised to read the full tutorial to get information about the
You will need a machine with the following
- Docker and docker-compose installed
- Node.js v8 if you want to run JavaScript client applications
- Node.js v12 if you want to run JavaScript client applications
- Java v8 if you want to run Java client applications
- Maven to build the Java applications
@ -68,9 +68,14 @@ This will start a docker container for Fabric CLI commands, and put you in the c
**For a JavaScript Contract:**
```
docker exec cliMagnetoCorp peer chaincode install -n papercontract -v 0 -p /opt/gopath/src/github.com/contract -l node
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
docker exec cliMagnetoCorp peer chaincode instantiate -n papercontract -v 0 -l node -c '{"Args":["org.papernet.commercialpaper:instantiate"]}' -C mychannel -P "AND ('Org1MSP.member')"
```
**For a Java Contract:**

59
commercial-paper/cp.sh Executable file
View file

@ -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

View file

@ -53,7 +53,7 @@ public class State {
}
public static String[] splitKey(String key) {
System.out.println("Splittin gkey " + key + " " + java.util.Arrays.asList(key.split(":")));
System.out.println("splitting key " + key + " " + java.util.Arrays.asList(key.split(":")));
return key.split(":");
}

View file

@ -6,29 +6,37 @@
// Bring key classes into scope, most importantly Fabric SDK network class
const fs = require('fs');
const { FileSystemWallet, X509WalletMixin } = require('fabric-network');
const { Wallets } = require('fabric-network');
const path = require('path');
const fixtures = path.resolve(__dirname, '../../../../basic-network');
// A wallet stores a collection of identities
const wallet = new FileSystemWallet('../identity/user/balaji/wallet');
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, '/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com');
const cert = fs.readFileSync(path.join(credPath, '/msp/signcerts/Admin@org1.example.com-cert.pem')).toString();
const key = fs.readFileSync(path.join(credPath, '/msp/keystore/cd96d5260ad4757551ed4a5a991e62130f8008a0bf996e4e4b84cd097a747fec_sk')).toString();
const certificate = fs.readFileSync(path.join(credPath, '/msp/signcerts/Admin@org1.example.com-cert.pem')).toString();
const privateKey = fs.readFileSync(path.join(credPath, '/msp/keystore/5ba12183ab07014ba831f9a79cf51fe7e6f62cdebe6193f070445243aedddee9_sk')).toString();
// Load credentials into wallet
const identityLabel = 'Admin@org1.example.com';
const identity = X509WalletMixin.createIdentity('Org1MSP', cert, key);
const identity = {
credentials: {
certificate,
privateKey
},
mspId: 'Org1MSP',
type: 'X.509'
}
await wallet.import(identityLabel, identity);
await wallet.put(identityLabel, identity);
} catch (error) {
console.log(`Error adding to wallet. ${error}`);

View file

@ -17,15 +17,17 @@ SPDX-License-Identifier: Apache-2.0
// Bring key classes into scope, most importantly Fabric SDK network class
const fs = require('fs');
const yaml = require('js-yaml');
const { FileSystemWallet, Gateway } = require('fabric-network');
const { Wallets, Gateway } = require('fabric-network');
const CommercialPaper = require('../../magnetocorp/contract/lib/paper.js');
// A wallet stores a collection of identities for use
const wallet = new FileSystemWallet('../identity/user/balaji/wallet');
// Main program function
async function main () {
// A wallet stores a collection of identities for use
const wallet = await Wallets.newFileSystemWallet('../identity/user/balaji/wallet');
// A gateway defines the peers used to access Fabric networks
const gateway = new Gateway();

View file

@ -33,15 +33,48 @@
"@types/node": "*"
}
},
"@types/caseless": {
"version": "0.12.2",
"resolved": "https://registry.npmjs.org/@types/caseless/-/caseless-0.12.2.tgz",
"integrity": "sha512-6ckxMjBBD8URvjB6J3NcnuAn5Pkl7t3TizAg+xdlzzQGSPSmBcXf8KoIH0ua/i+tio+ZRUHEXp0HEmvaR4kt0w=="
},
"@types/long": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.0.tgz",
"integrity": "sha512-1w52Nyx4Gq47uuu0EVcsHBxZFJgurQ+rTKS3qMHxR1GY2T8c2AJYd6vZoZ9q1rupaDjU0yT+Jc2XTyXkjeMA+Q=="
},
"@types/node": {
"version": "12.6.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.6.8.tgz",
"integrity": "sha512-aX+gFgA5GHcDi89KG5keey2zf0WfZk/HAQotEamsK2kbey+8yGKcson0hbK8E+v0NArlCJQCqMP161YhV6ZXLg=="
"version": "13.1.4",
"resolved": "https://registry.npmjs.org/@types/node/-/node-13.1.4.tgz",
"integrity": "sha512-Lue/mlp2egZJoHXZr4LndxDAd7i/7SQYhV0EjWfb/a4/OZ6tuVwMCVPiwkU5nsEipxEf7hmkSU7Em5VQ8P5NGA=="
},
"@types/request": {
"version": "2.48.4",
"resolved": "https://registry.npmjs.org/@types/request/-/request-2.48.4.tgz",
"integrity": "sha512-W1t1MTKYR8PxICH+A4HgEIPuAC3sbljoEVfyZbeFJJDbr30guDspJri2XOaM2E+Un7ZjrihaDi7cf6fPa2tbgw==",
"requires": {
"@types/caseless": "*",
"@types/node": "*",
"@types/tough-cookie": "*",
"form-data": "^2.5.0"
},
"dependencies": {
"form-data": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz",
"integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.6",
"mime-types": "^2.1.12"
}
}
}
},
"@types/tough-cookie": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-2.3.6.tgz",
"integrity": "sha512-wHNBMnkoEBiRAd3s8KTKwIuO9biFtTf0LehITzBhSco+HQI0xkXZbLOD55SW3Aqw3oUkHstkm5SPv58yaAdFPQ=="
},
"acorn": {
"version": "6.2.1",
@ -138,9 +171,9 @@
"integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg="
},
"aws4": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz",
"integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ=="
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.0.tgz",
"integrity": "sha512-Uvq6hVe90D0B2WEnUqtdgY1bATGz3mw33nH9Y+dmA+w5DHvUmBgkr5rM/KCHpCsiFNRUfokW/szpPPgMK2hm4A=="
},
"balanced-match": {
"version": "1.0.0",
@ -429,9 +462,9 @@
}
},
"elliptic": {
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.0.tgz",
"integrity": "sha512-eFOJTMyCYb7xtE/caJ6JJu+bhi67WCYNbkGSknu20pmM8Ke/bqOfdnZWxyoGN26JgfxTbXrsCkEw4KheCT/KGg==",
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.2.tgz",
"integrity": "sha512-f4x70okzZbIQl/NSRLkI/+tteV/9WqL98zx+SQ69KbXxmVrmjwsNUPn/gYJJ0sHvEak24cZgHIPegRePAtA/xw==",
"requires": {
"bn.js": "^4.4.0",
"brorand": "^1.0.1",
@ -449,9 +482,9 @@
"dev": true
},
"end-of-stream": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz",
"integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==",
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
"integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==",
"requires": {
"once": "^1.4.0"
}
@ -635,104 +668,118 @@
"integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A="
},
"fabric-ca-client": {
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/fabric-ca-client/-/fabric-ca-client-1.4.4.tgz",
"integrity": "sha512-lhs/ywszaatqCPObJx/884nGT4i3XWPqF/GKAhIoTfMWk5hXWoOliaV1pCbfkT6BVQMgYaoyx+k8hl+TiBlsDw==",
"version": "2.0.0-beta.2",
"resolved": "https://registry.npmjs.org/fabric-ca-client/-/fabric-ca-client-2.0.0-beta.2.tgz",
"integrity": "sha512-bA7qA2m8PjZF3LV5Qx8i79zFpOwkFUVYD6WDLB0TP8PGnrv66Tr5gWOP0E/HI35Es9hPiBvl7F8h9v63omLvZw==",
"requires": {
"@types/bytebuffer": "^5.0.34",
"bn.js": "^4.11.3",
"elliptic": "^6.2.3",
"fabric-common": "^2.0.0-beta.2",
"fs-extra": "^6.0.1",
"grpc": "1.21.1",
"js-sha3": "^0.7.0",
"jsrsasign": "^7.2.2",
"jssha": "^2.1.0",
"long": "^4.0.0",
"nconf": "^0.10.0",
"sjcl": "1.0.7",
"url": "^0.11.0",
"util": "^0.10.3",
"winston": "^2.2.0"
"util": "^0.10.3"
}
},
"fabric-client": {
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/fabric-client/-/fabric-client-1.4.4.tgz",
"integrity": "sha512-QIC9dFCmQN5pWx23CoWq8cJTYwChXB7kEoZbpls5xPZaXtwNnvwBdbVWT+E0qwZQkhpLYe8y3N/A6jC5X3Cqtw==",
"version": "2.0.0-beta.2",
"resolved": "https://registry.npmjs.org/fabric-client/-/fabric-client-2.0.0-beta.2.tgz",
"integrity": "sha512-sif1iAMfzBk4cg3yrcxoZso6vXYh0NR3pPHU9rYTIlFtozyu4IMZrF54b6gqpEQk34IkBHja1a8dLxxkcmWSDQ==",
"requires": {
"@types/bytebuffer": "^5.0.34",
"bn.js": "^4.11.3",
"callsite": "^1.0.0",
"elliptic": "^6.2.3",
"fabric-ca-client": "^1.4.4",
"fabric-ca-client": "^2.0.0-beta.2",
"fabric-common": "^2.0.0-beta.2",
"fabric-protos": "^2.0.0-beta.2",
"fs-extra": "^6.0.1",
"grpc": "1.21.1",
"hoek": "^4.2.1",
"ignore-walk": "^3.0.0",
"js-sha3": "^0.7.0",
"js-yaml": "^3.9.0",
"js-yaml": "^3.13.0",
"jsrsasign": "^7.2.2",
"jssha": "^2.1.0",
"klaw": "^2.0.0",
"long": "^4.0.0",
"promise-settle": "^0.3.0",
"tar-stream": "1.6.1",
"url": "^0.11.0",
"yn": "^3.1.0"
}
},
"fabric-common": {
"version": "2.0.0-beta.2",
"resolved": "https://registry.npmjs.org/fabric-common/-/fabric-common-2.0.0-beta.2.tgz",
"integrity": "sha512-RYCB5wghlKJe/7n0XJXRbndHac99+RVrYCluXHWjmqNuz5TnPV8IVQrHY/2B0UV0iXFYs0ZlQ6/gCKg3anHokQ==",
"requires": {
"elliptic": "^6.2.3",
"js-sha3": "^0.7.0",
"nano": "^6.4.4",
"nconf": "^0.10.0",
"pkcs11js": "^1.0.6",
"promise-settle": "^0.3.0",
"protobufjs": "5.0.3",
"sjcl": "1.0.7",
"stream-buffers": "3.0.1",
"tar-stream": "1.6.1",
"url": "^0.11.0",
"winston": "^2.2.0"
"winston": "^2.2.0",
"yn": "^3.1.0"
}
},
"fabric-network": {
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/fabric-network/-/fabric-network-1.4.4.tgz",
"integrity": "sha512-RMe9sq1jEfOrvxvW+cjPr2E88VMrg32yJHVI/K7pfObokwy955pzI24mnZbwTomyS8Vci66XmZLC24XeSYX/Mw==",
"version": "2.0.0-beta.2",
"resolved": "https://registry.npmjs.org/fabric-network/-/fabric-network-2.0.0-beta.2.tgz",
"integrity": "sha512-SjH/35BaM84c8c5+G3p5khiky5/hDklBQD0MKbKiycYa7IMD0MGO5oatp6RLnvZhI9yowgvzBcdC7tIPmiM76Q==",
"requires": {
"fabric-ca-client": "^1.4.4",
"fabric-client": "^1.4.4",
"nano": "^6.4.4",
"rimraf": "^2.6.2",
"uuid": "^3.2.1"
"fabric-ca-client": "^2.0.0-beta.2",
"fabric-client": "^2.0.0-beta.2",
"fabric-common": "^2.0.0-beta.2",
"fs-extra": "^8.1.0",
"nano": "^8.1.0"
},
"dependencies": {
"fabric-client": {
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/fabric-client/-/fabric-client-1.4.4.tgz",
"integrity": "sha512-QIC9dFCmQN5pWx23CoWq8cJTYwChXB7kEoZbpls5xPZaXtwNnvwBdbVWT+E0qwZQkhpLYe8y3N/A6jC5X3Cqtw==",
"cloudant-follow": {
"version": "0.18.2",
"resolved": "https://registry.npmjs.org/cloudant-follow/-/cloudant-follow-0.18.2.tgz",
"integrity": "sha512-qu/AmKxDqJds+UmT77+0NbM7Yab2K3w0qSeJRzsq5dRWJTEJdWeb+XpG4OpKuTE9RKOa/Awn2gR3TTnvNr3TeA==",
"requires": {
"@types/bytebuffer": "^5.0.34",
"bn.js": "^4.11.3",
"callsite": "^1.0.0",
"elliptic": "^6.2.3",
"fabric-ca-client": "^1.4.4",
"fs-extra": "^6.0.1",
"grpc": "1.21.1",
"hoek": "^4.2.1",
"ignore-walk": "^3.0.0",
"js-sha3": "^0.7.0",
"js-yaml": "^3.9.0",
"jsrsasign": "^7.2.2",
"jssha": "^2.1.0",
"klaw": "^2.0.0",
"long": "^4.0.0",
"nano": "^6.4.4",
"nconf": "^0.10.0",
"pkcs11js": "^1.0.6",
"promise-settle": "^0.3.0",
"protobufjs": "5.0.3",
"sjcl": "1.0.7",
"stream-buffers": "3.0.1",
"tar-stream": "1.6.1",
"url": "^0.11.0",
"winston": "^2.2.0"
"browser-request": "~0.3.0",
"debug": "^4.0.1",
"request": "^2.88.0"
}
},
"debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"requires": {
"ms": "^2.1.1"
}
},
"fs-extra": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
"integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==",
"requires": {
"graceful-fs": "^4.2.0",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
},
"nano": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/nano/-/nano-8.1.0.tgz",
"integrity": "sha512-suMHW9XtTP8doR4FnId5+6ZfbAvDIZOAVp3qe7zTHXp7BvT/Cf4G9xBjXAthrIzoa+fkcionEr9xo8cZtvqMmg==",
"requires": {
"@types/request": "^2.47.1",
"cloudant-follow": "^0.18.1",
"debug": "^4.1.1",
"errs": "^0.3.2",
"request": "^2.88.0"
}
}
}
},
"fabric-protos": {
"version": "2.0.0-beta.2",
"resolved": "https://registry.npmjs.org/fabric-protos/-/fabric-protos-2.0.0-beta.2.tgz",
"integrity": "sha512-fxl4ECLKAutaVMnMp78lZhzR5WYADORPN70M5MmaC+/Psse0r94w7a0i/QDG/7kItQiINtlUneEvy1NujQ/lLQ==",
"requires": {
"grpc": "1.23.3",
"protobufjs": "^5.0.3"
}
},
"fast-deep-equal": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz",
@ -853,15 +900,16 @@
"dev": true
},
"graceful-fs": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.0.tgz",
"integrity": "sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg=="
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz",
"integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ=="
},
"grpc": {
"version": "1.21.1",
"resolved": "https://registry.npmjs.org/grpc/-/grpc-1.21.1.tgz",
"integrity": "sha512-PFsZQazf62nP05a0xm23mlImMuw5oVlqF/0zakmsdqJgvbABe+d6VThY2PfhqJmWEL/FhQ6QNYsxS5EAM6++7g==",
"version": "1.23.3",
"resolved": "https://registry.npmjs.org/grpc/-/grpc-1.23.3.tgz",
"integrity": "sha512-7vdzxPw9s5UYch4aUn4hyM5tMaouaxUUkwkgJlwbR4AXMxiYZJOv19N2ps2eKiuUbJovo5fnGF9hg/X91gWYjw==",
"requires": {
"@types/bytebuffer": "^5.0.40",
"lodash.camelcase": "^4.3.0",
"lodash.clone": "^4.5.0",
"nan": "^2.13.2",
@ -902,7 +950,7 @@
}
},
"chownr": {
"version": "1.1.1",
"version": "1.1.2",
"bundled": true
},
"code-point-at": {
@ -921,6 +969,13 @@
"version": "1.0.2",
"bundled": true
},
"debug": {
"version": "3.2.6",
"bundled": true,
"requires": {
"ms": "^2.1.1"
}
},
"deep-extend": {
"version": "0.6.0",
"bundled": true
@ -934,7 +989,7 @@
"bundled": true
},
"fs-minipass": {
"version": "1.2.5",
"version": "1.2.6",
"bundled": true,
"requires": {
"minipass": "^2.2.1"
@ -958,12 +1013,24 @@
"wide-align": "^1.1.0"
}
},
"glob": {
"version": "7.1.4",
"bundled": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"has-unicode": {
"version": "2.0.1",
"bundled": true
},
"iconv-lite": {
"version": "0.4.23",
"version": "0.4.24",
"bundled": true,
"requires": {
"safer-buffer": ">= 2.1.2 < 3"
@ -985,7 +1052,7 @@
}
},
"inherits": {
"version": "2.0.3",
"version": "2.0.4",
"bundled": true
},
"ini": {
@ -1042,26 +1109,17 @@
}
}
},
"ms": {
"version": "2.1.2",
"bundled": true
},
"needle": {
"version": "2.3.1",
"version": "2.4.0",
"bundled": true,
"requires": {
"debug": "^4.1.0",
"debug": "^3.2.6",
"iconv-lite": "^0.4.4",
"sax": "^1.2.4"
},
"dependencies": {
"debug": {
"version": "4.1.1",
"bundled": true,
"requires": {
"ms": "^2.1.1"
}
},
"ms": {
"version": "2.1.1",
"bundled": true
}
}
},
"node-pre-gyp": {
@ -1093,7 +1151,7 @@
"bundled": true
},
"npm-packlist": {
"version": "1.4.1",
"version": "1.4.4",
"bundled": true,
"requires": {
"ignore-walk": "^3.0.1",
@ -1146,7 +1204,7 @@
"bundled": true
},
"process-nextick-args": {
"version": "2.0.0",
"version": "2.0.1",
"bundled": true
},
"rc": {
@ -1173,24 +1231,10 @@
}
},
"rimraf": {
"version": "2.6.3",
"version": "2.7.1",
"bundled": true,
"requires": {
"glob": "^7.1.3"
},
"dependencies": {
"glob": {
"version": "7.1.4",
"bundled": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
}
}
},
"safe-buffer": {
@ -1206,7 +1250,7 @@
"bundled": true
},
"semver": {
"version": "5.7.0",
"version": "5.7.1",
"bundled": true
},
"set-blocking": {
@ -1245,16 +1289,16 @@
"bundled": true
},
"tar": {
"version": "4.4.8",
"version": "4.4.10",
"bundled": true,
"requires": {
"chownr": "^1.1.1",
"fs-minipass": "^1.2.5",
"minipass": "^2.3.4",
"minizlib": "^1.1.1",
"minipass": "^2.3.5",
"minizlib": "^1.2.1",
"mkdirp": "^0.5.0",
"safe-buffer": "^5.1.2",
"yallist": "^3.0.2"
"yallist": "^3.0.3"
}
},
"util-deprecate": {
@ -1317,11 +1361,6 @@
"minimalistic-crypto-utils": "^1.0.1"
}
},
"hoek": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz",
"integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA=="
},
"http-signature": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
@ -1348,9 +1387,9 @@
"dev": true
},
"ignore-walk": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.1.tgz",
"integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==",
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.3.tgz",
"integrity": "sha512-m7o6xuOaT1aqheYHKf8W6J5pYH85ZI9w077erOzLje3JsB1gkafkAhHHY19dqjulgIZHFm32Cp5uNZgcQqdJKw==",
"requires": {
"minimatch": "^3.0.4"
}
@ -1573,11 +1612,6 @@
"resolved": "https://registry.npmjs.org/jsrsasign/-/jsrsasign-7.2.2.tgz",
"integrity": "sha1-rlIwy1V0RRu5eanMaXQoxg9ZjSA="
},
"jssha": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/jssha/-/jssha-2.3.1.tgz",
"integrity": "sha1-FHshJTaQNcpLL30hDcU58Amz3po="
},
"klaw": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/klaw/-/klaw-2.1.1.tgz",
@ -1631,16 +1665,16 @@
"integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA=="
},
"mime-db": {
"version": "1.40.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz",
"integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA=="
"version": "1.43.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz",
"integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ=="
},
"mime-types": {
"version": "2.1.24",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz",
"integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==",
"version": "2.1.26",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz",
"integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==",
"requires": {
"mime-db": "1.40.0"
"mime-db": "1.43.0"
}
},
"mimic-fn": {
@ -1825,9 +1859,10 @@
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
},
"pkcs11js": {
"version": "1.0.18",
"resolved": "https://registry.npmjs.org/pkcs11js/-/pkcs11js-1.0.18.tgz",
"integrity": "sha512-1MYcEAPhy+T1NbiBUw0WwllKXC0sxDCRQGLsks7AtFsaf88F/f+ukdSmCqV3Xyc0RNLIdTX/soy0zyNHOWQezw==",
"version": "1.0.19",
"resolved": "https://registry.npmjs.org/pkcs11js/-/pkcs11js-1.0.19.tgz",
"integrity": "sha512-BThNeWreqDXbMAZOTtG8PodY4WAS0HNHsXtsVbDBX4L4C58AvxIIXjjZrsBadXUagbjTllmZwsZHkebVUTpwcA==",
"optional": true,
"requires": {
"nan": "^2.14.0"
}
@ -1866,14 +1901,14 @@
}
},
"psl": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.2.0.tgz",
"integrity": "sha512-GEn74ZffufCmkDDLNcl3uuyF/aSD6exEyh1v/ZSdAomB82t6G9hzJVRx0jBmLDW+VfZqks3aScmMw9DszwUalA=="
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.7.0.tgz",
"integrity": "sha512-5NsSEDv8zY70ScRnOTn7bK7eanl2MvFrOrS/R6x+dBt5g1ghnj9Zv90kO8GwT8gxcu2ANyFprnFYB85IogIJOQ=="
},
"punycode": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz",
"integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0="
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
},
"qs": {
"version": "6.5.2",
@ -1886,9 +1921,9 @@
"integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA="
},
"readable-stream": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"version": "2.3.7",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
"integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
@ -1959,6 +1994,7 @@
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz",
"integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==",
"dev": true,
"requires": {
"glob": "^7.1.3"
}
@ -2073,11 +2109,6 @@
"resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
"integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA="
},
"stream-buffers": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/stream-buffers/-/stream-buffers-3.0.1.tgz",
"integrity": "sha1-aKOMX6re3tef95mI02jj+xMl7wY="
},
"string-width": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
@ -2219,13 +2250,6 @@
"requires": {
"psl": "^1.1.24",
"punycode": "^1.4.1"
},
"dependencies": {
"punycode": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
}
}
},
"tslib": {
@ -2283,6 +2307,13 @@
"requires": {
"punycode": "1.3.2",
"querystring": "0.2.0"
},
"dependencies": {
"punycode": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz",
"integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0="
}
}
},
"util": {
@ -2306,9 +2337,9 @@
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"uuid": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz",
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz",
"integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ=="
},
"verror": {
"version": "1.10.0",
@ -2406,6 +2437,11 @@
"window-size": "^0.1.4",
"y18n": "^3.2.0"
}
},
"yn": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz",
"integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q=="
}
}
}

View file

@ -17,15 +17,17 @@ SPDX-License-Identifier: Apache-2.0
// Bring key classes into scope, most importantly Fabric SDK network class
const fs = require('fs');
const yaml = require('js-yaml');
const { FileSystemWallet, Gateway } = require('fabric-network');
const { Wallets, Gateway } = require('fabric-network');
const CommercialPaper = require('../contract/lib/paper.js');
// A wallet stores a collection of identities for use
const wallet = new FileSystemWallet('../identity/user/balaji/wallet');
// Main program function
async function main() {
// A wallet stores a collection of identities for use
const wallet = await Wallets.newFileSystemWallet('../identity/user/balaji/wallet');
// A gateway defines the peers used to access Fabric networks
const gateway = new Gateway();

View file

@ -32,7 +32,4 @@ services:
- ./../../../../../basic-network/crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
networks:
- basic
#depends_on:
# - orderer.example.com
# - peer0.org1.example.com
# - couchdb

View file

@ -35,4 +35,4 @@ test {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-parameters"
}
}

View file

@ -0,0 +1,50 @@
/*
* SPDX-License-Identifier: Apache-2.0
*/
plugins {
id 'com.github.johnrengelman.shadow' version '5.1.0'
id 'java'
}
version '0.0.1'
sourceCompatibility = 1.8
repositories {
mavenLocal()
mavenCentral()
maven {
url 'https://jitpack.io'
}
}
dependencies {
implementation group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '2.0.0-beta.1'
implementation group: 'org.json', name: 'json', version: '20180813'
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2'
testImplementation 'org.assertj:assertj-core:3.11.1'
testImplementation 'org.mockito:mockito-core:2.+'
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}
shadowJar {
baseName = 'chaincode'
version = null
classifier = null
manifest {
attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter'
}
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-parameters"
}

View file

@ -1,5 +1,5 @@
/*
* SPDX-License-Identifier:
* SPDX-License-Identifier: Apache-2.0
*/
package org.example;

View file

@ -53,7 +53,7 @@ public class State {
}
public static String[] splitKey(String key) {
System.out.println("Splittin gkey " + key + " " + java.util.Arrays.asList(key.split(":")));
System.out.println("splitting key " + key + " " + java.util.Arrays.asList(key.split(":")));
return key.split(":");
}

View file

@ -1,25 +0,0 @@
package org.hyperledger.fabric;
import org.hyperledger.fabric.contract.ContractRouter;
import org.hyperledger.fabric.contract.metadata.MetadataBuilder;
public class DevRouter extends ContractRouter {
public DevRouter(String[] args) {
super(args);
System.out.println("+++DevRouter Starting...... +++");
}
public static DevRouter getDevRouter() {
String args[] = new String[] { "--id", "unittestchaincode" };
DevRouter dr = new DevRouter(args);
dr.findAllContracts();
MetadataBuilder.initialize(dr.getRoutingRegistry(), dr.getTypeRegistry());
// to output the metadata created
String metadata = MetadataBuilder.debugString();
System.out.println(metadata);
return dr;
}
}

View file

@ -1,57 +0,0 @@
/*
* SPDX-License-Identifier: Apache License 2.0
*/
package org.hyperledger.fabric.example;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.hyperledger.fabric.DevRouter;
import org.hyperledger.fabric.shim.ChaincodeStub;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
@TestInstance(Lifecycle.PER_CLASS)
public final class CommercialPaperContractTest {
DevRouter devRouter;
@BeforeAll
public void scanContracts() {
this.devRouter = DevRouter.getDevRouter();
}
ChaincodeStub newStub(String[] args) {
ChaincodeStub stub = mock(ChaincodeStub.class);
List<String> allargs = new ArrayList<String>();
Collections.addAll(allargs, args);
when(stub.getArgs()).thenReturn(allargs.stream().map(String::getBytes).collect(Collectors.toList()));
when(stub.getStringArgs()).thenReturn(allargs);
return stub;
}
@Nested
class IssuePaper {
// @Test
// public void regularIssue() {
// Response resp;
// ChaincodeStub stub = newStub(new String[] { "issue", "issuerName", "paper001", "today", "year", "420" });
// //
//
// resp = devRouter.invoke(stub);
// assertThat(resp.getStatus()).isEqualTo(Status.SUCCESS);
// assertThat(resp.getStringPayload()).isEqualTo("false");
// }
}
}

View file

@ -53,7 +53,7 @@ public class State {
}
public static String[] splitKey(String key) {
System.out.println("Splittin gkey " + key + " " + java.util.Arrays.asList(key.split(":")));
System.out.println("splitting key " + key + " " + java.util.Arrays.asList(key.split(":")));
return key.split(":");
}

View file

@ -6,29 +6,37 @@
// Bring key classes into scope, most importantly Fabric SDK network class
const fs = require('fs');
const { FileSystemWallet, X509WalletMixin } = require('fabric-network');
const { Wallets } = require('fabric-network');
const path = require('path');
const fixtures = path.resolve(__dirname, '../../../../basic-network');
// A wallet stores a collection of identities
const wallet = new FileSystemWallet('../identity/user/isabella/wallet');
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, '/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com');
const cert = fs.readFileSync(path.join(credPath, '/msp/signcerts/User1@org1.example.com-cert.pem')).toString();
const key = fs.readFileSync(path.join(credPath, '/msp/keystore/c75bd6911aca808941c3557ee7c97e90f3952e379497dc55eb903f31b50abc83_sk')).toString();
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/740efb1655d71c3984062726b31361c151463b13979271b86e41d5a3dc3594de_sk')).toString();
// Load credentials into wallet
const identityLabel = 'User1@org1.example.com';
const identity = X509WalletMixin.createIdentity('Org1MSP', cert, key);
await wallet.import(identityLabel, identity);
const identity = {
credentials: {
certificate,
privateKey
},
mspId: 'Org1MSP',
type: 'X.509'
}
await wallet.put(identityLabel,identity);
} catch (error) {
console.log(`Error adding to wallet. ${error}`);

View file

@ -17,16 +17,16 @@ SPDX-License-Identifier: Apache-2.0
// Bring key classes into scope, most importantly Fabric SDK network class
const fs = require('fs');
const yaml = require('js-yaml');
const { FileSystemWallet, Gateway } = require('fabric-network');
const { Wallets, Gateway } = require('fabric-network');
const CommercialPaper = require('../contract/lib/paper.js');
// A wallet stores a collection of identities for use
//const wallet = new FileSystemWallet('../user/isabella/wallet');
const wallet = new FileSystemWallet('../identity/user/isabella/wallet');
// Main program function
async function main() {
// A wallet stores a collection of identities for use
//const wallet = new FileSystemWallet('../user/isabella/wallet');
const wallet = await Wallets.newFileSystemWallet('../identity/user/isabella/wallet');
// A gateway defines the peers used to access Fabric networks
const gateway = new Gateway();

View file

@ -44,14 +44,14 @@
"integrity": "sha512-1w52Nyx4Gq47uuu0EVcsHBxZFJgurQ+rTKS3qMHxR1GY2T8c2AJYd6vZoZ9q1rupaDjU0yT+Jc2XTyXkjeMA+Q=="
},
"@types/node": {
"version": "12.12.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.7.tgz",
"integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w=="
"version": "13.1.4",
"resolved": "https://registry.npmjs.org/@types/node/-/node-13.1.4.tgz",
"integrity": "sha512-Lue/mlp2egZJoHXZr4LndxDAd7i/7SQYhV0EjWfb/a4/OZ6tuVwMCVPiwkU5nsEipxEf7hmkSU7Em5VQ8P5NGA=="
},
"@types/request": {
"version": "2.48.3",
"resolved": "https://registry.npmjs.org/@types/request/-/request-2.48.3.tgz",
"integrity": "sha512-3Wo2jNYwqgXcIz/rrq18AdOZUQB8cQ34CXZo+LUwPJNpvRAL86+Kc2wwI8mqpz9Cr1V+enIox5v+WZhy/p3h8w==",
"version": "2.48.4",
"resolved": "https://registry.npmjs.org/@types/request/-/request-2.48.4.tgz",
"integrity": "sha512-W1t1MTKYR8PxICH+A4HgEIPuAC3sbljoEVfyZbeFJJDbr30guDspJri2XOaM2E+Un7ZjrihaDi7cf6fPa2tbgw==",
"requires": {
"@types/caseless": "*",
"@types/node": "*",
@ -72,20 +72,20 @@
}
},
"@types/tough-cookie": {
"version": "2.3.5",
"resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-2.3.5.tgz",
"integrity": "sha512-SCcK7mvGi3+ZNz833RRjFIxrn4gI1PPR3NtuIS+6vMkvmsGjosqTJwRt5bAEFLRz+wtJMWv8+uOnZf2hi2QXTg=="
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-2.3.6.tgz",
"integrity": "sha512-wHNBMnkoEBiRAd3s8KTKwIuO9biFtTf0LehITzBhSco+HQI0xkXZbLOD55SW3Aqw3oUkHstkm5SPv58yaAdFPQ=="
},
"acorn": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.2.1.tgz",
"integrity": "sha512-JD0xT5FCRDNyjDda3Lrg/IxFscp9q4tiYtxE1/nOzlKCk7hIRuYjhq1kCNkbPjMRMZuFq20HNQn1I9k8Oj0E+Q==",
"version": "6.4.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.0.tgz",
"integrity": "sha512-gac8OEcQ2Li1dxIEWGZzsp2BitJxwkwcOm0zHAJLcPJaVvm58FRnk6RkuLRpU1EujipU2ZFODv2P9DLMfnV8mw==",
"dev": true
},
"acorn-jsx": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.1.tgz",
"integrity": "sha512-HJ7CfNHrfJLlNTzIEUTj43LNWGkqpRLxm3YjAlcD0ACydk9XynzYsCBHxut+iqt+1aBXkx9UP/w/ZqMr13XIzg==",
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.1.0.tgz",
"integrity": "sha512-tMUqwBWfLFbJbizRmEcWSLw6HnFzfdJs2sOJEOwwtVPMoH/0Ay+E703oZz78VSXZiiDcZrQ5XKjPIUQixhmgVw==",
"dev": true
},
"ajv": {
@ -171,9 +171,9 @@
"integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg="
},
"aws4": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz",
"integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ=="
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.0.tgz",
"integrity": "sha512-Uvq6hVe90D0B2WEnUqtdgY1bATGz3mw33nH9Y+dmA+w5DHvUmBgkr5rM/KCHpCsiFNRUfokW/szpPPgMK2hm4A=="
},
"balanced-match": {
"version": "1.0.0",
@ -462,9 +462,9 @@
}
},
"elliptic": {
"version": "6.5.1",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.1.tgz",
"integrity": "sha512-xvJINNLbTeWQjrl6X+7eQCrIy/YPv5XCpKW6kB5mKvtnGILoLDcySuwomfdzt0BMdLNVnuRNTuzKNHj0bva1Cg==",
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.2.tgz",
"integrity": "sha512-f4x70okzZbIQl/NSRLkI/+tteV/9WqL98zx+SQ69KbXxmVrmjwsNUPn/gYJJ0sHvEak24cZgHIPegRePAtA/xw==",
"requires": {
"bn.js": "^4.4.0",
"brorand": "^1.0.1",
@ -587,20 +587,12 @@
"dev": true,
"requires": {
"eslint-visitor-keys": "^1.1.0"
},
"dependencies": {
"eslint-visitor-keys": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz",
"integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==",
"dev": true
}
}
},
"eslint-visitor-keys": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz",
"integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==",
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz",
"integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==",
"dev": true
},
"espree": {
@ -638,15 +630,15 @@
}
},
"estraverse": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz",
"integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=",
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz",
"integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==",
"dev": true
},
"esutils": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz",
"integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=",
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
"dev": true
},
"extend": {
@ -676,12 +668,12 @@
"integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A="
},
"fabric-ca-client": {
"version": "2.0.0-snapshot.306",
"resolved": "https://registry.npmjs.org/fabric-ca-client/-/fabric-ca-client-2.0.0-snapshot.306.tgz",
"integrity": "sha512-L9TwHxv1iipA9euVQUPcE9chOc1q3aB60lOq8mjo7xPVLNBexOAXkQSqLJhtz08NOP2Mpas5Bl4x+bV2CtA7yg==",
"version": "2.0.0-beta.2",
"resolved": "https://registry.npmjs.org/fabric-ca-client/-/fabric-ca-client-2.0.0-beta.2.tgz",
"integrity": "sha512-bA7qA2m8PjZF3LV5Qx8i79zFpOwkFUVYD6WDLB0TP8PGnrv66Tr5gWOP0E/HI35Es9hPiBvl7F8h9v63omLvZw==",
"requires": {
"@types/bytebuffer": "^5.0.34",
"fabric-common": "^2.0.0-snapshot.299",
"fabric-common": "^2.0.0-beta.2",
"fs-extra": "^6.0.1",
"jsrsasign": "^7.2.2",
"url": "^0.11.0",
@ -689,15 +681,15 @@
}
},
"fabric-client": {
"version": "2.0.0-snapshot.303",
"resolved": "https://registry.npmjs.org/fabric-client/-/fabric-client-2.0.0-snapshot.303.tgz",
"integrity": "sha512-GYreJEbEyMfUAc+eLt0BmsvspjQ6eRm0atQBd4M1lqUsgCY6SVbKnBBbuYBf6SFnldmxec1iycEum9D9hy9Alw==",
"version": "2.0.0-beta.2",
"resolved": "https://registry.npmjs.org/fabric-client/-/fabric-client-2.0.0-beta.2.tgz",
"integrity": "sha512-sif1iAMfzBk4cg3yrcxoZso6vXYh0NR3pPHU9rYTIlFtozyu4IMZrF54b6gqpEQk34IkBHja1a8dLxxkcmWSDQ==",
"requires": {
"@types/bytebuffer": "^5.0.34",
"callsite": "^1.0.0",
"fabric-ca-client": "^2.0.0-snapshot.306",
"fabric-common": "^2.0.0-snapshot.299",
"fabric-protos": "^2.0.0-snapshot.157",
"fabric-ca-client": "^2.0.0-beta.2",
"fabric-common": "^2.0.0-beta.2",
"fabric-protos": "^2.0.0-beta.2",
"fs-extra": "^6.0.1",
"ignore-walk": "^3.0.0",
"js-yaml": "^3.13.0",
@ -705,16 +697,15 @@
"klaw": "^2.0.0",
"long": "^4.0.0",
"promise-settle": "^0.3.0",
"stream-buffers": "3.0.1",
"tar-stream": "1.6.1",
"url": "^0.11.0",
"yn": "^3.1.0"
}
},
"fabric-common": {
"version": "2.0.0-snapshot.299",
"resolved": "https://registry.npmjs.org/fabric-common/-/fabric-common-2.0.0-snapshot.299.tgz",
"integrity": "sha512-pPoELhdeJ4J5xDajo2J0Mn/Y3fLdfbbNhEaSuM0gUHsGes46iBaZ/vgJbuE8nmDZQfLmVItEtHg022/6P8JHHw==",
"version": "2.0.0-beta.2",
"resolved": "https://registry.npmjs.org/fabric-common/-/fabric-common-2.0.0-beta.2.tgz",
"integrity": "sha512-RYCB5wghlKJe/7n0XJXRbndHac99+RVrYCluXHWjmqNuz5TnPV8IVQrHY/2B0UV0iXFYs0ZlQ6/gCKg3anHokQ==",
"requires": {
"elliptic": "^6.2.3",
"js-sha3": "^0.7.0",
@ -727,13 +718,13 @@
}
},
"fabric-network": {
"version": "2.0.0-snapshot.263",
"resolved": "https://registry.npmjs.org/fabric-network/-/fabric-network-2.0.0-snapshot.263.tgz",
"integrity": "sha512-S6HQMs7gPxXyLvSfQ23NLIb0zW+hD3Ne7oitEAVYYDuDwi9C4KQtWSbMcCnecI1dyOKwpNT5nFWBbzLEUQOP5g==",
"version": "2.0.0-beta.2",
"resolved": "https://registry.npmjs.org/fabric-network/-/fabric-network-2.0.0-beta.2.tgz",
"integrity": "sha512-SjH/35BaM84c8c5+G3p5khiky5/hDklBQD0MKbKiycYa7IMD0MGO5oatp6RLnvZhI9yowgvzBcdC7tIPmiM76Q==",
"requires": {
"fabric-ca-client": "^2.0.0-snapshot.306",
"fabric-client": "^2.0.0-snapshot.303",
"fabric-common": "^2.0.0-snapshot.299",
"fabric-ca-client": "^2.0.0-beta.2",
"fabric-client": "^2.0.0-beta.2",
"fabric-common": "^2.0.0-beta.2",
"fs-extra": "^8.1.0",
"nano": "^8.1.0"
},
@ -781,9 +772,9 @@
}
},
"fabric-protos": {
"version": "2.0.0-snapshot.157",
"resolved": "https://registry.npmjs.org/fabric-protos/-/fabric-protos-2.0.0-snapshot.157.tgz",
"integrity": "sha512-P3QP3lzvEUN/0QUPRZig+IGTAQkYJFPlwIVp5WleCbeqqxBMMDKddZHN8l4jp+wiQ/uG+pD/oOvh1rPPE3N8sA==",
"version": "2.0.0-beta.2",
"resolved": "https://registry.npmjs.org/fabric-protos/-/fabric-protos-2.0.0-beta.2.tgz",
"integrity": "sha512-fxl4ECLKAutaVMnMp78lZhzR5WYADORPN70M5MmaC+/Psse0r94w7a0i/QDG/7kItQiINtlUneEvy1NujQ/lLQ==",
"requires": {
"grpc": "1.23.3",
"protobufjs": "^5.0.3"
@ -795,9 +786,9 @@
"integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk="
},
"fast-json-stable-stringify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",
"integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I="
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
"integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw=="
},
"fast-levenshtein": {
"version": "2.0.6",
@ -890,9 +881,9 @@
}
},
"glob": {
"version": "7.1.4",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz",
"integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==",
"version": "7.1.6",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
@ -1404,9 +1395,9 @@
}
},
"import-fresh": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.1.0.tgz",
"integrity": "sha512-PpuksHKGt8rXfWEr9m9EHIpgyyaltBy8+eF6GJM0QCAxMgxCfucMF3mjecK2QsJr0amJW7gTqh5/wht0z2UhEQ==",
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz",
"integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==",
"dev": true,
"requires": {
"parent-module": "^1.0.0",
@ -1439,9 +1430,9 @@
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw=="
},
"inquirer": {
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.5.0.tgz",
"integrity": "sha512-scfHejeG/lVZSpvCXpsB4j/wQNPM5JC8kiElOI0OUTwmc1RTpXr4H32/HOlQHcZiYl2z2VElwuCVDRG8vFmbnA==",
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.5.2.tgz",
"integrity": "sha512-cntlB5ghuB0iuO65Ovoi8ogLHiWGs/5yNrtUcKjFhSSiVeAIVpD7koaSU9RM8mpXw5YDi9RdYXGQMaOURB7ycQ==",
"dev": true,
"requires": {
"ansi-escapes": "^3.2.0",
@ -1674,16 +1665,16 @@
"integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA=="
},
"mime-db": {
"version": "1.42.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.42.0.tgz",
"integrity": "sha512-UbfJCR4UAVRNgMpfImz05smAXK7+c+ZntjaA26ANtkXLlOe947Aag5zdIcKQULAiF9Cq4WxBi9jUs5zkA84bYQ=="
"version": "1.43.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz",
"integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ=="
},
"mime-types": {
"version": "2.1.25",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.25.tgz",
"integrity": "sha512-5KhStqB5xpTAeGqKBAMgwaYMnQik7teQN4IAzC7npDv6kzeU6prfkR67bc87J1kWMPGkoaZSq1npmexMgkmEVg==",
"version": "2.1.26",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz",
"integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==",
"requires": {
"mime-db": "1.42.0"
"mime-db": "1.43.0"
}
},
"mimic-fn": {
@ -1804,17 +1795,17 @@
}
},
"optionator": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz",
"integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=",
"version": "0.8.3",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz",
"integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==",
"dev": true,
"requires": {
"deep-is": "~0.1.3",
"fast-levenshtein": "~2.0.4",
"fast-levenshtein": "~2.0.6",
"levn": "~0.3.0",
"prelude-ls": "~1.1.2",
"type-check": "~0.3.2",
"wordwrap": "~1.0.0"
"word-wrap": "~1.2.3"
}
},
"optjs": {
@ -1910,14 +1901,14 @@
}
},
"psl": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.4.0.tgz",
"integrity": "sha512-HZzqCGPecFLyoRj5HLfuDSKYTJkAfB5thKBIkRHtGjWwY7p1dAyveIbXIq4tO0KYfDF2tHqPUgY9SDnGm00uFw=="
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.7.0.tgz",
"integrity": "sha512-5NsSEDv8zY70ScRnOTn7bK7eanl2MvFrOrS/R6x+dBt5g1ghnj9Zv90kO8GwT8gxcu2ANyFprnFYB85IogIJOQ=="
},
"punycode": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
},
"qs": {
"version": "6.5.2",
@ -1930,9 +1921,9 @@
"integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA="
},
"readable-stream": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"version": "2.3.7",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
"integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
@ -2018,9 +2009,9 @@
}
},
"rxjs": {
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.2.tgz",
"integrity": "sha512-HUb7j3kvb7p7eCUHE3FqjoDsC1xfZQ4AHFWfTKSpZ+sAhhz5X1WX0ZuUqWbzB2QhSLp3DoLUG+hMdEDKqWo2Zg==",
"version": "6.5.4",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.4.tgz",
"integrity": "sha512-naMQXcgEo3csAEGvw/NydRA0fuS2nDZJiw1YUWFKU7aPPAPGZEsD4Iimit96qwCieH6y614MCLYwdkrWx7z/7Q==",
"dev": true,
"requires": {
"tslib": "^1.9.0"
@ -2042,9 +2033,9 @@
"integrity": "sha1-8MgtmKOxOah3aogIBQuCRDEIf8o="
},
"semver": {
"version": "5.7.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz",
"integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==",
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
"dev": true
},
"shebang-command": {
@ -2118,11 +2109,6 @@
"resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
"integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA="
},
"stream-buffers": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/stream-buffers/-/stream-buffers-3.0.1.tgz",
"integrity": "sha1-aKOMX6re3tef95mI02jj+xMl7wY="
},
"string-width": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
@ -2172,9 +2158,9 @@
}
},
"table": {
"version": "5.4.4",
"resolved": "https://registry.npmjs.org/table/-/table-5.4.4.tgz",
"integrity": "sha512-IIfEAUx5QlODLblLrGTTLJA7Tk0iLSGBvgY8essPRVNGHAzThujww1YqHLs6h3HfTg55h++RzLHH5Xw/rfv+mg==",
"version": "5.4.6",
"resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz",
"integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==",
"dev": true,
"requires": {
"ajv": "^6.10.2",
@ -2264,6 +2250,13 @@
"requires": {
"psl": "^1.1.24",
"punycode": "^1.4.1"
},
"dependencies": {
"punycode": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
}
}
},
"tslib": {
@ -2305,13 +2298,6 @@
"integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==",
"requires": {
"punycode": "^2.1.0"
},
"dependencies": {
"punycode": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
}
}
},
"url": {
@ -2399,10 +2385,10 @@
}
}
},
"wordwrap": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
"integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=",
"word-wrap": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
"integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==",
"dev": true
},
"wrap-ansi": {

View file

@ -1,10 +0,0 @@
#
# SPDX-License-Identifier: Apache-2.0
#
/.classpath
/.gradle/
/.project
/.settings/
/bin/
/build/

View file

@ -1,7 +1,12 @@
/*
* SPDX-License-Identifier: Apache-2.0
*/
plugins {
id 'java-library-distribution'
id 'com.github.johnrengelman.shadow' version '5.1.0'
id 'java'
}
version '0.0.1'
sourceCompatibility = 1.8
@ -12,15 +17,11 @@ repositories {
maven {
url 'https://jitpack.io'
}
maven {
url "https://nexus.hyperledger.org/content/repositories/snapshots/"
}
}
dependencies {
compileOnly group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.2'
compile group: 'org.json', name: 'json', version: '20180813'
implementation group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '2.0.0-beta.1'
implementation group: 'org.json', name: 'json', version: '20180813'
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2'
testImplementation 'org.assertj:assertj-core:3.11.1'
testImplementation 'org.mockito:mockito-core:2.+'
@ -33,6 +34,17 @@ test {
}
}
shadowJar {
baseName = 'chaincode'
version = null
classifier = null
manifest {
attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter'
}
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-parameters"
}

View file

@ -1,6 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*/
package org.example;
import static java.nio.charset.StandardCharsets.UTF_8;
@ -20,7 +21,7 @@ public class CommercialPaper extends State {
public final static String REDEEMED = "REDEEMED";
@Property()
private String state ="";
private String state="";
public String getState() {
return state;
@ -153,7 +154,6 @@ public class CommercialPaper extends State {
* @param {Buffer} data to form back into the object
*/
public static CommercialPaper deserialize(byte[] data) {
System.out.println("Byte data is "+ new String(data, UTF_8));
JSONObject json = new JSONObject(new String(data, UTF_8));
String issuer = json.getString("issuer");
@ -162,7 +162,7 @@ public class CommercialPaper extends State {
String maturityDateTime = json.getString("maturityDateTime");
String owner = json.getString("owner");
int faceValue = json.getInt("faceValue");
String state = json.getString("state");
String state = json.getString("state");
return createInstance(issuer, paperNumber, issueDateTime, maturityDateTime, faceValue,owner,state);
}
@ -179,4 +179,5 @@ public class CommercialPaper extends State {
.setFaceValue(faceValue).setKey().setIssueDateTime(issueDateTime).setOwner(owner).setState(state);
}
}

View file

@ -1,6 +1,3 @@
/*
* SPDX-License-Identifier: Apache-2.0
*/
package org.example;
import org.hyperledger.fabric.contract.Context;

View file

@ -3,7 +3,6 @@ SPDX-License-Identifier: Apache-2.0
*/
package org.example;
import java.util.logging.Logger;
import org.example.ledgerapi.State;
@ -25,7 +24,7 @@ import org.hyperledger.fabric.shim.ChaincodeStub;
* Define commercial paper smart contract by extending Fabric Contract class
*
*/
@Contract(name = "org.papernet.commercialpaper", info = @Info(title = "MyAsset contract", description = "", version = "0.0.1", license = @License(name = "SPDX-License-Identifier: ", url = ""), contact = @Contact(email = "java-contract@example.com", name = "java-contract", url = "http://java-contract.me")))
@Contract(name = "org.papernet.commercialpaper", info = @Info(title = "MyAsset contract", description = "", version = "0.0.1", license = @License(name = "SPDX-License-Identifier: Apache-2.0", url = ""), contact = @Contact(email = "java-contract@example.com", name = "java-contract", url = "http://java-contract.me")))
@Default
public class CommercialPaperContract implements ContractInterface {

View file

@ -40,7 +40,6 @@ public class State {
*/
public static byte[] serialize(Object object) {
String jsonStr = new JSONObject(object).toString();
System.out.println(jsonStr);
return jsonStr.getBytes(UTF_8);
}
@ -54,7 +53,7 @@ public class State {
}
public static String[] splitKey(String key) {
System.out.println("Splitting key " + key + " " + java.util.Arrays.asList(key.split(":")));
System.out.println("splitting key " + key + " " + java.util.Arrays.asList(key.split(":")));
return key.split(":");
}

View file

@ -1,7 +1,3 @@
/*
SPDX-License-Identifier: Apache-2.0
*/
package org.example.ledgerapi;
@FunctionalInterface

View file

@ -1,7 +1,3 @@
/*
SPDX-License-Identifier: Apache-2.0
*/
package org.example.ledgerapi;
import org.example.ledgerapi.impl.StateListImpl;

View file

@ -1,7 +1,3 @@
/*
SPDX-License-Identifier: Apache-2.0
*/
package org.example.ledgerapi.impl;
import java.util.Arrays;
@ -13,6 +9,10 @@ import org.hyperledger.fabric.contract.Context;
import org.hyperledger.fabric.shim.ChaincodeStub;
import org.hyperledger.fabric.shim.ledger.CompositeKey;
/*
SPDX-License-Identifier: Apache-2.0
*/
/**
* StateList provides a named virtual container for a set of ledger states. Each
* state has a unique key which associates it with the container, rather than
@ -74,8 +74,6 @@ public class StateListImpl implements StateList {
CompositeKey ledgerKey = this.ctx.getStub().createCompositeKey(this.name, State.splitKey(key));
byte[] data = this.ctx.getStub().getState(ledgerKey.toString());
System.out.println("Data is "+data);
System.out.println("LedgerKey "+ledgerKey.toString());
if (data != null) {
State state = this.deserializer.deserialize(data);
return state;

View file

@ -1,25 +0,0 @@
package org.hyperledger.fabric;
import org.hyperledger.fabric.contract.ContractRouter;
import org.hyperledger.fabric.contract.metadata.MetadataBuilder;
public class DevRouter extends ContractRouter {
public DevRouter(String[] args) {
super(args);
System.out.println("+++DevRouter Starting...... +++");
}
public static DevRouter getDevRouter() {
String args[] = new String[] { "--id", "unittestchaincode" };
DevRouter dr = new DevRouter(args);
dr.findAllContracts();
MetadataBuilder.initialize(dr.getRoutingRegistry(), dr.getTypeRegistry());
// to output the metadata created
String metadata = MetadataBuilder.debugString();
System.out.println(metadata);
return dr;
}
}

View file

@ -1,42 +0,0 @@
/*
SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.fabric.example;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.hyperledger.fabric.DevRouter;
import org.hyperledger.fabric.shim.ChaincodeStub;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
@TestInstance(Lifecycle.PER_CLASS)
public final class CommercialPaperContractTest {
DevRouter devRouter;
@BeforeAll
public void scanContracts() {
this.devRouter = DevRouter.getDevRouter();
}
ChaincodeStub newStub(String[] args) {
ChaincodeStub stub = mock(ChaincodeStub.class);
List<String> allargs = new ArrayList<String>();
Collections.addAll(allargs, args);
when(stub.getArgs()).thenReturn(allargs.stream().map(String::getBytes).collect(Collectors.toList()));
when(stub.getStringArgs()).thenReturn(allargs);
return stub;
}
}