fix clippy (#715)

* fix clippy

* remove used id in codegen

* fix clippy again
This commit is contained in:
Niklas Adolfsson
2022-11-11 12:03:23 +01:00
committed by GitHub
parent 33a9ec91af
commit 9235d5041c
10 changed files with 18 additions and 20 deletions
+2 -4
View File
@@ -92,14 +92,13 @@ impl<'a> TypeGenerator<'a> {
let mut root_mod =
Module::new(self.types_mod_ident.clone(), self.types_mod_ident.clone());
for (id, ty) in self.type_registry.types().iter().enumerate() {
for ty in self.type_registry.types().iter() {
if ty.ty().path().namespace().is_empty() {
// prelude types e.g. Option/Result have no namespace, so we don't generate them
continue
}
self.insert_type(
ty.ty().clone(),
id as u32,
ty.ty().path().namespace().to_vec(),
&self.types_mod_ident,
&mut root_mod,
@@ -112,7 +111,6 @@ impl<'a> TypeGenerator<'a> {
fn insert_type(
&'a self,
ty: Type<PortableForm>,
id: u32,
path: Vec<String>,
root_mod_ident: &Ident,
module: &mut Module,
@@ -136,7 +134,7 @@ impl<'a> TypeGenerator<'a> {
TypeDefGen::from_type(ty, self, &self.crate_path),
);
} else {
self.insert_type(ty, id, path[1..].to_vec(), root_mod_ident, child_mod)
self.insert_type(ty, path[1..].to_vec(), root_mod_ident, child_mod)
}
}
+1 -1
View File
@@ -59,7 +59,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.unwrap();
println!(" account controlled by: {:?}", controller_acc);
let era_reward_addr = polkadot::storage().staking().eras_reward_points(&era.index);
let era_reward_addr = polkadot::storage().staking().eras_reward_points(era.index);
let era_result = api.storage().fetch(&era_reward_addr, None).await?;
println!("Era reward points: {:?}", era_result);
+3 -3
View File
@@ -57,7 +57,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Example 2. Obtained keys:");
for key in keys.iter() {
println!("Key: 0x{}", hex::encode(&key));
println!("Key: 0x{}", hex::encode(key));
if let Some(storage_data) = api.storage().fetch_raw(&key.0, None).await? {
// We know the return value to be `QueryId` (`u64`) from inspecting either:
@@ -80,7 +80,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// We know that the first key is a u32 (the `XcmVersion`) and is hashed by twox64_concat.
// We can build a `StorageMapKey` that replicates that, and append those bytes to the above.
StorageMapKey::new(&2u32, StorageHasher::Twox64Concat).to_bytes(&mut query_key);
StorageMapKey::new(2u32, StorageHasher::Twox64Concat).to_bytes(&mut query_key);
// The final query key is essentially the result of:
// `twox_128("XcmPallet") ++ twox_128("VersionNotifiers") ++ twox_64(2u32) ++ 2u32`
@@ -90,7 +90,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Obtained keys:");
for key in keys.iter() {
println!("Key: 0x{}", hex::encode(&key));
println!("Key: 0x{}", hex::encode(key));
if let Some(storage_data) = api.storage().fetch_raw(&key.0, None).await? {
// We know the return value to be `QueryId` (`u64`) from inspecting either:
+1 -1
View File
@@ -51,7 +51,7 @@ impl DecodeWithMetadata for DecodedValueThunk {
metadata: &Metadata,
) -> Result<Self::Target, Error> {
let mut v = Vec::with_capacity(bytes.len());
v.extend_from_slice(*bytes);
v.extend_from_slice(bytes);
*bytes = &[];
Ok(DecodedValueThunk {
type_id,
+1 -1
View File
@@ -68,7 +68,7 @@ where
let event_bytes = client
.rpc()
.storage(&*system_events_key().0, Some(block_hash))
.storage(&system_events_key().0, Some(block_hash))
.await?
.map(|e| e.0)
.unwrap_or_else(Vec::new);
+2 -2
View File
@@ -18,8 +18,8 @@ pub fn write_storage_address_root_bytes<Address: StorageAddress>(
addr: &Address,
out: &mut Vec<u8>,
) {
out.extend(&sp_core::twox_128(addr.pallet_name().as_bytes()));
out.extend(&sp_core::twox_128(addr.entry_name().as_bytes()));
out.extend(sp_core::twox_128(addr.pallet_name().as_bytes()));
out.extend(sp_core::twox_128(addr.entry_name().as_bytes()));
}
/// Outputs the [`storage_address_root_bytes`] as well as any additional bytes that represent
+1 -1
View File
@@ -138,7 +138,7 @@ impl<'a> TxPayload for DynamicTxPayload<'a> {
let pallet = metadata.pallet(&self.pallet_name)?;
let call_id = pallet.call_ty_id().ok_or(MetadataError::CallNotFound)?;
let call_value =
Value::unnamed_variant(self.call_name.to_owned(), self.fields.clone());
Value::unnamed_variant(self.call_name.clone(), self.fields.clone());
pallet.index().encode_to(out);
scale_value::scale::encode_as_type(&call_value, call_id, metadata.types(), out)?;
@@ -101,12 +101,12 @@ async fn tx_dynamic_transfer() -> Result<(), subxt::Error> {
let alice_account_addr = subxt::dynamic::storage(
"System",
"Account",
vec![Value::from_bytes(&alice.account_id())],
vec![Value::from_bytes(alice.account_id())],
);
let bob_account_addr = subxt::dynamic::storage(
"System",
"Account",
vec![Value::from_bytes(&bob.account_id())],
vec![Value::from_bytes(bob.account_id())],
);
let alice_pre = api
@@ -122,7 +122,7 @@ async fn tx_dynamic_transfer() -> Result<(), subxt::Error> {
"Balances",
"transfer",
vec![
Value::unnamed_variant("Id", vec![Value::from_bytes(&bob.account_id())]),
Value::unnamed_variant("Id", vec![Value::from_bytes(bob.account_id())]),
Value::u128(10_000u128),
],
);
@@ -145,11 +145,11 @@ async fn tx_dynamic_transfer() -> Result<(), subxt::Error> {
let expected_fields = Composite::Named(vec![
(
"from".into(),
Value::unnamed_composite(vec![Value::from_bytes(&alice.account_id())]),
Value::unnamed_composite(vec![Value::from_bytes(alice.account_id())]),
),
(
"to".into(),
Value::unnamed_composite(vec![Value::from_bytes(&bob.account_id())]),
Value::unnamed_composite(vec![Value::from_bytes(bob.account_id())]),
),
("amount".into(), Value::u128(10_000)),
]);
@@ -242,7 +242,7 @@ async fn storage_current_era() -> Result<(), Error> {
async fn storage_era_reward_points() -> Result<(), Error> {
let ctx = test_context().await;
let api = ctx.client();
let reward_points_addr = node_runtime::storage().staking().eras_reward_points(&0);
let reward_points_addr = node_runtime::storage().staking().eras_reward_points(0);
let current_era_result = api.storage().fetch(&reward_points_addr, None).await;
assert!(current_era_result.is_ok());
+1 -1
View File
@@ -72,7 +72,7 @@ async fn storage_n_mapish_key_is_properly_created() -> Result<(), subxt::Error>
bytes.extend(&sp_core::twox_128("KeyOwner".as_bytes())[..]);
// twox64_concat a *tuple* of the args expected:
let suffix = (KeyTypeId([1, 2, 3, 4]), vec![5u8, 6, 7, 8]).encode();
bytes.extend(&sp_core::twox_64(&suffix));
bytes.extend(sp_core::twox_64(&suffix));
bytes.extend(&suffix);
bytes
};