├── .gitignore ├── .travis.yml ├── .travis ├── deploy.sh ├── fix_github_https_repo.sh └── github_deploy_key.enc ├── .vscode └── settings.json ├── LICENSE ├── LICENSE.txt ├── README.md ├── lerna.json ├── markdown-license.txt ├── package.json ├── packages ├── animaltracking-network │ ├── .eslintignore │ ├── .eslintrc.yml │ ├── .gitignore │ ├── .npmignore │ ├── LICENSE.txt │ ├── README.md │ ├── jsdoc.json │ ├── lib │ │ └── model.cto.js │ ├── network.png │ ├── networkimage.svg │ ├── networkimageanimated.svg │ ├── package.json │ ├── permissions.acl │ └── test │ │ ├── mozart.cto.js │ │ └── util.js ├── basic-sample-network │ ├── .eslintignore │ ├── .eslintrc.yml │ ├── .gitignore │ ├── .npmignore │ ├── .vscode │ │ ├── launch.json │ │ └── settings.json │ ├── LICENSE.txt │ ├── README.md │ ├── config │ │ └── default.json │ ├── features │ │ ├── sample.feature │ │ └── support │ │ │ └── index.js │ ├── index.js │ ├── jsdoc.json │ ├── lib │ │ └── sample.js │ ├── models │ │ └── sample.cto │ ├── networkimage.svg │ ├── networkimageanimated.svg │ ├── package.json │ ├── permissions.acl │ └── test │ │ └── sample.js ├── bond-network │ ├── .eslintignore │ ├── .eslintrc.yml │ ├── .gitignore │ ├── .npmignore │ ├── LICENSE.txt │ ├── README.md │ ├── config │ │ └── default.json │ ├── index.js │ ├── jsdoc.json │ ├── lib │ │ └── logic.js │ ├── models │ │ └── bond.cto │ ├── networkimage.svg │ ├── networkimageanimated.svg │ ├── package.json │ ├── permissions.acl │ └── test │ │ └── Bond.js ├── carauction-network │ ├── .eslintignore │ ├── .eslintrc.yml │ ├── .gitignore │ ├── .npmignore │ ├── LICENSE.txt │ ├── README.md │ ├── config │ │ └── default.json │ ├── index.js │ ├── jsdoc.json │ ├── lib │ │ └── logic.js │ ├── models │ │ └── auction.cto │ ├── networkimage.svg │ ├── networkimageanimated.svg │ ├── package.json │ ├── permissions.acl │ └── test │ │ └── CarAuction.js ├── digitalproperty-network │ ├── .eslintignore │ ├── .eslintrc.yml │ ├── .gitignore │ ├── .npmignore │ ├── LICENSE.txt │ ├── README.md │ ├── config │ │ └── default.json │ ├── index.js │ ├── jsdoc.json │ ├── lib │ │ └── DigitalLandTitle.js │ ├── networkimage.svg │ ├── networkimageanimated.svg │ ├── package.json │ ├── permissions.acl │ └── test │ │ └── DigitalLandTitle.js ├── fund-clearing-network │ ├── .eslintignore │ ├── .eslintrc.yml │ ├── .gitignore │ ├── .npmignore │ ├── README.md │ ├── config │ │ └── default.json │ ├── features │ │ ├── 1.SubmitTransferRequests.feature │ │ ├── 2.CreateBatch.feature │ │ ├── 3.MarkPreProcessComplete.feature │ │ ├── 4.CompleteSettlement.feature │ │ ├── 5.MarkPostProcessComplete.feature │ │ └── support │ │ │ └── index.js │ ├── header.txt │ ├── jsdoc.json │ ├── lib │ │ ├── clearing.js │ │ └── permissionHelper.js │ ├── models │ │ └── org.clearing.cto │ ├── networkimage.svg │ ├── networkimageanimated.svg │ ├── package.json │ ├── permissions.acl │ ├── queries.qry │ └── test │ │ ├── clearing.js │ │ ├── clearing_fv.js │ │ └── permissionHelper.js ├── letters-of-credit-network │ ├── .eslintignore │ ├── .eslintrc.yml │ ├── .gitignore │ ├── .npmignore │ ├── LICENSE.txt │ ├── README.md │ ├── config │ │ └── default.json │ ├── index.js │ ├── jsdoc.json │ ├── lib │ │ └── logic.js │ ├── models │ │ └── org.example.loc.cto │ ├── networkimage.svg │ ├── networkimageanimated.svg │ ├── package.json │ ├── permissions.acl │ └── test │ │ └── script.js ├── marbles-network │ ├── .eslintignore │ ├── .eslintrc.yml │ ├── .gitignore │ ├── .npmignore │ ├── LICENSE.txt │ ├── README.md │ ├── index.js │ ├── jsdoc.json │ ├── lib │ │ └── logic.js │ ├── models │ │ └── marbles.cto │ ├── networkimage.svg │ ├── networkimageanimated.svg │ ├── package.json │ ├── permissions.acl │ └── test │ │ └── MarblesTests.js ├── perishable-network │ ├── .eslintignore │ ├── .eslintrc.yml │ ├── .gitignore │ ├── .npmignore │ ├── LICENSE.txt │ ├── README.md │ ├── config │ │ └── default.json │ ├── index.js │ ├── jsdoc.json │ ├── lib │ │ └── logic.js │ ├── models │ │ └── perishable.cto │ ├── networkimage.svg │ ├── networkimageanimated.svg │ ├── package.json │ ├── permissions.acl │ └── test │ │ └── perishable.js ├── pii-network │ ├── .eslintignore │ ├── .eslintrc.yml │ ├── .gitignore │ ├── .npmignore │ ├── LICENSE.txt │ ├── README.md │ ├── config │ │ └── default.json │ ├── index.js │ ├── jsdoc.json │ ├── lib │ │ └── logic.js │ ├── models │ │ └── pii.cto │ ├── networkimage.svg │ ├── networkimageanimated.svg │ ├── package.json │ ├── permissions.acl │ ├── queries.qry │ └── test │ │ └── pii.js ├── trade-network │ ├── .eslintignore │ ├── .eslintrc.yml │ ├── .gitignore │ ├── .npmignore │ ├── LICENSE.txt │ ├── README.md │ ├── config │ │ └── default.json │ ├── index.js │ ├── jsdoc.json │ ├── lib │ │ └── logic.js │ ├── models │ │ └── trading.cto │ ├── networkimage.svg │ ├── networkimageanimated.svg │ ├── package.json │ ├── permissions.acl │ ├── queries.qry │ └── test │ │ └── trading.js ├── vehicle-lifecycle-network │ ├── .eslintignore │ ├── .eslintrc.yml │ ├── .gitignore │ ├── .npmignore │ ├── LICENSE.txt │ ├── README.md │ ├── config │ │ └── default.json │ ├── index.js │ ├── jsdoc.json │ ├── lib │ │ ├── manufacturer.js │ │ ├── setup.js │ │ └── vda.js │ ├── networkimage.svg │ ├── networkimageanimated.svg │ ├── package.json │ ├── permissions.acl │ ├── queries.qry │ └── test │ │ ├── manufacturer.js │ │ ├── setup.js │ │ ├── util.js │ │ └── vda.js └── vehicle-manufacture-network │ ├── .eslintignore │ ├── .eslintrc.yml │ ├── .gitignore │ ├── .npmignore │ ├── LICENSE.txt │ ├── README.md │ ├── config │ └── default.json │ ├── index.js │ ├── jsdoc.json │ ├── lib │ └── script.js │ ├── models │ └── org.acme.vehicle_network.cto │ ├── networkimage.svg │ ├── networkimageanimated.svg │ ├── package.json │ ├── permissions.acl │ └── test │ └── script.js └── scripts ├── pkgbump.js ├── pkgcheck.js └── pkgstamp.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | dist 61 | 62 | node_modules 63 | package-lock.json 64 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '8' 4 | dist: trusty 5 | before_install: | 6 | set -ev 7 | set -o pipefail 8 | npm install -g @alrra/travis-scripts 9 | deploy: 10 | provider: script 11 | script: ./.travis/deploy.sh 12 | skip_cleanup: true 13 | on: 14 | all_branches: true 15 | cache: 16 | directories: 17 | - node_modules 18 | 19 | notifications: 20 | webhooks: 21 | urls: 22 | - https://chat.hyperledger.org/hooks/BG3PeSerMSWRDSceE/GPCnCSqxMoyfqaTvLePSGudWjoCBwAcCT6bAKYRjK2sKSCM9 23 | on_success: always # default: always 24 | on_failure: always # default: always 25 | on_start: always # default: never 26 | on_cancel: always # default: always 27 | on_error: always # default: always 28 | -------------------------------------------------------------------------------- /.travis/fix_github_https_repo.sh: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | #/bin/bash 14 | #-- Script to automate https://help.github.com/articles/why-is-git-always-asking-for-my-password 15 | 16 | REPO_URL=`git remote -v | grep -m1 '^origin' | sed -Ene's#.*(https://[^[:space:]]*).*#\1#p'` 17 | if [ -z "$REPO_URL" ]; then 18 | echo "-- ERROR: Could not identify Repo url." 19 | echo " It is possible this repo is already using SSH instead of HTTPS." 20 | exit 21 | fi 22 | 23 | USER=`echo $REPO_URL | sed -Ene's#https://github.com/([^/]*)/(.*).git#\1#p'` 24 | if [ -z "$USER" ]; then 25 | echo "-- ERROR: Could not identify User." 26 | exit 27 | fi 28 | 29 | REPO=`echo $REPO_URL | sed -Ene's#https://github.com/([^/]*)/(.*).git#\2#p'` 30 | if [ -z "$REPO" ]; then 31 | echo "-- ERROR: Could not identify Repo." 32 | exit 33 | fi 34 | 35 | NEW_URL="git@github.com:$USER/$REPO.git" 36 | echo "Changing repo url from " 37 | echo " '$REPO_URL'" 38 | echo " to " 39 | echo " '$NEW_URL'" 40 | echo "" 41 | 42 | CHANGE_CMD="git remote set-url origin $NEW_URL" 43 | `$CHANGE_CMD` 44 | 45 | echo "Success" -------------------------------------------------------------------------------- /.travis/github_deploy_key.enc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-archives/composer-sample-networks/c214e64fb9b03e939f5ac331fe07c1a3471ab935/.travis/github_deploy_key.enc -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "vsicons.presets.angular": false 3 | } -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); 2 | you may not use this file except in compliance with the License. 3 | You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sample Hyperledger Composer Business Network Definitions 2 | 3 | :warning: :warning: :warning: 4 | 5 | **As of the 29th August 2019, the Hyperledger Composer project is in deprecated status. None of the maintainers are actively developing new features. None of the maintainers are actively providing support via GitHub issues. However, if you wish to submit code changes via pull requests, these will be merged.** 6 | 7 | **It is highly recommended that you use Hyperledger Fabric v1.4+ instead, which features significant improvements to the developer experience, including a new programming model.** 8 | 9 | **More information available here: [What's new in Hyperledger Fabric v1.4](https://hyperledger-fabric.readthedocs.io/en/release-1.4/whatsnew.html#improved-programming-model-for-developing-applications)** 10 | 11 | :warning: :warning: :warning: 12 | 13 | You must install [Lerna](https://lernajs.io) to build this multi-package repository. 14 | 15 | $ npm install -g lerna 16 | 17 | Once Lerna is installed, and this repository is cloned, then you must bootstrap the 18 | repository so that all of the dependencies are installed and all of the packages are 19 | linked together: 20 | 21 | $ lerna bootstrap 22 | 23 | You can then work with the packages under [packages/](packages/) on a per-package 24 | basis as any normal node.js package. 25 | 26 | Alternatively, you can execute npm commands across all of the packages at once using 27 | Lerna: 28 | 29 | $ lerna run test 30 | 31 | ## License 32 | Hyperledger Project source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the LICENSE file. Hyperledger Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at http://creativecommons.org/licenses/by/4.0/. 33 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "lerna": "2.0.0", 3 | "packages": [ 4 | "packages/*" 5 | ], 6 | "version": "0.2.6", 7 | "hoist": true, 8 | "nohoist": "*-model" 9 | } 10 | -------------------------------------------------------------------------------- /markdown-license.txt: -------------------------------------------------------------------------------- 1 | ## License 2 | Hyperledger Project source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the LICENSE file. Hyperledger Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at http://creativecommons.org/licenses/by/4.0/. -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "colors": "^1.1.2", 4 | "lerna": "^2.5.1", 5 | "license-check-and-add": "~2.3.0", 6 | "moment": "^2.17.1", 7 | "semver": "^5.3.0", 8 | "sleep-promise": "^2.0.0" 9 | }, 10 | "name": "sample-networks", 11 | "description": "You must install [Lerna](https://lernajs.io) to build this multi-package repository.", 12 | "version": "0.2.6", 13 | "main": "index.js", 14 | "private": true, 15 | "scripts": { 16 | "licchk": "license-check-and-add", 17 | "postinstall": "npm run pkgcheck && npm run bootstrap", 18 | "bootstrap": "lerna bootstrap", 19 | "test": "npm run licchk & lerna run test", 20 | "pkgcheck": "node ./scripts/pkgcheck.js", 21 | "pkgstamp": "node ./scripts/pkgstamp.js", 22 | "pkgbump": "node ./scripts/pkgbump.js && node ./scripts/pkgcheck.js --fix" 23 | }, 24 | "repository": { 25 | "type": "git", 26 | "url": "https://github.com/hyperledger/composer-sample-networks" 27 | }, 28 | "keywords": [ 29 | "blockchain", 30 | "hyperledger", 31 | "solutions" 32 | ], 33 | "author": "Hyperledger Composer", 34 | "license": "Apache-2.0", 35 | "license-check-and-add-config": { 36 | "folder": ".", 37 | "license": "LICENSE.txt", 38 | "exact_paths_method": "EXCLUDE", 39 | "exact_paths": [ 40 | ".git", 41 | "packages", 42 | "node_modules", 43 | "markdown-license.txt" 44 | ], 45 | "file_type_method": "EXCLUDE", 46 | "file_types": [ 47 | ".enc", 48 | ".yml", 49 | ".log" 50 | ], 51 | "insert_license": false, 52 | "license_formats": { 53 | "js": { 54 | "prepend": "/*", 55 | "append": " */", 56 | "eachLine": { 57 | "prepend": " * " 58 | } 59 | }, 60 | "md": { 61 | "file": "markdown-license.txt" 62 | } 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /packages/animaltracking-network/.eslintignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | coverage 14 | dist 15 | go 16 | node_modules 17 | out 18 | -------------------------------------------------------------------------------- /packages/animaltracking-network/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es6: true 3 | node: true 4 | mocha: true 5 | extends: 'eslint:recommended' 6 | parserOptions: 7 | ecmaVersion: 8 8 | sourceType: 9 | - script 10 | rules: 11 | indent: 12 | - error 13 | - 4 14 | linebreak-style: 15 | - error 16 | - unix 17 | quotes: 18 | - error 19 | - single 20 | semi: 21 | - error 22 | - always 23 | no-unused-vars: 24 | - error 25 | - args: none 26 | no-console: off 27 | curly: error 28 | eqeqeq: error 29 | no-throw-literal: error 30 | strict: error 31 | dot-notation: error 32 | no-tabs: error 33 | no-trailing-spaces: error 34 | no-use-before-define: error 35 | no-useless-call: error 36 | no-with: error 37 | operator-linebreak: error 38 | require-jsdoc: 39 | - error 40 | - require: 41 | ClassDeclaration: true 42 | MethodDefinition: true 43 | FunctionDeclaration: true 44 | valid-jsdoc: 45 | - error 46 | - requireReturn: false 47 | yoda: error 48 | -------------------------------------------------------------------------------- /packages/animaltracking-network/.gitignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # JSDoc 14 | out 15 | 16 | # Logs 17 | logs 18 | *.log 19 | npm-debug.log* 20 | 21 | # Runtime data 22 | pids 23 | *.pid 24 | *.seed 25 | 26 | # Directory for instrumented libs generated by jscoverage/JSCover 27 | lib-cov 28 | 29 | # Coverage directory used by tools like istanbul 30 | coverage 31 | 32 | # nyc test coverage 33 | .nyc_output 34 | 35 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 36 | .grunt 37 | 38 | # node-waf configuration 39 | .lock-wscript 40 | 41 | # Compiled binary addons (http://nodejs.org/api/addons.html) 42 | build/Release 43 | 44 | # Dependency directories 45 | node_modules 46 | jspm_packages 47 | 48 | # Optional npm cache directory 49 | .npm 50 | 51 | # Optional REPL history 52 | .node_repl_history 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | chaincode/src/* 58 | !chaincode/src/concerto 59 | chaincode/bin 60 | chaincode/pkg 61 | 62 | *.swp 63 | 64 | composer-logs 65 | 66 | -------------------------------------------------------------------------------- /packages/animaltracking-network/.npmignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | # dist 61 | -------------------------------------------------------------------------------- /packages/animaltracking-network/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); 2 | you may not use this file except in compliance with the License. 3 | You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. -------------------------------------------------------------------------------- /packages/animaltracking-network/README.md: -------------------------------------------------------------------------------- 1 | # Animal Tracking Network 2 | 3 | > This is an Animal Tracking Business Network based on UK DEFRA government regulations (https://www.gov.uk/animal-movement-england). Farmers can move animals between farms/fields and the UK government farming regulator has visibility into the locations of all animals and all animal movements between farms. 4 | 5 | This business network defines: 6 | 7 | **Participants** 8 | `Farmer` `Regulator` 9 | 10 | **Assets** 11 | `Animal` `Business` `Field` 12 | 13 | **Transactions** 14 | `AnimalMovementDeparture` `AnimalMovementArrival` `SetupDemo` 15 | 16 | Each Farmer owns a Business that is identified by a Single Business Identifier (SBI). A Farmer owns a set of Animals. A Business owns a set of Fields. A Field contains a set of Animals owned by the Farmer. Animals can be transferred between Farmers or between Fields. 17 | 18 | To test this Business Network Definition in the **Test** tab: 19 | 20 | Submit a `SetupDemo` transaction: 21 | 22 | ``` 23 | { 24 | "$class": "com.biz.SetupDemo" 25 | } 26 | ``` 27 | 28 | This transaction populates the Participant Registries with two `Farmer` participants and a `Regulator` participant. The Asset Registries will have eight `Animal` assets, two `Business` assets and four `Field` assets. 29 | 30 | Submit a `AnimalMovementDeparture` transaction: 31 | 32 | ``` 33 | { 34 | "$class": "com.biz.AnimalMovementDeparture", 35 | "fromField": "resource:com.biz.Field#FIELD_1", 36 | "animal": "resource:com.biz.Animal#ANIMAL_1", 37 | "from": "resource:com.biz.Business#BUSINESS_1", 38 | "to": "resource:com.biz.Business#BUSINESS_2" 39 | } 40 | ``` 41 | 42 | This transaction moves `ANIMAL_1` from `FIELD_1` at `BUSINESS_1` to `BUSINESS_2`. 43 | 44 | Submit a `AnimalMovementArrival` transaction: 45 | 46 | ``` 47 | { 48 | "$class": "com.biz.AnimalMovementArrival", 49 | "arrivalField": "resource:com.biz.Field#FIELD_2", 50 | "animal": "resource:com.biz.Animal#ANIMAL_1", 51 | "from": "resource:com.biz.Business#BUSINESS_1", 52 | "to": "resource:com.biz.Business#BUSINESS_2" 53 | } 54 | ``` 55 | 56 | This transaction confirms the receipt of `ANIMAL_1` from `BUSINESS_1` to `FIELD_2` at `BUSINESS_2`. 57 | 58 | Congratulations! 59 | 60 | ## License 61 | Hyperledger Project source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the LICENSE file. Hyperledger Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at http://creativecommons.org/licenses/by/4.0/. 62 | -------------------------------------------------------------------------------- /packages/animaltracking-network/jsdoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": { 3 | "allowUnknownTags": true, 4 | "dictionaries": ["jsdoc","closure"] 5 | }, 6 | "source": { 7 | "include": [ 8 | "./lib" 9 | ], 10 | "includePattern": ".+\\.js(doc|x)?$" 11 | }, 12 | "plugins": ["plugins/markdown"], 13 | "templates": { 14 | "logoFile": "", 15 | "cleverLinks": false, 16 | "monospaceLinks": false, 17 | "dateFormat": "ddd MMM Do YYYY", 18 | "outputSourceFiles": true, 19 | "outputSourcePath": true, 20 | "systemName": "Animal Tracking Network", 21 | "footer": "", 22 | "copyright": "Released under the Apache License v2.0", 23 | "navType": "vertical", 24 | "theme": "spacelab", 25 | "linenums": true, 26 | "collapseSymbols": false, 27 | "inverseNav": true, 28 | "protocol": "html://", 29 | "methodHeadingReturns": false 30 | }, 31 | "markdown": { 32 | "parser": "gfm", 33 | "hardwrap": true 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/animaltracking-network/network.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-archives/composer-sample-networks/c214e64fb9b03e939f5ac331fe07c1a3471ab935/packages/animaltracking-network/network.png -------------------------------------------------------------------------------- /packages/animaltracking-network/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "engines": { 3 | "composer": "^0.20.0" 4 | }, 5 | "name": "animaltracking-network", 6 | "version": "0.2.6", 7 | "description": "Animal Tracking network based on UK DEFRA regulations", 8 | "networkImage": "https://hyperledger.github.io/composer-sample-networks/packages/animaltracking-network/networkimage.svg", 9 | "networkImageanimated": "https://hyperledger.github.io/composer-sample-networks/packages/animaltracking-network/networkimageanimated.svg", 10 | "scripts": { 11 | "prepublish": "mkdirp ./dist && composer archive create --sourceType dir --sourceName . -a ./dist/animaltracking-network.bna", 12 | "pretest": "npm run lint", 13 | "test": "mocha -t 0 --recursive", 14 | "lint": "eslint .", 15 | "postlint": "npm run licchk", 16 | "licchk": "license-check-and-add", 17 | "postlicchk": "npm run doc", 18 | "doc": "jsdoc --pedantic --recurse -c jsdoc.json", 19 | "pkgstamp": "node ./scripts/pkgstamp.js" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "https://github.com/hyperledger/composer" 24 | }, 25 | "author": "Hyperledger Composer", 26 | "license": "Apache-2.0", 27 | "keywords": [ 28 | "defra", 29 | "farmer", 30 | "compliance", 31 | "animal", 32 | "movement", 33 | "composer", 34 | "composer-network" 35 | ], 36 | "devDependencies": { 37 | "chai": "^3.5.0", 38 | "composer-admin": "^0.20.0-0", 39 | "composer-cli": "^0.20.0-0", 40 | "composer-client": "^0.20.0-0", 41 | "composer-common": "^0.20.0-0", 42 | "composer-connector-embedded": "^0.20.0-0", 43 | "eslint": "^3.6.1", 44 | "jsdoc": "^3.5.5", 45 | "license-check-and-add": "~2.3.0", 46 | "mkdirp": "^0.5.1", 47 | "mocha": "^3.2.0" 48 | }, 49 | "license-check-and-add-config": { 50 | "folder": ".", 51 | "license": "LICENSE.txt", 52 | "exact_paths_method": "EXCLUDE", 53 | "exact_paths": [ 54 | "composer-logs", 55 | "dist", 56 | "node_modules", 57 | "out", 58 | ".git" 59 | ], 60 | "file_type_method": "EXCLUDE", 61 | "file_types": [ 62 | ".yml" 63 | ], 64 | "insert_license": false, 65 | "license_formats": { 66 | "js|cto|acl": { 67 | "prepend": "/*", 68 | "append": " */", 69 | "eachLine": { 70 | "prepend": " * " 71 | } 72 | }, 73 | "md": { 74 | "file": "../../markdown-license.txt" 75 | } 76 | } 77 | }, 78 | "dependencies": { 79 | "animaltracking-model": "^0.2.0" 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /packages/animaltracking-network/permissions.acl: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /** 16 | * Sample access control list. 17 | */ 18 | rule Default { 19 | description: "Allow all participants access to all resources" 20 | participant: "com.biz.User" 21 | operation: ALL 22 | resource: "com.biz.*" 23 | action: ALLOW 24 | } 25 | 26 | rule SystemACL { 27 | description: "System ACL to permit all access" 28 | participant: "org.hyperledger.composer.system.Participant" 29 | operation: ALL 30 | resource: "org.hyperledger.composer.system.**" 31 | action: ALLOW 32 | } 33 | 34 | rule NetworkAdminUser { 35 | description: "Grant business network administrators full access to user resources" 36 | participant: "org.hyperledger.composer.system.NetworkAdmin" 37 | operation: ALL 38 | resource: "**" 39 | action: ALLOW 40 | } 41 | 42 | rule NetworkAdminSystem { 43 | description: "Grant business network administrators full access to system resources" 44 | participant: "org.hyperledger.composer.system.NetworkAdmin" 45 | operation: ALL 46 | resource: "org.hyperledger.composer.system.**" 47 | action: ALLOW 48 | } -------------------------------------------------------------------------------- /packages/animaltracking-network/test/util.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | let namespace = 'com.biz'; 18 | 19 | module.exports.setupDemo = (businessNetworkConnection) => { 20 | let factory = businessNetworkConnection.getBusinessNetwork().getFactory(); 21 | 22 | let setupDemo = factory.newTransaction(namespace, 'SetupDemo'); 23 | return businessNetworkConnection.submitTransaction(setupDemo); 24 | }; -------------------------------------------------------------------------------- /packages/basic-sample-network/.eslintignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | coverage 14 | dist 15 | go 16 | node_modules 17 | out 18 | -------------------------------------------------------------------------------- /packages/basic-sample-network/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es6: true 3 | node: true 4 | mocha: true 5 | extends: 'eslint:recommended' 6 | parserOptions: 7 | ecmaVersion: 8 8 | sourceType: 9 | - script 10 | rules: 11 | indent: 12 | - error 13 | - 4 14 | linebreak-style: 15 | - error 16 | - unix 17 | quotes: 18 | - error 19 | - single 20 | semi: 21 | - error 22 | - always 23 | no-unused-vars: 24 | - error 25 | - args: none 26 | no-console: off 27 | curly: error 28 | eqeqeq: error 29 | no-throw-literal: error 30 | no-var: error 31 | dot-notation: error 32 | no-tabs: error 33 | no-trailing-spaces: error 34 | no-use-before-define: error 35 | no-useless-call: error 36 | no-with: error 37 | operator-linebreak: error 38 | require-jsdoc: 39 | - error 40 | - require: 41 | ClassDeclaration: true 42 | MethodDefinition: true 43 | FunctionDeclaration: true 44 | valid-jsdoc: 45 | - error 46 | - requireReturn: false 47 | yoda: error 48 | -------------------------------------------------------------------------------- /packages/basic-sample-network/.gitignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | dist 61 | 62 | node_modules 63 | composer-logs -------------------------------------------------------------------------------- /packages/basic-sample-network/.npmignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | # dist 61 | -------------------------------------------------------------------------------- /packages/basic-sample-network/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible Node.js debug attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Launch Program", 11 | "program": "${file}" 12 | }, 13 | { 14 | "type": "node", 15 | "protocol": "inspector", 16 | "request": "launch", 17 | "name": "Launch Program", 18 | "program": "${workspaceRoot}/node_modules/.bin/_mocha", 19 | "args": [ "-t", "0" ], 20 | "cwd": "${workspaceRoot}", 21 | "smartStep": true 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /packages/basic-sample-network/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "vsicons.presets.angular": false 3 | } -------------------------------------------------------------------------------- /packages/basic-sample-network/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); 2 | you may not use this file except in compliance with the License. 3 | You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | -------------------------------------------------------------------------------- /packages/basic-sample-network/README.md: -------------------------------------------------------------------------------- 1 | # Basic Sample Business Network 2 | 3 | > This is the "Hello World" of Hyperledger Composer samples, which demonstrates the core functionality of Hyperledger Composer by changing the value of an asset. 4 | 5 | This business network defines: 6 | 7 | **Participant** 8 | `SampleParticipant` 9 | 10 | **Asset** 11 | `SampleAsset` 12 | 13 | **Transaction** 14 | `SampleTransaction` 15 | 16 | **Event** 17 | `SampleEvent` 18 | 19 | SampleAssets are owned by a SampleParticipant, and the value property on a SampleAsset can be modified by submitting a SampleTransaction. The SampleTransaction emits a SampleEvent that notifies applications of the old and new values for each modified SampleAsset. 20 | 21 | To test this Business Network Definition in the **Test** tab: 22 | 23 | Create a `SampleParticipant` participant: 24 | 25 | ``` 26 | { 27 | "$class": "org.example.basic.SampleParticipant", 28 | "participantId": "Toby", 29 | "firstName": "Tobias", 30 | "lastName": "Hunter" 31 | } 32 | ``` 33 | 34 | Create a `SampleAsset` asset: 35 | 36 | ``` 37 | { 38 | "$class": "org.example.basic.SampleAsset", 39 | "assetId": "assetId:1", 40 | "owner": "resource:org.example.basic.SampleParticipant#Toby", 41 | "value": "original value" 42 | } 43 | ``` 44 | 45 | Submit a `SampleTransaction` transaction: 46 | 47 | ``` 48 | { 49 | "$class": "org.example.basic.SampleTransaction", 50 | "asset": "resource:org.example.basic.SampleAsset#assetId:1", 51 | "newValue": "new value" 52 | } 53 | ``` 54 | 55 | After submitting this transaction, you should now see the transaction in the Transaction Registry and that a `SampleEvent` has been emitted. As a result, the value of the `assetId:1` should now be `new value` in the Asset Registry. 56 | 57 | Congratulations! 58 | 59 | ## License 60 | Hyperledger Project source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the LICENSE file. Hyperledger Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at http://creativecommons.org/licenses/by/4.0/. 61 | -------------------------------------------------------------------------------- /packages/basic-sample-network/config/default.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "config":"" 4 | } 5 | -------------------------------------------------------------------------------- /packages/basic-sample-network/features/support/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const composerSteps = require('composer-cucumber-steps'); 18 | const cucumber = require('cucumber'); 19 | 20 | module.exports = function () { 21 | composerSteps.call(this); 22 | }; 23 | 24 | if (cucumber.defineSupportCode) { 25 | cucumber.defineSupportCode((context) => { 26 | module.exports.call(context); 27 | }); 28 | } 29 | -------------------------------------------------------------------------------- /packages/basic-sample-network/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | -------------------------------------------------------------------------------- /packages/basic-sample-network/jsdoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": { 3 | "allowUnknownTags": true, 4 | "dictionaries": ["jsdoc","closure"] 5 | }, 6 | "source": { 7 | "include": [ 8 | "./lib" 9 | ], 10 | "includePattern": ".+\\.js(doc|x)?$" 11 | }, 12 | "plugins": ["plugins/markdown"], 13 | "templates": { 14 | "logoFile": "", 15 | "cleverLinks": false, 16 | "monospaceLinks": false, 17 | "dateFormat": "ddd MMM Do YYYY", 18 | "outputSourceFiles": true, 19 | "outputSourcePath": true, 20 | "systemName": "Sample Network", 21 | "footer": "", 22 | "copyright": "Released under the Apache License v2.0", 23 | "navType": "vertical", 24 | "theme": "spacelab", 25 | "linenums": true, 26 | "collapseSymbols": false, 27 | "inverseNav": true, 28 | "protocol": "html://", 29 | "methodHeadingReturns": false 30 | }, 31 | "markdown": { 32 | "parser": "gfm", 33 | "hardwrap": true 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/basic-sample-network/lib/sample.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /* global getAssetRegistry getFactory emit */ 16 | 17 | /** 18 | * Sample transaction processor function. 19 | * @param {org.example.basic.SampleTransaction} tx The sample transaction instance. 20 | * @transaction 21 | */ 22 | async function sampleTransaction(tx) { // eslint-disable-line no-unused-vars 23 | 24 | // Save the old value of the asset. 25 | const oldValue = tx.asset.value; 26 | 27 | // Update the asset with the new value. 28 | tx.asset.value = tx.newValue; 29 | 30 | // Get the asset registry for the asset. 31 | const assetRegistry = await getAssetRegistry('org.example.basic.SampleAsset'); 32 | // Update the asset in the asset registry. 33 | await assetRegistry.update(tx.asset); 34 | 35 | // Emit an event for the modified asset. 36 | let event = getFactory().newEvent('org.example.basic', 'SampleEvent'); 37 | event.asset = tx.asset; 38 | event.oldValue = oldValue; 39 | event.newValue = tx.newValue; 40 | emit(event); 41 | } 42 | -------------------------------------------------------------------------------- /packages/basic-sample-network/models/sample.cto: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /** 16 | * Sample business network definition. 17 | */ 18 | namespace org.example.basic 19 | 20 | asset SampleAsset identified by assetId { 21 | o String assetId 22 | --> SampleParticipant owner 23 | o String value 24 | } 25 | 26 | participant SampleParticipant identified by participantId { 27 | o String participantId 28 | o String firstName 29 | o String lastName 30 | } 31 | 32 | transaction SampleTransaction { 33 | --> SampleAsset asset 34 | o String newValue 35 | } 36 | 37 | event SampleEvent { 38 | --> SampleAsset asset 39 | o String oldValue 40 | o String newValue 41 | } 42 | -------------------------------------------------------------------------------- /packages/basic-sample-network/permissions.acl: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /** 16 | * Sample access control list. 17 | */ 18 | rule EverybodyCanReadEverything { 19 | description: "Allow all participants read access to all resources" 20 | participant: "org.example.basic.SampleParticipant" 21 | operation: READ 22 | resource: "org.example.basic.*" 23 | action: ALLOW 24 | } 25 | 26 | rule EverybodyCanSubmitTransactions { 27 | description: "Allow all participants to submit transactions" 28 | participant: "org.example.basic.SampleParticipant" 29 | operation: CREATE 30 | resource: "org.example.basic.SampleTransaction" 31 | action: ALLOW 32 | } 33 | 34 | rule OwnerHasFullAccessToTheirAssets { 35 | description: "Allow all participants full access to their assets" 36 | participant(p): "org.example.basic.SampleParticipant" 37 | operation: ALL 38 | resource(r): "org.example.basic.SampleAsset" 39 | condition: (r.owner.getIdentifier() === p.getIdentifier()) 40 | action: ALLOW 41 | } 42 | 43 | rule SystemACL { 44 | description: "System ACL to permit all access" 45 | participant: "org.hyperledger.composer.system.Participant" 46 | operation: ALL 47 | resource: "org.hyperledger.composer.system.**" 48 | action: ALLOW 49 | } 50 | 51 | rule NetworkAdminUser { 52 | description: "Grant business network administrators full access to user resources" 53 | participant: "org.hyperledger.composer.system.NetworkAdmin" 54 | operation: ALL 55 | resource: "**" 56 | action: ALLOW 57 | } 58 | 59 | rule NetworkAdminSystem { 60 | description: "Grant business network administrators full access to system resources" 61 | participant: "org.hyperledger.composer.system.NetworkAdmin" 62 | operation: ALL 63 | resource: "org.hyperledger.composer.system.**" 64 | action: ALLOW 65 | } -------------------------------------------------------------------------------- /packages/bond-network/.eslintignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | coverage 14 | dist 15 | go 16 | node_modules 17 | out 18 | -------------------------------------------------------------------------------- /packages/bond-network/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es6: true 3 | node: true 4 | mocha: true 5 | extends: 'eslint:recommended' 6 | parserOptions: 7 | ecmaVersion: 8 8 | sourceType: 9 | - script 10 | rules: 11 | indent: 12 | - error 13 | - 4 14 | linebreak-style: 15 | - error 16 | - unix 17 | quotes: 18 | - error 19 | - single 20 | semi: 21 | - error 22 | - always 23 | no-unused-vars: 24 | - error 25 | - args: none 26 | no-console: off 27 | curly: error 28 | eqeqeq: error 29 | no-throw-literal: error 30 | no-var: error 31 | dot-notation: error 32 | no-tabs: error 33 | no-trailing-spaces: error 34 | no-use-before-define: error 35 | no-useless-call: error 36 | no-with: error 37 | operator-linebreak: error 38 | require-jsdoc: 39 | - error 40 | - require: 41 | ClassDeclaration: true 42 | MethodDefinition: true 43 | FunctionDeclaration: true 44 | valid-jsdoc: 45 | - error 46 | - requireReturn: false 47 | yoda: error 48 | -------------------------------------------------------------------------------- /packages/bond-network/.gitignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | dist 61 | 62 | node_modules 63 | composer-logs -------------------------------------------------------------------------------- /packages/bond-network/.npmignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | # dist 61 | -------------------------------------------------------------------------------- /packages/bond-network/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); 2 | you may not use this file except in compliance with the License. 3 | You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | -------------------------------------------------------------------------------- /packages/bond-network/README.md: -------------------------------------------------------------------------------- 1 | # Bond Network 2 | 3 | > The Bond Network allows the issuer of a bond to update the bond information whilst other members of the business network can only read the bond data. 4 | 5 | This business network defines: 6 | 7 | **Participants** 8 | `Issuer` `Member` 9 | 10 | **Assets** 11 | `BondAsset` 12 | 13 | **Transactions** 14 | `PublishBond` 15 | 16 | The `PublishBond` transaction submitted by an `Issuer` participant will create a new `BondAsset`. 17 | 18 | To test this Business Network Definition in the **Test** tab: 19 | 20 | Create a `Issuer` participant: 21 | 22 | ``` 23 | { 24 | "$class": "org.acme.bond.Issuer", 25 | "memberId": "memberId:1", 26 | "name": "Billy Thompson" 27 | } 28 | ``` 29 | 30 | Create a `Member` participant: 31 | 32 | ``` 33 | { 34 | "$class": "org.acme.bond.Member", 35 | "memberId": "memberId:1", 36 | "name": "Jenny Jones" 37 | } 38 | ``` 39 | 40 | Submit a `PublishBond` transaction: 41 | 42 | ``` 43 | { 44 | "$class": "org.acme.bond.PublishBond", 45 | "ISINCode": "ISINCode:1234", 46 | "bond": { 47 | "$class": "org.acme.bond.Bond", 48 | "instrumentId": [], 49 | "exchangeId": [], 50 | "maturity": "2017-07-13T09:39:05.369Z", 51 | "parValue": 1000, 52 | "faceAmount": 1000, 53 | "paymentFrequency": { 54 | "$class": "org.acme.bond.PaymentFrequency", 55 | "periodMultiplier": 0, 56 | "period": "DAY" 57 | }, 58 | "dayCountFraction": "", 59 | "issuer": "resource:org.acme.bond.Issuer#memberId:1" 60 | } 61 | } 62 | ``` 63 | 64 | The `PublishBond` transaction will create a new `BondAsset` in the Asset Registry. 65 | 66 | Congratulations! 67 | 68 | ## License 69 | Hyperledger Project source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the LICENSE file. Hyperledger Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at http://creativecommons.org/licenses/by/4.0/. -------------------------------------------------------------------------------- /packages/bond-network/config/default.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "config":"" 4 | } 5 | -------------------------------------------------------------------------------- /packages/bond-network/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | -------------------------------------------------------------------------------- /packages/bond-network/jsdoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": { 3 | "allowUnknownTags": true, 4 | "dictionaries": ["jsdoc","closure"] 5 | }, 6 | "source": { 7 | "include": [ 8 | "./lib" 9 | ], 10 | "includePattern": ".+\\.js(doc|x)?$" 11 | }, 12 | "plugins": ["plugins/markdown"], 13 | "templates": { 14 | "logoFile": "", 15 | "cleverLinks": false, 16 | "monospaceLinks": false, 17 | "dateFormat": "ddd MMM Do YYYY", 18 | "outputSourceFiles": true, 19 | "outputSourcePath": true, 20 | "systemName": "Financial Bond Network", 21 | "footer": "", 22 | "copyright": "Released under the Apache License v2.0", 23 | "navType": "vertical", 24 | "theme": "spacelab", 25 | "linenums": true, 26 | "collapseSymbols": false, 27 | "inverseNav": true, 28 | "protocol": "html://", 29 | "methodHeadingReturns": false 30 | }, 31 | "markdown": { 32 | "parser": "gfm", 33 | "hardwrap": true 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/bond-network/lib/logic.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /* global getAssetRegistry getFactory */ 16 | 17 | /** 18 | * Publish a new bond 19 | * @param {org.acme.bond.PublishBond} publishBond - the publishBond transaction 20 | * @transaction 21 | */ 22 | async function publish(publishBond) { // eslint-disable-line no-unused-vars 23 | 24 | const registry = await getAssetRegistry('org.acme.bond.BondAsset'); 25 | const factory = getFactory(); 26 | 27 | // Create the bond asset. 28 | const bondAsset = factory.newResource('org.acme.bond', 'BondAsset', publishBond.ISINCode); 29 | bondAsset.bond = publishBond.bond; 30 | 31 | // Add the bond asset to the registry. 32 | await registry.add(bondAsset); 33 | } -------------------------------------------------------------------------------- /packages/bond-network/models/bond.cto: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /** 16 | * Definition of a Bond, based on the FpML schema: 17 | * http://www.fpml.org/spec/fpml-5-3-2-wd-2/html/reporting/schemaDocumentation/schemas/fpml-asset-5-3_xsd/elements/bond.html 18 | * 19 | */ 20 | namespace org.acme.bond 21 | 22 | enum CouponType { 23 | o FIXED 24 | o FLOATING 25 | } 26 | 27 | participant Member identified by memberId { 28 | o String memberId 29 | o String name 30 | } 31 | 32 | participant Issuer extends Member { 33 | } 34 | 35 | enum PeriodEnum { 36 | o DAY 37 | o WEEK 38 | o MONTH 39 | o YEAR 40 | } 41 | 42 | concept PaymentFrequency { 43 | o Integer periodMultiplier 44 | o PeriodEnum period 45 | } 46 | 47 | concept Bond { 48 | o String[] instrumentId 49 | o String description optional 50 | o String currency optional 51 | o String[] exchangeId 52 | o String clearanceSystem optional 53 | o String definition optional 54 | o String seniority optional 55 | o CouponType couponType optional 56 | o Double couponRate optional 57 | o DateTime maturity 58 | o Double parValue 59 | o Double faceAmount 60 | o PaymentFrequency paymentFrequency 61 | o String dayCountFraction 62 | --> Issuer issuer 63 | } 64 | 65 | asset BondAsset identified by ISINCode { 66 | o String ISINCode 67 | o Bond bond 68 | } 69 | 70 | transaction PublishBond { 71 | o String ISINCode 72 | o Bond bond 73 | } 74 | -------------------------------------------------------------------------------- /packages/bond-network/networkimage.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | Bond Network Image 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /packages/bond-network/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "engines": { 3 | "composer": "^0.20.0" 4 | }, 5 | "name": "bond-network", 6 | "version": "0.2.6", 7 | "description": "Bond Reference Data Sharing Business Network", 8 | "networkImage": "https://hyperledger.github.io/composer-sample-networks/packages/bond-network/networkimage.svg", 9 | "networkImageanimated": "https://hyperledger.github.io/composer-sample-networks/packages/bond-network/networkimageanimated.svg", 10 | "scripts": { 11 | "prepublish": "mkdirp ./dist && composer archive create --sourceType dir --sourceName . -a ./dist/bond-network.bna", 12 | "pretest": "npm run lint", 13 | "lint": "eslint .", 14 | "postlint": "npm run licchk", 15 | "licchk": "license-check-and-add", 16 | "postlicchk": "npm run doc", 17 | "doc": "jsdoc --pedantic --recurse -c jsdoc.json", 18 | "test": "mocha -t 0 --recursive", 19 | "deploy": "./scripts/deploy.sh" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "https://github.com/hyperledger/composer-sample-networks.git" 24 | }, 25 | "keywords": [ 26 | "bonds", 27 | "reference data", 28 | "finance", 29 | "composer", 30 | "composer-network" 31 | ], 32 | "author": "Hyperledger Composer", 33 | "license": "Apache-2.0", 34 | "devDependencies": { 35 | "chai": "^3.5.0", 36 | "composer-admin": "^0.20.0-0", 37 | "composer-cli": "^0.20.0-0", 38 | "composer-client": "^0.20.0-0", 39 | "composer-common": "^0.20.0-0", 40 | "composer-connector-embedded": "^0.20.0-0", 41 | "eslint": "^3.6.1", 42 | "istanbul": "^0.4.5", 43 | "jsdoc": "^3.5.5", 44 | "license-check-and-add": "~2.3.0", 45 | "mkdirp": "^0.5.1", 46 | "mocha": "^3.2.0", 47 | "moment": "^2.17.1" 48 | }, 49 | "license-check-and-add-config": { 50 | "folder": ".", 51 | "license": "LICENSE.txt", 52 | "exact_paths_method": "EXCLUDE", 53 | "exact_paths": [ 54 | "composer-logs", 55 | "dist", 56 | "node_modules", 57 | "out", 58 | ".git" 59 | ], 60 | "file_type_method": "EXCLUDE", 61 | "file_types": [ 62 | ".yml" 63 | ], 64 | "insert_license": false, 65 | "license_formats": { 66 | "js|cto|acl": { 67 | "prepend": "/*", 68 | "append": " */", 69 | "eachLine": { 70 | "prepend": " * " 71 | } 72 | }, 73 | "md": { 74 | "file": "../../markdown-license.txt" 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /packages/bond-network/permissions.acl: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /** 16 | * Access Control List for the bond data 17 | */ 18 | rule Issuer { 19 | description: "Allow full access to the issuer of a bond" 20 | participant(i): "org.acme.bond.Issuer" 21 | operation: ALL 22 | resource(a): "org.acme.bond.BondAsset" 23 | condition: (a.bond.issuer.memberId === i.memberId) 24 | action: ALLOW 25 | } 26 | 27 | rule Default { 28 | description: "Allow read access" 29 | participant: "org.acme.bond.*" 30 | operation: ALL 31 | resource: "org.acme.bond.*" 32 | action: ALLOW 33 | } 34 | 35 | rule SystemACL { 36 | description: "System ACL to permit all access" 37 | participant: "org.hyperledger.composer.system.Participant" 38 | operation: ALL 39 | resource: "org.hyperledger.composer.system.**" 40 | action: ALLOW 41 | } 42 | 43 | rule NetworkAdminUser { 44 | description: "Grant business network administrators full access to user resources" 45 | participant: "org.hyperledger.composer.system.NetworkAdmin" 46 | operation: ALL 47 | resource: "**" 48 | action: ALLOW 49 | } 50 | 51 | rule NetworkAdminSystem { 52 | description: "Grant business network administrators full access to system resources" 53 | participant: "org.hyperledger.composer.system.NetworkAdmin" 54 | operation: ALL 55 | resource: "org.hyperledger.composer.system.**" 56 | action: ALLOW 57 | } -------------------------------------------------------------------------------- /packages/carauction-network/.eslintignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | coverage 14 | dist 15 | go 16 | node_modules 17 | out 18 | -------------------------------------------------------------------------------- /packages/carauction-network/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es6: true 3 | node: true 4 | mocha: true 5 | extends: 'eslint:recommended' 6 | parserOptions: 7 | ecmaVersion: 8 8 | sourceType: 9 | - script 10 | rules: 11 | indent: 12 | - error 13 | - 4 14 | linebreak-style: 15 | - error 16 | - unix 17 | quotes: 18 | - error 19 | - single 20 | semi: 21 | - error 22 | - always 23 | no-unused-vars: 24 | - error 25 | - args: none 26 | no-console: off 27 | curly: error 28 | eqeqeq: error 29 | no-throw-literal: error 30 | no-var: error 31 | dot-notation: error 32 | no-tabs: error 33 | no-trailing-spaces: error 34 | no-use-before-define: error 35 | no-useless-call: error 36 | no-with: error 37 | operator-linebreak: error 38 | require-jsdoc: 39 | - error 40 | - require: 41 | ClassDeclaration: true 42 | MethodDefinition: true 43 | FunctionDeclaration: true 44 | valid-jsdoc: 45 | - error 46 | - requireReturn: false 47 | yoda: error 48 | -------------------------------------------------------------------------------- /packages/carauction-network/.gitignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | dist 61 | 62 | node_modules 63 | composer-logs -------------------------------------------------------------------------------- /packages/carauction-network/.npmignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | # dist 61 | -------------------------------------------------------------------------------- /packages/carauction-network/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); 2 | you may not use this file except in compliance with the License. 3 | You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | -------------------------------------------------------------------------------- /packages/carauction-network/config/default.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "config":"" 4 | } 5 | -------------------------------------------------------------------------------- /packages/carauction-network/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | -------------------------------------------------------------------------------- /packages/carauction-network/jsdoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": { 3 | "allowUnknownTags": true, 4 | "dictionaries": ["jsdoc","closure"] 5 | }, 6 | "source": { 7 | "include": [ 8 | "./lib" 9 | ], 10 | "includePattern": ".+\\.js(doc|x)?$" 11 | }, 12 | "plugins": ["plugins/markdown"], 13 | "templates": { 14 | "logoFile": "", 15 | "cleverLinks": false, 16 | "monospaceLinks": false, 17 | "dateFormat": "ddd MMM Do YYYY", 18 | "outputSourceFiles": true, 19 | "outputSourcePath": true, 20 | "systemName": "Car Auction Network", 21 | "footer": "", 22 | "copyright": "Released under the Apache License v2.0", 23 | "navType": "vertical", 24 | "theme": "spacelab", 25 | "linenums": true, 26 | "collapseSymbols": false, 27 | "inverseNav": true, 28 | "protocol": "html://", 29 | "methodHeadingReturns": false 30 | }, 31 | "markdown": { 32 | "parser": "gfm", 33 | "hardwrap": true 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/carauction-network/models/auction.cto: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /** 16 | * Defines a data model for a blind vehicle auction 17 | */ 18 | namespace org.acme.vehicle.auction 19 | 20 | asset Vehicle identified by vin { 21 | o String vin 22 | --> Member owner 23 | } 24 | 25 | enum ListingState { 26 | o FOR_SALE 27 | o RESERVE_NOT_MET 28 | o SOLD 29 | } 30 | 31 | asset VehicleListing identified by listingId { 32 | o String listingId 33 | o Double reservePrice 34 | o String description 35 | o ListingState state 36 | o Offer[] offers optional 37 | --> Vehicle vehicle 38 | } 39 | 40 | abstract participant User identified by email { 41 | o String email 42 | o String firstName 43 | o String lastName 44 | } 45 | 46 | participant Member extends User { 47 | o Double balance 48 | } 49 | 50 | participant Auctioneer extends User { 51 | } 52 | 53 | transaction Offer { 54 | o Double bidPrice 55 | --> VehicleListing listing 56 | --> Member member 57 | } 58 | 59 | transaction CloseBidding { 60 | --> VehicleListing listing 61 | } 62 | -------------------------------------------------------------------------------- /packages/carauction-network/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "engines": { 3 | "composer": "^0.20.0" 4 | }, 5 | "name": "carauction-network", 6 | "version": "0.2.6", 7 | "description": "Car Auction Business Network", 8 | "networkImage": "https://hyperledger.github.io/composer-sample-networks/packages/carauction-network/networkimage.svg", 9 | "networkImageanimated": "https://hyperledger.github.io/composer-sample-networks/packages/carauction-network/networkimageanimated.svg", 10 | "scripts": { 11 | "prepublish": "mkdirp ./dist && composer archive create --sourceType dir --sourceName . -a ./dist/carauction-network.bna", 12 | "pretest": "npm run lint", 13 | "lint": "eslint .", 14 | "postlint": "npm run licchk", 15 | "licchk": "license-check-and-add", 16 | "postlicchk": "npm run doc", 17 | "doc": "jsdoc --pedantic --recurse -c jsdoc.json", 18 | "test": "mocha -t 0 --recursive", 19 | "deploy": "./scripts/deploy.sh" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "https://github.com/hyperledger/composer-sample-networks.git" 24 | }, 25 | "keywords": [ 26 | "car", 27 | "auction", 28 | "composer", 29 | "composer-network" 30 | ], 31 | "author": "Hyperledger Composer", 32 | "license": "Apache-2.0", 33 | "devDependencies": { 34 | "chai": "^3.5.0", 35 | "composer-admin": "^0.20.0-0", 36 | "composer-cli": "^0.20.0-0", 37 | "composer-client": "^0.20.0-0", 38 | "composer-common": "^0.20.0-0", 39 | "composer-connector-embedded": "^0.20.0-0", 40 | "eslint": "^3.6.1", 41 | "istanbul": "^0.4.5", 42 | "jsdoc": "^3.5.5", 43 | "license-check-and-add": "~2.3.0", 44 | "mkdirp": "^0.5.1", 45 | "mocha": "^3.2.0", 46 | "moment": "^2.17.1" 47 | }, 48 | "license-check-and-add-config": { 49 | "folder": ".", 50 | "license": "LICENSE.txt", 51 | "exact_paths_method": "EXCLUDE", 52 | "exact_paths": [ 53 | "composer-logs", 54 | "dist", 55 | "node_modules", 56 | "out", 57 | ".git" 58 | ], 59 | "file_type_method": "EXCLUDE", 60 | "file_types": [ 61 | ".yml" 62 | ], 63 | "insert_license": false, 64 | "license_formats": { 65 | "js|cto|acl": { 66 | "prepend": "/*", 67 | "append": " */", 68 | "eachLine": { 69 | "prepend": " * " 70 | } 71 | }, 72 | "md": { 73 | "file": "../../markdown-license.txt" 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /packages/carauction-network/permissions.acl: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /** 16 | * Access Control List for the auction network. 17 | */ 18 | rule Auctioneer { 19 | description: "Allow the auctioneer full access" 20 | participant: "org.acme.vehicle.auction.Auctioneer" 21 | operation: ALL 22 | resource: "org.acme.vehicle.auction.*" 23 | action: ALLOW 24 | } 25 | 26 | rule Member { 27 | description: "Allow the member read access" 28 | participant: "org.acme.vehicle.auction.Member" 29 | operation: READ 30 | resource: "org.acme.vehicle.auction.*" 31 | action: ALLOW 32 | } 33 | 34 | rule VehicleOwner { 35 | description: "Allow the owner of a vehicle total access" 36 | participant(m): "org.acme.vehicle.auction.Member" 37 | operation: ALL 38 | resource(v): "org.acme.vehicle.auction.Vehicle" 39 | condition: (v.owner.getIdentifier() == m.getIdentifier()) 40 | action: ALLOW 41 | } 42 | 43 | rule VehicleListingOwner { 44 | description: "Allow the owner of a vehicle total access to their vehicle listing" 45 | participant(m): "org.acme.vehicle.auction.Member" 46 | operation: ALL 47 | resource(v): "org.acme.vehicle.auction.VehicleListing" 48 | condition: (v.vehicle.owner.getIdentifier() == m.getIdentifier()) 49 | action: ALLOW 50 | } 51 | 52 | rule SystemACL { 53 | description: "System ACL to permit all access" 54 | participant: "org.hyperledger.composer.system.Participant" 55 | operation: ALL 56 | resource: "org.hyperledger.composer.system.**" 57 | action: ALLOW 58 | } 59 | 60 | rule NetworkAdminUser { 61 | description: "Grant business network administrators full access to user resources" 62 | participant: "org.hyperledger.composer.system.NetworkAdmin" 63 | operation: ALL 64 | resource: "**" 65 | action: ALLOW 66 | } 67 | 68 | rule NetworkAdminSystem { 69 | description: "Grant business network administrators full access to system resources" 70 | participant: "org.hyperledger.composer.system.NetworkAdmin" 71 | operation: ALL 72 | resource: "org.hyperledger.composer.system.**" 73 | action: ALLOW 74 | } -------------------------------------------------------------------------------- /packages/digitalproperty-network/.eslintignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | coverage 14 | dist 15 | go 16 | node_modules 17 | out 18 | -------------------------------------------------------------------------------- /packages/digitalproperty-network/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es6: true 3 | node: true 4 | mocha: true 5 | extends: 'eslint:recommended' 6 | parserOptions: 7 | ecmaVersion: 8 8 | sourceType: 9 | - script 10 | rules: 11 | indent: 12 | - error 13 | - 4 14 | linebreak-style: 15 | - error 16 | - unix 17 | quotes: 18 | - error 19 | - single 20 | semi: 21 | - error 22 | - always 23 | no-unused-vars: 24 | - error 25 | - args: none 26 | no-console: off 27 | no-undefl: off 28 | curly: error 29 | eqeqeq: error 30 | no-throw-literal: error 31 | strict: error 32 | no-var: error 33 | dot-notation: error 34 | no-tabs: error 35 | no-trailing-spaces: error 36 | no-use-before-define: error 37 | no-useless-call: error 38 | no-with: error 39 | operator-linebreak: error 40 | require-jsdoc: 41 | - error 42 | - require: 43 | ClassDeclaration: true 44 | MethodDefinition: true 45 | FunctionDeclaration: true 46 | valid-jsdoc: 47 | - error 48 | - requireReturn: false 49 | yoda: error 50 | -------------------------------------------------------------------------------- /packages/digitalproperty-network/.gitignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | dist 61 | composer-logs -------------------------------------------------------------------------------- /packages/digitalproperty-network/.npmignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | # dist 61 | -------------------------------------------------------------------------------- /packages/digitalproperty-network/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); 2 | you may not use this file except in compliance with the License. 3 | You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. -------------------------------------------------------------------------------- /packages/digitalproperty-network/README.md: -------------------------------------------------------------------------------- 1 | # Digital Property Network 2 | 3 | > This Defines a business network where house sellers can list their properties for sale. 4 | 5 | This business network defines: 6 | 7 | **Participant** 8 | `Person` 9 | 10 | **Assets** 11 | `LandTitle` `SalesAgreement` 12 | 13 | **Transaction** 14 | `RegisterPropertyForSale` 15 | 16 | A `Person` is responsible for a `LandTitle`. By creating a `SalesAgreement` between two `Person` participants you are then able to submit a `RegisterPropertyForSale` transaction. 17 | 18 | To test this Business Network Definition in the **Test** tab: 19 | 20 | Create two `Person` participants: 21 | 22 | ``` 23 | { 24 | "$class": "net.biz.digitalPropertyNetwork.Person", 25 | "personId": "personId:Billy", 26 | "firstName": "Billy", 27 | "lastName": "Thompson" 28 | } 29 | ``` 30 | 31 | ``` 32 | { 33 | "$class": "net.biz.digitalPropertyNetwork.Person", 34 | "personId": "personId:Jenny", 35 | "firstName": "Jenny", 36 | "lastName": "Jones" 37 | } 38 | ``` 39 | 40 | Create a `LandTitle` asset: 41 | 42 | ``` 43 | { 44 | "$class": "net.biz.digitalPropertyNetwork.LandTitle", 45 | "titleId": "titleId:ABCD", 46 | "owner": "resource:net.biz.digitalPropertyNetwork.Person#personId:Billy", 47 | "information": "Detached House" 48 | } 49 | ``` 50 | 51 | Create a `SalesAgreement` asset: 52 | 53 | ``` 54 | { 55 | "$class": "net.biz.digitalPropertyNetwork.SalesAgreement", 56 | "salesId": "salesId:1234", 57 | "buyer": "resource:net.biz.digitalPropertyNetwork.Person#personId:Jenny", 58 | "seller": "resource:net.biz.digitalPropertyNetwork.Person#personId:Billy", 59 | "title": "resource:net.biz.digitalPropertyNetwork.LandTitle#titleId:ABCD" 60 | } 61 | ``` 62 | 63 | Submit a `RegisterPropertyForSale` transaction: 64 | 65 | ``` 66 | { 67 | "$class": "net.biz.digitalPropertyNetwork.RegisterPropertyForSale", 68 | "seller": "resource:net.biz.digitalPropertyNetwork.Person#personId:Billy", 69 | "title": "resource:net.biz.digitalPropertyNetwork.LandTitle#titleId:ABCD" 70 | } 71 | ``` 72 | 73 | This `RegisterPropertyForSale` transaction will update `titleId:ABCD` `LandTitle` asset to `forSale`. 74 | 75 | Congratulations! 76 | 77 | ## License 78 | Hyperledger Project source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the LICENSE file. Hyperledger Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at http://creativecommons.org/licenses/by/4.0/. -------------------------------------------------------------------------------- /packages/digitalproperty-network/config/default.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "config":"" 4 | } 5 | -------------------------------------------------------------------------------- /packages/digitalproperty-network/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | -------------------------------------------------------------------------------- /packages/digitalproperty-network/jsdoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": { 3 | "allowUnknownTags": true, 4 | "dictionaries": ["jsdoc","closure"] 5 | }, 6 | "source": { 7 | "include": [ 8 | "./lib" 9 | ], 10 | "includePattern": ".+\\.js(doc|x)?$" 11 | }, 12 | "plugins": ["plugins/markdown"], 13 | "templates": { 14 | "logoFile": "", 15 | "cleverLinks": false, 16 | "monospaceLinks": false, 17 | "dateFormat": "ddd MMM Do YYYY", 18 | "outputSourceFiles": true, 19 | "outputSourcePath": true, 20 | "systemName": "Digital Property Network", 21 | "footer": "", 22 | "copyright": "Released under the Apache License v2.0", 23 | "navType": "vertical", 24 | "theme": "spacelab", 25 | "linenums": true, 26 | "collapseSymbols": false, 27 | "inverseNav": true, 28 | "protocol": "html://", 29 | "methodHeadingReturns": false 30 | }, 31 | "markdown": { 32 | "parser": "gfm", 33 | "hardwrap": true 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/digitalproperty-network/lib/DigitalLandTitle.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /* global getAssetRegistry */ 16 | 17 | 'use strict'; 18 | /** 19 | * Process a property that is held for sale 20 | * @param {net.biz.digitalPropertyNetwork.RegisterPropertyForSale} propertyForSale the property to be sold 21 | * @transaction 22 | */ 23 | async function onRegisterPropertyForSale(propertyForSale) { // eslint-disable-line no-unused-vars 24 | console.log('### onRegisterPropertyForSale ' + propertyForSale.toString()); 25 | propertyForSale.title.forSale = true; 26 | 27 | const registry = await getAssetRegistry('net.biz.digitalPropertyNetwork.LandTitle'); 28 | await registry.update(propertyForSale.title); 29 | } 30 | -------------------------------------------------------------------------------- /packages/digitalproperty-network/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "engines": { 3 | "composer": "^0.20.0" 4 | }, 5 | "name": "digitalproperty-network", 6 | "version": "0.2.6", 7 | "description": "Digital Property Network", 8 | "networkImage": "https://hyperledger.github.io/composer-sample-networks/packages/digitalproperty-network/networkimage.svg", 9 | "networkImageanimated": "https://hyperledger.github.io/composer-sample-networks/packages/digitalproperty-network/networkimageanimated.svg", 10 | "scripts": { 11 | "prepublish": "mkdirp ./dist && composer archive create --sourceType dir --sourceName . -a ./dist/digitalproperty-network.bna", 12 | "pretest": "npm run lint", 13 | "lint": "eslint .", 14 | "postlint": "npm run licchk", 15 | "licchk": "license-check-and-add", 16 | "postlicchk": "npm run doc", 17 | "doc": "jsdoc --pedantic --recurse -c jsdoc.json", 18 | "test": "mocha -t 0 --recursive", 19 | "deploy": "./scripts/deploy.sh" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "https://github.com/hyperledger/composer-sample-networks.git" 24 | }, 25 | "keywords": [ 26 | "land", 27 | "composer", 28 | "composer-network" 29 | ], 30 | "author": "Hyperledger Composer", 31 | "license": "Apache-2.0", 32 | "devDependencies": { 33 | "chai": "^3.5.0", 34 | "composer-admin": "^0.20.0-0", 35 | "composer-cli": "^0.20.0-0", 36 | "composer-client": "^0.20.0-0", 37 | "composer-common": "^0.20.0-0", 38 | "composer-connector-embedded": "^0.20.0-0", 39 | "eslint": "^3.6.1", 40 | "istanbul": "^0.4.5", 41 | "jsdoc": "^3.5.5", 42 | "license-check-and-add": "~2.3.0", 43 | "mkdirp": "^0.5.1", 44 | "mocha": "^3.2.0", 45 | "moment": "^2.17.1" 46 | }, 47 | "dependencies": { 48 | "digitalproperty-model": "^0.2.0" 49 | }, 50 | "license-check-and-add-config": { 51 | "folder": ".", 52 | "license": "LICENSE.txt", 53 | "exact_paths_method": "EXCLUDE", 54 | "exact_paths": [ 55 | "composer-logs", 56 | "dist", 57 | "node_modules", 58 | "out", 59 | ".git" 60 | ], 61 | "file_type_method": "EXCLUDE", 62 | "file_types": [ 63 | ".yml" 64 | ], 65 | "insert_license": false, 66 | "license_formats": { 67 | "js|cto|acl": { 68 | "prepend": "/*", 69 | "append": " */", 70 | "eachLine": { 71 | "prepend": " * " 72 | } 73 | }, 74 | "md": { 75 | "file": "../../markdown-license.txt" 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /packages/digitalproperty-network/permissions.acl: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /** 16 | * Sample access control list. 17 | */ 18 | rule Default { 19 | description: "Allow all participants access to all resources" 20 | participant: "ANY" 21 | operation: ALL 22 | resource: "net.biz.digitalPropertyNetwork.*" 23 | action: ALLOW 24 | } 25 | 26 | rule SystemACL { 27 | description: "System ACL to permit all access" 28 | participant: "org.hyperledger.composer.system.Participant" 29 | operation: ALL 30 | resource: "org.hyperledger.composer.system.**" 31 | action: ALLOW 32 | } 33 | 34 | rule NetworkAdminUser { 35 | description: "Grant business network administrators full access to user resources" 36 | participant: "org.hyperledger.composer.system.NetworkAdmin" 37 | operation: ALL 38 | resource: "**" 39 | action: ALLOW 40 | } 41 | 42 | rule NetworkAdminSystem { 43 | description: "Grant business network administrators full access to system resources" 44 | participant: "org.hyperledger.composer.system.NetworkAdmin" 45 | operation: ALL 46 | resource: "org.hyperledger.composer.system.**" 47 | action: ALLOW 48 | } -------------------------------------------------------------------------------- /packages/fund-clearing-network/.eslintignore: -------------------------------------------------------------------------------- 1 | coverage 2 | dist 3 | go 4 | lib 5 | node_modules 6 | out -------------------------------------------------------------------------------- /packages/fund-clearing-network/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es6: true 3 | node: true 4 | mocha: true 5 | extends: 'eslint:recommended' 6 | parserOptions: 7 | ecmaVersion: 8 8 | sourceType: 9 | - script 10 | rules: 11 | indent: 12 | - error 13 | - 4 14 | linebreak-style: 15 | - error 16 | - unix 17 | quotes: 18 | - error 19 | - single 20 | semi: 21 | - error 22 | - always 23 | no-unused-vars: 24 | - error 25 | - args: none 26 | no-console: off 27 | curly: error 28 | eqeqeq: error 29 | no-throw-literal: error 30 | no-var: error 31 | dot-notation: error 32 | no-tabs: error 33 | no-trailing-spaces: error 34 | no-use-before-define: error 35 | no-useless-call: error 36 | no-with: error 37 | operator-linebreak: error 38 | require-jsdoc: 39 | - error 40 | - require: 41 | ClassDeclaration: true 42 | MethodDefinition: true 43 | FunctionDeclaration: true 44 | valid-jsdoc: 45 | - error 46 | - requireReturn: false 47 | yoda: error -------------------------------------------------------------------------------- /packages/fund-clearing-network/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # nyc test coverage 18 | .nyc_output 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # node-waf configuration 24 | .lock-wscript 25 | 26 | # Compiled binary addons (http://nodejs.org/api/addons.html) 27 | build/Release 28 | 29 | # Dependency directories 30 | node_modules 31 | jspm_packages 32 | 33 | # Optional npm cache directory 34 | .npm 35 | 36 | # Optional REPL history 37 | .node_repl_history 38 | 39 | # JSDoc 40 | out 41 | 42 | # Mac files. 43 | **/.DS_Store 44 | 45 | *.swp 46 | 47 | # Build generated files should be ignored by git, but not by npm. 48 | dist 49 | 50 | node_modules -------------------------------------------------------------------------------- /packages/fund-clearing-network/.npmignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # nyc test coverage 18 | .nyc_output 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # node-waf configuration 24 | .lock-wscript 25 | 26 | # Compiled binary addons (http://nodejs.org/api/addons.html) 27 | build/Release 28 | 29 | # Dependency directories 30 | node_modules 31 | jspm_packages 32 | 33 | # Optional npm cache directory 34 | .npm 35 | 36 | # Optional REPL history 37 | .node_repl_history 38 | 39 | # JSDoc 40 | out 41 | 42 | # Mac files. 43 | **/.DS_Store 44 | 45 | *.swp 46 | 47 | # Build generated files should be ignored by git, but not by npm. 48 | # dist -------------------------------------------------------------------------------- /packages/fund-clearing-network/config/default.json: -------------------------------------------------------------------------------- 1 | { 2 | "composer": { 3 | "log": { 4 | "debug": "composer[none]:*", 5 | "console": { 6 | "maxLevel": "none" 7 | }, 8 | "file": { 9 | "filename" : "./log.txt" 10 | } 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /packages/fund-clearing-network/features/support/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const composerSteps = require('composer-cucumber-steps'); 18 | const cucumber = require('cucumber'); 19 | 20 | module.exports = function () { 21 | composerSteps.call(this); 22 | }; 23 | 24 | if (cucumber.defineSupportCode) { 25 | cucumber.defineSupportCode((context) => { 26 | module.exports.call(context); 27 | }); 28 | } -------------------------------------------------------------------------------- /packages/fund-clearing-network/header.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ -------------------------------------------------------------------------------- /packages/fund-clearing-network/jsdoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": { 3 | "allowUnknownTags": true, 4 | "dictionaries": ["jsdoc","closure"] 5 | }, 6 | "source": { 7 | "include": [ 8 | "./lib" 9 | ], 10 | "includePattern": ".+\\.js(doc|x)?$" 11 | }, 12 | "plugins": ["plugins/markdown"], 13 | "templates": { 14 | "logoFile": "", 15 | "cleverLinks": false, 16 | "monospaceLinks": false, 17 | "dateFormat": "ddd MMM Do YYYY", 18 | "outputSourceFiles": true, 19 | "outputSourcePath": true, 20 | "systemName": "Fund Clearing Network", 21 | "footer": "", 22 | "copyright": "Released under the Apache License v2.0", 23 | "navType": "vertical", 24 | "theme": "spacelab", 25 | "linenums": true, 26 | "collapseSymbols": false, 27 | "inverseNav": true, 28 | "protocol": "html://", 29 | "methodHeadingReturns": false 30 | }, 31 | "markdown": { 32 | "parser": "gfm", 33 | "hardwrap": true 34 | } 35 | } -------------------------------------------------------------------------------- /packages/fund-clearing-network/lib/permissionHelper.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | /** 17 | * Permissions helper for ACL rules 18 | */ 19 | 20 | /** 21 | * Check to see if participant is within the transfer request 22 | * @param {*} transferRequest input TransferRequest 23 | * @param {*} participant the issuing Participant 24 | * @returns {boolean} boolean true/false 25 | */ 26 | function partyWithinTransferRequest(transferRequest, participant){ // eslint-disable-line no-unused-vars 27 | return (transferRequest.fromBank.getIdentifier() === participant.getIdentifier()) || (transferRequest.toBank.getIdentifier() === participant.getIdentifier()); 28 | } 29 | 30 | /** 31 | * Check to see if participant is within the batch transfer request 32 | * @param {*} batchRequest the BatchTransferRequest 33 | * @param {*} participant the issuing Participant 34 | * @returns {boolean} boolean true/false 35 | */ 36 | function partyWithinBatchTransferRequest(batchRequest, participant){// eslint-disable-line no-unused-vars 37 | let allParties = []; 38 | for (let i=0; i BankingParticipant fromBank 21 | --> BankingParticipant toBank 22 | } 23 | 24 | asset BatchTransferRequest identified by batchId { 25 | o String batchId 26 | o Settlement settlement 27 | o BatchState state 28 | --> BankingParticipant[] parties 29 | --> TransferRequest[] transferRequests 30 | } 31 | 32 | transaction SubmitTransferRequest { 33 | o String transferId 34 | o String toBank 35 | o TransferRequestState state 36 | o Transfer details 37 | } 38 | 39 | transaction CreateBatch { 40 | o String batchId 41 | o UsdExchangeRate[] usdRates 42 | } 43 | 44 | transaction MarkPreProcessComplete { 45 | o String batchId 46 | } 47 | 48 | transaction CompleteSettlement { 49 | o String batchId 50 | o UsdExchangeRate[] usdRates 51 | } 52 | 53 | transaction MarkPostProcessComplete { 54 | o String batchId 55 | } 56 | 57 | event BatchCreatedEvent { 58 | o String batchId 59 | } 60 | 61 | concept Settlement { 62 | o Double amount 63 | o Currency currency 64 | --> BankingParticipant creditorBank 65 | --> BankingParticipant debtorBank 66 | } 67 | 68 | concept UsdExchangeRate { 69 | o String to 70 | o Double rate 71 | } 72 | 73 | concept Transfer { 74 | o Currency currency 75 | o Double amount 76 | o Integer fromAccount 77 | o Integer toAccount 78 | } 79 | 80 | enum Currency { 81 | o EURO 82 | o STERLING 83 | o USD 84 | o YEN 85 | o CHF 86 | o CAD 87 | } 88 | 89 | enum TransferRequestState { 90 | o PENDING 91 | o PROCESSING 92 | o PRE_PROCESS_COMPLETE 93 | o COMPLETE 94 | o ERROR 95 | } 96 | 97 | enum BatchState { 98 | o PENDING_PRE_PROCESS 99 | o READY_TO_SETTLE 100 | o PENDING_POST_PROCESS 101 | o COMPLETE 102 | } -------------------------------------------------------------------------------- /packages/fund-clearing-network/networkimage.svg: -------------------------------------------------------------------------------- 1 | Asset 33 -------------------------------------------------------------------------------- /packages/fund-clearing-network/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "engines": { 3 | "composer": "^0.20.0" 4 | }, 5 | "name": "fund-clearing-network", 6 | "version": "0.2.6", 7 | "description": "Sample network to facilitate the transafer of funds between participants", 8 | "networkImage": "https://hyperledger.github.io/composer-sample-networks/packages/fund-clearing-network/networkimage.svg", 9 | "networkImageanimated": "https://hyperledger.github.io/composer-sample-networks/packages/fund-clearing-network/networkimageanimated.svg", 10 | "scripts": { 11 | "prepublish": "mkdirp ./dist && composer archive create --sourceType dir --sourceName . -a ./dist/fund-clearing-network.bna", 12 | "pretest": "npm run lint", 13 | "lint": "eslint .", 14 | "postlint": "npm run licchk", 15 | "licchk": "license-check", 16 | "postlicchk": "npm run doc", 17 | "doc": "jsdoc --pedantic --recurse -c jsdoc.json", 18 | "test-mocha": "mocha -t 0 --recursive", 19 | "test-cucumber": "cucumber-js", 20 | "test-all": "mocha -t 0 --recursive && cucumber-js", 21 | "test-cover": "nyc npm run test-all", 22 | "test": "npm run test-all" 23 | }, 24 | "repository": { 25 | "type": "git", 26 | "url": "https://github.com/hyperledger/composer-sample-networks.git" 27 | }, 28 | "keywords": [ 29 | "sample", 30 | "composer", 31 | "composer-network" 32 | ], 33 | "author": "Hyperledger Composer", 34 | "license": "Apache-2.0", 35 | "devDependencies": { 36 | "chai": "^3.5.0", 37 | "chai-as-promised": "^6.0.0", 38 | "composer-admin": "^0.20.0-0", 39 | "composer-cli": "^0.20.0-0", 40 | "composer-client": "^0.20.0-0", 41 | "composer-connector-embedded": "^0.20.0-0", 42 | "composer-cucumber-steps": "^0.20.0-0", 43 | "cucumber": "^2.2.0", 44 | "eslint": "^3.6.1", 45 | "istanbul": "^0.4.5", 46 | "jsdoc": "^3.5.5", 47 | "license-check": "^1.1.5", 48 | "mkdirp": "^0.5.1", 49 | "mocha": "^3.2.0", 50 | "moment": "^2.17.1", 51 | "nyc": "^11.0.2", 52 | "rewire": "^4.0.0", 53 | "sinon": "2.3.8" 54 | }, 55 | "license-check-config": { 56 | "src": [ 57 | "**/*.js", 58 | "!./coverage/**/*", 59 | "!./node_modules/**/*", 60 | "!./out/**/*", 61 | "!./scripts/**/*" 62 | ], 63 | "path": "header.txt", 64 | "blocking": true, 65 | "logInfo": false, 66 | "logError": true 67 | }, 68 | "nyc": { 69 | "exclude": [ 70 | "coverage/**", 71 | "features/**", 72 | "out/**", 73 | "test/**" 74 | ], 75 | "reporter": [ 76 | "text-summary", 77 | "html" 78 | ], 79 | "all": true, 80 | "check-coverage": true, 81 | "statements": 100, 82 | "branches": 100, 83 | "functions": 100, 84 | "lines": 100 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /packages/fund-clearing-network/queries.qry: -------------------------------------------------------------------------------- 1 | /** 2 | * Queries for Fund Clearing 3 | */ 4 | 5 | query TransferRequestsByBankInState { 6 | description: "Select all TransferRequests for a participating bank in a given state" 7 | statement: 8 | SELECT org.clearing.TransferRequest 9 | WHERE (fromBank == _$bank) 10 | } 11 | 12 | query TransferRequestsByBanksInState { 13 | description: "Select all TransferRequests for a participating bank in a given state" 14 | statement: 15 | SELECT org.clearing.TransferRequest 16 | WHERE ((fromBank == _$bank1 AND toBank == _$bank2 AND state == _$state) OR (fromBank == _$bank2 AND toBank == _$bank1 AND state == _$state)) 17 | } 18 | 19 | query BatchTransferRequestById { 20 | description: "Select a BatchTransferRequest by the UUID" 21 | statement: 22 | SELECT org.clearing.BatchTransferRequest 23 | WHERE (_$batchId == batchId) 24 | } 25 | 26 | query BatchTransferRequestsByBankInState { 27 | description: "Select all BatchTransferRequests in a given state for a participating bank" 28 | statement: 29 | SELECT org.clearing.BatchTransferRequest 30 | WHERE ((parties CONTAINS _$party) AND (state == _$state)) 31 | } 32 | 33 | query BatchTransferRequestForBanksInState { 34 | description: "Select all BatchTransferRequests in a given state for two participating banks" 35 | statement: 36 | SELECT org.clearing.BatchTransferRequest 37 | WHERE ((parties CONTAINS [_$bank1, _$bank2]) AND (state == _$state)) 38 | } 39 | -------------------------------------------------------------------------------- /packages/letters-of-credit-network/.eslintignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | coverage 14 | dist 15 | go 16 | node_modules 17 | out -------------------------------------------------------------------------------- /packages/letters-of-credit-network/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es6: true 3 | node: true 4 | mocha: true 5 | extends: 'eslint:recommended' 6 | parserOptions: 7 | ecmaVersion: 8 8 | sourceType: 9 | - script 10 | rules: 11 | indent: 12 | - error 13 | - 4 14 | linebreak-style: 15 | - error 16 | - unix 17 | quotes: 18 | - error 19 | - single 20 | semi: 21 | - error 22 | - always 23 | no-unused-vars: 24 | - error 25 | - args: none 26 | no-var: error 27 | no-console: off 28 | curly: error 29 | eqeqeq: error 30 | no-throw-literal: error 31 | dot-notation: error 32 | no-tabs: error 33 | no-trailing-spaces: error 34 | no-useless-call: error 35 | no-with: error 36 | operator-linebreak: error 37 | require-jsdoc: 38 | - error 39 | - require: 40 | ClassDeclaration: true 41 | MethodDefinition: true 42 | FunctionDeclaration: true 43 | yoda: error 44 | no-confusing-arrow: 2 45 | no-constant-condition: 2 46 | -------------------------------------------------------------------------------- /packages/letters-of-credit-network/.gitignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | dist 61 | 62 | node_modules 63 | composer-logs 64 | -------------------------------------------------------------------------------- /packages/letters-of-credit-network/.npmignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | # dist 61 | -------------------------------------------------------------------------------- /packages/letters-of-credit-network/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); 2 | you may not use this file except in compliance with the License. 3 | You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. -------------------------------------------------------------------------------- /packages/letters-of-credit-network/config/default.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "config":"" 4 | } 5 | -------------------------------------------------------------------------------- /packages/letters-of-credit-network/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | -------------------------------------------------------------------------------- /packages/letters-of-credit-network/jsdoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": { 3 | "allowUnknownTags": true, 4 | "dictionaries": ["jsdoc","closure"] 5 | }, 6 | "source": { 7 | "include": [ 8 | "./lib" 9 | ], 10 | "includePattern": ".+\\.js(doc|x)?$" 11 | }, 12 | "plugins": ["plugins/markdown"], 13 | "templates": { 14 | "logoFile": "", 15 | "cleverLinks": false, 16 | "monospaceLinks": false, 17 | "dateFormat": "ddd MMM Do YYYY", 18 | "outputSourceFiles": true, 19 | "outputSourcePath": true, 20 | "systemName": "Perishable Goods Network", 21 | "footer": "", 22 | "copyright": "Released under the Apache License v2.0", 23 | "navType": "vertical", 24 | "theme": "spacelab", 25 | "linenums": true, 26 | "collapseSymbols": false, 27 | "inverseNav": true, 28 | "protocol": "html://", 29 | "methodHeadingReturns": false 30 | }, 31 | "markdown": { 32 | "parser": "gfm", 33 | "hardwrap": true 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/letters-of-credit-network/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "engines": { 3 | "composer": "^0.20.0" 4 | }, 5 | "name": "letters-of-credit-network", 6 | "description": "letters of credit network", 7 | "networkImage": "https://hyperledger.github.io/composer-sample-networks/packages/letters-of-credit-network/networkimage.svg", 8 | "networkImageanimated": "https://hyperledger.github.io/composer-sample-networks/packages/letters-of-credit-network/networkimageanimated.svg", 9 | "version": "0.2.6", 10 | "scripts": { 11 | "prepublish": "mkdirp ./dist && composer archive create --sourceType dir --sourceName . -a ./dist/letters-of-credit-network.bna", 12 | "lint": "eslint .", 13 | "postlint": "npm run licchk", 14 | "licchk": "license-check-and-add", 15 | "pretest": "npm run lint", 16 | "test": "mocha -t 0 --recursive", 17 | "test-cover": "nyc npm run test" 18 | }, 19 | "keywords": [ 20 | "letter", 21 | "credit", 22 | "composer", 23 | "composer-network" 24 | ], 25 | "repository": { 26 | "type": "git", 27 | "url": "https://github.com/hyperledger/composer-sample-networks.git" 28 | }, 29 | "author": "Hyperledger Composer", 30 | "license": "Apache-2.0", 31 | "devDependencies": { 32 | "browserfs": "^1.2.0", 33 | "chai": "^3.5.0", 34 | "chai-as-promised": "^6.0.0", 35 | "composer-admin": "^0.20.0-0", 36 | "composer-cli": "^0.20.0-0", 37 | "composer-client": "^0.20.0-0", 38 | "composer-common": "^0.20.0-0", 39 | "composer-connector-embedded": "^0.20.0-0", 40 | "eslint": "^3.6.1", 41 | "istanbul": "^0.4.5", 42 | "jsdoc": "^3.5.5", 43 | "license-check-and-add": "~2.3.0", 44 | "mkdirp": "^0.5.1", 45 | "mocha": "^3.2.0", 46 | "moment": "^2.17.1", 47 | "nyc": "^11.0.2" 48 | }, 49 | "license-check-and-add-config": { 50 | "folder": ".", 51 | "license": "LICENSE.txt", 52 | "exact_paths_method": "EXCLUDE", 53 | "exact_paths": [ 54 | "composer-logs", 55 | "dist", 56 | "node_modules", 57 | "out", 58 | ".git" 59 | ], 60 | "file_type_method": "EXCLUDE", 61 | "file_types": [ 62 | ".yml" 63 | ], 64 | "insert_license": false, 65 | "license_formats": { 66 | "js|cto|acl|qry": { 67 | "prepend": "/*", 68 | "append": " */", 69 | "eachLine": { 70 | "prepend": " * " 71 | } 72 | }, 73 | "md": { 74 | "file": "../../markdown-license.txt" 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /packages/marbles-network/.eslintignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | coverage 14 | dist 15 | go 16 | node_modules 17 | out 18 | -------------------------------------------------------------------------------- /packages/marbles-network/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es6: true 3 | node: true 4 | mocha: true 5 | extends: 'eslint:recommended' 6 | parserOptions: 7 | ecmaVersion: 8 8 | sourceType: 9 | - script 10 | rules: 11 | indent: 12 | - error 13 | - 4 14 | linebreak-style: 15 | - error 16 | - unix 17 | quotes: 18 | - error 19 | - single 20 | semi: 21 | - error 22 | - always 23 | no-unused-vars: 24 | - error 25 | - args: none 26 | no-console: off 27 | curly: error 28 | eqeqeq: error 29 | no-throw-literal: error 30 | no-var: error 31 | dot-notation: error 32 | no-tabs: error 33 | no-trailing-spaces: error 34 | no-use-before-define: error 35 | no-useless-call: error 36 | no-with: error 37 | operator-linebreak: error 38 | require-jsdoc: 39 | - error 40 | - require: 41 | ClassDeclaration: true 42 | MethodDefinition: true 43 | FunctionDeclaration: true 44 | valid-jsdoc: 45 | - error 46 | - requireReturn: false 47 | yoda: error 48 | -------------------------------------------------------------------------------- /packages/marbles-network/.gitignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | dist 61 | composer-logs 62 | -------------------------------------------------------------------------------- /packages/marbles-network/.npmignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | # dist 61 | -------------------------------------------------------------------------------- /packages/marbles-network/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); 2 | you may not use this file except in compliance with the License. 3 | You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. -------------------------------------------------------------------------------- /packages/marbles-network/README.md: -------------------------------------------------------------------------------- 1 | # Marbles Network 2 | 3 | > This is an interactive and distributed, marble trading demo. List marbles for sale and exchange marbles between participants. 4 | 5 | This business network defines: 6 | 7 | **Participant** 8 | `Player` 9 | 10 | **Asset** 11 | `Marble` 12 | 13 | **Transaction** 14 | `TradeMarble` 15 | 16 | `Player` participants are able to have `Marble` assets and trade these with `TradeMarble` transaction. 17 | 18 | To test this Business Network Definition in the **Test** tab: 19 | 20 | Create two `Player` participant: 21 | 22 | ``` 23 | { 24 | "$class": "org.hyperledger_composer.marbles.Player", 25 | "email": "memberA@acme.org", 26 | "firstName": "Jenny", 27 | "lastName": "Jones" 28 | } 29 | ``` 30 | 31 | ``` 32 | { 33 | "$class": "org.hyperledger_composer.marbles.Player", 34 | "email": "memberB@acme.org", 35 | "firstName": "Billy", 36 | "lastName": "Thompson" 37 | } 38 | ``` 39 | 40 | Create a `Marble` asset: 41 | 42 | ``` 43 | { 44 | "$class": "org.hyperledger_composer.marbles.Marble", 45 | "marbleId": "marbleId:1234", 46 | "size": "SMALL", 47 | "color": "BLUE", 48 | "owner": "resource:org.hyperledger_composer.marbles.Player#email:memberA@acme.org" 49 | } 50 | ``` 51 | 52 | Submit a `Transaction` transaction: 53 | 54 | ``` 55 | { 56 | "$class": "org.hyperledger_composer.marbles.TradeMarble", 57 | "marble": "resource:org.hyperledger_composer.marbles.Marble#marbleId:1234", 58 | "newOwner": "resource:org.hyperledger_composer.marbles.Player#email:memberB@acme.org" 59 | } 60 | ``` 61 | 62 | This transaction has transferred `marbleId:1234` from `memberA@acme.org` to `memberB@acme.org`. 63 | 64 | Congratulations! 65 | 66 | ## License 67 | Hyperledger Project source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the LICENSE file. Hyperledger Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at http://creativecommons.org/licenses/by/4.0/. -------------------------------------------------------------------------------- /packages/marbles-network/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | -------------------------------------------------------------------------------- /packages/marbles-network/jsdoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": { 3 | "allowUnknownTags": true, 4 | "dictionaries": ["jsdoc","closure"] 5 | }, 6 | "source": { 7 | "include": [ 8 | "./lib" 9 | ], 10 | "includePattern": ".+\\.js(doc|x)?$" 11 | }, 12 | "plugins": ["plugins/markdown"], 13 | "templates": { 14 | "logoFile": "", 15 | "cleverLinks": false, 16 | "monospaceLinks": false, 17 | "dateFormat": "ddd MMM Do YYYY", 18 | "outputSourceFiles": true, 19 | "outputSourcePath": true, 20 | "systemName": "Marble Trading Network", 21 | "footer": "", 22 | "copyright": "Released under the Apache License v2.0", 23 | "navType": "vertical", 24 | "theme": "spacelab", 25 | "linenums": true, 26 | "collapseSymbols": false, 27 | "inverseNav": true, 28 | "protocol": "html://", 29 | "methodHeadingReturns": false 30 | }, 31 | "markdown": { 32 | "parser": "gfm", 33 | "hardwrap": true 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/marbles-network/lib/logic.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /* global getAssetRegistry */ 16 | 17 | /** 18 | * Trade a marble to a new player 19 | * @param {org.hyperledger_composer.marbles.TradeMarble} tradeMarble - the trade marble transaction 20 | * @transaction 21 | */ 22 | async function tradeMarble(tradeMarble) { // eslint-disable-line no-unused-vars 23 | tradeMarble.marble.owner = tradeMarble.newOwner; 24 | const assetRegistry = await getAssetRegistry('org.hyperledger_composer.marbles.Marble'); 25 | await assetRegistry.update(tradeMarble.marble); 26 | } 27 | -------------------------------------------------------------------------------- /packages/marbles-network/models/marbles.cto: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /** 16 | * Defines a data model for a marble trading network 17 | */ 18 | namespace org.hyperledger_composer.marbles 19 | 20 | enum MarbleColor { 21 | o RED 22 | o GREEN 23 | o BLUE 24 | o PURPLE 25 | o ORANGE 26 | } 27 | 28 | enum MarbleSize { 29 | o SMALL 30 | o MEDIUM 31 | o LARGE 32 | } 33 | 34 | asset Marble identified by marbleId { 35 | o String marbleId 36 | o MarbleSize size 37 | o MarbleColor color 38 | --> Player owner 39 | } 40 | 41 | participant Player identified by email { 42 | o String email 43 | o String firstName 44 | o String lastName 45 | } 46 | 47 | transaction TradeMarble { 48 | --> Marble marble 49 | --> Player newOwner 50 | } 51 | -------------------------------------------------------------------------------- /packages/marbles-network/networkimage.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | Marbles Image 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /packages/marbles-network/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "engines": { 3 | "composer": "^0.20.0" 4 | }, 5 | "name": "marbles-network", 6 | "version": "0.2.6", 7 | "description": "Marble Trading Network", 8 | "networkImage": "https://hyperledger.github.io/composer-sample-networks/packages/marbles-network/networkimage.svg", 9 | "networkImageanimated": "https://hyperledger.github.io/composer-sample-networks/packages/marbles-network/networkimageanimated.svg", 10 | "scripts": { 11 | "prepublish": "mkdirp ./dist && composer archive create --sourceType dir --sourceName . -a ./dist/marbles-network.bna", 12 | "pretest": "npm run lint", 13 | "lint": "eslint .", 14 | "postlint": "npm run licchk", 15 | "licchk": "license-check-and-add", 16 | "postlicchk": "npm run doc", 17 | "doc": "jsdoc --pedantic --recurse -c jsdoc.json", 18 | "test": "mocha -t 0 --recursive", 19 | "deploy": "./scripts/deploy.sh" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "https://github.com/hyperledger/composer-sample-networks.git" 24 | }, 25 | "keywords": [ 26 | "marbles", 27 | "trading", 28 | "composer", 29 | "composer-network" 30 | ], 31 | "author": "Hyperledger Composer", 32 | "license": "Apache-2.0", 33 | "devDependencies": { 34 | "chai": "^3.5.0", 35 | "composer-admin": "^0.20.0-0", 36 | "composer-cli": "^0.20.0-0", 37 | "composer-client": "^0.20.0-0", 38 | "composer-common": "^0.20.0-0", 39 | "composer-connector-embedded": "^0.20.0-0", 40 | "eslint": "^3.6.1", 41 | "istanbul": "^0.4.5", 42 | "jsdoc": "^3.5.5", 43 | "license-check-and-add": "~2.3.0", 44 | "mkdirp": "^0.5.1", 45 | "mocha": "^3.2.0", 46 | "moment": "^2.17.1" 47 | }, 48 | "license-check-and-add-config": { 49 | "folder": ".", 50 | "license": "LICENSE.txt", 51 | "exact_paths_method": "EXCLUDE", 52 | "exact_paths": [ 53 | "composer-logs", 54 | "dist", 55 | "node_modules", 56 | "out", 57 | ".git" 58 | ], 59 | "file_type_method": "EXCLUDE", 60 | "file_types": [ 61 | ".yml" 62 | ], 63 | "insert_license": false, 64 | "license_formats": { 65 | "js|cto|acl": { 66 | "prepend": "/*", 67 | "append": " */", 68 | "eachLine": { 69 | "prepend": " * " 70 | } 71 | }, 72 | "md": { 73 | "file": "../../markdown-license.txt" 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /packages/marbles-network/permissions.acl: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /** 16 | * Sample access control list. 17 | */ 18 | rule Default { 19 | description: "Allow all participants access to all resources" 20 | participant: "ANY" 21 | operation: ALL 22 | resource: "org.hyperledger_composer.marbles.*" 23 | action: ALLOW 24 | } 25 | 26 | rule SystemACL { 27 | description: "System ACL to permit all access" 28 | participant: "org.hyperledger.composer.system.Participant" 29 | operation: ALL 30 | resource: "org.hyperledger.composer.system.**" 31 | action: ALLOW 32 | } 33 | 34 | rule NetworkAdminUser { 35 | description: "Grant business network administrators full access to user resources" 36 | participant: "org.hyperledger.composer.system.NetworkAdmin" 37 | operation: ALL 38 | resource: "**" 39 | action: ALLOW 40 | } 41 | 42 | rule NetworkAdminSystem { 43 | description: "Grant business network administrators full access to system resources" 44 | participant: "org.hyperledger.composer.system.NetworkAdmin" 45 | operation: ALL 46 | resource: "org.hyperledger.composer.system.**" 47 | action: ALLOW 48 | } -------------------------------------------------------------------------------- /packages/perishable-network/.eslintignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | coverage 14 | dist 15 | go 16 | node_modules 17 | out 18 | -------------------------------------------------------------------------------- /packages/perishable-network/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es6: false 3 | node: true 4 | mocha: true 5 | extends: 'eslint:recommended' 6 | parserOptions: 7 | ecmaVersion: 8 8 | sourceType: 9 | - script 10 | rules: 11 | indent: 12 | - error 13 | - 4 14 | linebreak-style: 15 | - error 16 | - unix 17 | quotes: 18 | - error 19 | - single 20 | semi: 21 | - error 22 | - always 23 | no-unused-vars: 24 | - error 25 | - args: none 26 | no-console: off 27 | curly: error 28 | eqeqeq: error 29 | no-throw-literal: error 30 | dot-notation: error 31 | no-tabs: error 32 | no-trailing-spaces: error 33 | no-use-before-define: error 34 | no-useless-call: error 35 | no-with: error 36 | operator-linebreak: error 37 | require-jsdoc: 38 | - error 39 | - require: 40 | ClassDeclaration: true 41 | MethodDefinition: true 42 | FunctionDeclaration: true 43 | valid-jsdoc: 44 | - error 45 | - requireReturn: false 46 | yoda: error 47 | -------------------------------------------------------------------------------- /packages/perishable-network/.gitignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | dist 61 | 62 | node_modules 63 | composer-logs 64 | -------------------------------------------------------------------------------- /packages/perishable-network/.npmignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | # dist 61 | -------------------------------------------------------------------------------- /packages/perishable-network/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); 2 | you may not use this file except in compliance with the License. 3 | You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. -------------------------------------------------------------------------------- /packages/perishable-network/README.md: -------------------------------------------------------------------------------- 1 | # Perishable Goods Network 2 | 3 | > Example business network that shows growers, shippers and importers defining contracts for the price of perishable goods, based on temperature readings received for shipping containers. 4 | 5 | The business network defines a contract between growers and importers. The contract stipulates that: On receipt of the shipment the importer pays the grower the unit price x the number of units in the shipment. Shipments that arrive late are free. Shipments that have breached the low temperate threshold have a penalty applied proportional to the magnitude of the breach x a penalty factor. Shipments that have breached the high temperate threshold have a penalty applied proportional to the magnitude of the breach x a penalty factor. 6 | 7 | This business network defines: 8 | 9 | **Participants** 10 | `Grower` `Importer` `Shipper` 11 | 12 | **Assets** 13 | `Contract` `Shipment` 14 | 15 | **Transactions** 16 | `TemperatureReading` `ShipmentReceived` `SetupDemo` 17 | 18 | To test this Business Network Definition in the **Test** tab: 19 | 20 | Submit a `SetupDemo` transaction: 21 | 22 | ``` 23 | { 24 | "$class": "org.acme.shipping.perishable.SetupDemo" 25 | } 26 | ``` 27 | 28 | This transaction populates the Participant Registries with a `Grower`, an `Importer` and a `Shipper`. The Asset Registries will have a `Contract` asset and a `Shipment` asset. 29 | 30 | Submit a `TemperatureReading` transaction: 31 | 32 | ``` 33 | { 34 | "$class": "org.acme.shipping.perishable.TemperatureReading", 35 | "centigrade": 8, 36 | "shipment": "resource:org.acme.shipping.perishable.Shipment#SHIP_001" 37 | } 38 | ``` 39 | 40 | If the temperature reading falls outside the min/max range of the contract, the price received by the grower will be reduced. You may submit several readings if you wish. Each reading will be aggregated within `SHIP_001` Shipment Asset Registry. 41 | 42 | Submit a `ShipmentReceived` transaction for `SHIP_001` to trigger the payout to the grower, based on the parameters of the `CON_001` contract: 43 | 44 | ``` 45 | { 46 | "$class": "org.acme.shipping.perishable.ShipmentReceived", 47 | "shipment": "resource:org.acme.shipping.perishable.Shipment#SHIP_001" 48 | } 49 | ``` 50 | 51 | If the date-time of the `ShipmentReceived` transaction is after the `arrivalDateTime` on `CON_001` then the grower will no receive any payment for the shipment. 52 | 53 | Congratulations! 54 | 55 | ## License 56 | Hyperledger Project source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the LICENSE file. Hyperledger Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at http://creativecommons.org/licenses/by/4.0/. 57 | -------------------------------------------------------------------------------- /packages/perishable-network/config/default.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "config":"" 4 | } 5 | -------------------------------------------------------------------------------- /packages/perishable-network/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | -------------------------------------------------------------------------------- /packages/perishable-network/jsdoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": { 3 | "allowUnknownTags": true, 4 | "dictionaries": ["jsdoc","closure"] 5 | }, 6 | "source": { 7 | "include": [ 8 | "./lib" 9 | ], 10 | "includePattern": ".+\\.js(doc|x)?$" 11 | }, 12 | "plugins": ["plugins/markdown"], 13 | "templates": { 14 | "logoFile": "", 15 | "cleverLinks": false, 16 | "monospaceLinks": false, 17 | "dateFormat": "ddd MMM Do YYYY", 18 | "outputSourceFiles": true, 19 | "outputSourcePath": true, 20 | "systemName": "Perishable Goods Network", 21 | "footer": "", 22 | "copyright": "Released under the Apache License v2.0", 23 | "navType": "vertical", 24 | "theme": "spacelab", 25 | "linenums": true, 26 | "collapseSymbols": false, 27 | "inverseNav": true, 28 | "protocol": "html://", 29 | "methodHeadingReturns": false 30 | }, 31 | "markdown": { 32 | "parser": "gfm", 33 | "hardwrap": true 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/perishable-network/networkimage.svg: -------------------------------------------------------------------------------- 1 | Asset 18 -------------------------------------------------------------------------------- /packages/perishable-network/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "engines": { 3 | "composer": "^0.20.0" 4 | }, 5 | "name": "perishable-network", 6 | "version": "0.2.6", 7 | "description": "Shipping Perishable Goods Business Network", 8 | "networkImage": "https://hyperledger.github.io/composer-sample-networks/packages/perishable-network/networkimage.svg", 9 | "networkImageanimated": "https://hyperledger.github.io/composer-sample-networks/packages/perishable-network/networkimageanimated.svg", 10 | "scripts": { 11 | "prepublish": "mkdirp ./dist && composer archive create --sourceType dir --sourceName . -a ./dist/perishable-network.bna", 12 | "pretest": "npm run lint", 13 | "lint": "eslint .", 14 | "postlint": "npm run licchk", 15 | "licchk": "license-check-and-add", 16 | "postlicchk": "npm run doc", 17 | "doc": "jsdoc --pedantic --recurse -c jsdoc.json", 18 | "test": "mocha -t 0 --recursive", 19 | "deploy": "./scripts/deploy.sh" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "https://github.com/hyperledger/composer-sample-networks.git" 24 | }, 25 | "keywords": [ 26 | "shipping", 27 | "goods", 28 | "perishable", 29 | "composer", 30 | "composer-network" 31 | ], 32 | "author": "Hyperledger Composer", 33 | "license": "Apache-2.0", 34 | "devDependencies": { 35 | "chai": "^3.5.0", 36 | "composer-admin": "^0.20.0-0", 37 | "composer-cli": "^0.20.0-0", 38 | "composer-client": "^0.20.0-0", 39 | "composer-common": "^0.20.0-0", 40 | "composer-connector-embedded": "^0.20.0-0", 41 | "eslint": "^3.6.1", 42 | "istanbul": "^0.4.5", 43 | "jsdoc": "^3.5.5", 44 | "license-check-and-add": "~2.3.0", 45 | "mkdirp": "^0.5.1", 46 | "mocha": "^3.2.0", 47 | "moment": "^2.17.1", 48 | "sinon": "2.3.8" 49 | }, 50 | "license-check-and-add-config": { 51 | "folder": ".", 52 | "license": "LICENSE.txt", 53 | "exact_paths_method": "EXCLUDE", 54 | "exact_paths": [ 55 | "composer-logs", 56 | "dist", 57 | "node_modules", 58 | "out", 59 | ".git" 60 | ], 61 | "file_type_method": "EXCLUDE", 62 | "file_types": [ 63 | ".yml" 64 | ], 65 | "insert_license": false, 66 | "license_formats": { 67 | "js|cto|acl": { 68 | "prepend": "/*", 69 | "append": " */", 70 | "eachLine": { 71 | "prepend": " * " 72 | } 73 | }, 74 | "md": { 75 | "file": "../../markdown-license.txt" 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /packages/perishable-network/permissions.acl: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /** 16 | * Sample access control list. 17 | */ 18 | rule Default { 19 | description: "Allow all participants access to all resources" 20 | participant: "ANY" 21 | operation: ALL 22 | resource: "org.acme.shipping.perishable.*" 23 | action: ALLOW 24 | } 25 | 26 | rule SystemACL { 27 | description: "System ACL to permit all access" 28 | participant: "org.hyperledger.composer.system.Participant" 29 | operation: ALL 30 | resource: "org.hyperledger.composer.system.**" 31 | action: ALLOW 32 | } 33 | 34 | rule NetworkAdminUser { 35 | description: "Grant business network administrators full access to user resources" 36 | participant: "org.hyperledger.composer.system.NetworkAdmin" 37 | operation: ALL 38 | resource: "**" 39 | action: ALLOW 40 | } 41 | 42 | rule NetworkAdminSystem { 43 | description: "Grant business network administrators full access to system resources" 44 | participant: "org.hyperledger.composer.system.NetworkAdmin" 45 | operation: ALL 46 | resource: "org.hyperledger.composer.system.**" 47 | action: ALLOW 48 | } -------------------------------------------------------------------------------- /packages/pii-network/.eslintignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | coverage 14 | dist 15 | go 16 | node_modules 17 | out 18 | -------------------------------------------------------------------------------- /packages/pii-network/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es6: true 3 | node: true 4 | mocha: true 5 | extends: 'eslint:recommended' 6 | parserOptions: 7 | ecmaVersion: 8 8 | sourceType: 9 | - script 10 | rules: 11 | indent: 12 | - error 13 | - 4 14 | linebreak-style: 15 | - error 16 | - unix 17 | quotes: 18 | - error 19 | - single 20 | semi: 21 | - error 22 | - always 23 | no-unused-vars: 24 | - error 25 | - args: none 26 | no-console: off 27 | curly: error 28 | eqeqeq: error 29 | no-throw-literal: error 30 | strict: error 31 | no-var: error 32 | dot-notation: error 33 | no-tabs: error 34 | no-trailing-spaces: error 35 | no-use-before-define: error 36 | no-useless-call: error 37 | no-with: error 38 | operator-linebreak: error 39 | require-jsdoc: 40 | - error 41 | - require: 42 | ClassDeclaration: true 43 | MethodDefinition: true 44 | FunctionDeclaration: true 45 | valid-jsdoc: 46 | - error 47 | - requireReturn: false 48 | yoda: error 49 | -------------------------------------------------------------------------------- /packages/pii-network/.gitignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | dist 61 | 62 | node_modules 63 | composer-logs 64 | -------------------------------------------------------------------------------- /packages/pii-network/.npmignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | # dist 61 | -------------------------------------------------------------------------------- /packages/pii-network/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); 2 | you may not use this file except in compliance with the License. 3 | You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. -------------------------------------------------------------------------------- /packages/pii-network/README.md: -------------------------------------------------------------------------------- 1 | # Personally Identifiable Information Network 2 | 3 | > A business network where members can grant/revoke access to their personal information to other members. 4 | 5 | This business network defines: 6 | 7 | **Participant** 8 | `Member` 9 | 10 | **Transaction** 11 | `AuthorizeAccess` `RevokeAccess` 12 | 13 | To test this Business Network Definition in the **Test** tab: 14 | 15 | Create two `Member` participants: 16 | 17 | ``` 18 | { 19 | "$class": "org.acme.pii.Member", 20 | "email": "memberA@acme.org", 21 | "firstName": "Billy", 22 | "lastName": "Thompson" 23 | } 24 | ``` 25 | 26 | ``` 27 | { 28 | "$class": "org.acme.pii.Member", 29 | "email": "memberB@acme.org", 30 | "firstName": "Jenny", 31 | "lastName": "Jones" 32 | } 33 | ``` 34 | 35 | Submit a `AuthorizeAccess` transaction: 36 | 37 | ``` 38 | { 39 | "$class": "org.acme.pii.AuthorizeAccess", 40 | "memberId": "org.acme.pii.Member#memberA@acme.org" 41 | } 42 | ``` 43 | 44 | This `AuthorizeAccess` allowed `memberA@acme.org` permission to view personal information of other members. 45 | 46 | Submit a `RevokeAccess` transaction: 47 | 48 | ``` 49 | { 50 | "$class": "org.acme.pii.RevokeAccess", 51 | "memberId": "org.acme.pii.Member#memberB@acme.org" 52 | } 53 | ``` 54 | 55 | This `RevokeAccess` revoked `memberB@acme.org` permission to view personal information of other members. 56 | 57 | Congratulations! 58 | 59 | ## License 60 | Hyperledger Project source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the LICENSE file. Hyperledger Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at http://creativecommons.org/licenses/by/4.0/. -------------------------------------------------------------------------------- /packages/pii-network/config/default.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "config":"" 4 | } 5 | -------------------------------------------------------------------------------- /packages/pii-network/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | -------------------------------------------------------------------------------- /packages/pii-network/jsdoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": { 3 | "allowUnknownTags": true, 4 | "dictionaries": ["jsdoc","closure"] 5 | }, 6 | "source": { 7 | "include": [ 8 | "./lib" 9 | ], 10 | "includePattern": ".+\\.js(doc|x)?$" 11 | }, 12 | "plugins": ["plugins/markdown"], 13 | "templates": { 14 | "logoFile": "", 15 | "cleverLinks": false, 16 | "monospaceLinks": false, 17 | "dateFormat": "ddd MMM Do YYYY", 18 | "outputSourceFiles": true, 19 | "outputSourcePath": true, 20 | "systemName": "Financial Bond Network", 21 | "footer": "", 22 | "copyright": "Released under the Apache License v2.0", 23 | "navType": "vertical", 24 | "theme": "spacelab", 25 | "linenums": true, 26 | "collapseSymbols": false, 27 | "inverseNav": true, 28 | "protocol": "html://", 29 | "methodHeadingReturns": false 30 | }, 31 | "markdown": { 32 | "parser": "gfm", 33 | "hardwrap": true 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/pii-network/models/pii.cto: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /** 16 | * A business network where members can grant/revoke access to their personal information to other members 17 | */ 18 | namespace org.acme.pii 19 | 20 | concept Address { 21 | o String street 22 | o String house 23 | o String city 24 | o String county 25 | o String country 26 | o String zip 27 | } 28 | 29 | participant Member identified by email { 30 | o String email 31 | o String firstName 32 | o String lastName 33 | o DateTime dob optional 34 | o Address address optional 35 | o String[] authorized optional 36 | } 37 | 38 | abstract transaction MemberTransaction { 39 | o String memberId 40 | } 41 | 42 | transaction AuthorizeAccess extends MemberTransaction { 43 | } 44 | 45 | transaction RevokeAccess extends MemberTransaction { 46 | } 47 | 48 | event MemberEvent { 49 | o MemberTransaction memberTransaction 50 | } -------------------------------------------------------------------------------- /packages/pii-network/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "engines": { 3 | "composer": "^0.20.0" 4 | }, 5 | "name": "pii-network", 6 | "version": "0.2.6", 7 | "description": "Business Network to illustrate using Access Control over Personally Identifiable Information (PII).", 8 | "networkImage": "https://hyperledger.github.io/composer-sample-networks/packages/pii-network/networkimage.svg", 9 | "networkImageanimated": "https://hyperledger.github.io/composer-sample-networks/packages/pii-network/networkimageanimated.svg", 10 | "scripts": { 11 | "prepublish": "mkdirp ./dist && composer archive create --sourceType dir --sourceName . -a ./dist/pii-network.bna", 12 | "pretest": "npm run lint", 13 | "lint": "eslint .", 14 | "postlint": "npm run licchk", 15 | "licchk": "license-check-and-add", 16 | "postlicchk": "npm run doc", 17 | "doc": "jsdoc --pedantic --recurse -c jsdoc.json", 18 | "test": "mocha -t 0 --recursive", 19 | "deploy": "./scripts/deploy.sh" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "https://github.com/hyperledger/composer-sample-networks.git" 24 | }, 25 | "keywords": [ 26 | "access control", 27 | "security", 28 | "composer", 29 | "composer-network" 30 | ], 31 | "author": "Hyperledger Composer", 32 | "license": "Apache-2.0", 33 | "devDependencies": { 34 | "chai": "^3.5.0", 35 | "composer-admin": "^0.20.0-0", 36 | "composer-cli": "^0.20.0-0", 37 | "composer-client": "^0.20.0-0", 38 | "composer-common": "^0.20.0-0", 39 | "composer-connector-embedded": "^0.20.0-0", 40 | "eslint": "^3.6.1", 41 | "istanbul": "^0.4.5", 42 | "jsdoc": "^3.5.5", 43 | "license-check-and-add": "~2.3.0", 44 | "mkdirp": "^0.5.1", 45 | "mocha": "^3.2.0", 46 | "moment": "^2.17.1" 47 | }, 48 | "license-check-and-add-config": { 49 | "folder": ".", 50 | "license": "LICENSE.txt", 51 | "exact_paths_method": "EXCLUDE", 52 | "exact_paths": [ 53 | "composer-logs", 54 | "dist", 55 | "node_modules", 56 | "out", 57 | ".git" 58 | ], 59 | "file_type_method": "EXCLUDE", 60 | "file_types": [ 61 | ".yml" 62 | ], 63 | "insert_license": false, 64 | "license_formats": { 65 | "js|cto|acl|qry": { 66 | "prepend": "/*", 67 | "append": " */", 68 | "eachLine": { 69 | "prepend": " * " 70 | } 71 | }, 72 | "md": { 73 | "file": "../../markdown-license.txt" 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /packages/pii-network/queries.qry: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | query selectMembers { 16 | description: "Select all members" 17 | statement: 18 | SELECT org.acme.pii.Member 19 | } 20 | -------------------------------------------------------------------------------- /packages/trade-network/.eslintignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | coverage 13 | dist 14 | go 15 | node_modules 16 | out 17 | -------------------------------------------------------------------------------- /packages/trade-network/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es6: true 3 | node: true 4 | mocha: true 5 | extends: 'eslint:recommended' 6 | parserOptions: 7 | ecmaVersion: 8 8 | sourceType: 9 | - script 10 | rules: 11 | indent: 12 | - error 13 | - 4 14 | linebreak-style: 15 | - error 16 | - unix 17 | quotes: 18 | - error 19 | - single 20 | semi: 21 | - error 22 | - always 23 | no-unused-vars: 24 | - error 25 | - args: none 26 | no-console: off 27 | curly: error 28 | eqeqeq: error 29 | no-throw-literal: error 30 | no-var: error 31 | dot-notation: error 32 | no-tabs: error 33 | no-trailing-spaces: error 34 | no-use-before-define: error 35 | no-useless-call: error 36 | no-with: error 37 | operator-linebreak: error 38 | require-jsdoc: 39 | - error 40 | - require: 41 | ClassDeclaration: true 42 | MethodDefinition: true 43 | FunctionDeclaration: true 44 | valid-jsdoc: 45 | - error 46 | - requireReturn: false 47 | yoda: error 48 | -------------------------------------------------------------------------------- /packages/trade-network/.gitignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | # Logs 13 | logs 14 | *.log 15 | npm-debug.log* 16 | 17 | # Runtime data 18 | pids 19 | *.pid 20 | *.seed 21 | 22 | # Directory for instrumented libs generated by jscoverage/JSCover 23 | lib-cov 24 | 25 | # Coverage directory used by tools like istanbul 26 | coverage 27 | 28 | # nyc test coverage 29 | .nyc_output 30 | 31 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 32 | .grunt 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (http://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules 42 | jspm_packages 43 | 44 | # Optional npm cache directory 45 | .npm 46 | 47 | # Optional REPL history 48 | .node_repl_history 49 | 50 | # JSDoc 51 | out 52 | 53 | # Mac files. 54 | **/.DS_Store 55 | 56 | *.swp 57 | 58 | # Build generated files should be ignored by git, but not by npm. 59 | dist 60 | 61 | node_modules 62 | composer-logs 63 | -------------------------------------------------------------------------------- /packages/trade-network/.npmignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | # Logs 13 | logs 14 | *.log 15 | npm-debug.log* 16 | 17 | # Runtime data 18 | pids 19 | *.pid 20 | *.seed 21 | 22 | # Directory for instrumented libs generated by jscoverage/JSCover 23 | lib-cov 24 | 25 | # Coverage directory used by tools like istanbul 26 | coverage 27 | 28 | # nyc test coverage 29 | .nyc_output 30 | 31 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 32 | .grunt 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (http://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules 42 | jspm_packages 43 | 44 | # Optional npm cache directory 45 | .npm 46 | 47 | # Optional REPL history 48 | .node_repl_history 49 | 50 | # JSDoc 51 | out 52 | 53 | # Mac files. 54 | **/.DS_Store 55 | 56 | *.swp 57 | 58 | # Build generated files should be ignored by git, but not by npm. 59 | # dist 60 | -------------------------------------------------------------------------------- /packages/trade-network/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); 2 | you may not use this file except in compliance with the License. 3 | You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. -------------------------------------------------------------------------------- /packages/trade-network/README.md: -------------------------------------------------------------------------------- 1 | # Trade Network 2 | 3 | > This Business Network illustrates commodity trading. 4 | 5 | This business network defines: 6 | 7 | **Participant** 8 | `Trader` 9 | 10 | **Asset** 11 | `Commodity` 12 | 13 | **Transaction(s)** 14 | `Transaction` 15 | 16 | **Event** 17 | `TradeNotification ` 18 | 19 | To test this Business Network Definition in the **Test** tab: 20 | 21 | Create two `Trader` participants: 22 | 23 | ``` 24 | { 25 | "$class": "org.example.trading.Trader", 26 | "tradeId": "TRADER1", 27 | "firstName": "Jenny", 28 | "lastName": "Jones" 29 | } 30 | ``` 31 | 32 | ``` 33 | { 34 | "$class": "org.example.trading.Trader", 35 | "tradeId": "TRADER2", 36 | "firstName": "Amy", 37 | "lastName": "Williams" 38 | } 39 | ``` 40 | 41 | Create a `Commodity` asset: 42 | 43 | ``` 44 | { 45 | "$class": "org.example.trading.Commodity", 46 | "tradingSymbol": "ABC", 47 | "description": "Test commodity", 48 | "mainExchange": "Euronext", 49 | "quantity": 72.297, 50 | "owner": "resource:org.example.trading.Trader#TRADER1" 51 | } 52 | ``` 53 | 54 | Submit a `Trade` transaction: 55 | 56 | ``` 57 | { 58 | "$class": "org.example.trading.Trade", 59 | "commodity": "resource:org.example.trading.Commodity#ABC", 60 | "newOwner": "resource:org.example.trading.Trader#TRADER2" 61 | } 62 | ``` 63 | 64 | After submitting this transaction, you should now see the transaction in the transaction registry. As a result, the owner of the commodity `ABC` should now be owned `TRADER2` in the Asset Registry. 65 | 66 | Congratulations! 67 | 68 | ## License 69 | Hyperledger Project source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the LICENSE file. Hyperledger Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at http://creativecommons.org/licenses/by/4.0/. -------------------------------------------------------------------------------- /packages/trade-network/config/default.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "config":"" 4 | } 5 | -------------------------------------------------------------------------------- /packages/trade-network/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | -------------------------------------------------------------------------------- /packages/trade-network/jsdoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": { 3 | "allowUnknownTags": true, 4 | "dictionaries": ["jsdoc","closure"] 5 | }, 6 | "source": { 7 | "include": [ 8 | "./lib" 9 | ], 10 | "includePattern": ".+\\.js(doc|x)?$" 11 | }, 12 | "plugins": ["plugins/markdown"], 13 | "templates": { 14 | "logoFile": "", 15 | "cleverLinks": false, 16 | "monospaceLinks": false, 17 | "dateFormat": "ddd MMM Do YYYY", 18 | "outputSourceFiles": true, 19 | "outputSourcePath": true, 20 | "systemName": "Financial Bond Network", 21 | "footer": "", 22 | "copyright": "Released under the Apache License v2.0", 23 | "navType": "vertical", 24 | "theme": "spacelab", 25 | "linenums": true, 26 | "collapseSymbols": false, 27 | "inverseNav": true, 28 | "protocol": "html://", 29 | "methodHeadingReturns": false 30 | }, 31 | "markdown": { 32 | "parser": "gfm", 33 | "hardwrap": true 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/trade-network/lib/logic.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /* global getAssetRegistry getFactory emit query */ 16 | 17 | /** 18 | * Track the trade of a commodity from one trader to another 19 | * @param {org.example.trading.Trade} trade - the trade to be processed 20 | * @transaction 21 | */ 22 | async function tradeCommodity(trade) { // eslint-disable-line no-unused-vars 23 | 24 | // set the new owner of the commodity 25 | trade.commodity.owner = trade.newOwner; 26 | const assetRegistry = await getAssetRegistry('org.example.trading.Commodity'); 27 | 28 | // emit a notification that a trade has occurred 29 | const tradeNotification = getFactory().newEvent('org.example.trading', 'TradeNotification'); 30 | tradeNotification.commodity = trade.commodity; 31 | emit(tradeNotification); 32 | 33 | // persist the state of the commodity 34 | await assetRegistry.update(trade.commodity); 35 | } 36 | 37 | /** 38 | * Remove all high volume commodities 39 | * @param {org.example.trading.RemoveHighQuantityCommodities} remove - the remove to be processed 40 | * @transaction 41 | */ 42 | async function removeHighQuantityCommodities(remove) { // eslint-disable-line no-unused-vars 43 | 44 | const assetRegistry = await getAssetRegistry('org.example.trading.Commodity'); 45 | const results = await query('selectCommoditiesWithHighQuantity'); 46 | 47 | // since all registry requests have to be serialized anyway, there is no benefit to calling Promise.all 48 | // on an array of promises 49 | results.forEach(async trade => { 50 | const removeNotification = getFactory().newEvent('org.example.trading', 'RemoveNotification'); 51 | removeNotification.commodity = trade; 52 | emit(removeNotification); 53 | await assetRegistry.remove(trade); 54 | }); 55 | } -------------------------------------------------------------------------------- /packages/trade-network/models/trading.cto: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | /** 15 | * Commodity trading network 16 | */ 17 | namespace org.example.trading 18 | 19 | asset Commodity identified by tradingSymbol { 20 | o String tradingSymbol 21 | o String description 22 | o String mainExchange 23 | o Double quantity 24 | --> Trader owner 25 | } 26 | 27 | participant Trader identified by tradeId { 28 | o String tradeId 29 | o String firstName 30 | o String lastName 31 | } 32 | 33 | transaction Trade { 34 | --> Commodity commodity 35 | --> Trader newOwner 36 | } 37 | 38 | event TradeNotification { 39 | --> Commodity commodity 40 | } 41 | 42 | transaction RemoveHighQuantityCommodities { 43 | } 44 | 45 | event RemoveNotification { 46 | --> Commodity commodity 47 | } 48 | -------------------------------------------------------------------------------- /packages/trade-network/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "engines": { 3 | "composer": "^0.20.0" 4 | }, 5 | "name": "trade-network", 6 | "version": "0.2.6", 7 | "description": "Commodities Trading Business Network", 8 | "networkImage": "https://hyperledger.github.io/composer-sample-networks/packages/trade-network/networkimage.svg", 9 | "networkImageanimated": "https://hyperledger.github.io/composer-sample-networks/packages/trade-network/networkimageanimated.svg", 10 | "scripts": { 11 | "prepublish": "mkdirp ./dist && composer archive create --sourceType dir --sourceName . -a ./dist/trade-network.bna", 12 | "pretest": "npm run lint", 13 | "lint": "eslint .", 14 | "postlint": "npm run licchk", 15 | "licchk": "license-check-and-add", 16 | "postlicchk": "npm run doc", 17 | "doc": "jsdoc --pedantic --recurse -c jsdoc.json", 18 | "test": "mocha -t 0 --recursive", 19 | "deploy": "./scripts/deploy.sh" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "https://github.com/hyperledger/composer-sample-networks.git" 24 | }, 25 | "keywords": [ 26 | "commodities", 27 | "trading", 28 | "composer", 29 | "composer-network" 30 | ], 31 | "author": "Hyperledger Composer", 32 | "license": "Apache-2.0", 33 | "devDependencies": { 34 | "chai": "^3.5.0", 35 | "composer-admin": "^0.20.0-0", 36 | "composer-cli": "^0.20.0-0", 37 | "composer-client": "^0.20.0-0", 38 | "composer-common": "^0.20.0-0", 39 | "composer-connector-embedded": "^0.20.0-0", 40 | "eslint": "^3.6.1", 41 | "istanbul": "^0.4.5", 42 | "jsdoc": "^3.5.5", 43 | "license-check-and-add": "~2.3.0", 44 | "mkdirp": "^0.5.1", 45 | "mocha": "^3.2.0", 46 | "moment": "^2.17.1" 47 | }, 48 | "license-check-and-add-config": { 49 | "folder": ".", 50 | "license": "LICENSE.txt", 51 | "exact_paths_method": "EXCLUDE", 52 | "exact_paths": [ 53 | "composer-logs", 54 | "dist", 55 | "node_modules", 56 | "out", 57 | ".git" 58 | ], 59 | "file_type_method": "EXCLUDE", 60 | "file_types": [ 61 | ".yml" 62 | ], 63 | "insert_license": false, 64 | "license_formats": { 65 | "js|cto|acl|qry": { 66 | "prepend": "/*", 67 | "append": " */", 68 | "eachLine": { 69 | "prepend": " * " 70 | } 71 | }, 72 | "md": { 73 | "file": "../../markdown-license.txt" 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /packages/trade-network/permissions.acl: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | /** 15 | * Access control rules for mynetwork 16 | */ 17 | rule Default { 18 | description: "Allow all participants access to all resources" 19 | participant: "ANY" 20 | operation: ALL 21 | resource: "org.example.trading.*" 22 | action: ALLOW 23 | } 24 | 25 | rule SystemACL { 26 | description: "System ACL to permit all access" 27 | participant: "org.hyperledger.composer.system.Participant" 28 | operation: ALL 29 | resource: "org.hyperledger.composer.system.**" 30 | action: ALLOW 31 | } 32 | 33 | rule NetworkAdminUser { 34 | description: "Grant business network administrators full access to user resources" 35 | participant: "org.hyperledger.composer.system.NetworkAdmin" 36 | operation: ALL 37 | resource: "**" 38 | action: ALLOW 39 | } 40 | 41 | rule NetworkAdminSystem { 42 | description: "Grant business network administrators full access to system resources" 43 | participant: "org.hyperledger.composer.system.NetworkAdmin" 44 | operation: ALL 45 | resource: "org.hyperledger.composer.system.**" 46 | action: ALLOW 47 | } -------------------------------------------------------------------------------- /packages/trade-network/queries.qry: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | query selectCommodities { 16 | description: "Select all commodities" 17 | statement: 18 | SELECT org.example.trading.Commodity 19 | } 20 | 21 | query selectCommoditiesByExchange { 22 | description: "Select all commodities based on their main exchange" 23 | statement: 24 | SELECT org.example.trading.Commodity 25 | WHERE (mainExchange==_$exchange) 26 | } 27 | 28 | query selectCommoditiesByOwner { 29 | description: "Select all commodities based on their owner" 30 | statement: 31 | SELECT org.example.trading.Commodity 32 | WHERE (owner == _$owner) 33 | } 34 | 35 | query selectCommoditiesWithHighQuantity { 36 | description: "Select commodities based on quantity" 37 | statement: 38 | SELECT org.example.trading.Commodity 39 | WHERE (quantity > 60) 40 | } -------------------------------------------------------------------------------- /packages/vehicle-lifecycle-network/.eslintignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | coverage 14 | dist 15 | go 16 | node_modules 17 | out -------------------------------------------------------------------------------- /packages/vehicle-lifecycle-network/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es6: true 3 | node: true 4 | mocha: true 5 | extends: 'eslint:recommended' 6 | parserOptions: 7 | ecmaVersion: 8 8 | sourceType: 9 | - script 10 | rules: 11 | indent: 12 | - error 13 | - 4 14 | linebreak-style: 15 | - error 16 | - unix 17 | quotes: 18 | - error 19 | - single 20 | semi: 21 | - error 22 | - always 23 | no-unused-vars: 24 | - error 25 | - args: none 26 | no-var: error 27 | no-console: off 28 | curly: error 29 | eqeqeq: error 30 | no-throw-literal: error 31 | dot-notation: error 32 | no-tabs: error 33 | no-trailing-spaces: error 34 | no-useless-call: error 35 | no-with: error 36 | operator-linebreak: error 37 | require-jsdoc: 38 | - error 39 | - require: 40 | ClassDeclaration: true 41 | MethodDefinition: true 42 | FunctionDeclaration: true 43 | yoda: error 44 | no-confusing-arrow: 2 45 | no-constant-condition: 2 46 | -------------------------------------------------------------------------------- /packages/vehicle-lifecycle-network/.gitignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | dist 61 | 62 | node_modules 63 | composer-logs 64 | -------------------------------------------------------------------------------- /packages/vehicle-lifecycle-network/.npmignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | # dist 61 | -------------------------------------------------------------------------------- /packages/vehicle-lifecycle-network/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); 2 | you may not use this file except in compliance with the License. 3 | You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. -------------------------------------------------------------------------------- /packages/vehicle-lifecycle-network/config/default.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "config":"" 4 | } 5 | -------------------------------------------------------------------------------- /packages/vehicle-lifecycle-network/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | -------------------------------------------------------------------------------- /packages/vehicle-lifecycle-network/jsdoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": { 3 | "allowUnknownTags": true, 4 | "dictionaries": ["jsdoc","closure"] 5 | }, 6 | "source": { 7 | "include": [ 8 | "./lib" 9 | ], 10 | "includePattern": ".+\\.js(doc|x)?$" 11 | }, 12 | "plugins": ["plugins/markdown"], 13 | "templates": { 14 | "logoFile": "", 15 | "cleverLinks": false, 16 | "monospaceLinks": false, 17 | "dateFormat": "ddd MMM Do YYYY", 18 | "outputSourceFiles": true, 19 | "outputSourcePath": true, 20 | "systemName": "Vehicle Lifecycle Network", 21 | "footer": "", 22 | "copyright": "Released under the Apache License v2.0", 23 | "navType": "vertical", 24 | "theme": "spacelab", 25 | "linenums": true, 26 | "collapseSymbols": false, 27 | "inverseNav": true, 28 | "protocol": "html://", 29 | "methodHeadingReturns": false 30 | }, 31 | "markdown": { 32 | "parser": "gfm", 33 | "hardwrap": true 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/vehicle-lifecycle-network/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "engines": { 3 | "composer": "^0.20.0" 4 | }, 5 | "name": "vehicle-lifecycle-network", 6 | "version": "0.2.6", 7 | "description": "Vehicle Lifecycle Network", 8 | "networkImage": "https://hyperledger.github.io/composer-sample-networks/packages/vehicle-lifecycle-network/networkimage.svg", 9 | "networkImageanimated": "https://hyperledger.github.io/composer-sample-networks/packages/vehicle-lifecycle-network/networkimageanimated.svg", 10 | "scripts": { 11 | "prepublish": "mkdirp ./dist && composer archive create --sourceType dir --sourceName . -a ./dist/vehicle-lifecycle-network.bna", 12 | "pretest": "npm run lint", 13 | "lint": "eslint .", 14 | "postlint": "npm run licchk", 15 | "licchk": "license-check-and-add", 16 | "postlicchk": "npm run doc", 17 | "doc": "jsdoc --pedantic --recurse -c jsdoc.json", 18 | "test": "mocha -t 0 --recursive", 19 | "deploy": "./scripts/deploy.sh" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "https://github.com/hyperledger/composer-sample-networks.git" 24 | }, 25 | "keywords": [ 26 | "vehicle", 27 | "lifecycle", 28 | "composer", 29 | "composer-network" 30 | ], 31 | "author": "Hyperledger Composer", 32 | "license": "Apache-2.0", 33 | "dependencies": { 34 | "vehicle-lifecycle-model": "^0.2.0" 35 | }, 36 | "devDependencies": { 37 | "chai": "^3.5.0", 38 | "composer-admin": "^0.20.0-0", 39 | "composer-cli": "^0.20.0-0", 40 | "composer-client": "^0.20.0-0", 41 | "composer-common": "^0.20.0-0", 42 | "composer-connector-embedded": "^0.20.0-0", 43 | "eslint": "^3.6.1", 44 | "istanbul": "^0.4.5", 45 | "jsdoc": "^3.5.5", 46 | "license-check-and-add": "~2.3.0", 47 | "mkdirp": "^0.5.1", 48 | "mocha": "^3.2.0", 49 | "moment": "^2.17.1" 50 | }, 51 | "license-check-and-add-config": { 52 | "folder": ".", 53 | "license": "LICENSE.txt", 54 | "exact_paths_method": "EXCLUDE", 55 | "exact_paths": [ 56 | "composer-logs", 57 | "dist", 58 | "node_modules", 59 | "out", 60 | ".git" 61 | ], 62 | "file_type_method": "EXCLUDE", 63 | "file_types": [ 64 | ".yml" 65 | ], 66 | "insert_license": false, 67 | "license_formats": { 68 | "js|cto|acl|qry": { 69 | "prepend": "/*", 70 | "append": " */", 71 | "eachLine": { 72 | "prepend": " * " 73 | } 74 | }, 75 | "md": { 76 | "file": "../../markdown-license.txt" 77 | } 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /packages/vehicle-lifecycle-network/permissions.acl: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /** 16 | * Sample access control list. 17 | */ 18 | rule Default { 19 | description: "Allow all participants access to all resources" 20 | participant: "ANY" 21 | operation: ALL 22 | resource: "org.acme.vehicle.lifecycle.**" 23 | action: ALLOW 24 | } 25 | 26 | rule SystemACL { 27 | description: "System ACL to permit all access" 28 | participant: "org.hyperledger.composer.system.Participant" 29 | operation: ALL 30 | resource: "org.hyperledger.composer.system.**" 31 | action: ALLOW 32 | } 33 | 34 | rule NetworkAdminUser { 35 | description: "Grant business network administrators full access to user resources" 36 | participant: "org.hyperledger.composer.system.NetworkAdmin" 37 | operation: ALL 38 | resource: "**" 39 | action: ALLOW 40 | } 41 | 42 | rule NetworkAdminSystem { 43 | description: "Grant business network administrators full access to system resources" 44 | participant: "org.hyperledger.composer.system.NetworkAdmin" 45 | operation: ALL 46 | resource: "org.hyperledger.composer.system.**" 47 | action: ALLOW 48 | } -------------------------------------------------------------------------------- /packages/vehicle-lifecycle-network/queries.qry: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | query selectAllCarsByColour { 16 | description: "Select all cars based on their colour" 17 | statement: 18 | SELECT org.vda.Vehicle 19 | WHERE (vehicleDetails.colour==_$colour) 20 | } 21 | -------------------------------------------------------------------------------- /packages/vehicle-lifecycle-network/test/setup.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const Util = require('./util'); 18 | 19 | const NS = 'org.acme.vehicle.lifecycle'; 20 | const NS_M = 'org.acme.vehicle.lifecycle.manufacturer'; 21 | const NS_D = 'org.vda'; 22 | 23 | describe('Setup', () => { 24 | let businessNetworkConnection; 25 | let factory; 26 | 27 | beforeEach(async () => { 28 | businessNetworkConnection = await Util.deployAndConnect(); 29 | factory = businessNetworkConnection.getBusinessNetwork().getFactory(); 30 | }); 31 | 32 | describe('Setup', () => { 33 | describe('#setupDemo', () => { 34 | /** 35 | * 36 | * @param {String} registry - name of a registry 37 | */ 38 | async function getAllFromRegistry(type, registry) { 39 | const func = 'get' + type + 'Registry'; 40 | const bnc = await businessNetworkConnection[func](registry); 41 | return await bnc.getAll(); 42 | } 43 | 44 | it('should create a scenario', async () => { 45 | // submit the transaction 46 | const setupDemo = factory.newTransaction(NS, 'SetupDemo'); 47 | 48 | await businessNetworkConnection.submitTransaction(setupDemo); 49 | 50 | // (participants) get regulator registry 51 | const regulators = await getAllFromRegistry('Participant', NS + '.Regulator'); 52 | regulators.length.should.equal(1); 53 | 54 | // (participants) get manufacturer registry 55 | const manufacturers = await getAllFromRegistry('Participant', NS_M + '.Manufacturer'); 56 | manufacturers.length.should.be.above(1); 57 | 58 | // (participants) get private owner registry 59 | const privateOwners = await getAllFromRegistry('Participant', NS + '.PrivateOwner'); 60 | privateOwners.length.should.be.above(10); 61 | 62 | // (assets) get vehicles registry 63 | const vehicles = await getAllFromRegistry('Asset', NS_D + '.Vehicle'); 64 | vehicles.length.should.be.above(10); 65 | }); 66 | }); 67 | 68 | }); 69 | 70 | }); 71 | -------------------------------------------------------------------------------- /packages/vehicle-manufacture-network/.eslintignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | coverage 14 | dist 15 | go 16 | node_modules 17 | out -------------------------------------------------------------------------------- /packages/vehicle-manufacture-network/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es6: true 3 | node: true 4 | mocha: true 5 | extends: 'eslint:recommended' 6 | parserOptions: 7 | ecmaVersion: 8 8 | sourceType: 9 | - script 10 | rules: 11 | indent: 12 | - error 13 | - 4 14 | linebreak-style: 15 | - error 16 | - unix 17 | quotes: 18 | - error 19 | - single 20 | semi: 21 | - error 22 | - always 23 | no-unused-vars: 24 | - error 25 | - args: none 26 | no-var: error 27 | no-console: off 28 | curly: error 29 | eqeqeq: error 30 | no-throw-literal: error 31 | dot-notation: error 32 | no-tabs: error 33 | no-trailing-spaces: error 34 | no-useless-call: error 35 | no-with: error 36 | operator-linebreak: error 37 | require-jsdoc: 38 | - error 39 | - require: 40 | ClassDeclaration: true 41 | MethodDefinition: true 42 | FunctionDeclaration: true 43 | yoda: error 44 | no-confusing-arrow: 2 45 | no-constant-condition: 2 46 | -------------------------------------------------------------------------------- /packages/vehicle-manufacture-network/.gitignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | dist 61 | 62 | node_modules 63 | composer-logs 64 | -------------------------------------------------------------------------------- /packages/vehicle-manufacture-network/.npmignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # JSDoc 52 | out 53 | 54 | # Mac files. 55 | **/.DS_Store 56 | 57 | *.swp 58 | 59 | # Build generated files should be ignored by git, but not by npm. 60 | # dist 61 | -------------------------------------------------------------------------------- /packages/vehicle-manufacture-network/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); 2 | you may not use this file except in compliance with the License. 3 | You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. -------------------------------------------------------------------------------- /packages/vehicle-manufacture-network/config/default.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "config":"" 4 | } 5 | -------------------------------------------------------------------------------- /packages/vehicle-manufacture-network/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | -------------------------------------------------------------------------------- /packages/vehicle-manufacture-network/jsdoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": { 3 | "allowUnknownTags": true, 4 | "dictionaries": ["jsdoc","closure"] 5 | }, 6 | "source": { 7 | "include": [ 8 | "./lib" 9 | ], 10 | "includePattern": ".+\\.js(doc|x)?$" 11 | }, 12 | "plugins": ["plugins/markdown"], 13 | "templates": { 14 | "logoFile": "", 15 | "cleverLinks": false, 16 | "monospaceLinks": false, 17 | "dateFormat": "ddd MMM Do YYYY", 18 | "outputSourceFiles": true, 19 | "outputSourcePath": true, 20 | "systemName": "Vehicle Manufacture Network", 21 | "footer": "", 22 | "copyright": "Released under the Apache License v2.0", 23 | "navType": "vertical", 24 | "theme": "spacelab", 25 | "linenums": true, 26 | "collapseSymbols": false, 27 | "inverseNav": true, 28 | "protocol": "html://", 29 | "methodHeadingReturns": false 30 | }, 31 | "markdown": { 32 | "parser": "gfm", 33 | "hardwrap": true 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/vehicle-manufacture-network/models/org.acme.vehicle_network.cto: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /** 16 | * New model file 17 | */ 18 | 19 | namespace org.acme.vehicle_network 20 | 21 | // BASE DEFINTIONS 22 | 23 | concept VehicleDetails { 24 | --> Manufacturer make 25 | o String modelType 26 | o String colour 27 | } 28 | 29 | abstract participant Company identified by companyId { 30 | o String companyId 31 | o String name 32 | } 33 | 34 | participant Person identified by username { 35 | o String username 36 | o String email optional 37 | } 38 | 39 | 40 | // MANUFACTURE DEFINITIONS 41 | participant Manufacturer extends Company { 42 | } 43 | 44 | enum OrderStatus { 45 | o PLACED 46 | o SCHEDULED_FOR_MANUFACTURE 47 | o VIN_ASSIGNED 48 | o OWNER_ASSIGNED 49 | o DELIVERED 50 | } 51 | 52 | concept Options { 53 | o String trim 54 | o String interior 55 | o String[] extras 56 | } 57 | 58 | asset Order identified by orderId { 59 | o String orderId 60 | o VehicleDetails vehicleDetails 61 | o OrderStatus orderStatus 62 | o Options options 63 | --> Person orderer 64 | } 65 | 66 | transaction PlaceOrder { 67 | o String orderId 68 | o VehicleDetails vehicleDetails 69 | o Options options 70 | --> Person orderer 71 | } 72 | 73 | event PlaceOrderEvent { 74 | o String orderId 75 | o VehicleDetails vehicleDetails 76 | o Options options 77 | --> Person orderer 78 | } 79 | 80 | transaction UpdateOrderStatus { 81 | o OrderStatus orderStatus 82 | o String vin optional 83 | --> Order order 84 | } 85 | 86 | event UpdateOrderStatusEvent { 87 | o OrderStatus orderStatus 88 | o Order order 89 | } 90 | 91 | 92 | // REGULATOR DEFINITIONS 93 | participant Regulator extends Company { 94 | } 95 | 96 | enum VehicleStatus { 97 | o ACTIVE 98 | o OFF_THE_ROAD 99 | o SCRAPPED 100 | } 101 | 102 | asset Vehicle identified by vin { 103 | o String vin 104 | o VehicleDetails vehicleDetails 105 | o VehicleStatus vehicleStatus 106 | --> Person owner optional 107 | } 108 | 109 | // DEMO SPECIFIC DEFINITIONS 110 | transaction SetupDemo { 111 | } -------------------------------------------------------------------------------- /packages/vehicle-manufacture-network/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "engines": { 3 | "composer": "^0.20.0" 4 | }, 5 | "name": "vehicle-manufacture-network", 6 | "description": "Vehicle manufacture network", 7 | "networkImage": "https://hyperledger.github.io/composer-sample-networks/packages/vehicle-manufacture-network/networkimage.svg", 8 | "networkImageanimated": "https://hyperledger.github.io/composer-sample-networks/packages/vehicle-manufacture-network/networkimageanimated.svg", 9 | "version": "0.2.6", 10 | "scripts": { 11 | "prepublish": "mkdirp ./dist && composer archive create --sourceType dir --sourceName . -a ./dist/vehicle-manufacture-network.bna", 12 | "pretest": "npm run lint", 13 | "lint": "eslint .", 14 | "postlint": "npm run licchk", 15 | "licchk": "license-check-and-add", 16 | "postlicchk": "npm run doc", 17 | "doc": "jsdoc --pedantic --recurse -c jsdoc.json", 18 | "test": "mocha -t 0 --recursive" 19 | }, 20 | "repository": { 21 | "type": "git", 22 | "url": "https://github.com/hyperledger/composer-sample-networks.git" 23 | }, 24 | "keywords": [ 25 | "vehicle", 26 | "manufacture", 27 | "composer", 28 | "composer-network" 29 | ], 30 | "author": "Hyperledger Composer", 31 | "license": "Apache 2.0", 32 | "devDependencies": { 33 | "browserfs": "^1.2.0", 34 | "chai": "^3.5.0", 35 | "chai-as-promised": "^6.0.0", 36 | "composer-admin": "^0.20.0-0", 37 | "composer-cli": "^0.20.0-0", 38 | "composer-client": "^0.20.0-0", 39 | "composer-connector-embedded": "^0.20.0-0", 40 | "eslint": "^3.6.1", 41 | "istanbul": "^0.4.5", 42 | "jsdoc": "^3.5.5", 43 | "license-check-and-add": "~2.3.0", 44 | "mkdirp": "^0.5.1", 45 | "mocha": "^3.2.0", 46 | "moment": "^2.17.1" 47 | }, 48 | "license-check-and-add-config": { 49 | "folder": ".", 50 | "license": "LICENSE.txt", 51 | "exact_paths_method": "EXCLUDE", 52 | "exact_paths": [ 53 | "composer-logs", 54 | "dist", 55 | "node_modules", 56 | "out", 57 | ".git" 58 | ], 59 | "file_type_method": "EXCLUDE", 60 | "file_types": [ 61 | ".yml" 62 | ], 63 | "insert_license": false, 64 | "license_formats": { 65 | "js|cto|acl|qry": { 66 | "prepend": "/*", 67 | "append": " */", 68 | "eachLine": { 69 | "prepend": " * " 70 | } 71 | }, 72 | "md": { 73 | "file": "../../markdown-license.txt" 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /scripts/pkgbump.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /* 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | 'use strict'; 17 | 18 | const fs = require('fs'); 19 | const path = require('path'); 20 | const semver = require('semver'); 21 | 22 | const lernaDirectory = path.resolve('.'); 23 | const lernaConfigFile = path.resolve(lernaDirectory, 'lerna.json'); 24 | const lernaConfig = require(lernaConfigFile); 25 | const targetVersion = semver.inc(lernaConfig.version, 'patch'); 26 | lernaConfig.version = targetVersion; 27 | fs.writeFileSync(lernaConfigFile, JSON.stringify(lernaConfig, null, 2), 'utf8'); --------------------------------------------------------------------------------