gno
gno copied to clipboard
[tm2/gnovm] Identify each msg's event
Description
While fixing #2028 in #2030, I found out that all of events in single transactions are just being append into single object.
For example if we execute multi-msg tx
await adena.DoContract({
messages: [{
"type": "/vm.m_call",
"value": {
"caller": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
"send": "",
"pkg_path": "gno.land/r/demo/event",
"func": "Hello",
"args": []
}
},{
"type": "/vm.m_call",
"value": {
"caller": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
"send": "",
"pkg_path": "gno.land/r/demo/event",
"func": "Other",
"args": []
}
}],
gasFee: 1,
gasWanted: 2000000
});
Event gets like this
"Events": [
{
"@type": "/tm.gnoEvent",
"pkg_path": "gno.land/r/demo/event2",
"type": "t",
"func": "inner",
"attrs": [
{
"key": "k",
"value": "v"
}
]
},
{
"@type": "/tm.gnoEvent",
"pkg_path": "gno.land/r/demo/event2",
"type": "t",
"func": "Hello",
"attrs": [
{
"key": "k",
"value": "v"
}
]
},
{
"@type": "/tm.gnoEvent",
"pkg_path": "gno.land/r/demo/event",
"type": "t",
"func": "inner",
"attrs": [
{
"key": "k",
"value": "v"
}
]
},
{
"@type": "/tm.gnoEvent",
"pkg_path": "gno.land/r/demo/event",
"type": "t",
"func": "Hello",
"attrs": [
{
"key": "k",
"value": "v"
}
]
},
{
"@type": "/tm.gnoEvent",
"pkg_path": "gno.land/r/demo/event",
"type": "other",
"func": "Other",
"attrs": [
{
"key": "k",
"value": "v"
}
]
}
],
With current event struct, as you can see we don't know which call made which event(s). IMHO, we need identify (or divide) each function's event
- first group of event
{
"@type": "/tm.gnoEvent",
"pkg_path": "gno.land/r/demo/event2",
"type": "t",
"func": "inner",
"attrs": [
{
"key": "k",
"value": "v"
}
]
},
{
"@type": "/tm.gnoEvent",
"pkg_path": "gno.land/r/demo/event2",
"type": "t",
"func": "Hello",
"attrs": [
{
"key": "k",
"value": "v"
}
]
},
{
"@type": "/tm.gnoEvent",
"pkg_path": "gno.land/r/demo/event",
"type": "t",
"func": "inner",
"attrs": [
{
"key": "k",
"value": "v"
}
]
},
{
"@type": "/tm.gnoEvent",
"pkg_path": "gno.land/r/demo/event",
"type": "t",
"func": "Hello",
"attrs": [
{
"key": "k",
"value": "v"
}
]
},
- second group of event
{
"@type": "/tm.gnoEvent",
"pkg_path": "gno.land/r/demo/event",
"type": "other",
"func": "Other",
"attrs": [
{
"key": "k",
"value": "v"
}
]
}