fuel-indexer
fuel-indexer copied to clipboard
Wrapping all types in structs
It has been brought to my attention that the indexer can only capture an event if it has an ID associated with it, potentially in the form of a struct.
I may have misunderstood.
If it is not currently possible to capture events such as
log(5u64)
and instead we must do
log(SomeStruct { field: 5u64 })
then that is an unintuitive UX limitation. I expect to be able to log any type and capture it in the indexer rather than be limited to wrapping it into a struct.
@Braqzen
- I think I see what you're referring to
- I will tag this as "documentation" since I think we need to explain this clearly in the docs (maybe in the "What can I index" section)
- Open to ideas on where in the docs this should go
- When you
log(5)you're logging a reference type, whereas when you loglog(SomeStruct)you're logging a complex type- Complex types are made available via the
LogDatareceipt'sdatafield- We decode this
datafield from a byte array back into it's originalSomeStructform - Then you can access the
SomeStructvia your indexer handler such as:fn do_a_thing(s: SomeStruct)
- We decode this
- However, for reference types, these come via the
Logreceipt- Since these are reference types, there's no decoding to be done for them
- If you want to use this
log(5), you'd have to add theLogto your handler such as:fn do_a_thing(s: Log)- From here you can access your
5value via theLog'srafieldassert_eq!(s.ra, 5)
- From here you can access your
- Complex types are made available via the
- Again, I think this is a documentation issue, but open to ideas on where to document this