Remove serde requirement from FRAME macros (#8628)

* Remove `serde` requirement from FRAME macros

Currently there is some implicit requirement on `serde` being present in
the `Cargo.toml` of a pallet when `GenesisConfig` is used. This pr
removes this requirement by using the serde attribute `serde(crate = "..")`.

* build a unique reexport of serde in impl_opaque_keys, by abusing paste doc concatenation

* Optimize

Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
Bastian Köcher
2021-04-16 12:42:37 +02:00
committed by GitHub
parent 7527bd758c
commit c8136bd1df
43 changed files with 29 additions and 128 deletions
+18 -13
View File
@@ -1217,19 +1217,24 @@ macro_rules! impl_opaque_keys {
)*
}
) => {
$( #[ $attr ] )*
#[derive(
Default, Clone, PartialEq, Eq,
$crate::codec::Encode,
$crate::codec::Decode,
$crate::RuntimeDebug,
)]
#[cfg_attr(feature = "std", derive($crate::serde::Serialize, $crate::serde::Deserialize))]
pub struct $name {
$(
$( #[ $inner_attr ] )*
pub $field: <$type as $crate::BoundToRuntimeAppPublic>::Public,
)*
$crate::paste::paste! {
#[cfg(feature = "std")]
use $crate::serde as [< __opaque_keys_serde_import__ $name >];
$( #[ $attr ] )*
#[derive(
Default, Clone, PartialEq, Eq,
$crate::codec::Encode,
$crate::codec::Decode,
$crate::RuntimeDebug,
)]
#[cfg_attr(feature = "std", derive($crate::serde::Serialize, $crate::serde::Deserialize))]
#[cfg_attr(feature = "std", serde(crate = "__opaque_keys_serde_import__" $name))]
pub struct $name {
$(
$( #[ $inner_attr ] )*
pub $field: <$type as $crate::BoundToRuntimeAppPublic>::Public,
)*
}
}
impl $name {