Kathmandu
Note: as LIGO uses Mumbai protocol to Michelson type-check your programs, the flag
--disable-michelson-typecheckingis recommended to compile contracts to Kathmandu when using tickets / chest.
API
New primitives
Tezos
let emit: string => 'a => operation
Build an event operation. To actually emit an event, this operation must be returned the same way as other operations (origination / transfer ..)
Test
let get_last_events_from: typed_address <'p,'s> => string => list <'a>
Returns the list of all the event payloads emited with a given tag by a given address. Any call to this function must be annotated with the expected payload type.
Event testing
Here is how you emit events and fetch them from your tests:
namespace C {
// @entry
const main = (p: [int, int], _: unit) : [list<operation>, unit] => {
const op1 = Tezos.Operation.emit("%foo", p);
const op2 = Tezos.Operation.emit("%foo", p[0]);
return [[op1, op2], unit];
};
}
const test = () => {
const orig = Test.Originate.contract(contract_of(C), unit, 0 as tez);
Test.Typed_address.transfer_exn(orig.taddr, ["Main" as "Main", [1,2]], 0 as tez);
return [Test.State.last_events(orig.taddr, "foo") as list<[int, int]>, Test.State.last_events(orig.taddr, "foo") as list<int>];
};
const run_test = test();