From 90bf22a1fb4fa6df576ee6515e28511a98d6a159 Mon Sep 17 00:00:00 2001 From: Alexandru Vasile Date: Tue, 7 Feb 2023 19:37:09 +0200 Subject: [PATCH] XXX: Check nonce value Signed-off-by: Alexandru Vasile --- examples/examples/runtime_calls.rs | 32 ++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/examples/examples/runtime_calls.rs b/examples/examples/runtime_calls.rs index 0ed9f93be0..9dc470d9e8 100644 --- a/examples/examples/runtime_calls.rs +++ b/examples/examples/runtime_calls.rs @@ -18,7 +18,7 @@ use subxt::{ PlainTip, PolkadotExtrinsicParamsBuilder as Params, }, - PolkadotConfig, + SubstrateConfig, }, tx::PairSigner, OnlineClient, @@ -32,7 +32,7 @@ pub mod polkadot {} #[tokio::main] async fn main() -> Result<(), Box> { tracing_subscriber::fmt::init(); - let api = OnlineClient::::new().await?; + let api = OnlineClient::::new().await?; let api_tx = polkadot::runtime_api::Core::version(); println!("RuntimeApi payload: {:?}", api_tx); @@ -74,5 +74,33 @@ async fn main() -> Result<(), Box> { result ); + // Send from Alice to Bob. + let signer = PairSigner::new(AccountKeyring::Alice.pair()); + let dest = AccountKeyring::Bob.to_account_id().into(); + let tx = polkadot::tx() + .balances() + .transfer(dest, 123_456_789_012_345); + let _hash = api + .tx() + .sign_and_submit_then_watch_default(&tx, &signer) + .await? + .wait_for_finalized() + .await?; + + // Check nonce again. + let alice = AccountKeyring::Alice.to_account_id().into(); + let api_tx = polkadot::runtime_api::AccountNonceApi::account_nonce(alice); + println!("RuntimeApi payload: {:?}", api_tx); + + let bytes = api.runtime_api().at(None).await?.call(api_tx).await?; + println!("Result: {:?}", bytes); + + let result: polkadot::runtime_api::AccountNonceApi::account_nonce_target = + Decode::decode(&mut &bytes[..])?; + println!( + "Result for polkadot::runtime_api::AccountNonceApi::account_nonce: {:?}\n\n", + result + ); + Ok(()) }