diff --git a/chaincode-docker-devmode/.gitignore b/chaincode-docker-devmode/.gitignore index 699c14a5..3bb4c8e8 100644 --- a/chaincode-docker-devmode/.gitignore +++ b/chaincode-docker-devmode/.gitignore @@ -1,3 +1,3 @@ /myc.block -/chaincode/sacc/sacc -/chaincode/chaincode_example02/chaincode_example02 +/chaincode/sacc/go/sacc +/chaincode/abstore/go/abstore diff --git a/chaincode-docker-devmode/README.rst b/chaincode-docker-devmode/README.rst index 91bccb30..aa57190b 100644 --- a/chaincode-docker-devmode/README.rst +++ b/chaincode-docker-devmode/README.rst @@ -86,14 +86,14 @@ Now, compile your chaincode: .. code:: bash - cd chaincode_example02/go - go build -o chaincode_example02 + cd abstore/go + go build -o abstore Now run the chaincode: .. code:: bash - CORE_PEER_ADDRESS=peer:7052 CORE_CHAINCODE_ID_NAME=mycc:0 ./chaincode_example02 + CORE_PEER_ADDRESS=peer:7052 CORE_CHAINCODE_ID_NAME=mycc:0 ./abstore The chaincode is started with peer and chaincode logs indicating successful registration with the peer. Note that at this stage the chaincode is not associated with any channel. This is done in subsequent steps @@ -114,7 +114,7 @@ We'll leverage the CLI container to drive these calls. .. code:: bash - peer chaincode install -p chaincodedev/chaincode/chaincode_example02/go -n mycc -v 0 + peer chaincode install -p chaincodedev/chaincode/abstore/go -n mycc -v 0 peer chaincode instantiate -n mycc -v 0 -c '{"Args":["init","a","100","b","200"]}' -C myc Now issue an invoke to move ``10`` from ``a`` to ``b``. @@ -132,7 +132,7 @@ Finally, query ``a``. We should see a value of ``90``. Testing new chaincode --------------------- -By default, we mount only ``chaincode_example02``. However, you can easily test different +By default, we mount only ``abstore``. However, you can easily test different chaincodes by adding them to the ``chaincode`` subdirectory and relaunching your network. At this point they will be accessible in your ``chaincode`` container. diff --git a/chaincode-docker-devmode/docker-compose-simple.yaml b/chaincode-docker-devmode/docker-compose-simple.yaml index 725a3eaf..0d2ea71e 100644 --- a/chaincode-docker-devmode/docker-compose-simple.yaml +++ b/chaincode-docker-devmode/docker-compose-simple.yaml @@ -73,7 +73,7 @@ services: - GOPATH=/opt/gopath - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock - FABRIC_LOGGING_SPEC=DEBUG - - CORE_PEER_ID=example02 + - CORE_PEER_ID=abstore - CORE_PEER_ADDRESS=peer:7051 - CORE_PEER_LOCALMSPID=DEFAULT - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp diff --git a/chaincode/chaincode_example02/go/chaincode_example02.go b/chaincode/abstore/go/abstore.go similarity index 80% rename from chaincode/chaincode_example02/go/chaincode_example02.go rename to chaincode/abstore/go/abstore.go index 53438066..6b64d577 100644 --- a/chaincode/chaincode_example02/go/chaincode_example02.go +++ b/chaincode/abstore/go/abstore.go @@ -16,12 +16,6 @@ limitations under the License. package main -//WARNING - this chaincode's ID is hard-coded in chaincode_example04 to illustrate one way of -//calling chaincode from a chaincode. If this example is modified, chaincode_example04.go has -//to be modified as well with the new ID of chaincode_example02. -//chaincode_example05 show's how chaincode ID can be passed in as a parameter instead of -//hard-coding. - import ( "fmt" "strconv" @@ -30,12 +24,12 @@ import ( pb "github.com/hyperledger/fabric/protos/peer" ) -// SimpleChaincode example simple Chaincode implementation -type SimpleChaincode struct { +// ABstore Chaincode implementation +type ABstore struct { } -func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response { - fmt.Println("ex02 Init") +func (t *ABstore) Init(stub shim.ChaincodeStubInterface) pb.Response { + fmt.Println("ABstore Init") _, args := stub.GetFunctionAndParameters() var A, B string // Entities var Aval, Bval int // Asset holdings @@ -72,8 +66,8 @@ func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response { return shim.Success(nil) } -func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response { - fmt.Println("ex02 Invoke") +func (t *ABstore) Invoke(stub shim.ChaincodeStubInterface) pb.Response { + fmt.Println("ABstore Invoke") function, args := stub.GetFunctionAndParameters() if function == "invoke" { // Make payment of X units from A to B @@ -90,7 +84,7 @@ func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response { } // Transaction makes payment of X units from A to B -func (t *SimpleChaincode) invoke(stub shim.ChaincodeStubInterface, args []string) pb.Response { +func (t *ABstore) invoke(stub shim.ChaincodeStubInterface, args []string) pb.Response { var A, B string // Entities var Aval, Bval int // Asset holdings var X int // Transaction value @@ -147,7 +141,7 @@ func (t *SimpleChaincode) invoke(stub shim.ChaincodeStubInterface, args []string } // Deletes an entity from state -func (t *SimpleChaincode) delete(stub shim.ChaincodeStubInterface, args []string) pb.Response { +func (t *ABstore) delete(stub shim.ChaincodeStubInterface, args []string) pb.Response { if len(args) != 1 { return shim.Error("Incorrect number of arguments. Expecting 1") } @@ -164,7 +158,7 @@ func (t *SimpleChaincode) delete(stub shim.ChaincodeStubInterface, args []string } // query callback representing the query of a chaincode -func (t *SimpleChaincode) query(stub shim.ChaincodeStubInterface, args []string) pb.Response { +func (t *ABstore) query(stub shim.ChaincodeStubInterface, args []string) pb.Response { var A string // Entities var err error @@ -192,8 +186,8 @@ func (t *SimpleChaincode) query(stub shim.ChaincodeStubInterface, args []string) } func main() { - err := shim.Start(new(SimpleChaincode)) + err := shim.Start(new(ABstore)) if err != nil { - fmt.Printf("Error starting Simple chaincode: %s", err) + fmt.Printf("Error starting ABstore chaincode: %s", err) } } diff --git a/chaincode/chaincode_example02/java/build.gradle b/chaincode/abstore/java/build.gradle similarity index 88% rename from chaincode/chaincode_example02/java/build.gradle rename to chaincode/abstore/java/build.gradle index 5221272c..0f02f85f 100644 --- a/chaincode/chaincode_example02/java/build.gradle +++ b/chaincode/abstore/java/build.gradle @@ -29,6 +29,6 @@ shadowJar { classifier = null manifest { - attributes 'Main-Class': 'org.hyperledger.fabric.example.SimpleChaincode' + attributes 'Main-Class': 'org.hyperledger.fabric_samples.ABstore' } } diff --git a/chaincode/chaincode_example02/java/settings.gradle b/chaincode/abstore/java/settings.gradle similarity index 100% rename from chaincode/chaincode_example02/java/settings.gradle rename to chaincode/abstore/java/settings.gradle diff --git a/chaincode/chaincode_example02/java/src/main/java/org/hyperledger/fabric/example/SimpleChaincode.java b/chaincode/abstore/java/src/main/java/org/hyperledger/fabric-samples/ABstore.java similarity index 96% rename from chaincode/chaincode_example02/java/src/main/java/org/hyperledger/fabric/example/SimpleChaincode.java rename to chaincode/abstore/java/src/main/java/org/hyperledger/fabric-samples/ABstore.java index dd93a4e0..e7cfd3d1 100644 --- a/chaincode/chaincode_example02/java/src/main/java/org/hyperledger/fabric/example/SimpleChaincode.java +++ b/chaincode/abstore/java/src/main/java/org/hyperledger/fabric-samples/ABstore.java @@ -3,7 +3,7 @@ Copyright IBM Corp., DTCC All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.fabric.example; +package org.hyperledger.fabric_samples; import java.util.List; @@ -16,9 +16,9 @@ import org.hyperledger.fabric.shim.ChaincodeStub; import static java.nio.charset.StandardCharsets.UTF_8; -public class SimpleChaincode extends ChaincodeBase { +public class ABstore extends ChaincodeBase { - private static Log _logger = LogFactory.getLog(SimpleChaincode.class); + private static Log _logger = LogFactory.getLog(ABstore.class); @Override public Response init(ChaincodeStub stub) { @@ -136,7 +136,7 @@ public class SimpleChaincode extends ChaincodeBase { public static void main(String[] args) { System.out.println("OpenSSL avaliable: " + OpenSsl.isAvailable()); - new SimpleChaincode().start(args); + new ABstore().start(args); } } diff --git a/chaincode/chaincode_example02/node/chaincode_example02.js b/chaincode/abstore/node/abstore.js similarity index 96% rename from chaincode/chaincode_example02/node/chaincode_example02.js rename to chaincode/abstore/node/abstore.js index 545092af..adcfdd9c 100644 --- a/chaincode/chaincode_example02/node/chaincode_example02.js +++ b/chaincode/abstore/node/abstore.js @@ -7,11 +7,11 @@ const shim = require('fabric-shim'); const util = require('util'); -var Chaincode = class { +var ABstore = class { // Initialize the chaincode async Init(stub) { - console.info('========= example02 Init ========='); + console.info('========= ABstore Init ========='); let ret = stub.getFunctionAndParameters(); console.info(ret); let args = ret.params; @@ -135,4 +135,4 @@ var Chaincode = class { } }; -shim.start(new Chaincode()); +shim.start(new ABstore()); diff --git a/chaincode/chaincode_example02/node/package.json b/chaincode/abstore/node/package.json similarity index 53% rename from chaincode/chaincode_example02/node/package.json rename to chaincode/abstore/node/package.json index 9a4ab407..e38c4e07 100644 --- a/chaincode/chaincode_example02/node/package.json +++ b/chaincode/abstore/node/package.json @@ -1,12 +1,14 @@ { - "name": "chaincode_example02", + "name": "abstore", "version": "1.0.0", - "description": "chaincode_example02 chaincode implemented in node.js", + "description": "ABstore chaincode implemented in node.js", "engines": { "node": ">=8.4.0", "npm": ">=5.3.0" }, - "scripts": { "start" : "node chaincode_example02.js" }, + "scripts": { + "start": "node abstore.js" + }, "engine-strict": true, "license": "Apache-2.0", "dependencies": { diff --git a/commercial-paper/organization/digibank/gateway/papernetConnection.yaml b/commercial-paper/organization/digibank/gateway/papernetConnection.yaml index 7fc40283..79036af6 100644 --- a/commercial-paper/organization/digibank/gateway/papernetConnection.yaml +++ b/commercial-paper/organization/digibank/gateway/papernetConnection.yaml @@ -100,7 +100,7 @@ channels: # this list with the query results of getInstalledChaincodes() and getInstantiatedChaincodes() chaincodes: # the format follows the "cannonical name" of chaincodes by fabric code - - example02:v1 + - abstore:v1 - marbles:1.0 # @@ -222,4 +222,4 @@ certificateAuthorities: - enrollId: admin enrollSecret: adminpw # [Optional] The optional name of the CA. - caName: ca-digibank \ No newline at end of file + caName: ca-digibank diff --git a/commercial-paper/organization/magnetocorp/gateway/papernetConnection.yaml b/commercial-paper/organization/magnetocorp/gateway/papernetConnection.yaml index 7fc40283..79036af6 100644 --- a/commercial-paper/organization/magnetocorp/gateway/papernetConnection.yaml +++ b/commercial-paper/organization/magnetocorp/gateway/papernetConnection.yaml @@ -100,7 +100,7 @@ channels: # this list with the query results of getInstalledChaincodes() and getInstantiatedChaincodes() chaincodes: # the format follows the "cannonical name" of chaincodes by fabric code - - example02:v1 + - abstore:v1 - marbles:1.0 # @@ -222,4 +222,4 @@ certificateAuthorities: - enrollId: admin enrollSecret: adminpw # [Optional] The optional name of the CA. - caName: ca-digibank \ No newline at end of file + caName: ca-digibank diff --git a/first-network/scripts/script.sh b/first-network/scripts/script.sh index 664dfba8..53259e3c 100755 --- a/first-network/scripts/script.sh +++ b/first-network/scripts/script.sh @@ -23,13 +23,12 @@ LANGUAGE=`echo "$LANGUAGE" | tr [:upper:] [:lower:]` COUNTER=1 MAX_RETRY=10 -CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go/" if [ "$LANGUAGE" = "node" ]; then - CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/node/" -fi - -if [ "$LANGUAGE" = "java" ]; then - CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/java/" + CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/node/" +elif [ "$LANGUAGE" = "java" ]; then + CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/java/" +else + CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/abstore/go/" fi echo "Channel name : "$CHANNEL_NAME diff --git a/first-network/scripts/step1org3.sh b/first-network/scripts/step1org3.sh index 94e9d005..5caac656 100755 --- a/first-network/scripts/step1org3.sh +++ b/first-network/scripts/step1org3.sh @@ -25,9 +25,12 @@ LANGUAGE=`echo "$LANGUAGE" | tr [:upper:] [:lower:]` COUNTER=1 MAX_RETRY=5 -CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go/" if [ "$LANGUAGE" = "node" ]; then - CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/node/" + CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/node/" +elif [ "$LANGUAGE" = "java" ]; then + CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/java/" +else + CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/abstore/go/" fi # import utils diff --git a/first-network/scripts/step2org3.sh b/first-network/scripts/step2org3.sh index 734a0d7c..c0a8d8d1 100755 --- a/first-network/scripts/step2org3.sh +++ b/first-network/scripts/step2org3.sh @@ -28,9 +28,12 @@ LANGUAGE=`echo "$LANGUAGE" | tr [:upper:] [:lower:]` COUNTER=1 MAX_RETRY=5 -CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go/" if [ "$LANGUAGE" = "node" ]; then - CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/node/" + CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/node/" +elif [ "$LANGUAGE" = "java" ]; then + CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/java/" +else + CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/abstore/go/" fi # import utils diff --git a/first-network/scripts/step3org3.sh b/first-network/scripts/step3org3.sh index 6a3ac3d5..381af51a 100755 --- a/first-network/scripts/step3org3.sh +++ b/first-network/scripts/step3org3.sh @@ -29,9 +29,12 @@ LANGUAGE=`echo "$LANGUAGE" | tr [:upper:] [:lower:]` COUNTER=1 MAX_RETRY=5 -CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go/" if [ "$LANGUAGE" = "node" ]; then - CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/node/" + CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/node/" +elif [ "$LANGUAGE" = "java" ]; then + CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/java/" +else + CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/abstore/go/" fi # import utils diff --git a/first-network/scripts/testorg3.sh b/first-network/scripts/testorg3.sh index e7a396de..dd876758 100755 --- a/first-network/scripts/testorg3.sh +++ b/first-network/scripts/testorg3.sh @@ -33,9 +33,12 @@ LANGUAGE=`echo "$LANGUAGE" | tr [:upper:] [:lower:]` COUNTER=1 MAX_RETRY=5 -CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go/" if [ "$LANGUAGE" = "node" ]; then - CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/node/" + CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/node/" +elif [ "$LANGUAGE" = "java" ]; then + CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/java/" +else + CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/abstore/go/" fi echo "Channel name : "$CHANNEL_NAME diff --git a/first-network/scripts/upgrade_to_v14.sh b/first-network/scripts/upgrade_to_v14.sh index fc671ac2..751f111f 100755 --- a/first-network/scripts/upgrade_to_v14.sh +++ b/first-network/scripts/upgrade_to_v14.sh @@ -23,9 +23,12 @@ LANGUAGE=$(echo "$LANGUAGE" | tr [:upper:] [:lower:]) COUNTER=1 MAX_RETRY=5 -CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go/" if [ "$LANGUAGE" = "node" ]; then - CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/node/" + CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/node/" +elif [ "$LANGUAGE" = "java" ]; then + CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/java/" +else + CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/abstore/go/" fi echo "Channel name : "$CHANNEL_NAME