From 6bcba673acbab62b52c07adeb079fe516124c243 Mon Sep 17 00:00:00 2001 From: James Wilson Date: Tue, 31 Oct 2023 12:29:58 +0000 Subject: [PATCH] clippy and fmt --- bin/tx-decoder/src/app.rs | 11 +++++------ desub-current/src/decoder/decode_storage.rs | 2 +- desub-current/src/decoder/mod.rs | 10 +++++----- desub-current/src/metadata/mod.rs | 2 +- desub-current/src/metadata/version_14.rs | 5 ++--- desub-current/tests/decode_extrinsics.rs | 15 ++++++-------- desub-current/tests/decode_storage.rs | 6 +++--- desub-json-resolver/src/extrinsics.rs | 2 +- desub-json-resolver/src/modules.rs | 6 +++--- desub-legacy/src/decoder.rs | 4 ++-- desub-legacy/src/decoder/extrinsics.rs | 2 +- desub-legacy/src/decoder/metadata.rs | 4 ++-- desub-legacy/src/decoder/storage.rs | 2 +- desub-legacy/src/regex.rs | 22 ++++++++++----------- desub-legacy/src/substrate_types.rs | 15 ++++---------- desub-legacy/src/substrate_types/data.rs | 2 +- desub-legacy/src/test_suite.rs | 2 +- desub-legacy/src/util.rs | 2 +- desub/src/lib.rs | 4 ++-- integration-tests/tests/storage.rs | 2 +- 20 files changed, 54 insertions(+), 66 deletions(-) diff --git a/bin/tx-decoder/src/app.rs b/bin/tx-decoder/src/app.rs index 1036fce5..efa228cb 100644 --- a/bin/tx-decoder/src/app.rs +++ b/bin/tx-decoder/src/app.rs @@ -105,13 +105,13 @@ impl<'a> AppState<'a> { let upgrade_block = get_upgrade_block(&self.app.network, version.try_into()?); let mut len = 0; let mut error_count = 0; - let decoder = self.decoder.read(); while let Some(Ok(block)) = blocks.next().await { let version = if upgrade_block == Some(block.block_num.try_into()?) && upgrade_block != Some(0) { previous.expect("Upgrade block must have previous version; qed") } else { version }; + let decoder = self.decoder.read(); if Self::decode(&decoder, block, version.try_into()?, errors).is_err() { error_count += 1; } @@ -142,16 +142,15 @@ impl<'a> AppState<'a> { /// returns the previous spec version. async fn register_metadata(&self, conn: &mut PgConnection, version: SpecVersion) -> Result, Error> { let (past, present) = past_and_present_version(conn, version.try_into()?).await?; - let mut decoder = self.decoder.write(); - if !decoder.has_version(&present) { + if !self.decoder.read().has_version(&present) { let meta = metadata(conn, present.try_into()?).await?; - decoder.register_version(present, &meta)?; + self.decoder.write().register_version(present, &meta)?; } if let Some(p) = past { - if !decoder.has_version(&p) { + if !self.decoder.read().has_version(&p) { let meta = metadata(conn, p.try_into()?).await?; - decoder.register_version(p, &meta)?; + self.decoder.write().register_version(p, &meta)?; } } Ok(past) diff --git a/desub-current/src/decoder/decode_storage.rs b/desub-current/src/decoder/decode_storage.rs index 973c35da..f3f5ada4 100644 --- a/desub-current/src/decoder/decode_storage.rs +++ b/desub-current/src/decoder/decode_storage.rs @@ -268,7 +268,7 @@ pub struct StorageMapKey<'b> { pub hasher: StorageHasher, } -impl<'m, 'b> StorageMapKey<'b> { +impl<'b> StorageMapKey<'b> { pub fn into_owned(self) -> StorageMapKey<'static> { StorageMapKey { bytes: Cow::Owned(self.bytes.into_owned()), ty: self.ty, hasher: self.hasher } } diff --git a/desub-current/src/decoder/mod.rs b/desub-current/src/decoder/mod.rs index d3131784..43efafb1 100644 --- a/desub-current/src/decoder/mod.rs +++ b/desub-current/src/decoder/mod.rs @@ -27,10 +27,10 @@ mod extrinsic_bytes; use crate::metadata::Metadata; use crate::TypeId; +use extrinsic_bytes::{AllExtrinsicBytes, ExtrinsicBytesError}; +use parity_scale_codec::{Compact, Decode}; use scale_decode::DecodeAsType; use scale_value::Value; -use parity_scale_codec::{Compact, Decode}; -use extrinsic_bytes::{AllExtrinsicBytes, ExtrinsicBytesError}; use serde::Serialize; use sp_runtime::{AccountId32, MultiAddress, MultiSignature}; use std::borrow::Cow; @@ -67,8 +67,8 @@ pub enum DecodeError { /// Decode a single [`Value`] from a piece of scale encoded data, given some metadata and the ID of the type that we /// are expecting it to decode into. -pub fn decode_value_by_id<'a, Id: Into>( - metadata: &'a Metadata, +pub fn decode_value_by_id>( + metadata: &Metadata, ty: Id, data: &mut &[u8], ) -> Result, DecodeValueError> { @@ -158,7 +158,7 @@ pub fn decode_extrinsics<'a>( metadata: &'a Metadata, data: &mut &[u8], ) -> Result>, (Vec>, DecodeError)> { - let extrinsic_bytes = AllExtrinsicBytes::new(*data).map_err(|e| (Vec::new(), e.into()))?; + let extrinsic_bytes = AllExtrinsicBytes::new(data).map_err(|e| (Vec::new(), e.into()))?; log::trace!("Decoding {} Total Extrinsics.", extrinsic_bytes.len()); diff --git a/desub-current/src/metadata/mod.rs b/desub-current/src/metadata/mod.rs index c923b56a..85756235 100644 --- a/desub-current/src/metadata/mod.rs +++ b/desub-current/src/metadata/mod.rs @@ -22,8 +22,8 @@ mod u8_map; mod version_14; use crate::{ScaleInfoTypeId, Type, TypeId}; -use parity_scale_codec::Decode; use frame_metadata::{RuntimeMetadata, RuntimeMetadataPrefixed}; +use parity_scale_codec::Decode; use readonly_array::ReadonlyArray; use scale_info::{form::PortableForm, PortableRegistry}; use u8_map::U8Map; diff --git a/desub-current/src/metadata/version_14.rs b/desub-current/src/metadata/version_14.rs index a326eb65..56e0e57f 100644 --- a/desub-current/src/metadata/version_14.rs +++ b/desub-current/src/metadata/version_14.rs @@ -36,9 +36,8 @@ pub fn decode(meta: RuntimeMetadataV14) -> Result { .map(|call_md| { // Get the type representing the variant of available calls: let calls_type_id = call_md.ty; - let calls_type = registry - .resolve(calls_type_id.id) - .ok_or_else(|| MetadataError::TypeNotFound(calls_type_id.id))?; + let calls_type = + registry.resolve(calls_type_id.id).ok_or_else(|| MetadataError::TypeNotFound(calls_type_id.id))?; // Expect that type to be a variant: let calls_type_def = &calls_type.type_def; diff --git a/desub-current/tests/decode_extrinsics.rs b/desub-current/tests/decode_extrinsics.rs index 26a3511d..d2c42749 100644 --- a/desub-current/tests/decode_extrinsics.rs +++ b/desub-current/tests/decode_extrinsics.rs @@ -16,7 +16,7 @@ use desub_current::{ decoder::{self, SignedExtensionWithAdditional}, - Metadata, Value, ValueDef + Metadata, Value, ValueDef, }; use scale_value::{Composite, Variant}; @@ -40,11 +40,11 @@ fn singleton_value(x: Value<()>) -> Value<()> { } fn hash_value(xs: Vec) -> Value<()> { - singleton_value(Value::from_bytes(&xs)) + singleton_value(Value::from_bytes(xs)) } fn assert_args_equal(args: &[Value], expected: Vec>) { - let args: Vec<_> = args.into_iter().map(|v| v.clone().remove_context()).collect(); + let args: Vec<_> = args.iter().map(|v| v.clone().remove_context()).collect(); assert_eq!(&args, &expected); } @@ -182,8 +182,8 @@ fn technical_committee_execute_unsigned() { name, values: Composite::Unnamed(args) }), .. } - if &*name == "Balances" - && matches!(&args[0], Value { value: ValueDef::Variant(Variant { name, ..}), .. } if &*name == "transfer") + if name == "Balances" + && matches!(&args[0], Value { value: ValueDef::Variant(Variant { name, ..}), .. } if name == "transfer") )); assert_eq!(ext.call_data.arguments[1].clone().remove_context(), Value::u128(500)); } @@ -201,10 +201,7 @@ fn tips_report_awesome_unsigned() { assert_eq!(&*ext.call_data.ty.name, "report_awesome"); assert_eq!(ext.call_data.arguments.len(), 2); - assert_eq!( - ext.call_data.arguments[0].clone().remove_context(), - Value::from_bytes("This person rocks!") - ); + assert_eq!(ext.call_data.arguments[0].clone().remove_context(), Value::from_bytes("This person rocks!")); } // Named structs shouldn't be an issue; this extrinsic contains one. diff --git a/desub-current/tests/decode_storage.rs b/desub-current/tests/decode_storage.rs index 110968da..004199f3 100644 --- a/desub-current/tests/decode_storage.rs +++ b/desub-current/tests/decode_storage.rs @@ -14,11 +14,11 @@ // You should have received a copy of the GNU General Public License // along with substrate-desub. If not, see . -use parity_scale_codec::Encode; use desub_current::{ decoder::{self, StorageHasher}, Metadata, Value, }; +use parity_scale_codec::Encode; static V14_METADATA_POLKADOT_SCALE: &[u8] = include_bytes!("data/v14_metadata_polkadot.scale"); @@ -141,7 +141,7 @@ fn balances_account() { let keys = entry.details.map_keys(); let bobs_accountid = sp_keyring::AccountKeyring::Bob.to_account_id(); - let bobs_value = account_id_to_value(&bobs_accountid); + let bobs_value = account_id_to_value(bobs_accountid); assert_eq!(keys.len(), 1); assert_hasher_eq!(keys[0].hasher, StorageHasher::Blake2_128Concat, bobs_value); @@ -164,7 +164,7 @@ fn imonline_authoredblocks() { let keys = entry.details.map_keys(); let bobs_accountid = sp_keyring::AccountKeyring::Bob.to_account_id(); - let bobs_value = account_id_to_value(&bobs_accountid); + let bobs_value = account_id_to_value(bobs_accountid); // Because the hashers are Twox64Concat, we can check the keys we provided: assert_eq!(keys.len(), 2); diff --git a/desub-json-resolver/src/extrinsics.rs b/desub-json-resolver/src/extrinsics.rs index 68be46f9..6b1b4f20 100644 --- a/desub-json-resolver/src/extrinsics.rs +++ b/desub-json-resolver/src/extrinsics.rs @@ -33,7 +33,7 @@ impl Extrinsics { } pub fn get(&self, ty: &str, spec: u32, chain: &str) -> Option<&desub_legacy::RustTypeMarker> { - if let Some(ty) = self.get_chain_types(chain, spec).map(|c| c.get(ty)).flatten() { + if let Some(ty) = self.get_chain_types(chain, spec).and_then(|c| c.get(ty)) { Some(ty) } else { self.default.get(ty) diff --git a/desub-json-resolver/src/modules.rs b/desub-json-resolver/src/modules.rs index 000b11ff..5f4510bc 100644 --- a/desub-json-resolver/src/modules.rs +++ b/desub-json-resolver/src/modules.rs @@ -49,7 +49,7 @@ impl Modules { /// Iterate over all the types in each module pub fn iter_types(&self) -> impl Iterator { - self.modules.values().map(|v| v.types.iter()).flatten() + self.modules.values().flat_map(|v| v.types.iter()) } } @@ -75,8 +75,8 @@ impl ModuleTypes { pub fn merge(&self, other: &ModuleTypes) -> ModuleTypes { let (mut types, mut fallbacks) = (self.types.clone(), self.fallbacks.clone()); let other = other.clone(); - types.extend(other.types.into_iter()); - fallbacks.extend(other.fallbacks.into_iter()); + types.extend(other.types); + fallbacks.extend(other.fallbacks); ModuleTypes { types, fallbacks } } diff --git a/desub-legacy/src/decoder.rs b/desub-legacy/src/decoder.rs index 6615bf1f..a1d8c145 100644 --- a/desub-legacy/src/decoder.rs +++ b/desub-legacy/src/decoder.rs @@ -41,12 +41,12 @@ pub use frame_metadata::v14::StorageEntryType; use crate::{ error::Error, - substrate_types::{self, StructField, SubstrateType, pallet_democracy}, + substrate_types::{self, pallet_democracy, StructField, SubstrateType}, CommonTypes, RustTypeMarker, TypeDetective, }; use bitvec::order::Lsb0 as BitOrderLsb0; -use parity_scale_codec::{Compact, CompactLen, Decode, Input}; use desub_common::SpecVersion; +use parity_scale_codec::{Compact, CompactLen, Decode, Input}; use std::{ cell::RefCell, collections::HashMap, diff --git a/desub-legacy/src/decoder/extrinsics.rs b/desub-legacy/src/decoder/extrinsics.rs index 797ad955..f26c5eb5 100644 --- a/desub-legacy/src/decoder/extrinsics.rs +++ b/desub-legacy/src/decoder/extrinsics.rs @@ -62,7 +62,7 @@ impl fmt::Display for GenericExtrinsic { if let Some(v) = &self.signature { s.push_str(&format!("{}", v)); } else { - s.push_str(&"None".to_string()); + s.push_str("None"); } s.push('\n'); s.push_str("CALL"); diff --git a/desub-legacy/src/decoder/metadata.rs b/desub-legacy/src/decoder/metadata.rs index d23fcc2a..d50775e2 100644 --- a/desub-legacy/src/decoder/metadata.rs +++ b/desub-legacy/src/decoder/metadata.rs @@ -40,8 +40,8 @@ pub use frame_metadata::{decode_different::DecodeDifferent, RuntimeMetadata, Run use super::storage::{StorageInfo, StorageLookupTable}; use crate::RustTypeMarker; use parity_scale_codec::{Decode, Encode, EncodeAsRef, HasCompact}; -use sp_core::{storage::StorageKey, twox_128}; use serde::{Deserialize, Serialize}; +use sp_core::{storage::StorageKey, twox_128}; use std::{ collections::{HashMap, HashSet}, @@ -229,7 +229,7 @@ impl<'a> Metadata { } fn generate_key>(prefix: S) -> Vec { - prefix.as_ref().split_ascii_whitespace().map(|s| twox_128(s.as_bytes()).to_vec()).flatten().collect() + prefix.as_ref().split_ascii_whitespace().flat_map(|s| twox_128(s.as_bytes()).to_vec()).collect() } /// print out a detailed but human readable description of the module diff --git a/desub-legacy/src/decoder/storage.rs b/desub-legacy/src/decoder/storage.rs index 93c80494..279e3f61 100644 --- a/desub-legacy/src/decoder/storage.rs +++ b/desub-legacy/src/decoder/storage.rs @@ -54,7 +54,7 @@ impl StorageLookupTable { pub fn meta_for_key(&self, key: &[u8]) -> Option<&StorageInfo> { let key = self.table.keys().find(|&k| &key[..k.len()] == k.as_slice()); - key.map(|k| self.lookup(k)).flatten() + key.and_then(|k| self.lookup(k)) } pub fn extra_key_data<'a>(&self, key: &'a [u8]) -> Option<&'a [u8]> { diff --git a/desub-legacy/src/regex.rs b/desub-legacy/src/regex.rs index 895b17f8..476dd36a 100644 --- a/desub-legacy/src/regex.rs +++ b/desub-legacy/src/regex.rs @@ -186,7 +186,7 @@ pub fn remove_empty_generic>(s: S) -> Option { /// Sanitizes a type and returns parts that might correspond to PolkadotJS types pub fn sanitize_ty(ty: &str) -> Option { log::trace!("sanitizing ty {}", ty); - let ty = if let Some(no_empty_gen) = remove_empty_generic(&ty) { no_empty_gen } else { ty.to_string() }; + let ty = if let Some(no_empty_gen) = remove_empty_generic(ty) { no_empty_gen } else { ty.to_string() }; let ty = if let Some(no_trait) = remove_trait(&ty) { no_trait } else { ty }; let ty = if let Some(no_path) = remove_path(&ty) { no_path } else { ty }; let ty = if let Some(un_prefixed) = remove_prefix(&ty) { un_prefixed } else { ty }; @@ -206,16 +206,16 @@ pub fn sanitize_ty(ty: &str) -> Option { pub fn rust_tuple_decl() -> Regex { Regex::new( [ - r#"^\(([\w\d><:;\[\]()\n ]+)"#, - r#",? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*"#, - r#",? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*"#, - r#",? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*"#, - r#",? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*"#, - r#",? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*"#, - r#",? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*"#, - r#",? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*"#, - r#",? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*"#, - r#",? *([\w\d><:;\[\]()\n ]+)*\)$"#, + r"^\(([\w\d><:;\[\]()\n ]+)", + r",? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*", + r",? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*", + r",? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*", + r",? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*", + r",? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*", + r",? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*", + r",? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*", + r",? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*,? *([\w\d><:;\[\]()\n ]+)*", + r",? *([\w\d><:;\[\]()\n ]+)*\)$", ] .join("") .as_str(), diff --git a/desub-legacy/src/substrate_types.rs b/desub-legacy/src/substrate_types.rs index 210aede9..f5ed1396 100644 --- a/desub-legacy/src/substrate_types.rs +++ b/desub-legacy/src/substrate_types.rs @@ -25,9 +25,9 @@ mod remote; use self::remote::*; use crate::{Error, SetField}; use bitvec::order::Lsb0 as BitOrderLsb0; +use serde::Serialize; use sp_core::crypto::{AccountId32, Ss58Codec}; use sp_runtime::MultiAddress; -use serde::Serialize; use std::{convert::TryFrom, fmt}; pub use self::data::Data; @@ -37,8 +37,8 @@ pub type Address = MultiAddress; /// Stripped down version of https://docs.substrate.io/rustdocs/latest/pallet_democracy /// Remove when/if the real pallet_democracy is published. pub mod pallet_democracy { - use sp_runtime::RuntimeDebug; use parity_scale_codec::{Decode, Input}; + use sp_runtime::RuntimeDebug; /// Static copy of https://docs.substrate.io/rustdocs/latest/pallet_democracy/struct.Vote.html #[derive(Copy, Clone, Eq, PartialEq, Default, RuntimeDebug)] pub struct Vote { @@ -58,9 +58,10 @@ pub mod pallet_democracy { } /// Static copy of https://docs.substrate.io/rustdocs/latest/pallet_democracy/enum.Conviction.html - #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, RuntimeDebug)] + #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, RuntimeDebug, Default)] pub enum Conviction { /// 0.1x votes, unlocked. + #[default] None, /// 1x votes, locked for an enactment period following a successful vote. Locked1x, @@ -76,12 +77,6 @@ pub mod pallet_democracy { Locked6x, } - impl Default for Conviction { - fn default() -> Self { - Conviction::None - } - } - impl Conviction { /// The amount of time (in number of periods) that our conviction implies a successful voter's /// balance should be locked for. @@ -115,8 +110,6 @@ pub mod pallet_democracy { } } - - /// A 'stateful' version of [RustTypeMarker](enum.RustTypeMarker.html). /// 'Std' variant is not here like in RustTypeMarker. /// Instead common types are just apart of the enum diff --git a/desub-legacy/src/substrate_types/data.rs b/desub-legacy/src/substrate_types/data.rs index e736bcb6..e200d434 100644 --- a/desub-legacy/src/substrate_types/data.rs +++ b/desub-legacy/src/substrate_types/data.rs @@ -75,7 +75,7 @@ impl Encode for Data { Data::Raw(ref x) => { let l = x.len().min(32); let mut r = vec![l as u8 + 1; l + 1]; - r[1..].copy_from_slice(&x[..l as usize]); + r[1..].copy_from_slice(&x[..l]); r } Data::BlakeTwo256(ref h) => once(34u8).chain(h.iter().cloned()).collect(), diff --git a/desub-legacy/src/test_suite.rs b/desub-legacy/src/test_suite.rs index 04550dbd..23276364 100644 --- a/desub-legacy/src/test_suite.rs +++ b/desub-legacy/src/test_suite.rs @@ -26,6 +26,6 @@ pub fn mock_runtime(num: u32) -> RuntimeVersion { impl_version: num, apis: Cow::from(Vec::new()), transaction_version: 24, - state_version: 0 + state_version: 0, } } diff --git a/desub-legacy/src/util.rs b/desub-legacy/src/util.rs index efe2f5d7..1d6f2477 100644 --- a/desub-legacy/src/util.rs +++ b/desub-legacy/src/util.rs @@ -14,11 +14,11 @@ // along with substrate-desub. If not, see . use crate::{Error, SubstrateType}; -use sp_core::crypto::Ss58Codec; use serde::{ ser::{self, SerializeSeq}, Serializer, }; +use sp_core::crypto::Ss58Codec; use std::convert::TryFrom; // Utility function to serialize from slice/vec to hex diff --git a/desub/src/lib.rs b/desub/src/lib.rs index b2aae2c9..46d1fdf6 100644 --- a/desub/src/lib.rs +++ b/desub/src/lib.rs @@ -19,7 +19,6 @@ #[deny(unused)] mod error; -use parity_scale_codec::Decode; use desub_current::{ decoder::{self, Extrinsic}, Metadata as DesubMetadata, @@ -29,6 +28,7 @@ use desub_legacy::{ RustTypeMarker, TypeDetective, }; use frame_metadata::RuntimeMetadataPrefixed; +use parity_scale_codec::Decode; use serde_json::Value; use std::collections::HashMap; @@ -106,7 +106,7 @@ impl Decoder { if self.current_metadata.contains_key(&version) { let metadata = self.current_metadata.get(&version).expect("Checked if key is contained; qed"); match decoder::decode_extrinsics(metadata, &mut data) { - Ok(v) => Ok(serde_json::to_value(&v)?), + Ok(v) => Ok(serde_json::to_value(v)?), Err((ext, e)) => { Err(Error::V14 { source: e, ext: ext.into_iter().map(Extrinsic::into_owned).collect() }) } diff --git a/integration-tests/tests/storage.rs b/integration-tests/tests/storage.rs index 4cea8728..637c23cd 100644 --- a/integration-tests/tests/storage.rs +++ b/integration-tests/tests/storage.rs @@ -1,10 +1,10 @@ use crate::runtime_metadata::*; use anyhow::Result; -use parity_scale_codec::Encode; use desub_legacy::{ decoder::{Chain, Decoder, Metadata}, SubstrateType, }; +use parity_scale_codec::Encode; use sp_core::twox_128; /// T::BlockNumber in meta V11 Block 1768321