frame: support for serde added (#14261)

* frame: support for serde added

- enabled `serde` features in dependent crates, no gate feature introduced, linker should do the job and strip unused code.

- frame::staking: added impl of `serde::Serialize, serde::Deserialize` for `enum Forcing`

- primitives::runtime: impl_opaque_keys macro provides `Serialize/Deserialize` impl if `serde` is enabled

- primitives::staking: added impl of `serde::Serialize`, `serde::Deserialize` for `enum StakerStatus`

* frame::support: serde for pallets' GenesisConfig enabled in no-std

* Cargo.lock updated

* Update primitives/staking/Cargo.toml

Co-authored-by: Bastian Köcher <git@kchr.de>

* fix

* Cargo.lock update + missed serde/std in beefy

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
Michal Kucharczyk
2023-06-01 16:35:34 +01:00
committed by GitHub
parent 372708d7a2
commit dc7161276d
16 changed files with 70 additions and 71 deletions
+7 -7
View File
@@ -13,22 +13,22 @@ readme = "README.md"
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
serde = { version = "1.0.163", optional = true }
serde = { version = "1.0.163", default-features = false, features = ["alloc", "derive"]}
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [
"derive",
] }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
sp-std = { version = "8.0.0", default-features = false, path = "../../primitives/std" }
scale-info = { version = "2.5.0", default-features = false, features = ["derive", "serde"] }
sp-io = { version = "23.0.0", default-features = false, path = "../../primitives/io" }
sp-runtime = { version = "24.0.0", default-features = false, path = "../../primitives/runtime" }
sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../primitives/staking" }
sp-runtime = { version = "24.0.0", default-features = false, path = "../../primitives/runtime", features = ["serde"] }
sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../primitives/staking", features = ["serde"] }
sp-std = { version = "8.0.0", default-features = false, path = "../../primitives/std" }
frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" }
frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" }
pallet-session = { version = "4.0.0-dev", default-features = false, features = [
"historical",
], path = "../session" }
pallet-authorship = { version = "4.0.0-dev", default-features = false, path = "../authorship" }
sp-application-crypto = { version = "23.0.0", default-features = false, path = "../../primitives/application-crypto" }
sp-application-crypto = { version = "23.0.0", default-features = false, path = "../../primitives/application-crypto", features = ["serde"] }
frame-election-provider-support = { version = "4.0.0-dev", default-features = false, path = "../election-provider-support" }
log = { version = "0.4.17", default-features = false }
@@ -53,7 +53,7 @@ rand_chacha = { version = "0.2" }
default = ["std"]
std = [
"frame-benchmarking?/std",
"serde",
"serde/std",
"codec/std",
"scale-info/std",
"sp-std/std",
+13 -2
View File
@@ -849,8 +849,19 @@ impl<Balance: AtLeast32BitUnsigned + Clone, T: Get<&'static PiecewiseLinear<'sta
}
/// Mode of era-forcing.
#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[derive(
Copy,
Clone,
PartialEq,
Eq,
Encode,
Decode,
RuntimeDebug,
TypeInfo,
MaxEncodedLen,
serde::Serialize,
serde::Deserialize,
)]
pub enum Forcing {
/// Not forcing anything - just let whatever happen.
NotForcing,