Open martinhalford opened 1 year ago
Please try
Asset HelloWorld extends Contract
Hi @mttrbrts -
I tried asset
....
namespace hello@1.0.0
import org.accordproject.contract@0.2.0.Contract from https://models.accordproject.org/accordproject/contract@0.2.0.cto
@template
asset HelloWorld extends Contract {
o String name
}
...now getting error...
Error: Invalid or missing identifier for Type "HelloWorld" in namespace "hello@1.0.0".
After reading some doco, I also tried...
namespace hello@1.0.0
import org.accordproject.contract@0.2.0.Contract from https://models.accordproject.org/accordproject/contract@0.2.0.cto
@template
asset HelloWorld identified by name extends Contract {
o String name
}
...but then got the error...
D: Super class org.accordproject.contract@0.2.0.Contract has an explicit identifier contractId that cannot be redeclared. Line 5 column 1, to line 8 column 2.
For the record, was trying these models in https://playground.accordproject.org/ for ease and simplicity. However, I think the same happens in the CLI too.
Any ideas?
The concept org.accordproject.contract@0.2.0.Contract
already has an identifying field, so you cannot redeclare or override it for HelloWorld
.
This works:
namespace hello@1.0.0
import org.accordproject.contract@0.2.0.Contract from https://models.accordproject.org/accordproject/contract@0.2.0.cto
@template
asset HelloWorld extends Contract {
o String name
}
With this JSON data:
{
"$class": "hello@1.0.0.HelloWorld",
"contractId" : "foo",
"name": "John Doe"
}
What would make the debugging simpler is if we highlight which file is raising an error in the Playground...
Hi @dselman - Yes - that makes sense. I only tried redeclaring the id
field in an attempt to get the above to work.
Sadly, the model syntax above doesn't work for archive
for Cicero version 0.24.1-20230722135139
.
namespace hello@1.0.0
import org.accordproject.contract@0.2.0.Contract from https://models.accordproject.org/accordproject/contract@0.2.0.cto
@template
asset HelloWorld extends Contract {
o String name
}
This is what I get when I try to execute the archive
method on the cicero
cli.
% cicero --version
0.24.1-20230722135139
% cicero archive
11:41:24 am - INFO: Using current directory as template folder
11:41:25 am - ERROR: Failed to find an asset that extends org.accordproject.contract.Contract. The model for the template must contain a single asset that extends org.accordproject.contract.Contract.
(cc: @mttrbrts)
Suspect these issues are related. https://github.com/accordproject/cicero/issues/791
@dselman @mttrbrts
Bug Report 🐛
Tried this in Template Playground.
For following
model.cto
......getting error...
Is
extends
no longer required and/or been superseded / deprecated?(Note: If this is the case then suspect some of our CodeGen logic will fail / need refactoring.)