Bug Report 🐛
I need to emit multiple events based on the list of vendors, specified in my contract.
Here is how I envision that:
My grammar.tem.md:
[...]
{{#ulist vendors}}
{{businessName}}
{{/ulist}}
[...]
My model.cto:
event VendorNotification {
o String code
o String description
o Vendor vendor
}
transaction NotifyVendorsReq extends Request {
o String detectionCode
o String description
}
transaction NotifyVendorsRes extends Response {
o String output
}
participant Vendor identified by businessName {
o String businessName
}
asset MyContract extends Contract {
o Vendor[] vendors
}
And logic.ergo:
contract MyContractLogic over MyContract state State {
//Iterate through an array of vendors and emit an event for each of them
clause notifyVendors(request : NotifyVendorsReq) : NotifyVendorsRes emits VendorNotification[] {
emit foreach vendor in contract.vendors
return VendorNotification {
code: request.notificationCode,
description: request.description,
vendor: vendor
};
return NotifyVendorsRes{ output: "Received " ++ request.notificationCode ++ " " ++ request.description ++ " and sent notification to vendors " ++ toString(contract.vendors) }
}
}
cicero trigger throws “ERROR: Cannot read property ‘$coll’ of undefined”
Expected Behavior
The contract should emit an array of events
Current Behavior
Throws an error: “ERROR: Cannot read property ‘$coll’ of undefined”
Possible Solution
Would be good to make emit function compatible with an array of events.
Steps to Reproduce
Please see the bug report section.
Context (Environment)
Desktop
- OS: macOS
- Browser: NodeJS v10.18.1
- Version: "cicero": "^0.22.1"
Detailed Description
The emit function can receive an array of events and emit them one-by-one to address the situation when multiple events need to be emitted in one go.
Possible Implementation
Bug Report 🐛
I need to emit multiple events based on the list of vendors, specified in my contract.
Here is how I envision that:
My
grammar.tem.md:My
model.cto:And
logic.ergo:cicero triggerthrows “ERROR: Cannot read property ‘$coll’ of undefined”Expected Behavior
The contract should emit an array of events
Current Behavior
Throws an error: “ERROR: Cannot read property ‘$coll’ of undefined”
Possible Solution
Would be good to make
emitfunction compatible with an array of events.Steps to Reproduce
Please see the bug report section.
Context (Environment)
Desktop
Detailed Description
The
emitfunction can receive an array of events and emit them one-by-one to address the situation when multiple events need to be emitted in one go.Possible Implementation