-
Notifications
You must be signed in to change notification settings - Fork 55
pass arguments to contract init #789
Comments
Found Problem in https://github.com/accordproject/ergo/blob/master/packages/ergo-compiler/lib/logicmanager.js#L95 The If this can be added, optional parameters could be added to |
Signed-off-by: Sebastian Bach <Sebastian.Bach-p2y@rub.de>
Signed-off-by: Sebastian Bach <Sebastian.Bach-p2y@rub.de>
…oject#789 Signed-off-by: Sebastian Bach <Sebastian.Bach-p2y@rub.de>
…ordproject#789 Signed-off-by: Sebastian Bach <Sebastian.Bach-p2y@rub.de>
Sorry it took me a really long time to get back to you on this. The Ergo design is still a bit tainted by earlier JS execution model which used a dispatch on the request. Unfortunately that tends to confuse a couple of things. Notably you can write clause either as
So I think your example attempts at using
i.e., the fourth parameter in that call would be an object containing the Ergo parameters for the invocation which is an object with a single Hope this helps. |
Another useful pointer about this: The $ ergo invoke --template ./tests/volumediscount --clauseName volumediscount --data ./tests/volumediscount/data.json --params ./tests/volumediscount/params.json --state ./tests/volumediscount/state.json with a {
"request": {
"$class": "org.accordproject.volumediscount.VolumeDiscountRequest",
"netAnnualChargeVolume": 10.4
}
} (notice the |
Thanks for clarifying! By setting the Would it be possible to add an optional interface for those params to the Cicero Engine Or is this behaviour unwanted and one should call the |
hm. Actually I think so. I can't recall on top of my head why it isn't so. I'll have to review but I'll get back to you on that other issue! Please close this one if you feel it has been adequately answered. |
Describe the bug
When sending arguments to the init function of a contract (see accordproject/template-archive#604) the following error is produced:
The ergo code for the init function (the error occurs for both
params: initRequest
andrequest: initRequest
):To Reproduce
Steps to reproduce the behavior:
result = await engine.getErgoEngine().init(engine.logicManager, clauseId ,contract, request, date,null)
whererequest
is an object of typeinitRequest
.Expected behavior
The init clause should be executed properly
Additional context
For debugging purpose I printed the script and context in https://github.com/accordproject/ergo/blob/master/packages/ergo-engine/lib/vmengine.js#L67, which resulted in following output:
deref(context, "__contract")
results innull
andunbrand(vparams)
later fails for this reason.According to this output, the
params
key exists in thecontext
object prior to creating the VM but still it later does not?The text was updated successfully, but these errors were encountered: