Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
fix(ergotop) escaping in string printing
Browse files Browse the repository at this point in the history
Signed-off-by: Jerome Simeon <jeromesimeon@me.com>
  • Loading branch information
jeromesimeon committed Oct 14, 2019
1 parent f6d796b commit 39cc398
Show file tree
Hide file tree
Showing 41 changed files with 1,786 additions and 1,846 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ergo <command>

Commands:
ergo draft create a contract text from data
ergo request send a request to the contract
ergo execute send a request to the contract
ergo invoke invoke a clause of the contract
ergo initialize initialize the state for a contract
ergo compile compile a contract
Expand Down Expand Up @@ -96,12 +96,12 @@ $ ergo initialize --template ./examples/volumediscount --data ./examples/volumed
06:40:29 - info:
```

### Send a request
### Send a request to a contract

To send a request to a contract:

```sh
$ ergo request --template ./examples/volumediscount --data ./examples/volumediscount/data.json --request ./examples/volumediscount/request.json --state ./examples/volumediscount/state.json
$ ergo execute --template ./examples/volumediscount --data ./examples/volumediscount/data.json --request ./examples/volumediscount/request.json --state ./examples/volumediscount/state.json
06:40:01 - info:
{
"clause": "orgXaccordprojectXvolumediscountXVolumeDiscount",
Expand Down
26 changes: 0 additions & 26 deletions examples/helloworld/logic/logic2.ergo

This file was deleted.

21 changes: 0 additions & 21 deletions examples/helloworld/logic/logic5.ergo

This file was deleted.

21 changes: 0 additions & 21 deletions examples/helloworld/logic/logic6.ergo

This file was deleted.

39 changes: 0 additions & 39 deletions examples/helloworld/logic/logic7.ergo

This file was deleted.

30 changes: 0 additions & 30 deletions examples/helloworld/logic/logic8.ergo

This file was deleted.

21 changes: 0 additions & 21 deletions examples/helloworld/logic/logic9.ergo

This file was deleted.

4 changes: 4 additions & 0 deletions examples/helloworld1/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$class": "org.accordproject.helloworld.TemplateModel",
"name": "Fred Blogs"
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ transaction Request {

transaction Response {
o String output
o Integer number
}

/**
Expand Down
7 changes: 7 additions & 0 deletions examples/helloworld1/params.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"request": {
"$class": "org.accordproject.helloworld.Request",
"input": "Accord Project"
},
"hello": "Bonjour,"
}
4 changes: 4 additions & 0 deletions examples/helloworld1/request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$class": "org.accordproject.helloworld.Request",
"input": "Accord Project"
}
2 changes: 2 additions & 0 deletions examples/helloworld1/state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{ "$class": "org.accordproject.cicero.contract.AccordContractState",
"stateId" : "1" }
4 changes: 4 additions & 0 deletions examples/helloworld4/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$class": "org.accordproject.helloworld.TemplateModel",
"name": "Fred Blogs"
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@

namespace org.accordproject.helloworld

define function sayhello(name: String, input: String) : String {
return "Hello " ++ name ++ " (" ++ input ++ ")"
transaction Request {
o String input
}

transaction Response {
o String output
}

/**
* The template model
*/
@AccordTemplateModel("helloworld")
concept TemplateModel {
/**
* The name for the clause
*/
o String name
}

concept TextResponse {
o String text
}
7 changes: 7 additions & 0 deletions examples/helloworld4/params.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"request": {
"$class": "org.accordproject.helloworld.Request",
"input": "Accord Project"
},
"hello": "Bonjour,"
}
4 changes: 4 additions & 0 deletions examples/helloworld4/request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$class": "org.accordproject.helloworld.Request",
"input": "Accord Project"
}
2 changes: 2 additions & 0 deletions examples/helloworld4/state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{ "$class": "org.accordproject.cicero.contract.AccordContractState",
"stateId" : "1" }
4 changes: 4 additions & 0 deletions examples/helloworldErr/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$class": "org.accordproject.helloworld.TemplateModel",
"name": "Fred Blogs"
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ namespace org.accordproject.helloworld
contract HelloWorld over TemplateModel {
// Simple Clause
clause helloworld(request : Request) : Response {
return Response{ output: sayhello(contract.name,request.input) }
return Response{ output: "Hello \"" ++ contract.name ++ "\" (" ++ request.input ++ ")" }
}
}
7 changes: 7 additions & 0 deletions examples/helloworldErr/params.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"request": {
"$class": "org.accordproject.helloworld.Request",
"input": "Accord Project"
},
"hello": "Bonjour,"
}
4 changes: 4 additions & 0 deletions examples/helloworldErr/request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$class": "org.accordproject.helloworld.Request",
"input": "Accord Project"
}
2 changes: 2 additions & 0 deletions examples/helloworldErr/state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{ "$class": "org.accordproject.cicero.contract.AccordContractState",
"stateId" : "1" }
4 changes: 4 additions & 0 deletions examples/helloworldWarning/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$class": "org.accordproject.helloworld.TemplateModel",
"name": "Fred Blogs"
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,25 @@

namespace org.accordproject.helloworld

import org.accordproject.cicero.contract.*
transaction Request {
o String input
}

transaction Response {
o String output
}

/**
* The template model
*/
@AccordTemplateModel("helloworld")
concept TemplateModel {
/**
* The name for the clause
*/
o String name
}

contract HelloWorld over TemplateModel {
// Simple Clause
clause test(request : Request) : AccordContractState {
return state
}
concept TextResponse {
o String text
}
7 changes: 7 additions & 0 deletions examples/helloworldWarning/params.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"request": {
"$class": "org.accordproject.helloworld.Request",
"input": "Accord Project"
},
"hello": "Bonjour,"
}
4 changes: 4 additions & 0 deletions examples/helloworldWarning/request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$class": "org.accordproject.helloworld.Request",
"input": "Accord Project"
}
2 changes: 2 additions & 0 deletions examples/helloworldWarning/state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{ "$class": "org.accordproject.cicero.contract.AccordContractState",
"stateId" : "1" }
File renamed without changes.
2 changes: 1 addition & 1 deletion mechanization/Common/PrintTypedData.v
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Section PrintTypedData.
| dfloat f => toString f
| dbool true => "true"
| dbool false => "false"
| dstring s => jsonify (dstring (js_quote_string s))
| dstring s => jsonify (dstring s)
| dcoll arr =>
"["
++ (String.concat
Expand Down
2 changes: 1 addition & 1 deletion packages/ergo-cli/extracted/ergoccore.js

Large diffs are not rendered by default.

3,262 changes: 1,630 additions & 1,632 deletions packages/ergo-cli/extracted/ergotopcore.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/ergo-cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ require('yargs')
Logger.error(err.message + '\n' + JSON.stringify(err));
});
})
.command('request', 'send a request to the contract', (yargs) => {
.command('execute', 'send a request to the contract', (yargs) => {
yargs.demandOption(['data', 'request'], 'Please provide at least the contract data and a request');
yargs.usage('Usage: $0 request --data [file] --state [file] --request [file] [cto files] [ergo files]');
yargs.option('data', {
Expand Down Expand Up @@ -106,7 +106,7 @@ require('yargs')
}

// Run contract
Commands.request(argv.template, files, { file: argv.data }, argv.state ? { file: argv.state } : null,
Commands.execute(argv.template, files, { file: argv.data }, argv.state ? { file: argv.state } : null,
argv.currentTime, argv.request.map(r => { return { file: r }; }), argv.warnings)
.then((result) => {
Logger.info(JSON.stringify(result));
Expand Down
2 changes: 1 addition & 1 deletion packages/ergo-cli/lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Commands {
* @param {boolean} warnings whether to print warnings
* @returns {object} Promise to the result of execution
*/
static async request(template,files,contractInput,stateInput,currentTime,requestsInput,warnings) {
static async execute(template,files,contractInput,stateInput,currentTime,requestsInput,warnings) {
try {
const logicManager = await loadTemplate(template,files);
const contractJson = getJson(contractInput);
Expand Down
Loading

0 comments on commit 39cc398

Please sign in to comment.