-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: events api #125
Comments
IMO, this should emit the event on the runtime level, we want the smart contract developer to control what kinds of events they want to emit on the contract level. But in the other hand, emitting the event from POP API does improve the contract testing experience with tool like Contract UI: https://ui.use.ink/ |
I think that is a great point. As for having events for testing, this is why we have put so much effort in the error handling. Contracts using the pop api should not have to worry about the code not working. They should only have to worry about the logic they add on top of the api, this includes what to do with the return value from the api, as for errors - this is were top notch documentation and examples will become crucial (#108), to help the developer understanding how to convert the status code to a clear error and how to eventually structure their production level code with respect to the error handling of the api. @peterwht & @evilrobot-01, I would like to hear your view here so that we can implement the final decision. |
As for events in the runtime, the standard only has two:
The events for creating and destroying assets and metadata is an open question here. |
Events emitted from a contract results in: "contracts.ContractEmitted" from Also, in this example, However, outputting events from the runtime could be useful for monitoring activity in the API. My opinion is this:
|
Just mentioning that emitting events doesn't come for free: https://substrate.stackexchange.com/questions/4126/why-are-events-stored |
Additional relevant comments: #113 (comment) |
Contracts can't consume the emitted events AFAIK, so I think the conversation should be based around standards in this context. If fungibles is supporting a standard, it should potentially emit events to satisfy the standard, so that external event subcribers get the information they require to take some action. Access to signals of state changes, in a known format, is the most important thing. The consumer of the events can ultimately choose which events to subscribe to in order to fulfill their use case, potentially amalgamating information from multiple events if need be. Listening to multiple events to gather enough information to act isn't ideal, but better than not even sufficient information to act. Zooming out, what does a wallet supporting a PSP do to support a token. If it only looks for contract specific events, with specific interfaces/identifiers, then emitting them from the fungibles may be unnecessary. Let's be standards compliant first, then potentially consider whether the fungibles pallet should emit events and what shape they may be. By example, does assets emit enough, does fungibles emit enough, does the contract have enough to even emit. If assets emits something containing the new balance, but fungibles or the contract are unable to use that information to incorporate their own event, apart from querying, is there much than can be done by way of the contract events? |
We probably need to place these events into two buckets. Those contracts which want to comply to a standard for interoperability and composability, which may want to emit standards-based events. I agree with Peter here in making these types easily available, provided the contract has sufficient information to actually construct the event data. This may be a non-starter or may require the contract to track additional state. Providing reusable types to meet a standard is easy tho. Other contracts are consumers of Pop API and probably don't directly care about being standards compliant. I still feel that fungibles should emit standards compliant events where practical, so that ultimately wallets/dapps have the information they need readily available. |
Alright so providing the event in the api, as part of the standard and use case. In addition, emitting the event in the pallet. That seems both reasonable, especially in the contract where the developer can choose themselves whether to use it or not. |
Closed by #153 |
Events should be added to the api ink! library as well as emitted in the pallet.
The text was updated successfully, but these errors were encountered: