examples: Remove prior light client example

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2023-05-25 14:01:43 +03:00
parent 1ba4b8205d
commit e470006fac
@@ -1,38 +0,0 @@
use sp_keyring::AccountKeyring;
use subxt::rpc::LightClient;
use subxt::{tx::PairSigner, OnlineClient, PolkadotConfig};
use std::sync::Arc;
// Generate an interface that we can use from the node's metadata.
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
pub mod polkadot {}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a light client from the provided chain spec.
let light_client = LightClient::new(include_str!("../../artifacts/dev_spec.json"))?;
let api = OnlineClient::<PolkadotConfig>::from_rpc_client(Arc::new(light_client)).await?;
// Build a balance transfer extrinsic.
let dest = AccountKeyring::Bob.to_account_id().into();
let balance_transfer_tx = polkadot::tx().balances().transfer(dest, 10_000);
// Submit the balance transfer extrinsic from Alice, and wait for it to be successful
// and in a finalized block. We get back the extrinsic events if all is well.
let from = PairSigner::new(AccountKeyring::Alice.pair());
let events = api
.tx()
.sign_and_submit_then_watch_default(&balance_transfer_tx, &from)
.await?
.wait_for_finalized_success()
.await?;
// Find a Transfer event and print it.
let transfer_event = events.find_first::<polkadot::balances::events::Transfer>()?;
if let Some(event) = transfer_event {
println!("Balance transfer success: {event:?}");
}
Ok(())
}