Skip to content

Commit

Permalink
feature(dep) Switch to Concerto 1.0 & New Ergo compiler
Browse files Browse the repository at this point in the history
Signed-off-by: Jerome Simeon <jeromesimeon@me.com>
  • Loading branch information
jeromesimeon committed Apr 12, 2021
1 parent ac3c463 commit e110f94
Show file tree
Hide file tree
Showing 493 changed files with 39,772 additions and 61,275 deletions.
47,029 changes: 12,394 additions & 34,635 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion packages/cicero-cli/lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,8 @@ class Commands {
clause = new Clause(template);
clause.parse(sampleText, currentTime);

return engine.init(clause, currentTime, paramsJson);
// XXX Third parameter is utcOffset, should be added to CLI
return engine.init(clause, currentTime, null, paramsJson);
})
.catch((err) => {
Logger.error(err.message);
Expand Down
2 changes: 1 addition & 1 deletion packages/cicero-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"homepage": "https://www.accordproject.org/projects/cicero",
"dependencies": {
"@accordproject/concerto-core": "0.82.11",
"@accordproject/concerto-core": "1.0.0-alpha.5",
"@accordproject/cicero-core": "0.21.26",
"@accordproject/cicero-engine": "0.21.26",
"@accordproject/cicero-test": "0.21.26",
Expand Down
20 changes: 14 additions & 6 deletions packages/cicero-cli/test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,14 @@ describe('#parse', () => {
it('should parse a clause using a template', async () => {
const result = await Commands.parse(template, sample, null);
delete result.clauseId;
delete result.$identifier;
result.should.eql(parseReponse);
});

it('should parse a clause using a template archive', async () => {
const result = await Commands.parse(templateArchive, sample, null);
delete result.clauseId;
delete result.$identifier;
result.should.eql(parseReponse);
});

Expand All @@ -173,6 +175,7 @@ describe('#parse-output', async () => {
it('should parse a clause using a template and save to a JSON file', async () => {
const result = await Commands.parse(template, sample, dataOut);
delete result.clauseId;
delete result.$identifier;
result.should.eql(parseReponse);
});
});
Expand Down Expand Up @@ -267,12 +270,14 @@ describe('#draft', () => {
it('should create the text for a clause using a template', async () => {
const result = await Commands.draft(template, data, null);
delete result.clauseId;
delete result.$identifier;
result.should.eql(draftResponse);
});

it('should create the text for a clause using a template archive', async () => {
const result = await Commands.draft(templateArchive, data, null);
delete result.clauseId;
delete result.$identifier;
result.should.eql(draftResponse);
});

Expand All @@ -286,18 +291,21 @@ describe('#draft-output', async () => {
it('should create the text for a clause using a template and save to a file', async () => {
const result = await Commands.draft(template, data, sampleOut);
delete result.clauseId;
delete result.$identifier;
result.should.eql(draftResponse);
});

it('should create the slate for a clause using a template and save to a JSON file', async () => {
const result = await Commands.draft(template, data, sampleOutJson, null, { format: 'slate' });
delete result.clauseId;
delete result.$identifier;
result.should.not.be.null;
});

it('should create the slate for a ciceromark_parsed using a template and save to a JSON file', async () => {
const result = await Commands.draft(template, data, sampleOutJson, null, { format: 'ciceromark_parsed' });
delete result.clauseId;
delete result.$identifier;
result.should.not.be.null;
});
});
Expand Down Expand Up @@ -420,12 +428,14 @@ describe('#normalize', () => {
it('should normalize a clause using a template', async () => {
const result = await Commands.normalize(template, sample, false, null);
delete result.clauseId;
delete result.$identifier;
result.should.eql(draftResponse);
});

it('should normalize a clause using a template archive', async () => {
const result = await Commands.normalize(templateArchive, sample, false, null);
delete result.clauseId;
delete result.$identifier;
result.should.eql(draftResponse);
});

Expand Down Expand Up @@ -787,14 +797,12 @@ describe('#validateInitializeArgs', () => {
describe('#initialize', () => {
it('should initialize a clause using a template', async () => {
const response = await Commands.initialize(template, sample);
response.state.$class.should.be.equal('org.accordproject.cicero.contract.AccordContractState');
response.state.stateId.should.be.equal('org.accordproject.cicero.contract.AccordContractState#1');
response.state.$class.should.be.equal('org.accordproject.runtime.State');
});

it('should initialize a clause using a template archive', async () => {
const response = await Commands.initialize(templateArchive, sample);
response.state.$class.should.be.equal('org.accordproject.cicero.contract.AccordContractState');
response.state.stateId.should.be.equal('org.accordproject.cicero.contract.AccordContractState#1');
response.state.$class.should.be.equal('org.accordproject.runtime.State');
});

it('should fail to initialize on a bogus sample', async () => {
Expand Down Expand Up @@ -962,15 +970,15 @@ describe('#archive', async () => {
it('should create a JavaScript archive', async () => {
const tmpFile = await tmp.file();
const tmpArchive = tmpFile.path + '.cta';
await Commands.archive(template, 'cicero', tmpArchive, false);
await Commands.archive(template, 'es6', tmpArchive, false);
fs.readFileSync(tmpArchive).length.should.be.above(0);
tmpFile.cleanup();
});
it('should not create an unknown archive', async () => {
const tmpFile = await tmp.file();
const tmpArchive = tmpFile.path + '.cta';
return Commands.archive(template, 'foo', tmpArchive, false)
.should.be.rejectedWith('Unknown target: foo (available: es5,es6,cicero,java)');
.should.be.rejectedWith('Unknown target: foo (available: es6,java)');
});

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,27 @@
* limitations under the License.
*/

namespace org.accordproject.cicero.contract
concerto version ">= 1.0.0-alpha.3"

namespace org.accordproject.contract

/**
* Contract Data
* -- Describes the structure of contracts and clauses
*/

/* A contract state is an asset -- The runtime state of the contract */
asset AccordContractState identified by stateId {
o String stateId
}

/* A party to a contract */
participant AccordParty identified by partyId {
participant Party identified by partyId {
o String partyId
}

/* A contract is a asset -- This contains the contract data */
abstract asset AccordContract identified by contractId {
abstract asset Contract identified by contractId {
o String contractId
--> AccordParty[] parties optional
--> Party[] parties optional
}

/* A clause is an asset -- This contains the clause data */
abstract asset AccordClause identified by clauseId {
abstract asset Clause identified by clauseId {
o String clauseId
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

concerto version ">= 1.0.0-alpha.3"

namespace org.accordproject.runtime

import org.accordproject.contract.Party from https://models.accordproject.org/accordproject/contract.cto
import org.accordproject.contract.Contract from https://models.accordproject.org/accordproject/contract.cto

/**
* Runtime API
* -- Describes input and output of calls to a contract's clause
*/

/* A request is a transaction */
transaction Request {
}

/* A response is a transaction */
transaction Response {
}

/* An event that represents an obligation that needs to be fulfilled */
abstract event Obligation identified {
/* A back reference to the governing contract that emitted this obligation */
--> Contract contract

/* The party that is obligated */
--> Party promisor optional

/* The party that receives the performance */
--> Party promisee optional

/* The time before which the obligation is fulfilled */
o DateTime deadline optional
}

/* A contract state is an asset -- The runtime state of the contract */
asset State {
}

This file was deleted.

6 changes: 3 additions & 3 deletions packages/cicero-cli/test/data/helloemit/model/model.cto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace org.accordproject.helloemit

import org.accordproject.cicero.contract.* from https://models.accordproject.org/cicero/contract.cto
import org.accordproject.cicero.runtime.* from https://models.accordproject.org/cicero/runtime.cto
import org.accordproject.contract.* from https://models.accordproject.org/accordproject/contract.cto
import org.accordproject.runtime.* from https://models.accordproject.org/accordproject/runtime.cto

transaction MyRequest extends Request {
o String input
Expand All @@ -18,7 +18,7 @@ event Greeting {
/**
* The template model
*/
asset TemplateModel extends AccordClause {
asset TemplateModel extends Clause {
/**
* The name for the clause
*/
Expand Down
6 changes: 0 additions & 6 deletions packages/cicero-cli/test/data/helloemit/state.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@

namespace org.accordproject.helloworldstate

import org.accordproject.cicero.runtime.*
import org.accordproject.runtime.*

contract HelloWorldState over HelloWorldClause state HelloWorldState {
clause init(startsAt : Double) : Response {
set state HelloWorldState{
stateId: "org.accordproject.helloworldstate.HelloWorldState#0.0",
counter: startsAt
};
return Response{}
Expand All @@ -29,7 +28,6 @@ contract HelloWorldState over HelloWorldClause state HelloWorldState {
clause helloworldstate(request : MyRequest) : MyResponse {
let newCounter = state.counter + 1.0;
set state HelloWorldState{
stateId: "org.accordproject.helloworldstate.HelloWorldState#" ++ toString(state.counter),
counter: newCounter
};
return MyResponse{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,27 @@
* limitations under the License.
*/

namespace org.accordproject.cicero.contract
concerto version ">= 1.0.0-alpha.3"

namespace org.accordproject.contract

/**
* Contract Data
* -- Describes the structure of contracts and clauses
*/

/* A contract state is an asset -- The runtime state of the contract */
asset AccordContractState identified by stateId {
o String stateId
}

/* A party to a contract */
participant AccordParty identified by partyId {
participant Party identified by partyId {
o String partyId
}

/* A contract is a asset -- This contains the contract data */
abstract asset AccordContract identified by contractId {
abstract asset Contract identified by contractId {
o String contractId
--> AccordParty[] parties optional
--> Party[] parties optional
}

/* A clause is an asset -- This contains the clause data */
abstract asset AccordClause identified by clauseId {
abstract asset Clause identified by clauseId {
o String clauseId
}
Loading

0 comments on commit e110f94

Please sign in to comment.