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

Determination of whether a clause is stateful is confusing #722

Open
DianaLease opened this issue Nov 27, 2019 · 2 comments
Open

Determination of whether a clause is stateful is confusing #722

DianaLease opened this issue Nov 27, 2019 · 2 comments

Comments

@DianaLease
Copy link
Member

Describe the bug
getStateTypes() returns org.accordproject.cicero.contract.AccordContractState for clause templates that do not utilize state

Expected behavior
The distinction between stateful and stateless clauses should be more clear.

@jeromesimeon
Copy link
Member

jeromesimeon commented Nov 27, 2019

Good issue! But I think the description is a bit misleading. At the moment every clause is stateful, in the sense that there is no way to know if the state will or will not be changed except by looking at the logic for that clause (i.e., does it use set state or not).

It would be nice if the contract type or clause type was able to make that distinction.

This is a bit similar to the issue opened by @mttrbrts on emitted obligations here: #714

@jeromesimeon
Copy link
Member

jeromesimeon commented Nov 27, 2019

For the sake of argument, here is a contract which is stateful and for which getStateTypes() returns org.accordproject.cicero.contract.AccordContractState

namespace org.accordproject.helloworld

import org.accordproject.cicero.contract.AccordContractState

contract HelloWorld over HelloWorldClause {
  // Simple Clause
  clause helloworld(request : MyRequest) : MyResponse {
    set state AccordContractState{ stateId : "FOOBAR" };
    return MyResponse{ output: "Hello " ++ contract.name ++ " " ++ request.input }
  }
}

With the corresponding execution:

bash-3.2$ cicero trigger
15:06:15 - info: Using current directory as template folder
15:06:15 - info: Loading a default text/sample.md file.
15:06:15 - info: Loading a default request.json file.
15:06:16 - warn: A state file was not provided, initializing state. Try the --state flag or create a state.json in the root folder of your template.
15:06:16 - info:
{
  "clause": "helloworld@0.12.0-c0d3909d5b62ea58596f0e38e0f4362eca2b42be88585ce0d4cd5a6c6b9c1b15",
  "request": {
    "$class": "org.accordproject.helloworld.MyRequest",
    "input": "Accord Project"
  },
  "response": {
    "$class": "org.accordproject.helloworld.MyResponse",
    "output": "Hello Fred Blogs Accord Project",
    "transactionId": "5e2fdfce-c31c-4836-9ca7-22b7218f890f",
    "timestamp": "2019-11-27T20:06:16.684Z"
  },
  "state": {
    "$class": "org.accordproject.cicero.contract.AccordContractState",
    "stateId": "FOOBAR"
  },
  "emit": []
}

@jeromesimeon jeromesimeon transferred this issue from accordproject/template-archive Dec 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants