fuel-indexer icon indicating copy to clipboard operation
fuel-indexer copied to clipboard

Wrapping all types in structs

Open Braqzen opened this issue 2 years ago • 1 comments

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 avatar Nov 22 '23 15:11 Braqzen

@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 log log(SomeStruct) you're logging a complex type
    • Complex types are made available via the LogData receipt's data field
      • We decode this data field from a byte array back into it's original SomeStruct form
      • Then you can access the SomeStruct via your indexer handler such as: fn do_a_thing(s: SomeStruct)
    • However, for reference types, these come via the Log receipt
      • 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 the Log to your handler such as: fn do_a_thing(s: Log)
        • From here you can access your 5 value via the Log's ra field assert_eq!(s.ra, 5)
  • Again, I think this is a documentation issue, but open to ideas on where to document this

ra0x3 avatar Nov 29 '23 16:11 ra0x3