How to get all extrinsics executed in a block with subxt?
My question is identical to With subxt how can I subscribe to watch extrinsics?
There's some great examples of how to use subxt to listen to all events.
Polkadot-js events screen seem to show events grouped by the extrinsic that created them. Can I do the same in rust?
but the accepted answer 3 leaves me hanging at
- Map the extracted index to the extrinsic, as found in the block
Where do I find this list of extrinsics in the block? Should I fetch the full block with a new rpc call like this?
let mut blocks: Subscription<Header<u32, BlakeTwo256>> =
api.client.rpc().subscribe_blocks().await?;
while let Some(Ok(block)) = blocks.next().await {
println!(
"block number: {:?} hash:{:?} parent:{:?} state root:{:?} extrinsics root:{:?}",
block.number,
block.hash(),
block.parent_hash,
block.state_root,
block.extrinsics_root
);
if let Ok(Some(fullblock)) = api.client.rpc().block(Some(block.hash())).await
{
// block.
for extr in fullblock.block.extrinsics {
println!("Hello Extrinsics {:?}",extr);
}
}
}
if so what should I decode extr:OpaqueExtrinsic
with the value 0401000ba5620d6d8201
in to a type and encoded hash 0x8d5c44aba83278ee050e7595ba1e31ae9c0cc44ab4e02d0b55f83f07809556f3
?