Is it possible to retrieve data types for events from metadata?
The objective is to extend the types.EventRecords type for the given chain (in my case, Polkadot) to prevent unkown type errors when decoding events.
I'm attempting to list out the data types for events, and I'm unsure how si1Lookup works.
Sample code:
func TestGetEventsFromMeta(t *testing.T) {
c, err := NewConnection("http://localhost:9934")
assert.NoError(t, err)
meta, err := c.getLatestMetadata()
assert.NoError(t, err)
for _, mod := range meta.AsMetadataV14.Pallets {
if !mod.HasEvents {
continue
}
if typ, ok := meta.AsMetadataV14.EfficientLookup[mod.Events.Type.Int64()]; ok {
if len(typ.Def.Variant.Variants) > 0 {
for _, vars := range typ.Def.Variant.Variants {
fmt.Printf("%s\t%s\n", mod.Name, vars.Name)
for _, field := range vars.Fields {
// How to decode field data here? <---------------------------------------------------
fmt.Printf("%#v\n", meta.AsMetadataV14.Lookup.Types[field.Type.Int64()])
}
}
}
}
}
}
Is it possible to retrieve data types for events from metadata?
The objective is to extend the
types.EventRecords
type for the given chain (in my case, Polkadot) to prevent unkown type errors when decoding events.I'm attempting to list out the data types for events, and I'm unsure how
si1Lookup
works.Sample code:
Related to issue #220