mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-07 04:58:01 +00:00
XXX: Check nonce value
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
@@ -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<dyn std::error::Error>> {
|
||||
tracing_subscriber::fmt::init();
|
||||
let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
let api = OnlineClient::<SubstrateConfig>::new().await?;
|
||||
|
||||
let api_tx = polkadot::runtime_api::Core::version();
|
||||
println!("RuntimeApi payload: {:?}", api_tx);
|
||||
@@ -74,5 +74,33 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user