cadence
cadence copied to clipboard
Emitting default events
Issue To Be Solved
Currently events are not mandatory on resource creation or movement. It is up to contract developer to emit or not, even if they are defined in the contract. It would be nice to fire some default events, like:
- Resource Creation (for minting for example)
- Resource Movement
- Saving to storage
- Linking to storage
I am not 100% sure what is necessary and what is not, but as Cadence resources are stored in user's storage, there is currently no way to reliably verify, let's say if NFT is really minted 100 times, or there is some duplicate NFT with same id etc.
Thanks for the suggestions, @bluesign.
I definitely agree on adding events for objects moving in and out of storage, and I'm pretty sold on the idea of noting when new links are created. 👍
Do you have more motivating examples of why all resources should emit events during creation? I worry about the noisiness of this. I know why some resources would want this, of course, but all? 😅
I'm also not sure what you mean by "Resource Movement" (outside of moving in and out of storage). Any examples here would also be helpful.
Resource Movement
I was thinking here automatic event on Resource .owner change. This can help with finding out path resource took historically. something like: ResourceMoved( uuid, Address, Address )
This should be event on changes delta. So if I take from storage, do something, put back will not emit any event.
Resource creation
I think this should be also on change delta. So after transaction, if some new Resource is created, it should emit just event of ResourceCreated(uuid, Type)
Actually ResourceMovement can also cover ResourceCreated case, if from Address is NULL.
Can this be prioritized? In view of The regent mm incident this just shows how important this is. @dete