mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 20:47:56 +00:00
XXX: Extend example: runtime_calls
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
@@ -32,18 +32,47 @@ 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_tx = polkadot::runtime_api::Core::version();
|
||||
println!("RuntimeApi payload: {:?}", api_tx);
|
||||
|
||||
let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
let bytes = api.runtime_api().at(None).await?.call(api_tx).await?;
|
||||
|
||||
println!("Result: {:?}", bytes);
|
||||
|
||||
let result: polkadot::runtime_api::Core::version_target =
|
||||
Decode::decode(&mut &bytes[..])?;
|
||||
println!(
|
||||
"Result for polkadot::runtime_api::Core::version(): {:?}\n\n",
|
||||
result
|
||||
);
|
||||
|
||||
println!("Result is: {:?}", result);
|
||||
let api_tx = polkadot::runtime_api::Metadata::metadata_versions();
|
||||
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::Metadata::metadata_versions_target =
|
||||
Decode::decode(&mut &bytes[..])?;
|
||||
println!(
|
||||
"Result for polkadot::runtime_api::Metadata::metadata_versions(): {:?}\n\n",
|
||||
result
|
||||
);
|
||||
|
||||
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