pendulum-chain / pendulum-solidity-wrapper

A collection of Solidity wrapper contracts emulating common ERC interfaces to grant access to runtime features on Pendulum.
GNU General Public License v3.0
0 stars 0 forks source link

Emit Events when using chain extension to alter chain state #10

Closed ebma closed 1 year ago

ebma commented 1 year ago

At the moment, the psp_22 contract does not emit any events which makes it difficult to understand what happened in a call to the smart contract. I tested the events on-chain and e.g. when using the smart contract to transfer some asset between two accounts, this does not appear anywhere in the block.

We should consider emitting events from within the smart contract so that we can track what happened in a smart contract call.

ebma commented 1 year ago

Maybe we should also consider emitting relevant events from our chain extension. Although I am not 100% sure if this is possible. For example, when transferring some balance using the orml pallet adapter in our chain extension, it would be great if we can emit the related event. Do you know if this is possible @ashneverdawn?

ashneverdawn commented 1 year ago

Maybe we should also consider emitting relevant events from our chain extension. Although I am not 100% sure if this is possible. For example, when transferring some balance using the orml pallet adapter in our chain extension, it would be great if we can emit the related event. Do you know if this is possible @ashneverdawn?

This should be possible, yes.

And most importantly, as you said, contracts can and should emit events of their own. ink! has the functionality to emit events described here: https://use.ink/basics/events So we definitely need to implement that in the psp_22 contract.

ebma commented 1 year ago

It seems like this already works properly and I only didn't see any events being emitted because the chain extension functions were not called correctly. At least when testing with the ERC-20 wrapper, the expected events were emitted properly by the used pallets.

That's why I think I will close this ticket for now.