Remove unneeded Config bounds and BlockNumber associated type (#804)

* remove unneeded Config bounds and BlockNumber associated type

* clippy and fmt
This commit is contained in:
James Wilson
2023-01-27 14:01:47 +00:00
committed by GitHub
parent 171bd62bb2
commit ce0a82e322
27 changed files with 72 additions and 112 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Submit the transaction with default params:
let hash = api.tx().sign_and_submit_default(&tx, &signer).await?;
println!("Balance transfer extrinsic submitted: {}", hash);
println!("Balance transfer extrinsic submitted: {hash}");
Ok(())
}
@@ -50,7 +50,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// submit the transaction:
let hash = api.tx().sign_and_submit(&tx, &signer, tx_params).await?;
println!("Balance transfer extrinsic submitted: {}", hash);
println!("Balance transfer extrinsic submitted: {hash}");
Ok(())
}
+1 -2
View File
@@ -30,7 +30,6 @@ impl Config for MyConfig {
// polkadot runtime used, so some operations will fail. Normally when using a custom `Config`
// impl types MUST match exactly those used in the actual runtime.
type Index = u64;
type BlockNumber = <SubstrateConfig as Config>::BlockNumber;
type Hash = <SubstrateConfig as Config>::Hash;
type Hasher = <SubstrateConfig as Config>::Hasher;
type Header = <SubstrateConfig as Config>::Header;
@@ -58,7 +57,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// submit the transaction with default params:
let hash = api.tx().sign_and_submit_default(&tx, &signer).await?;
println!("Balance transfer extrinsic submitted: {}", hash);
println!("Balance transfer extrinsic submitted: {hash}");
Ok(())
}
+2 -2
View File
@@ -46,13 +46,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// submit the transaction with default params:
let hash = api.tx().sign_and_submit_default(&tx, &signer).await?;
println!("Balance transfer extrinsic submitted: {}", hash);
println!("Balance transfer extrinsic submitted: {hash}");
// 2. Dynamic constant access (the dynamic equivalent to the fetch_constants example).
let constant_address = subxt::dynamic::constant("Balances", "ExistentialDeposit");
let existential_deposit = api.constants().at(&constant_address)?.to_value()?;
println!("Existential Deposit: {}", existential_deposit);
println!("Existential Deposit: {existential_deposit}");
// 3. Dynamic storage access
+1 -1
View File
@@ -32,7 +32,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Look it up:
let existential_deposit = api.constants().at(&address)?;
println!("Existential Deposit: {}", existential_deposit);
println!("Existential Deposit: {existential_deposit}");
Ok(())
}
+4 -4
View File
@@ -45,14 +45,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
);
let alice_id = AccountKeyring::Alice.to_account_id();
println!(" Alice account id: {:?}", alice_id);
println!(" Alice account id: {alice_id:?}");
// Get Alice' Stash account ID
let alice_stash_id: AccountId32 = sr25519::Pair::from_string("//Alice//stash", None)
.expect("Could not obtain stash signer pair")
.public()
.into();
println!(" Alice//stash account id: {:?}", alice_stash_id);
println!(" Alice//stash account id: {alice_stash_id:?}");
// Map from all locked "stash" accounts to the controller account.
let controller_acc_addr = polkadot::storage().staking().bonded(&alice_stash_id);
@@ -63,7 +63,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.fetch(&controller_acc_addr)
.await?
.unwrap();
println!(" account controlled by: {:?}", controller_acc);
println!(" account controlled by: {controller_acc:?}");
let era_reward_addr = polkadot::storage().staking().eras_reward_points(era.index);
let era_result = api
@@ -72,7 +72,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.await?
.fetch(&era_reward_addr)
.await?;
println!("Era reward points: {:?}", era_result);
println!("Era reward points: {era_result:?}");
Ok(())
}
+3 -3
View File
@@ -40,7 +40,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("\nExample 1. Obtained keys:");
while let Some((key, value)) = iter.next().await? {
println!("Key: 0x{}", hex::encode(key));
println!(" Value: {}", value);
println!(" Value: {value}");
}
}
@@ -69,7 +69,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// - polkadot.rs generated file under `version_notifiers()` fn
// - metadata in json format
let value = u64::decode(&mut &*storage_data)?;
println!(" Value: {}", value);
println!(" Value: {value}");
}
}
}
@@ -109,7 +109,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// - polkadot.rs generated file under `version_notifiers()` fn
// - metadata in json format
let value = u64::decode(&mut &storage_data[..])?;
println!(" Value: {}", value);
println!(" Value: {value}");
}
}
}
+1 -1
View File
@@ -169,7 +169,7 @@ async fn handle_transfer_events() -> Result<(), Box<dyn std::error::Error>> {
}
// Report other statuses we see.
else {
println!("Current transaction status: {:?}", ev);
println!("Current transaction status: {ev:?}");
}
}
@@ -28,7 +28,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let update_client = api.updater();
tokio::spawn(async move {
let result = update_client.perform_runtime_updates().await;
println!("Runtime update failed with result={:?}", result);
println!("Runtime update failed with result={result:?}");
});
// If this client is kept in use a while, it'll update its metadata and such