diff --git a/frame-metadata/Cargo.toml b/frame-metadata/Cargo.toml index 394986c..7c888c4 100644 --- a/frame-metadata/Cargo.toml +++ b/frame-metadata/Cargo.toml @@ -13,9 +13,9 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] } cfg-if = "1.0.0" -scale-info = { git = "https://github.com/paritytech/scale-info", default-features = false, optional = true, features = ["derive"] } +scale-info = { version = "0.6.0", default-features = false, optional = true, features = ["derive"] } serde = { version = "1.0.101", optional = true, features = ["derive"] } [features] @@ -26,5 +26,6 @@ std = [ "codec/std", "scale-info/std", "scale-info/serde", + "scale-info/decode", "serde", ] diff --git a/frame-metadata/src/lib.rs b/frame-metadata/src/lib.rs index a3136ee..528b0a5 100644 --- a/frame-metadata/src/lib.rs +++ b/frame-metadata/src/lib.rs @@ -40,25 +40,10 @@ pub mod v12; #[cfg(feature = "v13")] pub mod v13; -cfg_if::cfg_if! { - if #[cfg(not(feature = "v13"))] { - /// Dummy trait in place of `scale_info::form::FormString`. - /// Since the `scale-info` crate is only imported for the `v13` feature. - pub trait FormString {} - - impl FormString for &'static str {} - #[cfg(feature = "std")] - impl FormString for String {} - } else { - pub(crate) use scale_info::form::FormString; - } -} - /// Metadata prefixed by a u32 for reserved usage #[derive(Eq, Encode, PartialEq)] #[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))] -#[cfg_attr(feature = "std", serde(bound(serialize = "S: Serialize")))] -pub struct RuntimeMetadataPrefixed(pub u32, pub RuntimeMetadata); +pub struct RuntimeMetadataPrefixed(pub u32, pub RuntimeMetadata); impl Into> for RuntimeMetadataPrefixed { fn into(self) -> Vec { @@ -71,10 +56,9 @@ impl Into> for RuntimeMetadataPrefixed { /// the enum nature of `RuntimeMetadata`. #[derive(Eq, Encode, PartialEq)] #[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))] -#[cfg_attr(feature = "std", serde(bound(serialize = "S: Serialize")))] -pub enum RuntimeMetadata { +pub enum RuntimeMetadata { /// Unused; enum filler. - V0(core::marker::PhantomData), + V0(RuntimeMetadataDeprecated), /// Version 1 for runtime metadata. No longer used. V1(RuntimeMetadataDeprecated), /// Version 2 for runtime metadata. No longer used. @@ -99,13 +83,13 @@ pub enum RuntimeMetadata { V11(RuntimeMetadataDeprecated), /// Version 12 for runtime metadata #[cfg(feature = "v12")] - V12(v12::RuntimeMetadataV12), + V12(v12::RuntimeMetadataV12), /// Version 12 for runtime metadata, as raw encoded bytes. #[cfg(not(feature = "v12"))] V12(OpaqueMetadata), /// Version 13 for runtime metadata. #[cfg(feature = "v13")] - V13(v13::RuntimeMetadataV13), + V13(v13::RuntimeMetadataV13), /// Version 13 for runtime metadata, as raw encoded bytes. #[cfg(not(feature = "v13"))] V13(OpaqueMetadata), @@ -122,7 +106,7 @@ pub struct OpaqueMetadata(pub Vec); pub enum RuntimeMetadataDeprecated {} impl Encode for RuntimeMetadataDeprecated { - fn encode_to(&self, _dest: &mut W) {} + fn encode_to(&self, _dest: &mut W) {} } impl codec::EncodeLike for RuntimeMetadataDeprecated {} diff --git a/frame-metadata/src/v12.rs b/frame-metadata/src/v12.rs index 4173c6d..1a85672 100644 --- a/frame-metadata/src/v12.rs +++ b/frame-metadata/src/v12.rs @@ -59,7 +59,7 @@ where B: Encode + 'static, O: Encode + 'static, { - fn encode_to(&self, dest: &mut W) { + fn encode_to(&self, dest: &mut W) { match self { DecodeDifferent::Encode(b) => b.encode_to(dest), DecodeDifferent::Decoded(o) => o.encode_to(dest), @@ -160,7 +160,7 @@ where E: Encode + 'static; impl Encode for FnEncode { - fn encode_to(&self, dest: &mut W) { + fn encode_to(&self, dest: &mut W) { self.0().encode_to(dest); } } @@ -262,7 +262,7 @@ pub struct DefaultByteGetter(pub &'static dyn DefaultByte); pub type ByteGetter = DecodeDifferent>; impl Encode for DefaultByteGetter { - fn encode_to(&self, dest: &mut W) { + fn encode_to(&self, dest: &mut W) { self.0.default_byte().encode_to(dest) } } @@ -359,7 +359,6 @@ pub struct ExtrinsicMetadata { /// The metadata of a runtime. #[derive(Eq, Encode, PartialEq)] #[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))] -#[cfg_attr(feature = "std", serde(bound(serialize = "S: Serialize")))] pub struct RuntimeMetadataV12 { /// Metadata of all the modules. pub modules: DecodeDifferentArray, diff --git a/frame-metadata/src/v13.rs b/frame-metadata/src/v13.rs index 5a75e3d..910c625 100644 --- a/frame-metadata/src/v13.rs +++ b/frame-metadata/src/v13.rs @@ -26,7 +26,7 @@ use super::RuntimeMetadataPrefixed; use codec::Encode; use scale_info::prelude::vec::Vec; use scale_info::{ - form::{Form, FormString, MetaForm, PortableForm}, + form::{Form, MetaForm, PortableForm}, meta_type, IntoPortable, PortableRegistry, Registry, TypeInfo, }; @@ -48,13 +48,12 @@ impl From for super::RuntimeMetadataPrefixed { // todo: [AJ] add back clone derive if required (requires PortableRegistry to implement clone) #[derive(PartialEq, Eq, Encode)] #[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))] -#[cfg_attr(feature = "std", serde(bound(serialize = "S: Serialize")))] -pub struct RuntimeMetadataV13 { - pub types: PortableRegistry, +pub struct RuntimeMetadataV13 { + pub types: PortableRegistry, /// Metadata of all the modules. - pub modules: Vec>>, + pub modules: Vec>, /// Metadata of the extrinsic. - pub extrinsic: ExtrinsicMetadata>, + pub extrinsic: ExtrinsicMetadata, } impl RuntimeMetadataV13 {