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
The Extrinsics<T: Config, C: Client> struct exposes a lot of functionalities that come in handy to learn more about an extrinsic. But it lacks a statically decoded representation of a specific Extrinsic type. Right now, you do not have a nice way of e.g. finding all TransferKeepAlive extrinsics in a block together with their events and signed extensions.
Status Quo
If you have the Extrinsics of a block, you can find StaticExtrinsics with extrinsics.find<E: StaticExtrinsic>() returning an iterator over elements of the type E. But by doing this, you lose the access to the information stored in the (untyped) ExtrinsicDetails: signed extensions and events.
To get e.g. all TransferKeepAlive extrinsics in a block with their events and signed extensions, you would have to iterate over all extrinsics and then return a tuple for all the ones that are a TransferKeepAlive. This tuple would have the statically decoded transfer + the untyped ExtrinsicDetails:
extrinsics.iter().filter_map(|e| {
if e.is_err(){
return None;
}
let e = e.unwrap();
match e.as_extrinsic::<TransferKeepAlive>(){
Err(e) => None,
Ok(transfer) => Some((transfer, e)) // the tuple contains all the information we need
}
})
This is a bit cumbersome and could lead people to not use the utility functions like Extrinsics::find<E: StaticExtrinsic>();
Proposal
We could introduce a new type StaticExtrinsicDetails and use it as a return value whenever we try to find/decode static extrinsics.
We could introduce a new type StaticExtrinsicDetails and use it as a return value whenever we try to find/decode static extrinsics.
That would be my preference: have find, find_first and find_last all return a simple struct with two public fields: the decoded extrinsic itself and the extrinsic details in case you want to do more! I'd probably have it look something like:
Problem
The
Extrinsics<T: Config, C: Client>
struct exposes a lot of functionalities that come in handy to learn more about an extrinsic. But it lacks a statically decoded representation of a specific Extrinsic type. Right now, you do not have a nice way of e.g. finding allTransferKeepAlive
extrinsics in a block together with their events and signed extensions.Status Quo
If you have the
Extrinsics
of a block, you can find StaticExtrinsics withextrinsics.find<E: StaticExtrinsic>()
returning an iterator over elements of the type E. But by doing this, you lose the access to the information stored in the (untyped) ExtrinsicDetails: signed extensions and events.To get e.g. all
TransferKeepAlive
extrinsics in a block with their events and signed extensions, you would have to iterate over all extrinsics and then return a tuple for all the ones that are aTransferKeepAlive
. This tuple would have the statically decoded transfer + the untyped ExtrinsicDetails:This is a bit cumbersome and could lead people to not use the utility functions like
Extrinsics::find<E: StaticExtrinsic>()
;Proposal
We could introduce a new type
StaticExtrinsicDetails
and use it as a return value whenever we try to find/decode static extrinsics.Alternative:
We could also just extend
ExtrinsicDetails
by another type parameter that is()
by default:Then we could do:
The text was updated successfully, but these errors were encountered: