mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 16:51:02 +00:00
Simplify paths to extrinsic and storage types needed for .find
This commit is contained in:
@@ -29,7 +29,7 @@ async fn main() -> Result<(), Error> {
|
||||
// same interface as `api.block(block.hash()).await`.
|
||||
let at_block = block.at().await?;
|
||||
|
||||
// Here we'll obtain and display the extrinsics:
|
||||
// Here we'll iterate over the extrinsics and display information about each one:
|
||||
let extrinsics = at_block.extrinsics().fetch().await?;
|
||||
for ext in extrinsics.iter() {
|
||||
let ext = ext?;
|
||||
@@ -40,7 +40,9 @@ async fn main() -> Result<(), Error> {
|
||||
let bytes_hex = format!("0x{}", hex::encode(ext.bytes()));
|
||||
let events = ext.events().await?;
|
||||
|
||||
// See the API docs for more ways to decode extrinsics:
|
||||
// See the API docs for more ways to decode extrinsics. Here we decode into
|
||||
// a statically generated type, but any type implementing scale_decode::DecodeAsType
|
||||
// can be used here, for instance subxt::dynamic::Value.
|
||||
let decoded_ext = ext.decode_call_data_as::<polkadot::Call>()?;
|
||||
|
||||
println!(" #{idx}: {pallet_name}.{call_name}:");
|
||||
@@ -68,6 +70,16 @@ async fn main() -> Result<(), Error> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Instead of iterating, we can also use the static interface to search & decode specific
|
||||
// extrinsics if we know what we are looking for:
|
||||
if let Some(ext) = extrinsics.find_first::<polkadot::para_inherent::calls::Enter>() {
|
||||
let ext = ext?;
|
||||
|
||||
println!("ParaInherent.Enter");
|
||||
println!(" backed_candidated: {:?}", ext.data.backed_candidates);
|
||||
println!(" disputes: {:?}", ext.data.disputes);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user