XXX/Dynamic: Add dynamic Runtime API calls

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2023-02-14 19:30:11 +02:00
parent c131c48124
commit 16944ea1fc
4 changed files with 179 additions and 5 deletions
+10 -1
View File
@@ -20,6 +20,8 @@ use subxt::{
},
SubstrateConfig,
},
dynamic::Value,
runtime_api::dynamic,
tx::PairSigner,
OnlineClient,
};
@@ -49,10 +51,17 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
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 alice = AccountKeyring::Alice.to_account_id();
let api_tx = dynamic::<polkadot::runtime_api::AccountNonceApi::account_nonce_target>(
"AccountNonceApi_account_nonce",
vec![Value::from_bytes(&alice)],
);
let bytes = api.runtime_api().at(None).await?.dyn_call(api_tx).await?;
println!("Result: {:?}", bytes);
// Send from Alice to Bob.
let signer = PairSigner::new(AccountKeyring::Alice.pair());
let dest = AccountKeyring::Bob.to_account_id().into();