mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 14:17:56 +00:00
blocks: Fetch chainHead call result
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
@@ -10,13 +10,14 @@
|
||||
//! polkadot --dev --tmp
|
||||
//! ```
|
||||
|
||||
use codec::Encode;
|
||||
use futures::StreamExt;
|
||||
use sp_keyring::AccountKeyring;
|
||||
use subxt::{
|
||||
OnlineClient,
|
||||
PolkadotConfig,
|
||||
};
|
||||
|
||||
use futures::StreamExt;
|
||||
|
||||
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
|
||||
pub mod polkadot {}
|
||||
|
||||
@@ -27,7 +28,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Create a client to use:
|
||||
let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
|
||||
let mut follow_sub = api.blocks().subscribe_chainhead_finalized(false).await?;
|
||||
let mut follow_sub = api.blocks().subscribe_chainhead_finalized(true).await?;
|
||||
// Handle all subscriptions from the `chainHead_follow`.
|
||||
while let Some(block) = follow_sub.next().await {
|
||||
let block = block?;
|
||||
@@ -46,6 +47,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
era.index,
|
||||
era.start
|
||||
);
|
||||
|
||||
let call_params = AccountKeyring::Alice.to_account_id().encode();
|
||||
let call = block
|
||||
.call("AccountNonceApi_account_nonce".into(), &call_params)
|
||||
.await?;
|
||||
println!("[hash={:?}] call={:?}", block.hash(), call);
|
||||
}
|
||||
|
||||
// Subscribe to the `chainHead_follow` method.
|
||||
|
||||
Reference in New Issue
Block a user