-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from mttrbrts/master
(doc) Added extended README files to all templates
- Loading branch information
Showing
28 changed files
with
902 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,112 @@ | ||
|
||
# Accord Protocol Template: acceptance-of-delivery | ||
# Acceptance of Delivery | ||
|
||
The is an Accord Protocol Template for a clause that allows the receiver of goods to inspect them for a given time period after delivery. | ||
This is a smart legal clause conforms that to the [Accord Protocol Template Specification](https://docs.google.com/document/d/1UacA_r2KGcBA2D4voDgGE8jqid-Uh4Dt09AE-shBKR0), the protocol is managed by the open-source community of the [Accord Project](https://accordproject.org). The clause can be parsed and executed by the [Cicero](https://github.com/accordproject/cicero) engine. | ||
|
||
## Description | ||
> This clause allows the receiver of goods to inspect them for a given time period after delivery. | ||
This clause contains: | ||
- *Some sample Clause Text* - [sample.txt](sample.txt) | ||
- *A template* - [grammar/template.tem](grammar/template.tem) | ||
- *A data model* - [models/model.cto](models/model.cto) | ||
- *Contact logic* (in JavaScript) - [logic/logic.js](lib/logic.js) | ||
|
||
## Running this clause | ||
|
||
### On your own machine | ||
|
||
1. [Download the Cicero template library](https://github.com/accordproject/cicero-template-library/archive/master.zip) | ||
|
||
2. Unzip the library with your favourite tool | ||
|
||
3. Then from the command-line, change the current directory to the folder containing this README.md file. | ||
``` | ||
cd acceptance-of-delivery | ||
``` | ||
4. With the [Cicero command-line tool](https://github.com/accordproject/cicero#installation): | ||
``` | ||
cicero execute --template ./ --dsl ./sample --data ./data.json | ||
``` | ||
> Note, all of the command-line flags (like `--template`) are optional. | ||
Alternatively you can use the simpler command below if you want to use all of the default files. | ||
``` | ||
cicero execute | ||
``` | ||
|
||
You should see the following output in your terminal: | ||
```bash | ||
mattmbp:acceptance-of-delivery matt$ cicero execute | ||
21:49:39 - info: Logging initialized. 2018-02-17T21:49:39.676Z | ||
21:49:39 - info: Using current directory as template folder | ||
21:49:39 - info: Loading a default sample.txt file. | ||
21:49:39 - info: Loading a default data.json file. | ||
21:49:40 - info: {"clause":"acceptance-of-delivery@0.0.3-e407ff0a315c5b1c267677edbda49a32d4e9ef890ad21a3e40b3bc110d06c88c","request":{"$class":"org.accordproject.acceptanceofdelivery.InspectDeliverable","deliverableReceivedAt":"January 1, 2018 16:34:00","inspectionPassed":true},"response":{"$class":"org.accordproject.acceptanceofdelivery.InspectionResponse","status":"OUTSIDE_INSPECTION_PERIOD","shipper":"resource:org.hyperledger.composer.system.Participant#Party%20A","receiver":"resource:org.hyperledger.composer.system.Participant#Party%20B","transactionId":"57df30ca-3755-457b-9176-5fae50dd3283","timestamp":"2018-02-17T21:49:40.206Z"}} | ||
``` | ||
|
||
### Sample Payload Data | ||
|
||
|
||
Request, as in [data.json](https://github.com/accordproject/cicero-template-library/blob/master/acceptance-of-delivery/data.json) | ||
```json | ||
{ | ||
"$class":"org.accordproject.acceptanceofdelivery.InspectDeliverable", | ||
"deliverableReceivedAt": "January 1, 2018 16:34:00", | ||
"inspectionPassed": true | ||
} | ||
``` | ||
|
||
For the request above, you should see the following response: | ||
```json | ||
{ | ||
"$class":"org.accordproject.acceptanceofdelivery.InspectionResponse", | ||
"status":"OUTSIDE_INSPECTION_PERIOD", | ||
"shipper":"resource:org.hyperledger.composer.system.Participant#Party%20A", | ||
"receiver":"resource:org.hyperledger.composer.system.Participant#Party%20B", | ||
"transactionId":"57df30ca-3755-457b-9176-5fae50dd3283", | ||
"timestamp":"2018-02-17T21:49:40.206Z" | ||
} | ||
``` | ||
|
||
|
||
## Testing this clause | ||
|
||
This clause comes with an automated test that ensures that it executes correctly under different conditions. To test the clause, complete the following steps. | ||
|
||
You need npm and node to test a clause. You can download both from [here](https://nodejs.org/). | ||
|
||
> This clause was tested with Node v8.9.3 and NPM v5.6.0 | ||
From the `acceptance-of-delivery` directory. | ||
|
||
1. Install all of the dependencies. | ||
``` | ||
npm install | ||
``` | ||
|
||
2. Run the tests | ||
``` | ||
npm test | ||
``` | ||
If successful, you should see the following output | ||
``` | ||
mattmbp:acceptance-of-delivery matt$ npm test | ||
> acceptance-of-delivery@0.0.3 test /Users/matt/dev/accordproject/cicero-template-library/acceptance-of-delivery | ||
> mocha | ||
21:57:31 - info: Logging initialized. 2018-02-17T21:57:31.074Z | ||
Logic | ||
#InspectDeliverable | ||
✓ passed inspection within time limit | ||
✓ failed inspection within time limit | ||
✓ inspection outside time limit | ||
✓ inspection before delivable should throw | ||
4 passing (458ms) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"$class":"org.accordproject.acceptanceofdelivery.InspectDeliverable", | ||
"deliverableReceivedAt": "January 1, 2018 16:34:00", | ||
"inspectionPassed": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,112 @@ | ||
# Fragile Goods | ||
|
||
# Accord Protocol Template: fragile-goods | ||
This is a smart legal clause conforms that to the [Accord Protocol Template Specification](https://docs.google.com/document/d/1UacA_r2KGcBA2D4voDgGE8jqid-Uh4Dt09AE-shBKR0), the protocol is managed by the open-source community of the [Accord Project](https://accordproject.org). The clause can be parsed and executed by the [Cicero](https://github.com/accordproject/cicero) engine. | ||
|
||
Stateless clause for shipping fragile goods. | ||
## Description | ||
|
||
> This clause specifies penalties for shocks caused to a fragile package in transport. | ||
This clause contains: | ||
- *Some sample Clause Text* - [sample.txt](sample.txt) | ||
- *A template* - [grammar/template.tem](grammar/template.tem) | ||
- *A data model* - [models/model.cto](models/model.cto) | ||
- *Contact logic* (in JavaScript) - [logic/logic.js](lib/logic.js) | ||
|
||
## Running this clause | ||
|
||
### On your own machine | ||
|
||
1. [Download the Cicero template library](https://github.com/accordproject/cicero-template-library/archive/master.zip) | ||
|
||
2. Unzip the library with your favourite tool | ||
|
||
3. Then from the command-line, change the current directory to the folder containing this README.md file. | ||
``` | ||
cd fragile-goods | ||
``` | ||
4. With the [Cicero command-line tool](https://github.com/accordproject/cicero#installation): | ||
``` | ||
cicero execute --template ./ --dsl ./sample --data ./data.json | ||
``` | ||
> Note, all of the command-line flags (like `--template`) are optional. | ||
Alternatively you can use the simpler command below if you want to use all of the default files. | ||
``` | ||
cicero execute | ||
``` | ||
|
||
You should see the following output in your terminal: | ||
```bash | ||
mattmbp:fragile-goods matt$ cicero execute | ||
10:53:14 - info: Logging initialized. 2018-02-18T10:53:14.801Z | ||
10:53:15 - info: Using current directory as template folder | ||
10:53:15 - info: Loading a default sample.txt file. | ||
10:53:15 - info: Loading a default data.json file. | ||
10:53:15 - info: {"clause":"fragile-goods@0.0.3-8f725043d1fe2e64c5bcdefdb5693d65ba37fba60f743ac0f2f8d5e5595fe901","request":{"$class":"io.clause.demo.fragileGoods.DeliveryUpdate","startTime":"January 1, 2018 16:34:00","finishTime":"January 1, 2018 16:34:11","status":"ARRIVED","accelerometerReadings":[0.2,0.6,-0.3,-0.7,0.1]},"response":{"$class":"io.clause.demo.fragileGoods.PayOut","amount":790,"transactionId":"609813f8-e5b4-49f9-86ab-265a4428ee0f","timestamp":"2018-02-18T10:53:15.589Z"}} | ||
``` | ||
|
||
### Sample Payload Data | ||
|
||
|
||
Request, as in [data.json](https://github.com/accordproject/cicero-template-library/blob/master/fragile-goods/data.json) | ||
```json | ||
{ | ||
"$class": "io.clause.demo.fragileGoods.DeliveryUpdate", | ||
"startTime":"January 1, 2018 16:34:00", | ||
"finishTime":"January 1, 2018 16:34:11", | ||
"status":"ARRIVED", | ||
"accelerometerReadings":[0.2,0.6,-0.3,-0.7,0.1] | ||
} | ||
``` | ||
|
||
For the request above, you should see the following response: | ||
```json | ||
{ | ||
"$class":"io.clause.demo.fragileGoods.PayOut", | ||
"amount":790, | ||
"transactionId":"609813f8-e5b4-49f9-86ab-265a4428ee0f", | ||
"timestamp":"2018-02-18T10:53:15.589Z" | ||
} | ||
``` | ||
|
||
|
||
## Testing this clause | ||
|
||
This clause comes with an automated test that ensures that it executes correctly under different conditions. To test the clause, complete the following steps. | ||
|
||
You need npm and node to test a clause. You can download both from [here](https://nodejs.org/). | ||
|
||
> This clause was tested with Node v8.9.3 and NPM v5.6.0 | ||
From the `fragile-goods` directory. | ||
|
||
1. Install all of the dependencies. | ||
``` | ||
npm install | ||
``` | ||
|
||
2. Run the tests | ||
``` | ||
npm test | ||
``` | ||
If successful, you should see the following output | ||
``` | ||
mattmbp:fragile-goods matt$ npm test | ||
> fragile-goods@0.0.3 test /Users/matt/dev/accordproject/cicero-template-library/fragile-goods | ||
> mocha | ||
10:54:35 - info: Logging initialized. 2018-02-18T10:54:35.125Z | ||
Logic | ||
#FragileGoodsDemo | ||
✓ should execute a completed delivery contract with all deductions | ||
✓ should execute an inflight delivery contract | ||
✓ should execute a completed on-time delivery contract with breaches | ||
✓ should execute a completed delivery contact with no deductions | ||
4 passing (468ms) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.