├── README.md ├── _exampleusage └── ExampleContract │ └── src │ ├── .gradle │ ├── 6.5.1 │ │ ├── gc.properties │ │ ├── fileChanges │ │ │ └── last-build.bin │ │ ├── fileHashes │ │ │ └── fileHashes.lock │ │ └── executionHistory │ │ │ └── executionHistory.lock │ ├── 7.4.1 │ │ ├── gc.properties │ │ ├── fileChanges │ │ │ └── last-build.bin │ │ ├── dependencies-accessors │ │ │ ├── gc.properties │ │ │ └── dependencies-accessors.lock │ │ ├── checksums │ │ │ ├── checksums.lock │ │ │ ├── md5-checksums.bin │ │ │ └── sha1-checksums.bin │ │ ├── fileHashes │ │ │ ├── fileHashes.bin │ │ │ ├── fileHashes.lock │ │ │ └── resourceHashesCache.bin │ │ └── executionHistory │ │ │ ├── executionHistory.bin │ │ │ └── executionHistory.lock │ ├── vcs-1 │ │ └── gc.properties │ ├── buildOutputCleanup │ │ ├── cache.properties │ │ ├── outputFiles.bin │ │ └── buildOutputCleanup.lock │ ├── file-system.probe │ └── checksums │ │ └── checksums.lock │ ├── build │ ├── tmp │ │ ├── jar │ │ │ └── MANIFEST.MF │ │ ├── shadowJar │ │ │ └── MANIFEST.MF │ │ ├── compileJava │ │ │ └── previous-compilation-data.bin │ │ ├── compileTestJava │ │ │ └── previous-compilation-data.bin │ │ └── expandedArchives │ │ │ └── org.jacoco.agent-0.8.7.jar_3a83c50b4a016f281c4e9f3500d16b55 │ │ │ ├── META-INF │ │ │ ├── maven │ │ │ │ └── org.jacoco │ │ │ │ │ └── org.jacoco.agent │ │ │ │ │ ├── pom.properties │ │ │ │ │ └── pom.xml │ │ │ └── MANIFEST.MF │ │ │ └── about.html │ ├── resources │ │ └── test │ │ │ └── mockito-extensions │ │ │ └── org.mockito.plugins.MockMaker │ ├── jacoco │ │ └── test.exec │ ├── test-results │ │ └── test │ │ │ ├── binary │ │ │ ├── output.bin │ │ │ ├── results.bin │ │ │ └── output.bin.idx │ │ │ ├── TEST-org.hyperledger.fabric.samples.privatedata.AssetTransferTest$QueryReadAssetTransaction.xml │ │ │ └── TEST-org.hyperledger.fabric.samples.privatedata.AssetTransferTest$InvokeWriteTransaction.xml │ ├── distributions │ │ ├── private-1.0-SNAPSHOT.tar │ │ └── private-shadow-1.0-SNAPSHOT.tar │ ├── reports │ │ ├── checkstyle │ │ │ ├── test.xml │ │ │ ├── main.xml │ │ │ ├── test.html │ │ │ └── main.html │ │ └── tests │ │ │ └── test │ │ │ ├── css │ │ │ ├── style.css │ │ │ └── base-style.css │ │ │ ├── packages │ │ │ └── org.hyperledger.fabric.samples.privatedata.html │ │ │ ├── classes │ │ │ ├── org.hyperledger.fabric.samples.privatedata.AssetTransferTest$QueryReadAssetTransaction.html │ │ │ └── org.hyperledger.fabric.samples.privatedata.AssetTransferTest$InvokeWriteTransaction.html │ │ │ ├── index.html │ │ │ └── js │ │ │ └── report.js │ ├── scriptsShadow │ │ ├── private.bat │ │ └── private │ └── scripts │ │ ├── private.bat │ │ └── private │ ├── bin │ └── test │ │ └── mockito-extensions │ │ └── org.mockito.plugins.MockMaker │ ├── src │ ├── test │ │ ├── resources │ │ │ └── mockito-extensions │ │ │ │ └── org.mockito.plugins.MockMaker │ │ └── java │ │ │ └── org │ │ │ └── hyperledger │ │ │ └── fabric │ │ │ └── samples │ │ │ └── privatedata │ │ │ └── AssetTransferTest.java │ └── main │ │ └── java │ │ └── org │ │ └── hyperledger │ │ └── fabric │ │ └── samples │ │ └── privatedata │ │ ├── TransferAgreement.java │ │ ├── AssetPrivateDetails.java │ │ ├── Asset.java │ │ └── AssetTransfer.java │ ├── .gitattributes │ ├── settings.gradle │ ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties │ ├── META-INF │ └── statedb │ │ └── couchdb │ │ └── collections │ │ └── assetCollection │ │ └── indexes │ │ └── indexOwner.json │ ├── config │ └── checkstyle │ │ ├── suppressions.xml │ │ └── checkstyle.xml │ ├── .settings │ └── org.eclipse.buildship.core.prefs │ ├── collections_config.json │ ├── .project │ ├── .classpath │ ├── build.gradle │ ├── gradlew.bat │ └── gradlew ├── gradle-plugin ├── .vscode │ └── settings.json ├── plugin │ ├── .settings │ │ └── org.eclipse.buildship.core.prefs │ ├── src │ │ ├── main │ │ │ └── java │ │ │ │ └── org │ │ │ │ └── hyperledger │ │ │ │ └── fabric │ │ │ │ ├── CustomData.java │ │ │ │ ├── ChaincodePackagePlugin.java │ │ │ │ ├── ChaincodePackageTask.java │ │ │ │ ├── ChaincodePackageExtension.java │ │ │ │ └── Library.java │ │ ├── test │ │ │ └── java │ │ │ │ └── org │ │ │ │ └── hyperledger │ │ │ │ └── fabric │ │ │ │ └── ChaincodePackagePluginTest.java │ │ └── functionalTest │ │ │ └── java │ │ │ └── org │ │ │ └── hyperledger │ │ │ └── fabric │ │ │ └── ChaincodePackagePluginFunctionalTest.java │ ├── .project │ ├── .classpath │ └── build.gradle ├── .gitignore ├── .gitattributes ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── settings.gradle ├── .settings │ └── org.eclipse.buildship.core.prefs ├── .project ├── gradlew.bat └── gradlew ├── .gitignore └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | # fabric-chaincode-build -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/6.5.1/gc.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/7.4.1/gc.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/vcs-1/gc.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/6.5.1/fileChanges/last-build.bin: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/7.4.1/fileChanges/last-build.bin: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/7.4.1/dependencies-accessors/gc.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/tmp/jar/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | 3 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/bin/test/mockito-extensions/org.mockito.plugins.MockMaker: -------------------------------------------------------------------------------- 1 | mock-maker-inline 2 | -------------------------------------------------------------------------------- /gradle-plugin/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic" 3 | } -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker: -------------------------------------------------------------------------------- 1 | mock-maker-inline 2 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/resources/test/mockito-extensions/org.mockito.plugins.MockMaker: -------------------------------------------------------------------------------- 1 | mock-maker-inline 2 | -------------------------------------------------------------------------------- /gradle-plugin/plugin/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | connection.project.dir=.. 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/buildOutputCleanup/cache.properties: -------------------------------------------------------------------------------- 1 | #Sat Mar 19 22:15:33 GMT 2022 2 | gradle.version=7.4.1 3 | -------------------------------------------------------------------------------- /gradle-plugin/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/tmp/shadowJar/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: org.hyperledger.fabric.contract.ContractRouter 3 | 4 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/jacoco/test.exec: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/build/jacoco/test.exec -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/file-system.probe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/.gradle/file-system.probe -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/checksums/checksums.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/.gradle/checksums/checksums.lock -------------------------------------------------------------------------------- /gradle-plugin/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/7.4.1/checksums/checksums.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/.gradle/7.4.1/checksums/checksums.lock -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/6.5.1/fileHashes/fileHashes.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/.gradle/6.5.1/fileHashes/fileHashes.lock -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/7.4.1/fileHashes/fileHashes.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/.gradle/7.4.1/fileHashes/fileHashes.bin -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/7.4.1/fileHashes/fileHashes.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/.gradle/7.4.1/fileHashes/fileHashes.lock -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/7.4.1/checksums/md5-checksums.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/.gradle/7.4.1/checksums/md5-checksums.bin -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/7.4.1/checksums/sha1-checksums.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/.gradle/7.4.1/checksums/sha1-checksums.bin -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/buildOutputCleanup/outputFiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/.gradle/buildOutputCleanup/outputFiles.bin -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/test-results/test/binary/output.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/build/test-results/test/binary/output.bin -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/test-results/test/binary/results.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/build/test-results/test/binary/results.bin -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/distributions/private-1.0-SNAPSHOT.tar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/build/distributions/private-1.0-SNAPSHOT.tar -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/test-results/test/binary/output.bin.idx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/build/test-results/test/binary/output.bin.idx -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/7.4.1/fileHashes/resourceHashesCache.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/.gradle/7.4.1/fileHashes/resourceHashesCache.bin -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/buildOutputCleanup/buildOutputCleanup.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/.gradle/buildOutputCleanup/buildOutputCleanup.lock -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/6.5.1/executionHistory/executionHistory.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/.gradle/6.5.1/executionHistory/executionHistory.lock -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/7.4.1/executionHistory/executionHistory.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/.gradle/7.4.1/executionHistory/executionHistory.bin -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/7.4.1/executionHistory/executionHistory.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/.gradle/7.4.1/executionHistory/executionHistory.lock -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/distributions/private-shadow-1.0-SNAPSHOT.tar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/build/distributions/private-shadow-1.0-SNAPSHOT.tar -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/tmp/compileJava/previous-compilation-data.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/build/tmp/compileJava/previous-compilation-data.bin -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/tmp/compileTestJava/previous-compilation-data.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/build/tmp/compileTestJava/previous-compilation-data.bin -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.gradle/7.4.1/dependencies-accessors/dependencies-accessors.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-chaincode-build/main/_exampleusage/ExampleContract/src/.gradle/7.4.1/dependencies-accessors/dependencies-accessors.lock -------------------------------------------------------------------------------- /gradle-plugin/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | 6 | pluginManagement { 7 | repositories { 8 | mavenLocal() 9 | gradlePluginPortal() 10 | } 11 | } 12 | rootProject.name = 'private' 13 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/META-INF/statedb/couchdb/collections/assetCollection/indexes/indexOwner.json: -------------------------------------------------------------------------------- 1 | { 2 | "index": { 3 | "fields": [ 4 | "objectType", 5 | "owner" 6 | ] 7 | }, 8 | "ddoc": "indexOwnerDoc", 9 | "name": "indexOwner", 10 | "type": "json" 11 | } 12 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/tmp/expandedArchives/org.jacoco.agent-0.8.7.jar_3a83c50b4a016f281c4e9f3500d16b55/META-INF/maven/org.jacoco/org.jacoco.agent/pom.properties: -------------------------------------------------------------------------------- 1 | #Generated by Maven 2 | #Tue May 04 15:32:11 CEST 2021 3 | version=0.8.7 4 | groupId=org.jacoco 5 | artifactId=org.jacoco.agent 6 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/config/checkstyle/suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/reports/checkstyle/test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | -------------------------------------------------------------------------------- /gradle-plugin/plugin/src/main/java/org/hyperledger/fabric/CustomData.java: -------------------------------------------------------------------------------- 1 | package org.hyperledger.fabric; 2 | 3 | public class CustomData { 4 | 5 | String websiteURL; 6 | // String port; 7 | 8 | public String getWebsiteURL(){ 9 | return this.websiteURL; 10 | } 11 | 12 | public void setWebsiteURL(String url){ 13 | this.websiteURL = url; 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /gradle-plugin/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.0/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'fabric-java-chaincode-package' 11 | include('plugin') 12 | -------------------------------------------------------------------------------- /gradle-plugin/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | arguments= 2 | auto.sync=false 3 | build.scans.enabled=false 4 | connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) 5 | connection.project.dir= 6 | eclipse.preferences.version=1 7 | gradle.user.home= 8 | java.home=/home/matthew/.sdkman/candidates/java/11.0.14.1-sem 9 | jvm.arguments= 10 | offline.mode=false 11 | override.workspace.settings=true 12 | show.console.view=true 13 | show.executions.view=true 14 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | arguments= 2 | auto.sync=false 3 | build.scans.enabled=false 4 | connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) 5 | connection.project.dir= 6 | eclipse.preferences.version=1 7 | gradle.user.home= 8 | java.home=/home/matthew/.sdkman/candidates/java/11.0.14.1-sem 9 | jvm.arguments= 10 | offline.mode=false 11 | override.workspace.settings=true 12 | show.console.view=true 13 | show.executions.view=true 14 | -------------------------------------------------------------------------------- /gradle-plugin/plugin/src/main/java/org/hyperledger/fabric/ChaincodePackagePlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Java source file was generated by the Gradle 'init' task. 3 | */ 4 | package org.hyperledger.fabric; 5 | 6 | import org.gradle.api.Project; 7 | import org.gradle.api.Plugin; 8 | 9 | /** 10 | * A simple 'hello world' plugin. 11 | */ 12 | public class ChaincodePackagePlugin implements Plugin { 13 | 14 | 15 | @Override 16 | public void apply(Project project) { 17 | project.getExtensions().create("chaincodePackage", 18 | ChaincodePackageExtension.class); 19 | 20 | project.getTasks().register("chaincodePackage", ChaincodePackageTask.class); 21 | } 22 | } -------------------------------------------------------------------------------- /gradle-plugin/plugin/src/main/java/org/hyperledger/fabric/ChaincodePackageTask.java: -------------------------------------------------------------------------------- 1 | package org.hyperledger.fabric; 2 | 3 | import org.gradle.api.DefaultTask; 4 | import org.gradle.api.tasks.TaskAction; 5 | 6 | 7 | 8 | public class ChaincodePackageTask extends DefaultTask { 9 | 10 | // @InputFile 11 | // abstract public RegularFileProperty getFile2(); 12 | // @OutputFile 13 | // abstract public RegularFileProperty getResultFile(); 14 | 15 | @TaskAction 16 | public void perform() { 17 | System.out.println("===>> Packaging"); 18 | ChaincodePackageExtension extension = getProject().getExtensions().findByType(ChaincodePackageExtension.class); 19 | 20 | System.out.println(extension.getConnectionJSON()); 21 | } 22 | } -------------------------------------------------------------------------------- /gradle-plugin/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | fabric-java-chaincode-package 4 | Project gradle-plugin created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.buildship.core.gradleprojectbuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.buildship.core.gradleprojectnature 16 | 17 | 18 | 19 | 0 20 | 21 | 30 22 | 23 | org.eclipse.core.resources.regexFilterMatcher 24 | node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /gradle-plugin/plugin/src/main/java/org/hyperledger/fabric/ChaincodePackageExtension.java: -------------------------------------------------------------------------------- 1 | 2 | package org.hyperledger.fabric; 3 | 4 | import org.gradle.api.tasks.Nested; 5 | 6 | public class ChaincodePackageExtension { 7 | 8 | String connectionJSON="default"; 9 | String host=""; 10 | 11 | @Nested 12 | CustomData customData; 13 | 14 | public String getConnectionJSON(){ 15 | return connectionJSON; 16 | } 17 | 18 | public void setConnectionJSON(String json){ 19 | this.connectionJSON = json; 20 | } 21 | 22 | public String getHost(){ 23 | return host; 24 | } 25 | 26 | public void setHost(String host){ 27 | this.host=host; 28 | } 29 | 30 | 31 | public CustomData getCustomData(){ 32 | return this.customData; 33 | } 34 | 35 | public void setCustomData(CustomData data){ 36 | this.customData = data; 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/reports/checkstyle/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /gradle-plugin/plugin/src/test/java/org/hyperledger/fabric/ChaincodePackagePluginTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Java source file was generated by the Gradle 'init' task. 3 | */ 4 | package org.hyperledger.fabric; 5 | 6 | import org.gradle.testfixtures.ProjectBuilder; 7 | import org.gradle.api.Project; 8 | import org.junit.Test; 9 | import static org.junit.Assert.*; 10 | 11 | /** 12 | * A simple unit test for the 'org.hyperledger.fabric.greeting' plugin. 13 | */ 14 | public class ChaincodePackagePluginTest { 15 | @Test public void pluginRegistersATask() { 16 | // Create a test project and apply the plugin 17 | // Project project = ProjectBuilder.builder().build(); 18 | // project.getPlugins().apply("org.hyperledger.fabric.chaincodepackage"); 19 | 20 | // System.out.println(project.getTasks().toString()); 21 | // // Verify the result 22 | // assertNotNull(project.getTasks().findByName("chaincodePackage")); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/collections_config.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "assetCollection", 4 | "policy": "OR('Org1MSP.member', 'Org2MSP.member')", 5 | "requiredPeerCount": 1, 6 | "maxPeerCount": 1, 7 | "blockToLive":1000000, 8 | "memberOnlyRead": true, 9 | "memberOnlyWrite": true 10 | }, 11 | { 12 | "name": "Org1MSPPrivateCollection", 13 | "policy": "OR('Org1MSP.member')", 14 | "requiredPeerCount": 0, 15 | "maxPeerCount": 1, 16 | "blockToLive":3, 17 | "memberOnlyRead": true, 18 | "memberOnlyWrite": false, 19 | "endorsementPolicy": { 20 | "signaturePolicy": "OR('Org1MSP.member')" 21 | } 22 | }, 23 | { 24 | "name": "Org2MSPPrivateCollection", 25 | "policy": "OR('Org2MSP.member')", 26 | "requiredPeerCount": 0, 27 | "maxPeerCount": 1, 28 | "blockToLive":3, 29 | "memberOnlyRead": true, 30 | "memberOnlyWrite": false, 31 | "endorsementPolicy": { 32 | "signaturePolicy": "OR('Org2MSP.member')" 33 | } 34 | } 35 | ] 36 | -------------------------------------------------------------------------------- /gradle-plugin/plugin/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | plugin 4 | Project plugin created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.buildship.core.gradleprojectbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.buildship.core.gradleprojectnature 22 | 23 | 24 | 25 | 1627045450662 26 | 27 | 30 28 | 29 | org.eclipse.core.resources.regexFilterMatcher 30 | node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | private 4 | Project chaincode-java created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.buildship.core.gradleprojectbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.buildship.core.gradleprojectnature 22 | 23 | 24 | 25 | 0 26 | 27 | 30 28 | 29 | org.eclipse.core.resources.regexFilterMatcher 30 | node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/tmp/expandedArchives/org.jacoco.agent-0.8.7.jar_3a83c50b4a016f281c4e9f3500d16b55/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Archiver-Version: Plexus Archiver 3 | Created-By: Apache Maven Bundle Plugin 4 | Built-By: godin 5 | Build-Jdk: 1.8.0_202 6 | Automatic-Module-Name: org.jacoco.agent 7 | Bnd-LastModified: 1620135133834 8 | Bundle-Description: JaCoCo Agent 9 | Bundle-License: https://www.eclipse.org/legal/epl-2.0/ 10 | Bundle-ManifestVersion: 2 11 | Bundle-Name: JaCoCo Agent 12 | Bundle-RequiredExecutionEnvironment: J2SE-1.5 13 | Bundle-SymbolicName: org.jacoco.agent 14 | Bundle-Vendor: Mountainminds GmbH & Co. KG 15 | Bundle-Version: 0.8.7.202105040129 16 | Eclipse-SourceReferences: scm:git:git://github.com/jacoco/jacoco.git;p 17 | ath="org.jacoco.agent";commitId=d19ea595a67af6f16d76b49ccdc12858c3570 18 | 298 19 | Export-Package: org.jacoco.agent;version="0.8.7" 20 | Originally-Created-By: Apache Maven Bundle Plugin 21 | Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.5))" 22 | Tool: Bnd-3.5.0.201709291849 23 | 24 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/test-results/test/TEST-org.hyperledger.fabric.samples.privatedata.AssetTransferTest$QueryReadAssetTransaction.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /gradle-plugin/plugin/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/reports/tests/test/css/style.css: -------------------------------------------------------------------------------- 1 | 2 | #summary { 3 | margin-top: 30px; 4 | margin-bottom: 40px; 5 | } 6 | 7 | #summary table { 8 | border-collapse: collapse; 9 | } 10 | 11 | #summary td { 12 | vertical-align: top; 13 | } 14 | 15 | .breadcrumbs, .breadcrumbs a { 16 | color: #606060; 17 | } 18 | 19 | .infoBox { 20 | width: 110px; 21 | padding-top: 15px; 22 | padding-bottom: 15px; 23 | text-align: center; 24 | } 25 | 26 | .infoBox p { 27 | margin: 0; 28 | } 29 | 30 | .counter, .percent { 31 | font-size: 120%; 32 | font-weight: bold; 33 | margin-bottom: 8px; 34 | } 35 | 36 | #duration { 37 | width: 125px; 38 | } 39 | 40 | #successRate, .summaryGroup { 41 | border: solid 2px #d0d0d0; 42 | -moz-border-radius: 10px; 43 | border-radius: 10px; 44 | } 45 | 46 | #successRate { 47 | width: 140px; 48 | margin-left: 35px; 49 | } 50 | 51 | #successRate .percent { 52 | font-size: 180%; 53 | } 54 | 55 | .success, .success a { 56 | color: #008000; 57 | } 58 | 59 | div.success, #successRate.success { 60 | background-color: #bbd9bb; 61 | border-color: #008000; 62 | } 63 | 64 | .failures, .failures a { 65 | color: #b60808; 66 | } 67 | 68 | .skipped, .skipped a { 69 | color: #c09853; 70 | } 71 | 72 | div.failures, #successRate.failures { 73 | background-color: #ecdada; 74 | border-color: #b60808; 75 | } 76 | 77 | ul.linkList { 78 | padding-left: 0; 79 | } 80 | 81 | ul.linkList li { 82 | list-style: none; 83 | margin-bottom: 5px; 84 | } 85 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/test-results/test/TEST-org.hyperledger.fabric.samples.privatedata.AssetTransferTest$InvokeWriteTransaction.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 15 | 17 | 18 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/src/main/java/org/hyperledger/fabric/samples/privatedata/TransferAgreement.java: -------------------------------------------------------------------------------- 1 | package org.hyperledger.fabric.samples.privatedata; 2 | 3 | import org.hyperledger.fabric.contract.annotation.DataType; 4 | import org.hyperledger.fabric.contract.annotation.Property; 5 | import org.hyperledger.fabric.shim.ChaincodeException; 6 | import org.json.JSONObject; 7 | 8 | import static java.nio.charset.StandardCharsets.UTF_8; 9 | 10 | @DataType() 11 | public final class TransferAgreement { 12 | 13 | @Property() 14 | private final String assetID; 15 | 16 | 17 | @Property() 18 | private String buyerID; 19 | 20 | public String getAssetID() { 21 | return assetID; 22 | } 23 | 24 | public String getBuyerID() { 25 | return buyerID; 26 | } 27 | 28 | public TransferAgreement(final String assetID, 29 | final String buyer) { 30 | this.assetID = assetID; 31 | this.buyerID = buyer; 32 | } 33 | 34 | public byte[] serialize() { 35 | String jsonStr = new JSONObject(this).toString(); 36 | return jsonStr.getBytes(UTF_8); 37 | } 38 | 39 | public static TransferAgreement deserialize(final byte[] assetJSON) { 40 | try { 41 | JSONObject json = new JSONObject(new String(assetJSON, UTF_8)); 42 | final String id = json.getString("assetID"); 43 | final String buyerID = json.getString("buyerID"); 44 | return new TransferAgreement(id, buyerID); 45 | } catch (Exception e) { 46 | throw new ChaincodeException("Deserialize error: " + e.getMessage(), "DATA_ERROR"); 47 | } 48 | } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/src/main/java/org/hyperledger/fabric/samples/privatedata/AssetPrivateDetails.java: -------------------------------------------------------------------------------- 1 | package org.hyperledger.fabric.samples.privatedata; 2 | 3 | import org.hyperledger.fabric.contract.annotation.DataType; 4 | import org.hyperledger.fabric.contract.annotation.Property; 5 | 6 | import org.hyperledger.fabric.shim.ChaincodeException; 7 | import org.json.JSONObject; 8 | 9 | import static java.nio.charset.StandardCharsets.UTF_8; 10 | 11 | @DataType() 12 | public final class AssetPrivateDetails { 13 | 14 | @Property() 15 | private final String assetID; 16 | 17 | @Property() 18 | private int appraisedValue; 19 | 20 | public String getAssetID() { 21 | return assetID; 22 | } 23 | 24 | public int getAppraisedValue() { 25 | return appraisedValue; 26 | } 27 | 28 | public AssetPrivateDetails(final String assetID, 29 | final int appraisedValue) { 30 | this.assetID = assetID; 31 | this.appraisedValue = appraisedValue; 32 | } 33 | 34 | public byte[] serialize() { 35 | String jsonStr = new JSONObject(this).toString(); 36 | return jsonStr.getBytes(UTF_8); 37 | } 38 | 39 | public static AssetPrivateDetails deserialize(final byte[] assetJSON) { 40 | try { 41 | JSONObject json = new JSONObject(new String(assetJSON, UTF_8)); 42 | final String id = json.getString("assetID"); 43 | final int appraisedValue = json.getInt("appraisedValue"); 44 | return new AssetPrivateDetails(id, appraisedValue); 45 | } catch (Exception e) { 46 | throw new ChaincodeException("Deserialize error: " + e.getMessage(), "DATA_ERROR"); 47 | } 48 | } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /gradle-plugin/plugin/src/functionalTest/java/org/hyperledger/fabric/ChaincodePackagePluginFunctionalTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Java source file was generated by the Gradle 'init' task. 3 | */ 4 | package org.hyperledger.fabric; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | import java.io.Writer; 9 | import java.io.FileWriter; 10 | import java.nio.file.Files; 11 | import org.gradle.testkit.runner.GradleRunner; 12 | import org.gradle.testkit.runner.BuildResult; 13 | import org.junit.Test; 14 | import static org.junit.Assert.*; 15 | 16 | /** 17 | * A simple functional test for the 'org.hyperledger.fabric.greeting' plugin. 18 | */ 19 | public class ChaincodePackagePluginFunctionalTest { 20 | @Test public void canRunTask() throws IOException { 21 | // // Setup the test build 22 | // File projectDir = new File("build/functionalTest"); 23 | // Files.createDirectories(projectDir.toPath()); 24 | // writeString(new File(projectDir, "settings.gradle"), ""); 25 | // writeString(new File(projectDir, "build.gradle"), 26 | // "plugins {" + 27 | // " id('org.hyperledger.fabric.chaincodepackage')" + 28 | // "}"); 29 | 30 | // // Run the build 31 | // GradleRunner runner = GradleRunner.create(); 32 | // runner.forwardOutput(); 33 | // runner.withPluginClasspath(); 34 | // runner.withArguments("chaincode"); 35 | // runner.withProjectDir(projectDir); 36 | // BuildResult result = runner.build(); 37 | 38 | // // Verify the result 39 | // assertTrue(result.getOutput().contains("Hello from plugin 'org.hyperledger.fabric.greeting'")); 40 | } 41 | 42 | private void writeString(File file, String string) throws IOException { 43 | try (Writer writer = new FileWriter(file)) { 44 | writer.write(string); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | plugins { 6 | id 'com.github.johnrengelman.shadow' version '5.1.0' 7 | id 'application' 8 | id 'checkstyle' 9 | id 'jacoco' 10 | id 'org.hyperledger.fabric.chaincodepackage' version '0.0.1-SNAPSHOT' 11 | } 12 | 13 | chaincodePackage { 14 | connectionJSON 'fred.json' 15 | host 'fred.com:9999' 16 | 17 | customData { 18 | websiteURL = 'https://gradle.org' 19 | } 20 | 21 | } 22 | 23 | 24 | 25 | group 'org.hyperledger.fabric.samples' 26 | version '1.0-SNAPSHOT' 27 | 28 | dependencies { 29 | 30 | compileOnly 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.+' 31 | 32 | // https://mvnrepository.com/artifact/org.json/json 33 | implementation group: 'org.json', name: 'json', version: '20211205' 34 | 35 | testImplementation 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.+' 36 | testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2' 37 | testImplementation 'org.assertj:assertj-core:3.11.1' 38 | testImplementation 'org.mockito:mockito-core:2.+' 39 | } 40 | 41 | repositories { 42 | maven { 43 | url "https://hyperledger.jfrog.io/hyperledger/fabric-maven" 44 | } 45 | jcenter() 46 | maven { 47 | url 'https://jitpack.io' 48 | } 49 | } 50 | 51 | application { 52 | mainClass = 'org.hyperledger.fabric.contract.ContractRouter' 53 | } 54 | 55 | checkstyle { 56 | toolVersion '8.21' 57 | configFile file("config/checkstyle/checkstyle.xml") 58 | } 59 | 60 | checkstyleMain { 61 | source ='src/main/java' 62 | } 63 | 64 | checkstyleTest { 65 | source ='src/test/java' 66 | } 67 | 68 | jacocoTestReport { 69 | dependsOn test 70 | } 71 | 72 | test { 73 | useJUnitPlatform() 74 | testLogging { 75 | events "passed", "skipped", "failed" 76 | } 77 | } 78 | 79 | mainClassName = 'org.hyperledger.fabric.contract.ContractRouter' 80 | 81 | shadowJar { 82 | baseName = 'chaincode' 83 | version = null 84 | classifier = null 85 | 86 | manifest { 87 | attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter' 88 | } 89 | } 90 | 91 | installDist.dependsOn check -------------------------------------------------------------------------------- /gradle-plugin/plugin/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * This generated file contains a sample Gradle plugin project to get you started. 5 | * For more details take a look at the Writing Custom Plugins chapter in the Gradle 6 | * User Manual available at https://docs.gradle.org/7.0/userguide/custom_plugins.html 7 | */ 8 | 9 | plugins { 10 | // Apply the Java Gradle plugin development plugin to add support for developing Gradle plugins 11 | id 'java-gradle-plugin' 12 | id 'maven-publish' 13 | } 14 | 15 | repositories { 16 | // Use Maven Central for resolving dependencies. 17 | mavenCentral() 18 | } 19 | 20 | dependencies { 21 | 22 | // https://mvnrepository.com/artifact/com.google.code.gson/gson 23 | implementation 'com.google.code.gson:gson:2.8.7' 24 | 25 | api 'org.apache.commons:commons-compress:1.20' 26 | 27 | // Use JUnit test framework for unit tests 28 | testImplementation 'junit:junit:4.13.1' 29 | } 30 | 31 | gradlePlugin { 32 | // Define the plugin 33 | plugins { 34 | greeting { 35 | id = 'org.hyperledger.fabric.chaincodepackage' 36 | implementationClass = 'org.hyperledger.fabric.ChaincodePackagePlugin' 37 | } 38 | } 39 | } 40 | 41 | // Add a source set for the functional test suite 42 | sourceSets { 43 | functionalTest { 44 | } 45 | } 46 | 47 | gradlePlugin.testSourceSets(sourceSets.functionalTest) 48 | configurations.functionalTestImplementation.extendsFrom(configurations.testImplementation) 49 | 50 | // Add a task to run the functional tests 51 | tasks.register('functionalTest', Test) { 52 | testClassesDirs = sourceSets.functionalTest.output.classesDirs 53 | classpath = sourceSets.functionalTest.runtimeClasspath 54 | } 55 | 56 | tasks.named('check') { 57 | // Run the functional tests as part of `check` 58 | dependsOn(tasks.functionalTest) 59 | } 60 | group = 'org.hyperledger.fabric' 61 | version = '0.0.1-SNAPSHOT' 62 | 63 | publishing { 64 | publications { 65 | mavenJava(MavenPublication) { 66 | groupId = 'org.hyperledger.fabric' 67 | artifactId = 'chaincodepackage' 68 | version = '0.0.1-SNAPSHOT' 69 | 70 | from components.java 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/scriptsShadow/private.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem private startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME%.. 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and PRIVATE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\lib\chaincode.jar 67 | 68 | @rem Execute private 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %PRIVATE_OPTS% -jar "%CLASSPATH%" %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable PRIVATE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%PRIVATE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/tmp/expandedArchives/org.jacoco.agent-0.8.7.jar_3a83c50b4a016f281c4e9f3500d16b55/about.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | About 6 | 7 | 8 | 9 |

About This Content

10 | 11 |

12 | 2021/05/04 13 |

14 | 15 |

License

16 | 17 |

18 | All Content in this distribution is made available by Mountainminds GmbH & Co. 19 | KG, Munich. Unless otherwise indicated below, the Content is provided to you 20 | under the terms and conditions of the Eclipse Public License Version 2.0 21 | ("EPL"). A copy of the EPL is available at 22 | https://www.eclipse.org/legal/epl-2.0/. 23 | For purposes of the EPL, "Program" will mean the Content. 24 |

25 | 26 |

Third Party Content

27 | 28 |

29 | The Content includes items that have been sourced from third parties as set 30 | out below. 31 |

32 | 33 |

ASM

34 | 35 |

36 | ASM 9.1 is subject to the terms and 37 | conditions of the following license: 38 |

39 | 40 |
41 | ASM: a very small and fast Java bytecode manipulation framework
42 | Copyright (c) 2000-2011 INRIA, France Telecom
43 | All rights reserved.
44 | 
45 | Redistribution and use in source and binary forms, with or without
46 | modification, are permitted provided that the following conditions
47 | are met:
48 | 1. Redistributions of source code must retain the above copyright
49 |    notice, this list of conditions and the following disclaimer.
50 | 2. Redistributions in binary form must reproduce the above copyright
51 |    notice, this list of conditions and the following disclaimer in the
52 |    documentation and/or other materials provided with the distribution.
53 | 3. Neither the name of the copyright holders nor the names of its
54 |    contributors may be used to endorse or promote products derived from
55 |    this software without specific prior written permission.
56 | 
57 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
58 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
60 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
61 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
62 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
63 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
64 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
65 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
67 | THE POSSIBILITY OF SUCH DAMAGE.
68 | 
69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/reports/tests/test/packages/org.hyperledger.fabric.samples.privatedata.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Test results - Package org.hyperledger.fabric.samples.privatedata 7 | 8 | 9 | 10 | 11 | 12 |
13 |

Package org.hyperledger.fabric.samples.privatedata

14 | 16 |
17 | 18 | 19 | 51 | 57 | 58 |
20 |
21 | 22 | 23 | 29 | 35 | 41 | 47 | 48 |
24 |
25 |
6
26 |

tests

27 |
28 |
30 |
31 |
0
32 |

failures

33 |
34 |
36 |
37 |
0
38 |

ignored

39 |
40 |
42 |
43 |
5.039s
44 |

duration

45 |
46 |
49 |
50 |
52 |
53 |
100%
54 |

successful

55 |
56 |
59 |
60 |
61 | 66 |
67 |

Classes

68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 93 | 94 | 95 | 96 | 97 | 98 | 99 |
ClassTestsFailuresIgnoredDurationSuccess rate
81 | InvokeWriteTransaction 82 | 3000.285s100%
91 | QueryReadAssetTransaction 92 | 3004.754s100%
100 |
101 |
102 | 111 |
112 | 113 | 114 | -------------------------------------------------------------------------------- /gradle-plugin/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/scripts/private.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem private startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME%.. 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and PRIVATE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS= 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\lib\private-1.0-SNAPSHOT.jar;%APP_HOME%\lib\json-20211205.jar 71 | 72 | 73 | @rem Execute private 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %PRIVATE_OPTS% -classpath "%CLASSPATH%" org.hyperledger.fabric.contract.ContractRouter %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable PRIVATE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%PRIVATE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/reports/tests/test/classes/org.hyperledger.fabric.samples.privatedata.AssetTransferTest$QueryReadAssetTransaction.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Test results - QueryReadAssetTransaction 7 | 8 | 9 | 10 | 11 | 12 |
13 |

QueryReadAssetTransaction

14 | 17 |
18 | 19 | 20 | 52 | 58 | 59 |
21 |
22 | 23 | 24 | 30 | 36 | 42 | 48 | 49 |
25 |
26 |
3
27 |

tests

28 |
29 |
31 |
32 |
0
33 |

failures

34 |
35 |
37 |
38 |
0
39 |

ignored

40 |
41 |
43 |
44 |
4.754s
45 |

duration

46 |
47 |
50 |
51 |
53 |
54 |
100%
55 |

successful

56 |
57 |
60 |
61 |
62 | 70 |
71 |

Tests

72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 |
TestDurationResult
invokeUnknownTransaction()0.037spassed
whenAssetDoesNotExist()0.040spassed
whenAssetExists()4.677spassed
96 |
97 |
98 |

Standard output

99 | 100 |
ReadAsset: collection assetCollection, ID asset1
101 | ReadAsset: collection assetCollection, ID asset1
102 | Asset not found: ID asset1
103 | 
104 |
105 |
106 |
107 | 116 |
117 | 118 | 119 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/reports/tests/test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Test results - Test Summary 7 | 8 | 9 | 10 | 11 | 12 |
13 |

Test Summary

14 |
15 | 16 | 17 | 49 | 55 | 56 |
18 |
19 | 20 | 21 | 27 | 33 | 39 | 45 | 46 |
22 |
23 |
6
24 |

tests

25 |
26 |
28 |
29 |
0
30 |

failures

31 |
32 |
34 |
35 |
0
36 |

ignored

37 |
38 |
40 |
41 |
5.039s
42 |

duration

43 |
44 |
47 |
48 |
50 |
51 |
100%
52 |

successful

53 |
54 |
57 |
58 |
59 | 67 |
68 |

Packages

69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 |
PackageTestsFailuresIgnoredDurationSuccess rate
83 | org.hyperledger.fabric.samples.privatedata 84 | 6005.039s100%
93 |
94 |
95 |

Classes

96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 |
ClassTestsFailuresIgnoredDurationSuccess rate
110 | org.hyperledger.fabric.samples.privatedata.AssetTransferTest$InvokeWriteTransaction 111 | 3000.285s100%
120 | org.hyperledger.fabric.samples.privatedata.AssetTransferTest$QueryReadAssetTransaction 121 | 3004.754s100%
130 |
131 |
132 | 141 |
142 | 143 | 144 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/reports/tests/test/css/base-style.css: -------------------------------------------------------------------------------- 1 | 2 | body { 3 | margin: 0; 4 | padding: 0; 5 | font-family: sans-serif; 6 | font-size: 12pt; 7 | } 8 | 9 | body, a, a:visited { 10 | color: #303030; 11 | } 12 | 13 | #content { 14 | padding-left: 50px; 15 | padding-right: 50px; 16 | padding-top: 30px; 17 | padding-bottom: 30px; 18 | } 19 | 20 | #content h1 { 21 | font-size: 160%; 22 | margin-bottom: 10px; 23 | } 24 | 25 | #footer { 26 | margin-top: 100px; 27 | font-size: 80%; 28 | white-space: nowrap; 29 | } 30 | 31 | #footer, #footer a { 32 | color: #a0a0a0; 33 | } 34 | 35 | #line-wrapping-toggle { 36 | vertical-align: middle; 37 | } 38 | 39 | #label-for-line-wrapping-toggle { 40 | vertical-align: middle; 41 | } 42 | 43 | ul { 44 | margin-left: 0; 45 | } 46 | 47 | h1, h2, h3 { 48 | white-space: nowrap; 49 | } 50 | 51 | h2 { 52 | font-size: 120%; 53 | } 54 | 55 | ul.tabLinks { 56 | padding-left: 0; 57 | padding-top: 10px; 58 | padding-bottom: 10px; 59 | overflow: auto; 60 | min-width: 800px; 61 | width: auto !important; 62 | width: 800px; 63 | } 64 | 65 | ul.tabLinks li { 66 | float: left; 67 | height: 100%; 68 | list-style: none; 69 | padding-left: 10px; 70 | padding-right: 10px; 71 | padding-top: 5px; 72 | padding-bottom: 5px; 73 | margin-bottom: 0; 74 | -moz-border-radius: 7px; 75 | border-radius: 7px; 76 | margin-right: 25px; 77 | border: solid 1px #d4d4d4; 78 | background-color: #f0f0f0; 79 | } 80 | 81 | ul.tabLinks li:hover { 82 | background-color: #fafafa; 83 | } 84 | 85 | ul.tabLinks li.selected { 86 | background-color: #c5f0f5; 87 | border-color: #c5f0f5; 88 | } 89 | 90 | ul.tabLinks a { 91 | font-size: 120%; 92 | display: block; 93 | outline: none; 94 | text-decoration: none; 95 | margin: 0; 96 | padding: 0; 97 | } 98 | 99 | ul.tabLinks li h2 { 100 | margin: 0; 101 | padding: 0; 102 | } 103 | 104 | div.tab { 105 | } 106 | 107 | div.selected { 108 | display: block; 109 | } 110 | 111 | div.deselected { 112 | display: none; 113 | } 114 | 115 | div.tab table { 116 | min-width: 350px; 117 | width: auto !important; 118 | width: 350px; 119 | border-collapse: collapse; 120 | } 121 | 122 | div.tab th, div.tab table { 123 | border-bottom: solid #d0d0d0 1px; 124 | } 125 | 126 | div.tab th { 127 | text-align: left; 128 | white-space: nowrap; 129 | padding-left: 6em; 130 | } 131 | 132 | div.tab th:first-child { 133 | padding-left: 0; 134 | } 135 | 136 | div.tab td { 137 | white-space: nowrap; 138 | padding-left: 6em; 139 | padding-top: 5px; 140 | padding-bottom: 5px; 141 | } 142 | 143 | div.tab td:first-child { 144 | padding-left: 0; 145 | } 146 | 147 | div.tab td.numeric, div.tab th.numeric { 148 | text-align: right; 149 | } 150 | 151 | span.code { 152 | display: inline-block; 153 | margin-top: 0em; 154 | margin-bottom: 1em; 155 | } 156 | 157 | span.code pre { 158 | font-size: 11pt; 159 | padding-top: 10px; 160 | padding-bottom: 10px; 161 | padding-left: 10px; 162 | padding-right: 10px; 163 | margin: 0; 164 | background-color: #f7f7f7; 165 | border: solid 1px #d0d0d0; 166 | min-width: 700px; 167 | width: auto !important; 168 | width: 700px; 169 | } 170 | 171 | span.wrapped pre { 172 | word-wrap: break-word; 173 | white-space: pre-wrap; 174 | word-break: break-all; 175 | } 176 | 177 | label.hidden { 178 | display: none; 179 | } -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/reports/checkstyle/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 55 | 56 | 57 | 58 | 59 | 60 | 63 | 64 | 65 | 66 | 67 |
61 |

CheckStyle Audit

62 |
Designed for use with CheckStyle and Ant.
68 |
69 |

Summary

70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 |
FilesErrors
10
78 |
79 |

Files

80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 |
NameErrors
/home/matthew/github.com/hyperledgendary/fabric-chaincode-build/_exampleusage/ExampleContract/src/src/test/java/org/hyperledger/fabric/samples/privatedata/AssetTransferTest.java0
88 |
89 | 90 |

File /home/matthew/github.com/hyperledgendary/fabric-chaincode-build/_exampleusage/ExampleContract/src/src/test/java/org/hyperledger/fabric/samples/privatedata/AssetTransferTest.java

91 | 92 | 93 | 94 | 95 |
Error DescriptionLine
96 | Back to top 97 |
98 | 99 | 100 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/src/main/java/org/hyperledger/fabric/samples/privatedata/Asset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | package org.hyperledger.fabric.samples.privatedata; 6 | 7 | import java.util.Objects; 8 | 9 | import static java.nio.charset.StandardCharsets.UTF_8; 10 | 11 | import org.hyperledger.fabric.contract.annotation.DataType; 12 | import org.hyperledger.fabric.contract.annotation.Property; 13 | 14 | import org.hyperledger.fabric.shim.ChaincodeException; 15 | import org.json.JSONObject; 16 | 17 | @DataType() 18 | public final class Asset { 19 | 20 | @Property() 21 | private final String assetID; 22 | 23 | @Property() 24 | private final String objectType; 25 | 26 | @Property() 27 | private final String color; 28 | 29 | @Property() 30 | private final int size; 31 | 32 | @Property() 33 | private String owner; 34 | 35 | public String getAssetID() { 36 | return assetID; 37 | } 38 | 39 | public String getColor() { 40 | return color; 41 | } 42 | 43 | public int getSize() { 44 | return size; 45 | } 46 | 47 | public String getOwner() { 48 | return owner; 49 | } 50 | 51 | public String getObjectType() { 52 | return objectType; 53 | } 54 | 55 | public void setOwner(final String newowner) { 56 | owner = newowner; 57 | } 58 | 59 | public Asset(final String type, 60 | final String assetID, final String color, 61 | final int size, final String owner) { 62 | this.objectType = type; 63 | this.assetID = assetID; 64 | this.color = color; 65 | this.size = size; 66 | this.owner = owner; 67 | } 68 | 69 | public byte[] serialize() { 70 | String jsonStr = new JSONObject(this).toString(); 71 | return jsonStr.getBytes(UTF_8); 72 | } 73 | 74 | public static Asset deserialize(final byte[] assetJSON) { 75 | return deserialize(new String(assetJSON, UTF_8)); 76 | } 77 | 78 | public static Asset deserialize(final String assetJSON) { 79 | try { 80 | JSONObject json = new JSONObject(assetJSON); 81 | final String id = json.getString("assetID"); 82 | final String type = json.getString("objectType"); 83 | final String color = json.getString("color"); 84 | final String owner = json.getString("owner"); 85 | final int size = json.getInt("size"); 86 | return new Asset(type, id, color, size, owner); 87 | } catch (Exception e) { 88 | throw new ChaincodeException("Deserialize error: " + e.getMessage(), "DATA_ERROR"); 89 | } 90 | } 91 | 92 | @Override 93 | public boolean equals(final Object obj) { 94 | if (this == obj) { 95 | return true; 96 | } 97 | 98 | if ((obj == null) || (getClass() != obj.getClass())) { 99 | return false; 100 | } 101 | 102 | Asset other = (Asset) obj; 103 | 104 | return Objects.deepEquals( 105 | new String[]{getAssetID(), getColor(), getOwner()}, 106 | new String[]{other.getAssetID(), other.getColor(), other.getOwner()}) 107 | && 108 | Objects.deepEquals( 109 | new int[]{getSize()}, 110 | new int[]{other.getSize()}); 111 | } 112 | 113 | @Override 114 | public int hashCode() { 115 | return Objects.hash(getObjectType(), getAssetID(), getColor(), getSize(), getOwner()); 116 | } 117 | 118 | @Override 119 | public String toString() { 120 | return this.getClass().getSimpleName() + "@" + Integer.toHexString(hashCode()) 121 | + " [assetID=" + assetID + ", type=" + objectType + ", color=" 122 | + color + ", size=" + size + ", owner=" + owner + "]"; 123 | } 124 | 125 | 126 | } 127 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/reports/tests/test/classes/org.hyperledger.fabric.samples.privatedata.AssetTransferTest$InvokeWriteTransaction.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Test results - InvokeWriteTransaction 7 | 8 | 9 | 10 | 11 | 12 |
13 |

InvokeWriteTransaction

14 | 17 |
18 | 19 | 20 | 52 | 58 | 59 |
21 |
22 | 23 | 24 | 30 | 36 | 42 | 48 | 49 |
25 |
26 |
3
27 |

tests

28 |
29 |
31 |
32 |
0
33 |

failures

34 |
35 |
37 |
38 |
0
39 |

ignored

40 |
41 |
43 |
44 |
0.285s
45 |

duration

46 |
47 |
50 |
51 |
53 |
54 |
100%
55 |

successful

56 |
57 |
60 |
61 |
62 | 73 |
74 |

Tests

75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 |
TestDurationResult
createAssetWhenAssetExists()0.016spassed
createAssetWhenNewAssetIsCreated()0.030spassed
transferAssetWhenExistingAssetIsTransferred()0.239spassed
99 |
100 |
101 |

Standard output

102 | 103 |
TransferAsset: verify asset asset1 exists
104 | ReadTransferAgreement Get: collection assetCollection, ID asset1, Key transferAgreementasset1
105 | Transfer Asset: collection assetCollection, ID asset1 to owner TestOrg2User
106 | AgreeToTransfer deleteKey: collection assetCollection, ID asset1, Key transferAgreementasset1
107 | CreateAsset Put: collection assetCollection, ID asset1
108 | Put: collection assetCollection, ID {"owner":"testOrg1User","color":"blue","size":5,"assetID":"asset1","objectType":"testasset"}
109 | Put AssetPrivateDetails: collection TestOrg1PrivateCollection, ID asset1
110 | 
111 |
112 |
113 |
114 |

Standard error

115 | 116 |
Asset asset1 already exists
117 | 
118 |
119 |
120 |
121 | 130 |
131 | 132 | 133 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/tmp/expandedArchives/org.jacoco.agent-0.8.7.jar_3a83c50b4a016f281c4e9f3500d16b55/META-INF/maven/org.jacoco/org.jacoco.agent/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 4.0.0 15 | 16 | 17 | org.jacoco 18 | org.jacoco.build 19 | 0.8.7 20 | ../org.jacoco.build 21 | 22 | 23 | org.jacoco.agent 24 | 25 | JaCoCo :: Agent 26 | JaCoCo Agent 27 | 28 | 29 | src 30 | 31 | 32 | 33 | org.apache.maven.plugins 34 | maven-dependency-plugin 35 | 36 | 37 | prepare-package 38 | 39 | copy 40 | 41 | 42 | 43 | 44 | ${project.groupId} 45 | org.jacoco.agent.rt 46 | all 47 | ${project.version} 48 | jacocoagent.jar 49 | 50 | 51 | ${project.build.directory}/classes 52 | false 53 | false 54 | true 55 | 56 | 57 | 58 | 59 | 60 | 61 | org.codehaus.mojo 62 | build-helper-maven-plugin 63 | 64 | 65 | attach-artifacts 66 | package 67 | 68 | attach-artifact 69 | 70 | 71 | 72 | 73 | ${project.build.directory}/classes/jacocoagent.jar 74 | jar 75 | runtime 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | org.apache.felix 85 | maven-bundle-plugin 86 | 87 | 88 | process-classes 89 | 90 | manifest 91 | 92 | 93 | 94 | 95 | 96 | org.apache.maven.plugins 97 | maven-jar-plugin 98 | 99 | 100 | ${project.build.outputDirectory}/META-INF/MANIFEST.MF 101 | 102 | 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/scriptsShadow/private: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## private start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/.." >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="private" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and PRIVATE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn ( ) { 37 | echo "$*" 38 | } 39 | 40 | die ( ) { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/lib/chaincode.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save() { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- "$DEFAULT_JVM_OPTS" "$JAVA_OPTS" "$GRADLE_OPTS" -jar "\"$CLASSPATH\"" "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/reports/tests/test/js/report.js: -------------------------------------------------------------------------------- 1 | (function (window, document) { 2 | "use strict"; 3 | 4 | var tabs = {}; 5 | 6 | function changeElementClass(element, classValue) { 7 | if (element.getAttribute("className")) { 8 | element.setAttribute("className", classValue); 9 | } else { 10 | element.setAttribute("class", classValue); 11 | } 12 | } 13 | 14 | function getClassAttribute(element) { 15 | if (element.getAttribute("className")) { 16 | return element.getAttribute("className"); 17 | } else { 18 | return element.getAttribute("class"); 19 | } 20 | } 21 | 22 | function addClass(element, classValue) { 23 | changeElementClass(element, getClassAttribute(element) + " " + classValue); 24 | } 25 | 26 | function removeClass(element, classValue) { 27 | changeElementClass(element, getClassAttribute(element).replace(classValue, "")); 28 | } 29 | 30 | function initTabs() { 31 | var container = document.getElementById("tabs"); 32 | 33 | tabs.tabs = findTabs(container); 34 | tabs.titles = findTitles(tabs.tabs); 35 | tabs.headers = findHeaders(container); 36 | tabs.select = select; 37 | tabs.deselectAll = deselectAll; 38 | tabs.select(0); 39 | 40 | return true; 41 | } 42 | 43 | function getCheckBox() { 44 | return document.getElementById("line-wrapping-toggle"); 45 | } 46 | 47 | function getLabelForCheckBox() { 48 | return document.getElementById("label-for-line-wrapping-toggle"); 49 | } 50 | 51 | function findCodeBlocks() { 52 | var spans = document.getElementById("tabs").getElementsByTagName("span"); 53 | var codeBlocks = []; 54 | for (var i = 0; i < spans.length; ++i) { 55 | if (spans[i].className.indexOf("code") >= 0) { 56 | codeBlocks.push(spans[i]); 57 | } 58 | } 59 | return codeBlocks; 60 | } 61 | 62 | function forAllCodeBlocks(operation) { 63 | var codeBlocks = findCodeBlocks(); 64 | 65 | for (var i = 0; i < codeBlocks.length; ++i) { 66 | operation(codeBlocks[i], "wrapped"); 67 | } 68 | } 69 | 70 | function toggleLineWrapping() { 71 | var checkBox = getCheckBox(); 72 | 73 | if (checkBox.checked) { 74 | forAllCodeBlocks(addClass); 75 | } else { 76 | forAllCodeBlocks(removeClass); 77 | } 78 | } 79 | 80 | function initControls() { 81 | if (findCodeBlocks().length > 0) { 82 | var checkBox = getCheckBox(); 83 | var label = getLabelForCheckBox(); 84 | 85 | checkBox.onclick = toggleLineWrapping; 86 | checkBox.checked = false; 87 | 88 | removeClass(label, "hidden"); 89 | } 90 | } 91 | 92 | function switchTab() { 93 | var id = this.id.substr(1); 94 | 95 | for (var i = 0; i < tabs.tabs.length; i++) { 96 | if (tabs.tabs[i].id === id) { 97 | tabs.select(i); 98 | break; 99 | } 100 | } 101 | 102 | return false; 103 | } 104 | 105 | function select(i) { 106 | this.deselectAll(); 107 | 108 | changeElementClass(this.tabs[i], "tab selected"); 109 | changeElementClass(this.headers[i], "selected"); 110 | 111 | while (this.headers[i].firstChild) { 112 | this.headers[i].removeChild(this.headers[i].firstChild); 113 | } 114 | 115 | var h2 = document.createElement("H2"); 116 | 117 | h2.appendChild(document.createTextNode(this.titles[i])); 118 | this.headers[i].appendChild(h2); 119 | } 120 | 121 | function deselectAll() { 122 | for (var i = 0; i < this.tabs.length; i++) { 123 | changeElementClass(this.tabs[i], "tab deselected"); 124 | changeElementClass(this.headers[i], "deselected"); 125 | 126 | while (this.headers[i].firstChild) { 127 | this.headers[i].removeChild(this.headers[i].firstChild); 128 | } 129 | 130 | var a = document.createElement("A"); 131 | 132 | a.setAttribute("id", "ltab" + i); 133 | a.setAttribute("href", "#tab" + i); 134 | a.onclick = switchTab; 135 | a.appendChild(document.createTextNode(this.titles[i])); 136 | 137 | this.headers[i].appendChild(a); 138 | } 139 | } 140 | 141 | function findTabs(container) { 142 | return findChildElements(container, "DIV", "tab"); 143 | } 144 | 145 | function findHeaders(container) { 146 | var owner = findChildElements(container, "UL", "tabLinks"); 147 | return findChildElements(owner[0], "LI", null); 148 | } 149 | 150 | function findTitles(tabs) { 151 | var titles = []; 152 | 153 | for (var i = 0; i < tabs.length; i++) { 154 | var tab = tabs[i]; 155 | var header = findChildElements(tab, "H2", null)[0]; 156 | 157 | header.parentNode.removeChild(header); 158 | 159 | if (header.innerText) { 160 | titles.push(header.innerText); 161 | } else { 162 | titles.push(header.textContent); 163 | } 164 | } 165 | 166 | return titles; 167 | } 168 | 169 | function findChildElements(container, name, targetClass) { 170 | var elements = []; 171 | var children = container.childNodes; 172 | 173 | for (var i = 0; i < children.length; i++) { 174 | var child = children.item(i); 175 | 176 | if (child.nodeType === 1 && child.nodeName === name) { 177 | if (targetClass && child.className.indexOf(targetClass) < 0) { 178 | continue; 179 | } 180 | 181 | elements.push(child); 182 | } 183 | } 184 | 185 | return elements; 186 | } 187 | 188 | // Entry point. 189 | 190 | window.onload = function() { 191 | initTabs(); 192 | initControls(); 193 | }; 194 | } (window, window.document)); -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/reports/checkstyle/main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 55 | 56 | 57 | 58 | 59 | 60 | 63 | 64 | 65 | 66 | 67 |
61 |

CheckStyle Audit

62 |
Designed for use with CheckStyle and Ant.
68 |
69 |

Summary

70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 |
FilesErrors
40
78 |
79 |

Files

80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 |
NameErrors
/home/matthew/github.com/hyperledgendary/fabric-chaincode-build/_exampleusage/ExampleContract/src/src/main/java/org/hyperledger/fabric/samples/privatedata/Asset.java0
/home/matthew/github.com/hyperledgendary/fabric-chaincode-build/_exampleusage/ExampleContract/src/src/main/java/org/hyperledger/fabric/samples/privatedata/AssetPrivateDetails.java0
/home/matthew/github.com/hyperledgendary/fabric-chaincode-build/_exampleusage/ExampleContract/src/src/main/java/org/hyperledger/fabric/samples/privatedata/AssetTransfer.java0
/home/matthew/github.com/hyperledgendary/fabric-chaincode-build/_exampleusage/ExampleContract/src/src/main/java/org/hyperledger/fabric/samples/privatedata/TransferAgreement.java0
97 |
98 | 99 |

File /home/matthew/github.com/hyperledgendary/fabric-chaincode-build/_exampleusage/ExampleContract/src/src/main/java/org/hyperledger/fabric/samples/privatedata/Asset.java

100 | 101 | 102 | 103 | 104 |
Error DescriptionLine
105 | Back to top 106 |

File /home/matthew/github.com/hyperledgendary/fabric-chaincode-build/_exampleusage/ExampleContract/src/src/main/java/org/hyperledger/fabric/samples/privatedata/AssetPrivateDetails.java

107 | 108 | 109 | 110 | 111 |
Error DescriptionLine
112 | Back to top 113 |

File /home/matthew/github.com/hyperledgendary/fabric-chaincode-build/_exampleusage/ExampleContract/src/src/main/java/org/hyperledger/fabric/samples/privatedata/AssetTransfer.java

114 | 115 | 116 | 117 | 118 |
Error DescriptionLine
119 | Back to top 120 |

File /home/matthew/github.com/hyperledgendary/fabric-chaincode-build/_exampleusage/ExampleContract/src/src/main/java/org/hyperledger/fabric/samples/privatedata/TransferAgreement.java

121 | 122 | 123 | 124 | 125 |
Error DescriptionLine
126 | Back to top 127 |
128 | 129 | 130 | -------------------------------------------------------------------------------- /gradle-plugin/plugin/src/main/java/org/hyperledger/fabric/Library.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Java source file was generated by the Gradle 'init' task. 3 | */ 4 | package org.hyperledger.fabric; 5 | 6 | import java.io.BufferedOutputStream; 7 | import java.io.ByteArrayOutputStream; 8 | import java.io.IOException; 9 | import java.io.OutputStream; 10 | import java.nio.file.FileVisitResult; 11 | import java.nio.file.Files; 12 | import java.nio.file.Path; 13 | import java.nio.file.Paths; 14 | import java.nio.file.SimpleFileVisitor; 15 | import java.nio.file.attribute.BasicFileAttributes; 16 | import java.util.Optional; 17 | 18 | import com.google.gson.Gson; 19 | 20 | import org.apache.commons.compress.archivers.tar.TarArchiveEntry; 21 | import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; 22 | import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream; 23 | 24 | public class Library { 25 | 26 | public static class Builder { 27 | private Builder() { 28 | this.metainf = Optional.empty(); 29 | } 30 | 31 | private Optional metainf; 32 | private Path fatJar; 33 | private Path outputFilename; 34 | private String label; 35 | 36 | 37 | public Builder metainf(Path metainf) { 38 | this.metainf = Optional.of(metainf.normalize()); 39 | return this; 40 | } 41 | 42 | public Builder fatjar(Path fatJar) { 43 | this.fatJar = fatJar.normalize(); 44 | return this; 45 | } 46 | 47 | public Builder label(String label){ 48 | this.label = label; 49 | return this; 50 | } 51 | 52 | public Builder output(Path outputFilename){ 53 | this.outputFilename = outputFilename; 54 | return this; 55 | } 56 | 57 | public Library build() { 58 | if (metainf.isPresent() && !Files.exists(metainf.get())) { 59 | throw new RuntimeException("Unable to find " + metainf); 60 | } 61 | 62 | if (fatJar == null || !Files.exists(fatJar)) { 63 | throw new RuntimeException("FatJar: Unable to find :" + fatJar+":"); 64 | } 65 | 66 | // check directory?? 67 | if (outputFilename == null || !Files.exists(outputFilename.getParent())) { 68 | throw new RuntimeException("OutputFilename: Unable to find :" + outputFilename +":"); 69 | } 70 | 71 | if (label == null){ 72 | throw new RuntimeException("Label is not specified"); 73 | } 74 | 75 | return new Library(metainf.get(), fatJar, outputFilename, label); 76 | } 77 | } 78 | 79 | public static Builder newBuilder() { 80 | return new Builder(); 81 | } 82 | 83 | 84 | public static class Metadata{ 85 | String label; 86 | String path; 87 | String type="java"; 88 | } 89 | 90 | private Path metainf; 91 | private Path fatJar; 92 | private Path outputFilename; 93 | private String label; 94 | 95 | private Library(Path metainf, Path fatJar,Path outputFilename, String label) { 96 | this.metainf = metainf; 97 | this.fatJar = fatJar; 98 | this.outputFilename = outputFilename; 99 | this.label = label; 100 | }; 101 | 102 | public void pack() throws IOException { 103 | byte[] innerTgz; 104 | 105 | try (ByteArrayOutputStream fOut = new ByteArrayOutputStream()) { 106 | BufferedOutputStream buffOut = new BufferedOutputStream(fOut); 107 | GzipCompressorOutputStream gzOut = new GzipCompressorOutputStream(buffOut); 108 | TarArchiveOutputStream tOut = new TarArchiveOutputStream(gzOut); 109 | 110 | Path source = this.metainf; 111 | 112 | Files.walkFileTree(source, new SimpleFileVisitor<>() { 113 | 114 | @Override 115 | public FileVisitResult visitFile(Path file, BasicFileAttributes attributes) { 116 | 117 | // only copy files, no symbolic links 118 | if (attributes.isSymbolicLink()) { 119 | return FileVisitResult.CONTINUE; 120 | } 121 | 122 | // get filename 123 | 124 | Path targetFile = Paths.get("META-INF", source.relativize(file).toString()); 125 | System.out.println("source=" + source + " file=" + file + " targetFile=" + targetFile); 126 | try { 127 | TarArchiveEntry tarEntry = new TarArchiveEntry(file.toFile(), targetFile.toString()); 128 | 129 | tOut.putArchiveEntry(tarEntry); 130 | 131 | Files.copy(file, tOut); 132 | 133 | tOut.closeArchiveEntry(); 134 | 135 | System.out.printf("file : %s%n", file); 136 | 137 | } catch (IOException e) { 138 | System.err.printf("Unable to tar.gz : %s%n%s%n", file, e); 139 | } 140 | 141 | return FileVisitResult.CONTINUE; 142 | } 143 | 144 | @Override 145 | public FileVisitResult visitFileFailed(Path file, IOException exc) { 146 | System.err.printf("Unable to tar.gz : %s%n%s%n", file, exc); 147 | return FileVisitResult.CONTINUE; 148 | } 149 | 150 | }); 151 | 152 | // add the jar file to the src directory 153 | TarArchiveEntry jarFileEntry = new TarArchiveEntry(this.fatJar.toFile(), 154 | Paths.get("src", "chaincode.jar").toString()); 155 | tOut.putArchiveEntry(jarFileEntry); 156 | Files.copy(this.fatJar, tOut); 157 | tOut.closeArchiveEntry(); 158 | 159 | tOut.finish(); 160 | tOut.flush(); 161 | tOut.close(); 162 | innerTgz = fOut.toByteArray(); 163 | } 164 | 165 | // create the output 166 | try (OutputStream fOut = Files.newOutputStream(this.outputFilename)) { 167 | BufferedOutputStream buffOut = new BufferedOutputStream(fOut); 168 | GzipCompressorOutputStream gzOut = new GzipCompressorOutputStream(buffOut); 169 | TarArchiveOutputStream tOut = new TarArchiveOutputStream(gzOut); 170 | TarArchiveEntry metadataEntry = new TarArchiveEntry("metadata.json"); 171 | 172 | Metadata md = new Metadata(); 173 | md.label=this.label; 174 | 175 | Gson gson = new Gson(); 176 | byte[] b = gson.toJson(md).getBytes(); 177 | 178 | metadataEntry.setSize(b.length); 179 | tOut.putArchiveEntry(metadataEntry); 180 | tOut.write(b); 181 | tOut.closeArchiveEntry(); 182 | 183 | 184 | TarArchiveEntry codetgz = new TarArchiveEntry("code.tar.gz"); 185 | codetgz.setSize(innerTgz.length); 186 | tOut.putArchiveEntry(codetgz); 187 | tOut.write(innerTgz); 188 | tOut.closeArchiveEntry(); 189 | 190 | 191 | tOut.finish(); 192 | tOut.flush(); 193 | tOut.close(); 194 | } 195 | 196 | } 197 | 198 | } 199 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/config/checkstyle/checkstyle.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 20 | 21 | 22 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/src/test/java/org/hyperledger/fabric/samples/privatedata/AssetTransferTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | package org.hyperledger.fabric.samples.privatedata; 6 | 7 | import static org.assertj.core.api.Assertions.assertThat; 8 | import static org.assertj.core.api.ThrowableAssert.catchThrowable; 9 | import static java.nio.charset.StandardCharsets.UTF_8; 10 | import static org.hyperledger.fabric.samples.privatedata.AssetTransfer.AGREEMENT_KEYPREFIX; 11 | import static org.hyperledger.fabric.samples.privatedata.AssetTransfer.ASSET_COLLECTION_NAME; 12 | import static org.mockito.ArgumentMatchers.anyString; 13 | import static org.mockito.Mockito.mock; 14 | import static org.mockito.Mockito.verify; 15 | import static org.mockito.Mockito.verifyZeroInteractions; 16 | import static org.mockito.Mockito.when; 17 | 18 | import java.io.IOException; 19 | import java.security.cert.CertificateException; 20 | import java.util.HashMap; 21 | import java.util.Map; 22 | import org.hyperledger.fabric.contract.ClientIdentity; 23 | import org.hyperledger.fabric.contract.Context; 24 | import org.hyperledger.fabric.shim.ChaincodeException; 25 | import org.hyperledger.fabric.shim.ChaincodeStub; 26 | import org.hyperledger.fabric.shim.ledger.CompositeKey; 27 | import org.junit.jupiter.api.Nested; 28 | import org.junit.jupiter.api.Test; 29 | 30 | public final class AssetTransferTest { 31 | 32 | @Nested 33 | class InvokeWriteTransaction { 34 | 35 | @Test 36 | public void createAssetWhenAssetExists() { 37 | AssetTransfer contract = new AssetTransfer(); 38 | Context ctx = mock(Context.class); 39 | ChaincodeStub stub = mock(ChaincodeStub.class); 40 | when(ctx.getStub()).thenReturn(stub); 41 | Map m = new HashMap(); 42 | m.put("asset_properties", dataAsset1Bytes); 43 | when(ctx.getStub().getTransient()).thenReturn(m); 44 | when(stub.getPrivateData(ASSET_COLLECTION_NAME, testAsset1ID)) 45 | .thenReturn(dataAsset1Bytes); 46 | 47 | Throwable thrown = catchThrowable(() -> { 48 | contract.CreateAsset(ctx); 49 | }); 50 | 51 | assertThat(thrown).isInstanceOf(ChaincodeException.class).hasNoCause() 52 | .hasMessage("Asset asset1 already exists"); 53 | assertThat(((ChaincodeException) thrown).getPayload()).isEqualTo("ASSET_ALREADY_EXISTS".getBytes()); 54 | } 55 | 56 | @Test 57 | public void createAssetWhenNewAssetIsCreated() throws CertificateException, IOException { 58 | AssetTransfer contract = new AssetTransfer(); 59 | Context ctx = mock(Context.class); 60 | ChaincodeStub stub = mock(ChaincodeStub.class); 61 | when(ctx.getStub()).thenReturn(stub); 62 | when(stub.getMspId()).thenReturn(testOrgOneMSP); 63 | ClientIdentity ci = mock(ClientIdentity.class); 64 | when(ci.getId()).thenReturn(testOrg1Client); 65 | when(ci.getMSPID()).thenReturn(testOrgOneMSP); 66 | when(ctx.getClientIdentity()).thenReturn(ci); 67 | 68 | Map m = new HashMap(); 69 | m.put("asset_properties", dataAsset1Bytes); 70 | when(ctx.getStub().getTransient()).thenReturn(m); 71 | 72 | when(stub.getPrivateData(ASSET_COLLECTION_NAME, testAsset1ID)) 73 | .thenReturn(new byte[0]); 74 | 75 | Asset created = contract.CreateAsset(ctx); 76 | assertThat(created).isEqualTo(testAsset1); 77 | 78 | verify(stub).putPrivateData(ASSET_COLLECTION_NAME, testAsset1ID, created.serialize()); 79 | } 80 | 81 | @Test 82 | public void transferAssetWhenExistingAssetIsTransferred() throws CertificateException, IOException { 83 | AssetTransfer contract = new AssetTransfer(); 84 | Context ctx = mock(Context.class); 85 | ChaincodeStub stub = mock(ChaincodeStub.class); 86 | when(ctx.getStub()).thenReturn(stub); 87 | when(stub.getMspId()).thenReturn(testOrgOneMSP); 88 | ClientIdentity ci = mock(ClientIdentity.class); 89 | when(ci.getId()).thenReturn(testOrg1Client); 90 | when(ctx.getClientIdentity()).thenReturn(ci); 91 | when(ci.getMSPID()).thenReturn(testOrgOneMSP); 92 | final String recipientOrgMsp = "TestOrg2"; 93 | final String buyerIdentity = "TestOrg2User"; 94 | Map m = new HashMap(); 95 | m.put("asset_owner", ("{ \"buyerMSP\": \"" + recipientOrgMsp + "\", \"assetID\": \"" + testAsset1ID + "\" }").getBytes()); 96 | when(ctx.getStub().getTransient()).thenReturn(m); 97 | 98 | when(stub.getPrivateDataHash(anyString(), anyString())).thenReturn("TestHashValue".getBytes()); 99 | when(stub.getPrivateData(ASSET_COLLECTION_NAME, testAsset1ID)) 100 | .thenReturn(dataAsset1Bytes); 101 | CompositeKey ck = mock(CompositeKey.class); 102 | when(ck.toString()).thenReturn(AGREEMENT_KEYPREFIX + testAsset1ID); 103 | when(stub.createCompositeKey(AGREEMENT_KEYPREFIX, testAsset1ID)).thenReturn(ck); 104 | when(stub.getPrivateData(ASSET_COLLECTION_NAME, AGREEMENT_KEYPREFIX + testAsset1ID)).thenReturn(buyerIdentity.getBytes(UTF_8)); 105 | contract.TransferAsset(ctx); 106 | 107 | Asset exptectedAfterTransfer = Asset.deserialize("{ \"objectType\": \"testasset\", \"assetID\": \"asset1\", \"color\": \"blue\", \"size\": 5, \"owner\": \"" + buyerIdentity + "\", \"appraisedValue\": 300 }"); 108 | 109 | verify(stub).putPrivateData(ASSET_COLLECTION_NAME, testAsset1ID, exptectedAfterTransfer.serialize()); 110 | String collectionOwner = testOrgOneMSP + "PrivateCollection"; 111 | verify(stub).delPrivateData(collectionOwner, testAsset1ID); 112 | verify(stub).delPrivateData(ASSET_COLLECTION_NAME, AGREEMENT_KEYPREFIX + testAsset1ID); 113 | } 114 | } 115 | 116 | @Nested 117 | class QueryReadAssetTransaction { 118 | 119 | @Test 120 | public void whenAssetExists() { 121 | AssetTransfer contract = new AssetTransfer(); 122 | Context ctx = mock(Context.class); 123 | ChaincodeStub stub = mock(ChaincodeStub.class); 124 | when(ctx.getStub()).thenReturn(stub); 125 | when(stub.getPrivateData(ASSET_COLLECTION_NAME, testAsset1ID)) 126 | .thenReturn(dataAsset1Bytes); 127 | 128 | Asset asset = contract.ReadAsset(ctx, testAsset1ID); 129 | 130 | assertThat(asset).isEqualTo(testAsset1); 131 | } 132 | 133 | @Test 134 | public void whenAssetDoesNotExist() { 135 | AssetTransfer contract = new AssetTransfer(); 136 | Context ctx = mock(Context.class); 137 | ChaincodeStub stub = mock(ChaincodeStub.class); 138 | when(ctx.getStub()).thenReturn(stub); 139 | when(stub.getStringState(testAsset1ID)).thenReturn(null); 140 | 141 | Asset asset = contract.ReadAsset(ctx, testAsset1ID); 142 | assertThat(asset).isNull(); 143 | } 144 | 145 | @Test 146 | public void invokeUnknownTransaction() { 147 | AssetTransfer contract = new AssetTransfer(); 148 | Context ctx = mock(Context.class); 149 | 150 | Throwable thrown = catchThrowable(() -> { 151 | contract.unknownTransaction(ctx); 152 | }); 153 | 154 | assertThat(thrown).isInstanceOf(ChaincodeException.class).hasNoCause() 155 | .hasMessage("Undefined contract method called"); 156 | assertThat(((ChaincodeException) thrown).getPayload()).isEqualTo(null); 157 | 158 | verifyZeroInteractions(ctx); 159 | } 160 | 161 | } 162 | 163 | private static String testOrgOneMSP = "TestOrg1"; 164 | private static String testOrg1Client = "testOrg1User"; 165 | 166 | private static String testAsset1ID = "asset1"; 167 | private static Asset testAsset1 = new Asset("testasset", "asset1", "blue", 5, testOrg1Client); 168 | private static byte[] dataAsset1Bytes = "{ \"objectType\": \"testasset\", \"assetID\": \"asset1\", \"color\": \"blue\", \"size\": 5, \"owner\": \"testOrg1User\", \"appraisedValue\": 300 }".getBytes(); 169 | 170 | } 171 | -------------------------------------------------------------------------------- /gradle-plugin/gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Use "xargs" to parse quoted args. 209 | # 210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 211 | # 212 | # In Bash we could simply go: 213 | # 214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 215 | # set -- "${ARGS[@]}" "$@" 216 | # 217 | # but POSIX shell has neither arrays nor command substitution, so instead we 218 | # post-process each arg (as a line of input to sed) to backslash-escape any 219 | # character that might be a shell metacharacter, then use eval to reverse 220 | # that process (while maintaining the separation between arguments), and wrap 221 | # the whole thing up as a single "set" statement. 222 | # 223 | # This will of course break if any of these variables contains a newline or 224 | # an unmatched quote. 225 | # 226 | 227 | eval "set -- $( 228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 229 | xargs -n1 | 230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 231 | tr '\n' ' ' 232 | )" '"$@"' 233 | 234 | exec "$JAVACMD" "$@" 235 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/build/scripts/private: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # private start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh private 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and PRIVATE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}.." && pwd -P ) || exit 84 | 85 | APP_NAME="private" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and PRIVATE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS="" 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/lib/private-1.0-SNAPSHOT.jar:$APP_HOME/lib/json-20211205.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and PRIVATE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $PRIVATE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | -classpath "$CLASSPATH" \ 204 | org.hyperledger.fabric.contract.ContractRouter \ 205 | "$@" 206 | 207 | # Use "xargs" to parse quoted args. 208 | # 209 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 210 | # 211 | # In Bash we could simply go: 212 | # 213 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 214 | # set -- "${ARGS[@]}" "$@" 215 | # 216 | # but POSIX shell has neither arrays nor command substitution, so instead we 217 | # post-process each arg (as a line of input to sed) to backslash-escape any 218 | # character that might be a shell metacharacter, then use eval to reverse 219 | # that process (while maintaining the separation between arguments), and wrap 220 | # the whole thing up as a single "set" statement. 221 | # 222 | # This will of course break if any of these variables contains a newline or 223 | # an unmatched quote. 224 | # 225 | 226 | eval "set -- $( 227 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $PRIVATE_OPTS" | 228 | xargs -n1 | 229 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 230 | tr '\n' ' ' 231 | )" '"$@"' 232 | 233 | exec "$JAVACMD" "$@" 234 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Use "xargs" to parse quoted args. 209 | # 210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 211 | # 212 | # In Bash we could simply go: 213 | # 214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 215 | # set -- "${ARGS[@]}" "$@" 216 | # 217 | # but POSIX shell has neither arrays nor command substitution, so instead we 218 | # post-process each arg (as a line of input to sed) to backslash-escape any 219 | # character that might be a shell metacharacter, then use eval to reverse 220 | # that process (while maintaining the separation between arguments), and wrap 221 | # the whole thing up as a single "set" statement. 222 | # 223 | # This will of course break if any of these variables contains a newline or 224 | # an unmatched quote. 225 | # 226 | 227 | eval "set -- $( 228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 229 | xargs -n1 | 230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 231 | tr '\n' ' ' 232 | )" '"$@"' 233 | 234 | exec "$JAVACMD" "$@" 235 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /_exampleusage/ExampleContract/src/src/main/java/org/hyperledger/fabric/samples/privatedata/AssetTransfer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | package org.hyperledger.fabric.samples.privatedata; 6 | 7 | import static java.nio.charset.StandardCharsets.UTF_8; 8 | 9 | import org.hyperledger.fabric.contract.Context; 10 | import org.hyperledger.fabric.contract.ContractInterface; 11 | import org.hyperledger.fabric.contract.annotation.Contact; 12 | import org.hyperledger.fabric.contract.annotation.Contract; 13 | import org.hyperledger.fabric.contract.annotation.Default; 14 | import org.hyperledger.fabric.contract.annotation.Info; 15 | import org.hyperledger.fabric.contract.annotation.License; 16 | import org.hyperledger.fabric.contract.annotation.Transaction; 17 | import org.hyperledger.fabric.shim.ChaincodeException; 18 | import org.hyperledger.fabric.shim.ChaincodeStub; 19 | import org.hyperledger.fabric.shim.ledger.CompositeKey; 20 | 21 | import org.hyperledger.fabric.shim.ledger.KeyValue; 22 | import org.hyperledger.fabric.shim.ledger.QueryResultsIterator; 23 | import org.json.JSONObject; 24 | 25 | import java.util.ArrayList; 26 | import java.util.Arrays; 27 | import java.util.List; 28 | import java.util.Map; 29 | 30 | /** 31 | * Main Chaincode class. A ContractInterface gets converted to Chaincode internally. 32 | * @see org.hyperledger.fabric.shim.Chaincode 33 | * 34 | * Each chaincode transaction function must take, Context as first parameter. 35 | * Unless specified otherwise via annotation (@Contract or @Transaction), the contract name 36 | * is the class name (without package) 37 | * and the transaction name is the method name. 38 | * 39 | * To create fabric test-network 40 | * cd fabric-samples/test-network 41 | * ./network.sh up createChannel -ca -s couchdb 42 | * To deploy this chaincode to test-network, use the collection config as described in 43 | * See queryResults = new ArrayList<>(); 160 | // retrieve asset with keys between startKey (inclusive) and endKey(exclusive) in lexical order. 161 | try (QueryResultsIterator results = stub.getPrivateDataByRange(ASSET_COLLECTION_NAME, startKey, endKey)) { 162 | for (KeyValue result : results) { 163 | if (result.getStringValue() == null || result.getStringValue().length() == 0) { 164 | System.err.printf("Invalid Asset json: %s\n", result.getStringValue()); 165 | continue; 166 | } 167 | Asset asset = Asset.deserialize(result.getStringValue()); 168 | queryResults.add(asset); 169 | System.out.println("QueryResult: " + asset.toString()); 170 | } 171 | } 172 | return queryResults.toArray(new Asset[0]); 173 | } 174 | 175 | // =======Rich queries ========================================================================= 176 | // Two examples of rich queries are provided below (parameterized query and ad hoc query). 177 | // Rich queries pass a query string to the state database. 178 | // Rich queries are only supported by state database implementations 179 | // that support rich query (e.g. CouchDB). 180 | // The query string is in the syntax of the underlying state database. 181 | // With rich queries there is no guarantee that the result set hasn't changed between 182 | // endorsement time and commit time, aka 'phantom reads'. 183 | // Therefore, rich queries should not be used in update transactions, unless the 184 | // application handles the possibility of result set changes between endorsement and commit time. 185 | // Rich queries can be used for point-in-time queries against a peer. 186 | // ============================================================================================ 187 | 188 | /** 189 | * QueryAssetByOwner queries for assets based on assetType, owner. 190 | * This is an example of a parameterized query where the query logic is baked into the chaincode, 191 | * and accepting a single query parameter (owner). 192 | * 193 | * @param ctx the transaction context 194 | * @param assetType type to query for 195 | * @param owner asset owner to query for 196 | * @return the asset found on the ledger if there was one 197 | */ 198 | @Transaction(intent = Transaction.TYPE.EVALUATE) 199 | public Asset[] QueryAssetByOwner(final Context ctx, final String assetType, final String owner) throws Exception { 200 | String queryString = String.format("{\"selector\":{\"objectType\":\"%s\",\"owner\":\"%s\"}}", assetType, owner); 201 | return getQueryResult(ctx, queryString); 202 | } 203 | 204 | /** 205 | * QueryAssets uses a query string to perform a query for assets. 206 | * Query string matching state database syntax is passed in and executed as is. 207 | * Supports ad hoc queries that can be defined at runtime by the client. 208 | * 209 | * @param ctx the transaction context 210 | * @param queryString query string matching state database syntax 211 | * @return the asset found on the ledger if there was one 212 | */ 213 | @Transaction(intent = Transaction.TYPE.EVALUATE) 214 | public Asset[] QueryAssets(final Context ctx, final String queryString) throws Exception { 215 | return getQueryResult(ctx, queryString); 216 | } 217 | 218 | private Asset[] getQueryResult(final Context ctx, final String queryString) throws Exception { 219 | ChaincodeStub stub = ctx.getStub(); 220 | System.out.printf("QueryAssets: %s\n", queryString); 221 | 222 | List queryResults = new ArrayList(); 223 | // retrieve asset with keys between startKey (inclusive) and endKey(exclusive) in lexical order. 224 | try (QueryResultsIterator results = stub.getPrivateDataQueryResult(ASSET_COLLECTION_NAME, queryString)) { 225 | for (KeyValue result : results) { 226 | if (result.getStringValue() == null || result.getStringValue().length() == 0) { 227 | System.err.printf("Invalid Asset json: %s\n", result.getStringValue()); 228 | continue; 229 | } 230 | Asset asset = Asset.deserialize(result.getStringValue()); 231 | queryResults.add(asset); 232 | System.out.println("QueryResult: " + asset.toString()); 233 | } 234 | } 235 | return queryResults.toArray(new Asset[0]); 236 | } 237 | 238 | 239 | /** 240 | * Creates a new asset on the ledger from asset properties passed in as transient map. 241 | * Asset owner will be inferred from the ClientId via stub api 242 | * 243 | * @param ctx the transaction context 244 | * Transient map with asset_properties key with asset json as value 245 | * @return the created asset 246 | */ 247 | @Transaction(intent = Transaction.TYPE.SUBMIT) 248 | public Asset CreateAsset(final Context ctx) { 249 | ChaincodeStub stub = ctx.getStub(); 250 | Map transientMap = ctx.getStub().getTransient(); 251 | if (!transientMap.containsKey("asset_properties")) { 252 | String errorMessage = String.format("CreateAsset call must specify asset_properties in Transient map input"); 253 | System.err.println(errorMessage); 254 | throw new ChaincodeException(errorMessage, AssetTransferErrors.INCOMPLETE_INPUT.toString()); 255 | } 256 | 257 | byte[] transientAssetJSON = transientMap.get("asset_properties"); 258 | final String assetID; 259 | final String type; 260 | final String color; 261 | int appraisedValue = 0; 262 | int size = 0; 263 | try { 264 | JSONObject json = new JSONObject(new String(transientAssetJSON, UTF_8)); 265 | Map tMap = json.toMap(); 266 | 267 | type = (String) tMap.get("objectType"); 268 | assetID = (String) tMap.get("assetID"); 269 | color = (String) tMap.get("color"); 270 | if (tMap.containsKey("size")) { 271 | size = (Integer) tMap.get("size"); 272 | } 273 | if (tMap.containsKey("appraisedValue")) { 274 | appraisedValue = (Integer) tMap.get("appraisedValue"); 275 | } 276 | } catch (Exception err) { 277 | String errorMessage = String.format("TransientMap deserialized error: %s ", err); 278 | System.err.println(errorMessage); 279 | throw new ChaincodeException(errorMessage, AssetTransferErrors.INCOMPLETE_INPUT.toString()); 280 | } 281 | 282 | //input validations 283 | String errorMessage = null; 284 | if (assetID.equals("")) { 285 | errorMessage = String.format("Empty input in Transient map: assetID"); 286 | } 287 | if (type.equals("")) { 288 | errorMessage = String.format("Empty input in Transient map: objectType"); 289 | } 290 | if (color.equals("")) { 291 | errorMessage = String.format("Empty input in Transient map: color"); 292 | } 293 | if (size <= 0) { 294 | errorMessage = String.format("Empty input in Transient map: size"); 295 | } 296 | if (appraisedValue <= 0) { 297 | errorMessage = String.format("Empty input in Transient map: appraisedValue"); 298 | } 299 | 300 | if (errorMessage != null) { 301 | System.err.println(errorMessage); 302 | throw new ChaincodeException(errorMessage, AssetTransferErrors.INCOMPLETE_INPUT.toString()); 303 | } 304 | 305 | Asset asset = new Asset(type, assetID, color, size, ""); 306 | // Check if asset already exists 307 | byte[] assetJSON = ctx.getStub().getPrivateData(ASSET_COLLECTION_NAME, assetID); 308 | if (assetJSON != null && assetJSON.length > 0) { 309 | errorMessage = String.format("Asset %s already exists", assetID); 310 | System.err.println(errorMessage); 311 | throw new ChaincodeException(errorMessage, AssetTransferErrors.ASSET_ALREADY_EXISTS.toString()); 312 | } 313 | 314 | // Get ID of submitting client identity 315 | String clientID = ctx.getClientIdentity().getId(); 316 | 317 | // Verify that the client is submitting request to peer in their organization 318 | // This is to ensure that a client from another org doesn't attempt to read or 319 | // write private data from this peer. 320 | verifyClientOrgMatchesPeerOrg(ctx); 321 | 322 | //Make submitting client the owner 323 | asset.setOwner(clientID); 324 | System.out.printf("CreateAsset Put: collection %s, ID %s\n", ASSET_COLLECTION_NAME, assetID); 325 | System.out.printf("Put: collection %s, ID %s\n", ASSET_COLLECTION_NAME, new String(asset.serialize())); 326 | stub.putPrivateData(ASSET_COLLECTION_NAME, assetID, asset.serialize()); 327 | 328 | // Get collection name for this organization. 329 | String orgCollectionName = getCollectionName(ctx); 330 | 331 | //Save AssetPrivateDetails to org collection 332 | AssetPrivateDetails assetPriv = new AssetPrivateDetails(assetID, appraisedValue); 333 | System.out.printf("Put AssetPrivateDetails: collection %s, ID %s\n", orgCollectionName, assetID); 334 | stub.putPrivateData(orgCollectionName, assetID, assetPriv.serialize()); 335 | 336 | return asset; 337 | } 338 | 339 | /** 340 | * AgreeToTransfer is used by the potential buyer of the asset to agree to the 341 | * asset value. The agreed to appraisal value is stored in the buying orgs 342 | * org specifc collection, while the the buyer client ID is stored in the asset collection 343 | * using a composite key 344 | * Uses transient map with key asset_value 345 | * 346 | * @param ctx the transaction context 347 | */ 348 | @Transaction(intent = Transaction.TYPE.SUBMIT) 349 | public void AgreeToTransfer(final Context ctx) { 350 | ChaincodeStub stub = ctx.getStub(); 351 | Map transientMap = ctx.getStub().getTransient(); 352 | if (!transientMap.containsKey("asset_value")) { 353 | String errorMessage = String.format("AgreeToTransfer call must specify \"asset_value\" in Transient map input"); 354 | System.err.println(errorMessage); 355 | throw new ChaincodeException(errorMessage, AssetTransferErrors.INCOMPLETE_INPUT.toString()); 356 | } 357 | 358 | byte[] transientAssetJSON = transientMap.get("asset_value"); 359 | AssetPrivateDetails assetPriv; 360 | String assetID; 361 | try { 362 | JSONObject json = new JSONObject(new String(transientAssetJSON, UTF_8)); 363 | assetID = json.getString("assetID"); 364 | final int appraisedValue = json.getInt("appraisedValue"); 365 | 366 | assetPriv = new AssetPrivateDetails(assetID, appraisedValue); 367 | } catch (Exception err) { 368 | String errorMessage = String.format("TransientMap deserialized error %s ", err); 369 | System.err.println(errorMessage); 370 | throw new ChaincodeException(errorMessage, AssetTransferErrors.INCOMPLETE_INPUT.toString()); 371 | } 372 | 373 | if (assetID.equals("")) { 374 | String errorMessage = String.format("Invalid input in Transient map: assetID"); 375 | System.err.println(errorMessage); 376 | throw new ChaincodeException(errorMessage, AssetTransferErrors.INCOMPLETE_INPUT.toString()); 377 | } 378 | if (assetPriv.getAppraisedValue() <= 0) { // appraisedValue field must be a positive integer 379 | String errorMessage = String.format("Input must be positive integer: appraisedValue"); 380 | System.err.println(errorMessage); 381 | throw new ChaincodeException(errorMessage, AssetTransferErrors.INCOMPLETE_INPUT.toString()); 382 | } 383 | System.out.printf("AgreeToTransfer: verify asset %s exists\n", assetID); 384 | Asset existing = ReadAsset(ctx, assetID); 385 | if (existing == null) { 386 | String errorMessage = String.format("Asset does not exist in the collection: ", assetID); 387 | System.err.println(errorMessage); 388 | throw new ChaincodeException(errorMessage, AssetTransferErrors.INCOMPLETE_INPUT.toString()); 389 | } 390 | // Get collection name for this organization. 391 | String orgCollectionName = getCollectionName(ctx); 392 | 393 | verifyClientOrgMatchesPeerOrg(ctx); 394 | 395 | //Save AssetPrivateDetails to org collection 396 | System.out.printf("Put AssetPrivateDetails: collection %s, ID %s\n", orgCollectionName, assetID); 397 | stub.putPrivateData(orgCollectionName, assetID, assetPriv.serialize()); 398 | 399 | String clientID = ctx.getClientIdentity().getId(); 400 | //Write the AgreeToTransfer key in assetCollection 401 | CompositeKey aggKey = stub.createCompositeKey(AGREEMENT_KEYPREFIX, assetID); 402 | System.out.printf("AgreeToTransfer Put: collection %s, ID %s, Key %s\n", ASSET_COLLECTION_NAME, assetID, aggKey); 403 | stub.putPrivateData(ASSET_COLLECTION_NAME, aggKey.toString(), clientID); 404 | } 405 | 406 | /** 407 | * TransferAsset transfers the asset to the new owner by setting a new owner ID based on 408 | * AgreeToTransfer data 409 | * 410 | * @param ctx the transaction context 411 | * @return none 412 | */ 413 | @Transaction(intent = Transaction.TYPE.SUBMIT) 414 | public void TransferAsset(final Context ctx) { 415 | ChaincodeStub stub = ctx.getStub(); 416 | Map transientMap = ctx.getStub().getTransient(); 417 | if (!transientMap.containsKey("asset_owner")) { 418 | String errorMessage = "TransferAsset call must specify \"asset_owner\" in Transient map input"; 419 | System.err.println(errorMessage); 420 | throw new ChaincodeException(errorMessage, AssetTransferErrors.INCOMPLETE_INPUT.toString()); 421 | } 422 | 423 | byte[] transientAssetJSON = transientMap.get("asset_owner"); 424 | final String assetID; 425 | final String buyerMSP; 426 | try { 427 | JSONObject json = new JSONObject(new String(transientAssetJSON, UTF_8)); 428 | assetID = json.getString("assetID"); 429 | buyerMSP = json.getString("buyerMSP"); 430 | 431 | } catch (Exception err) { 432 | String errorMessage = String.format("TransientMap deserialized error %s ", err); 433 | System.err.println(errorMessage); 434 | throw new ChaincodeException(errorMessage, AssetTransferErrors.INCOMPLETE_INPUT.toString()); 435 | } 436 | 437 | if (assetID.equals("")) { 438 | String errorMessage = String.format("Invalid input in Transient map: " + "assetID"); 439 | System.err.println(errorMessage); 440 | throw new ChaincodeException(errorMessage, AssetTransferErrors.INCOMPLETE_INPUT.toString()); 441 | } 442 | if (buyerMSP.equals("")) { 443 | String errorMessage = String.format("Invalid input in Transient map: " + "buyerMSP"); 444 | System.err.println(errorMessage); 445 | throw new ChaincodeException(errorMessage, AssetTransferErrors.INCOMPLETE_INPUT.toString()); 446 | } 447 | 448 | System.out.printf("TransferAsset: verify asset %s exists\n", assetID); 449 | byte[] assetJSON = stub.getPrivateData(ASSET_COLLECTION_NAME, assetID); 450 | 451 | if (assetJSON == null || assetJSON.length == 0) { 452 | String errorMessage = String.format("Asset %s does not exist in the collection", assetID); 453 | System.err.println(errorMessage); 454 | throw new ChaincodeException(errorMessage, AssetTransferErrors.INCOMPLETE_INPUT.toString()); 455 | } 456 | 457 | verifyClientOrgMatchesPeerOrg(ctx); 458 | Asset thisAsset = Asset.deserialize(assetJSON); 459 | // Verify transfer details and transfer owner 460 | verifyAgreement(ctx, assetID, thisAsset.getOwner(), buyerMSP); 461 | 462 | TransferAgreement transferAgreement = ReadTransferAgreement(ctx, assetID); 463 | if (transferAgreement == null) { 464 | String errorMessage = String.format("TransferAgreement does not exist for asset: %s", assetID); 465 | System.err.println(errorMessage); 466 | throw new ChaincodeException(errorMessage, AssetTransferErrors.INCOMPLETE_INPUT.toString()); 467 | } 468 | 469 | // Transfer asset in private data collection to new owner 470 | String newOwner = transferAgreement.getBuyerID(); 471 | thisAsset.setOwner(newOwner); 472 | 473 | //Save updated Asset to collection 474 | System.out.printf("Transfer Asset: collection %s, ID %s to owner %s\n", ASSET_COLLECTION_NAME, assetID, newOwner); 475 | stub.putPrivateData(ASSET_COLLECTION_NAME, assetID, thisAsset.serialize()); 476 | 477 | // delete the key from owners collection 478 | String ownersCollectionName = getCollectionName(ctx); 479 | stub.delPrivateData(ownersCollectionName, assetID); 480 | 481 | //Delete the transfer agreement from the asset collection 482 | CompositeKey aggKey = stub.createCompositeKey(AGREEMENT_KEYPREFIX, assetID); 483 | System.out.printf("AgreeToTransfer deleteKey: collection %s, ID %s, Key %s\n", ASSET_COLLECTION_NAME, assetID, aggKey); 484 | stub.delPrivateData(ASSET_COLLECTION_NAME, aggKey.toString()); 485 | } 486 | 487 | /** 488 | * Deletes a asset & related details from the ledger. 489 | * Input in transient map: asset_delete 490 | * 491 | * @param ctx the transaction context 492 | */ 493 | @Transaction(intent = Transaction.TYPE.SUBMIT) 494 | public void DeleteAsset(final Context ctx) { 495 | ChaincodeStub stub = ctx.getStub(); 496 | Map transientMap = ctx.getStub().getTransient(); 497 | if (!transientMap.containsKey("asset_delete")) { 498 | String errorMessage = String.format("DeleteAsset call must specify 'asset_delete' in Transient map input"); 499 | System.err.println(errorMessage); 500 | throw new ChaincodeException(errorMessage, AssetTransferErrors.INCOMPLETE_INPUT.toString()); 501 | } 502 | 503 | byte[] transientAssetJSON = transientMap.get("asset_delete"); 504 | final String assetID; 505 | 506 | try { 507 | JSONObject json = new JSONObject(new String(transientAssetJSON, UTF_8)); 508 | assetID = json.getString("assetID"); 509 | 510 | } catch (Exception err) { 511 | String errorMessage = String.format("TransientMap deserialized error: %s ", err); 512 | System.err.println(errorMessage); 513 | throw new ChaincodeException(errorMessage, AssetTransferErrors.INCOMPLETE_INPUT.toString()); 514 | } 515 | 516 | System.out.printf("DeleteAsset: verify asset %s exists\n", assetID); 517 | byte[] assetJSON = stub.getPrivateData(ASSET_COLLECTION_NAME, assetID); 518 | 519 | if (assetJSON == null || assetJSON.length == 0) { 520 | String errorMessage = String.format("Asset %s does not exist", assetID); 521 | System.err.println(errorMessage); 522 | throw new ChaincodeException(errorMessage, AssetTransferErrors.ASSET_NOT_FOUND.toString()); 523 | } 524 | String ownersCollectionName = getCollectionName(ctx); 525 | byte[] apdJSON = stub.getPrivateData(ownersCollectionName, assetID); 526 | 527 | if (apdJSON == null || apdJSON.length == 0) { 528 | String errorMessage = String.format("Failed to read asset from owner's Collection %s", ownersCollectionName); 529 | System.err.println(errorMessage); 530 | throw new ChaincodeException(errorMessage, AssetTransferErrors.ASSET_NOT_FOUND.toString()); 531 | } 532 | verifyClientOrgMatchesPeerOrg(ctx); 533 | 534 | // delete the key from asset collection 535 | System.out.printf("DeleteAsset: collection %s, ID %s\n", ASSET_COLLECTION_NAME, assetID); 536 | stub.delPrivateData(ASSET_COLLECTION_NAME, assetID); 537 | 538 | // Finally, delete private details of asset 539 | stub.delPrivateData(ownersCollectionName, assetID); 540 | } 541 | 542 | // Used by TransferAsset to verify that the transfer is being initiated by the owner and that 543 | // the buyer has agreed to the same appraisal value as the owner 544 | private void verifyAgreement(final Context ctx, final String assetID, final String owner, final String buyerMSP) { 545 | String clienID = ctx.getClientIdentity().getId(); 546 | 547 | // Check 1: verify that the transfer is being initiatied by the owner 548 | if (!clienID.equals(owner)) { 549 | throw new ChaincodeException("Submitting client identity does not own the asset", AssetTransferErrors.INVALID_ACCESS.toString()); 550 | } 551 | 552 | // Check 2: verify that the buyer has agreed to the appraised value 553 | String collectionOwner = getCollectionName(ctx); // get owner collection from caller identity 554 | String collectionBuyer = buyerMSP + "PrivateCollection"; 555 | 556 | // Get hash of owners agreed to value 557 | byte[] ownerAppraisedValueHash = ctx.getStub().getPrivateDataHash(collectionOwner, assetID); 558 | if (ownerAppraisedValueHash == null) { 559 | throw new ChaincodeException(String.format("Hash of appraised value for %s does not exist in collection %s", assetID, collectionOwner)); 560 | } 561 | 562 | // Get hash of buyers agreed to value 563 | byte[] buyerAppraisedValueHash = ctx.getStub().getPrivateDataHash(collectionBuyer, assetID); 564 | if (buyerAppraisedValueHash == null) { 565 | throw new ChaincodeException(String.format("Hash of appraised value for %s does not exist in collection %s. AgreeToTransfer must be called by the buyer first.", assetID, collectionBuyer)); 566 | } 567 | 568 | // Verify that the two hashes match 569 | if (!Arrays.equals(ownerAppraisedValueHash, buyerAppraisedValueHash)) { 570 | throw new ChaincodeException(String.format("Hash for appraised value for owner %x does not match value for seller %x", ownerAppraisedValueHash, buyerAppraisedValueHash)); 571 | } 572 | } 573 | 574 | private void verifyClientOrgMatchesPeerOrg(final Context ctx) { 575 | String clientMSPID = ctx.getClientIdentity().getMSPID(); 576 | String peerMSPID = ctx.getStub().getMspId(); 577 | 578 | if (!peerMSPID.equals(clientMSPID)) { 579 | String errorMessage = String.format("Client from org %s is not authorized to read or write private data from an org %s peer", clientMSPID, peerMSPID); 580 | System.err.println(errorMessage); 581 | throw new ChaincodeException(errorMessage, AssetTransferErrors.INVALID_ACCESS.toString()); 582 | } 583 | } 584 | 585 | private String getCollectionName(final Context ctx) { 586 | 587 | // Get the MSP ID of submitting client identity 588 | String clientMSPID = ctx.getClientIdentity().getMSPID(); 589 | // Create the collection name 590 | return clientMSPID + "PrivateCollection"; 591 | } 592 | 593 | } 594 | --------------------------------------------------------------------------------