Skip to content

Commit

Permalink
Guard common types by feature flags
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
  • Loading branch information
lexnv committed Jun 15, 2023
1 parent a012d1c commit f12cdc6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
21 changes: 21 additions & 0 deletions frame-metadata/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use scale_info::{
};

/// Metadata of an extrinsic's signed extension.
#[cfg(any(feature = "v14", feature = "v15-unstable"))]
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
#[cfg_attr(feature = "decode", derive(Decode))]
#[cfg_attr(feature = "serde_full", derive(Serialize))]
Expand All @@ -44,6 +45,7 @@ pub struct SignedExtensionMetadata<T: Form = MetaForm> {
pub additional_signed: T::Type,
}

#[cfg(any(feature = "v14", feature = "v15-unstable"))]
impl IntoPortable for SignedExtensionMetadata {
type Output = SignedExtensionMetadata<PortableForm>;

Expand All @@ -57,6 +59,7 @@ impl IntoPortable for SignedExtensionMetadata {
}

/// All metadata of the pallet's storage.
#[cfg(any(feature = "v14", feature = "v15-unstable"))]
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
#[cfg_attr(feature = "decode", derive(Decode))]
#[cfg_attr(feature = "serde_full", derive(Serialize))]
Expand All @@ -71,6 +74,7 @@ pub struct PalletStorageMetadata<T: Form = MetaForm> {
pub entries: Vec<StorageEntryMetadata<T>>,
}

#[cfg(any(feature = "v14", feature = "v15-unstable"))]
impl IntoPortable for PalletStorageMetadata {
type Output = PalletStorageMetadata<PortableForm>;

Expand All @@ -83,6 +87,7 @@ impl IntoPortable for PalletStorageMetadata {
}

/// Metadata about one storage entry.
#[cfg(any(feature = "v14", feature = "v15-unstable"))]
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
#[cfg_attr(feature = "decode", derive(Decode))]
#[cfg_attr(feature = "serde_full", derive(Serialize))]
Expand All @@ -103,6 +108,7 @@ pub struct StorageEntryMetadata<T: Form = MetaForm> {
pub docs: Vec<T::String>,
}

#[cfg(any(feature = "v14", feature = "v15-unstable"))]
impl IntoPortable for StorageEntryMetadata {
type Output = StorageEntryMetadata<PortableForm>;

Expand All @@ -122,6 +128,7 @@ impl IntoPortable for StorageEntryMetadata {
///
/// `Optional` means you should expect an `Option<T>`, with `None` returned if the key is not present.
/// `Default` means you should expect a `T` with the default value of default if the key is not present.
#[cfg(any(feature = "v14", feature = "v15-unstable"))]
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
#[cfg_attr(feature = "decode", derive(Decode))]
#[cfg_attr(feature = "serde_full", derive(Serialize))]
Expand All @@ -133,6 +140,7 @@ pub enum StorageEntryModifier {
}

/// Hasher used by storage maps
#[cfg(any(feature = "v14", feature = "v15-unstable"))]
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
#[cfg_attr(feature = "decode", derive(Decode))]
#[cfg_attr(feature = "serde_full", derive(Serialize))]
Expand All @@ -154,6 +162,7 @@ pub enum StorageHasher {
}

/// A type of storage value.
#[cfg(any(feature = "v14", feature = "v15-unstable"))]
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
#[cfg_attr(feature = "decode", derive(Decode))]
#[cfg_attr(feature = "serde_full", derive(Serialize))]
Expand All @@ -175,6 +184,7 @@ pub enum StorageEntryType<T: Form = MetaForm> {
},
}

#[cfg(any(feature = "v14", feature = "v15-unstable"))]
impl IntoPortable for StorageEntryType {
type Output = StorageEntryType<PortableForm>;

Expand All @@ -195,6 +205,7 @@ impl IntoPortable for StorageEntryType {
}

/// Metadata for all calls in a pallet
#[cfg(any(feature = "v14", feature = "v15-unstable"))]
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
#[cfg_attr(feature = "decode", derive(Decode))]
#[cfg_attr(feature = "serde_full", derive(Serialize))]
Expand All @@ -207,6 +218,7 @@ pub struct PalletCallMetadata<T: Form = MetaForm> {
pub ty: T::Type,
}

#[cfg(any(feature = "v14", feature = "v15-unstable"))]
impl IntoPortable for PalletCallMetadata {
type Output = PalletCallMetadata<PortableForm>;

Expand All @@ -217,13 +229,15 @@ impl IntoPortable for PalletCallMetadata {
}
}

#[cfg(any(feature = "v14", feature = "v15-unstable"))]
impl From<MetaType> for PalletCallMetadata {
fn from(ty: MetaType) -> Self {
Self { ty }
}
}

/// Metadata about the pallet Event type.
#[cfg(any(feature = "v14", feature = "v15-unstable"))]
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
#[cfg_attr(feature = "decode", derive(Decode))]
#[cfg_attr(feature = "serde_full", derive(Serialize))]
Expand All @@ -232,6 +246,7 @@ pub struct PalletEventMetadata<T: Form = MetaForm> {
pub ty: T::Type,
}

#[cfg(any(feature = "v14", feature = "v15-unstable"))]
impl IntoPortable for PalletEventMetadata {
type Output = PalletEventMetadata<PortableForm>;

Expand All @@ -242,13 +257,15 @@ impl IntoPortable for PalletEventMetadata {
}
}

#[cfg(any(feature = "v14", feature = "v15-unstable"))]
impl From<MetaType> for PalletEventMetadata {
fn from(ty: MetaType) -> Self {
Self { ty }
}
}

/// Metadata about one pallet constant.
#[cfg(any(feature = "v14", feature = "v15-unstable"))]
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
#[cfg_attr(feature = "decode", derive(Decode))]
#[cfg_attr(feature = "serde_full", derive(Serialize))]
Expand All @@ -267,6 +284,7 @@ pub struct PalletConstantMetadata<T: Form = MetaForm> {
pub docs: Vec<T::String>,
}

#[cfg(any(feature = "v14", feature = "v15-unstable"))]
impl IntoPortable for PalletConstantMetadata {
type Output = PalletConstantMetadata<PortableForm>;

Expand All @@ -281,6 +299,7 @@ impl IntoPortable for PalletConstantMetadata {
}

/// Metadata about a pallet error.
#[cfg(any(feature = "v14", feature = "v15-unstable"))]
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
#[cfg_attr(feature = "decode", derive(Decode))]
#[cfg_attr(feature = "serde_full", derive(Serialize))]
Expand All @@ -290,6 +309,7 @@ pub struct PalletErrorMetadata<T: Form = MetaForm> {
pub ty: T::Type,
}

#[cfg(any(feature = "v14", feature = "v15-unstable"))]
impl IntoPortable for PalletErrorMetadata {
type Output = PalletErrorMetadata<PortableForm>;

Expand All @@ -300,6 +320,7 @@ impl IntoPortable for PalletErrorMetadata {
}
}

#[cfg(any(feature = "v14", feature = "v15-unstable"))]
impl From<MetaType> for PalletErrorMetadata {
fn from(ty: MetaType) -> Self {
Self { ty }
Expand Down
1 change: 0 additions & 1 deletion frame-metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ pub mod v15;
#[cfg(feature = "v14")]
pub use self::v14::*;

#[cfg(any(feature = "v14", feature = "v15-unstable"))]
mod common;

/// Metadata prefix.
Expand Down

0 comments on commit f12cdc6

Please sign in to comment.