You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// return the values of the fields in the event as a Compositefnfield_values(&self) -> Result<scale_value::Composite<scale_value::scale::TypeId>,Error>// return the values of the fields in the event as some type Efnas_event<E:StaticEvent>(&self) -> Result<Option<E>,Error>fnas_pallet_event<E:DecodeWithMetadata>(&self) -> Result<E,Error>// try to decode the event into some specific pallet::Eventfnas_pallet_event<E:DecodeWithMetadata>(&self) -> Result<E,Error>// try to decode the event into the root runtime::Eventfnas_root_event<E:RootEvent>(&self) -> Result<E,Error>
Ie, we have 4 different ways to decode events (and the same interface exists foer calls for consistency).
as_root_n is the most generally useful way to statically decode things nowadays I think, and renders as_pallet_n redundant. And moreso, as_pallet_n fns may decode things into the wrong types if the types happen to align closely enough, so I think it's a bit of a footgun. (ie if you try to decode some extrinsic into pallet_a::Call, it will succeed even if it was actually from pallet_b::Call as long as the types line up for the variant we're decoding)
as_n (ie as_event and as_extrinsic) are used in all of the find() functions, which are quite nice ergonomically, so I'd keep them for now just for that reason.
field_values (for events and extrinsics) is the only way to dynamically decode fields, which Probably makes marginally more sense than decoding the entire outer variant (you can check the variant/pallet names separately already anyway).
So, I'd propose that we remove as_pallet_extrinsic and as_pallet_event for now. I'd like to remove more, but the find() APIs are just a little too appealing to want to remove, though one can manually iterate extrinsics/events, and search/decode based on pallet and variant name)
The text was updated successfully, but these errors were encountered:
Events and extrinsics both now provide:
Ie, we have 4 different ways to decode events (and the same interface exists foer calls for consistency).
as_root_n
is the most generally useful way to statically decode things nowadays I think, and rendersas_pallet_n
redundant. And moreso,as_pallet_n
fns may decode things into the wrong types if the types happen to align closely enough, so I think it's a bit of a footgun. (ie if you try to decode some extrinsic intopallet_a::Call
, it will succeed even if it was actually frompallet_b::Call
as long as the types line up for the variant we're decoding)as_n
(ieas_event
andas_extrinsic
) are used in all of thefind()
functions, which are quite nice ergonomically, so I'd keep them for now just for that reason.field_values
(for events and extrinsics) is the only way to dynamically decode fields, which Probably makes marginally more sense than decoding the entire outer variant (you can check the variant/pallet names separately already anyway).So, I'd propose that we remove
as_pallet_extrinsic
andas_pallet_event
for now. I'd like to remove more, but thefind()
APIs are just a little too appealing to want to remove, though one can manually iterate extrinsics/events, and search/decode based on pallet and variant name)The text was updated successfully, but these errors were encountered: