gno icon indicating copy to clipboard operation
gno copied to clipboard

[tm2/gnovm] Identify each msg's event

Open r3v4s opened this issue 1 year ago • 0 comments

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

  1. 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"
    }
  ]
},
  1. second group of event
{
  "@type": "/tm.gnoEvent",
  "pkg_path": "gno.land/r/demo/event",
  "type": "other",
  "func": "Other",
  "attrs": [
    {
      "key": "k",
      "value": "v"
    }
  ]
}

r3v4s avatar May 03 '24 11:05 r3v4s