[SEP-41] Update events to support extensions #1948
Replies: 9 comments 9 replies
|
💯 It's time to do this. This idea has come up in past discussions and in every previous discussion the focus has been on keeping the changes minimal. But in hindsight the first time this came up we should have blanket changed the specification to allow contract developers to use maps for any of the event bodies and be extendable. This has zero impact on chain to any existing contract, but does impact off-chain systems that index on-chain data, and require that they start are tolerant of the two different formats that each event can be represented with. Given that indexers already do this for the most prevalent events, transfer and mint, it seems very reasonable to expect it to be feasible for the other events. |
|
Reviewing d385931: In the linked change there is the phrase "original data format" used. Instead of naming the data format "original" can we call it by the name of the data format, which is "single-value" or "vec" depending on the event? "Original" creates a new term to navigate, define, relate to. For example, say: Events can be emitted by tokens in two formats, a single-value/vec data format, and a map data format. |
|
Cross-referencing https://github.com/orgs/stellar/discussions/1916 here. Both discussions are essentially the same, but this one goes further in pushing the map format to all events. |
|
In the PR #1947, the trait doc-comments are still showing only the old event formats. @mootz12: can you plz update them similarly to stellar-protocol/ecosystem/sep-0041.md Lines 107 to 108 in 6ddff4f |
|
Once we're aligned on SEP-41, we'll want to fan this update to SEP-57 as well. |
|
Just to confirm, there is no plan to update the format used for SAC events, right? So realistically applications will only need to update if they support contract tokens that use maps instead of the single-value approach? |
|
Wanted to add some additional motivation for the change:
|
|
The feedback about this change is positive both today and in the past when discussed linked in other comments above, and it aligns SEP-41 document with implementations that have misinterpreted it in ways that make sense are is intuitive. The change is backwards compatible. Let's merge the attached PR in 7 days, on July 27th, if there is no concerns raised. |
|
Looks nice. We'll add support for this right away to StellarExpert. |
Uh oh!
There was an error while loading. Please reload this page.
Summary
SEP-41 defines a handful of core token events that downstream services use to index data for tokens in the Stellar ecosystem. Today most of these events emit their data as a bare
i128. Thetransferandmintevents already define an alternate form where the data is aMapwith anamount: i128entry plus an optionalto_muxed_identry.This proposal generalizes the existing
Mapdata format to all SEP-41 events. Any event may be extended with further keys by other token SEPs or implementations. Consumers must tolerate unknown keys on event data.The existing data forms remain valid, and event consumers are required to support both the legacy form and the map form.
Why
As the token ecosystem grows, standards might want to emit additional data during events. Currently, for tokens to stay compliant with SEP-41 based indexers, they would need to define and emit additional events. These events will likely contain duplicate data or require downstream systems to match them with the SEP-41 event.
Further, the default data format for events in Soroban is a map. The
#[contractevent]macro defaults todata_format = "map", so even a single data field event serializes its data as aMaprather than a bare value. Consider the following event definition:While this event looks like it conforms to SEP-41, the data section would be a
Mapinstead of ani128. This impacts the current compatibility of SEP-57's event definitions with SEP-41.SEP-41 consumers already accept both the
i128andMapdata forms for thetransferandmintevents, so extending that handling to the remaining events should be a small change.Change
PR: #1947
References
All reactions