canvas-ui icon indicating copy to clipboard operation
canvas-ui copied to clipboard

Display contract events

Open Robbepop opened this issue 5 years ago • 1 comments

Contracts can emit events which are especially useful to inspect for other third party tools. The Canvas UI should display those events next to the other events upon interaction with smart contracts. This currently does not happen from my personal observations but we really want to have those.

All information about how to decode such an event is stored inside the metadata. Event event topics are now properly included in the encoding.

The Canvas UI should also feature a log for every contract and its events. There should be one log per contract. It should be possible to merge different logs. Event logs should be displayed in chronological order of their appearance.

  • [ ] Implement events emitted by smart contracts displaying next to other events.
  • [ ] Implement event log UI as described above.

Robbepop avatar Oct 21 '20 11:10 Robbepop

@kwingram25 I have been working on implementing a UI to show the contract events similar to how RPC outcomes are shown. So for testing this i created this contract which emits two events. But i am facing some issues with this.

#[ink(event)]
    pub struct CrazyEvent {
        #[ink(topic)]
        account: AccountId,
    }
    #[ink(event)]
    pub struct SuperCrazyEvent {
        #[ink(topic)]
        account: AccountId,
        #[ink(topic)]
        balance: Balance,
    }

I executed the contract function from ui and console logged the event object. For the first event CrazyEvent the topics array is coming as excepted [EventNameInHex, AccountIDInHex] but for the second event SuperCrazyEvent the topics array is coming in a different order [BalanceInHex, EventNameInHex, AccountIDInHex]. This inconsistency makes it difficult to understand how to decode the data using the type info for a event found in ABI.

So here are my doubts:

  1. Is the event data to be decoded from the topics array itself ?
  2. If so is the type info for event args embedded in the contract event object because i haven't seen it from my observation ?
  3. Shouldn't the topics array comes in a defined manner if we are to use the type info in ABI to decode it ?

These are just observations i made from what i know about the application so i might have missed something that was obvious. I will share detailed logs if necessary.

Details canvas-node v0.1.4 cargo-contract 0.8.0

MathewtheCoder avatar Feb 11 '21 05:02 MathewtheCoder