diff --git a/Cargo.lock b/Cargo.lock index 064d2bd86ca6b..e341c7de4e7d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16203,6 +16203,7 @@ dependencies = [ "pallet-examples", "parity-scale-codec", "scale-info", + "serde", "sp-api 26.0.0", "sp-arithmetic 23.0.0", "sp-block-builder", diff --git a/prdoc/pr_7764.prdoc b/prdoc/pr_7764.prdoc new file mode 100644 index 0000000000000..c90c132092ffe --- /dev/null +++ b/prdoc/pr_7764.prdoc @@ -0,0 +1,17 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Add Serialize & Deserialize to umbrella crate derive module + +doc: + - audience: Runtime Dev + description: | + This PR adds serde::Serialize and serde::Deserialize to the frame umbrella crate + `derive` and indirectly `prelude` modules. They can now be accessed through those. + Note: serde will still need to be added as a dependency in consuming crates. That or + you'll need to specify th `#[serde(crate = "PATH_TO_SERDE::serde")]` attribute at the + location where Serialize/Deserialize are used. + +crates: +- name: polkadot-sdk-frame + bump: minor diff --git a/substrate/frame/Cargo.toml b/substrate/frame/Cargo.toml index 8fc0d84684305..9756893337455 100644 --- a/substrate/frame/Cargo.toml +++ b/substrate/frame/Cargo.toml @@ -24,6 +24,7 @@ codec = { features = [ scale-info = { features = [ "derive", ], workspace = true } +serde = { workspace = true } # primitive deps, used for developing FRAME pallets. sp-arithmetic = { workspace = true } @@ -95,6 +96,7 @@ std = [ "frame-try-runtime?/std", "log/std", "scale-info/std", + "serde/std", "sp-api?/std", "sp-arithmetic/std", "sp-block-builder?/std", diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 1c4b2ed5b821d..4ea9f6728bb66 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -548,6 +548,13 @@ pub mod derive { PartialOrdNoBound, RuntimeDebugNoBound, }; pub use scale_info::TypeInfo; + pub use serde; + /// The `serde` `Serialize`/`Deserialize` derive macros and traits. + /// + /// You will either need to add `serde` as a dependency in your crate's `Cargo.toml` + /// or specify the `#[serde(crate = "PATH_TO_THIS_CRATE::serde")]` attribute that points + /// to the path where serde can be found. + pub use serde::{Deserialize, Serialize}; pub use sp_runtime::RuntimeDebug; }