Open ascjones opened 3 years ago
Another possibility is to capture the #[repr(u64)]
and encode that into an optional repr
field in TypeDefVariant
sidenote: the Encode/Decode implementation on IdentityField is wrong and should be removed https://github.com/paritytech/substrate/pull/9445
Then should I reconsider the removal of discriminant: u64
in https://github.com/paritytech/scale-info/pull/112?
if the only use of discriminant is bitflag maybe it is better to have dedicated syntax.
But otherwise it is true that the discriminant gives useful information in this specific case.
In substrate we have the following type:
It is wrapped in a
BitFlags
in the following wrapper type to allow custom encoding/decoding.Question is how to represent this with
scale_info
: it is encoded as a rawu64
but we need to also have access to theIdentityField
enum definition which maps the discriminants reduced tou8
indices.A temporary workaround is to provide the following
TypeInfo
implementationSee how it represents
BitFlags<IdentityField>
including theIdentityField
as a type parameter, and the field itself as typeu64
.However this requires some string matching for downstream type generators, so a preferable solution might be to add fist class support for a
BitFlags
likeTypeDef
variant.On the other we might not want to be adding a new
TypeDef
variant for each corner case, be curious to see what others think./cc @jacogr