diff --git a/Cargo.toml b/Cargo.toml index b934eec2e..eb062025f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ log = "0.4" parity-scale-codec = { version = "3.4.0", default-features = false } parity-util-mem = "0.12.0" scale-info = { version = "2.1.1", default-features = false } -serde = "1.0" +serde = { version = "1.0.188", default-features = false } # Procedural macro dependencies proc-macro2 = "1.0.67" diff --git a/tuxedo-core/Cargo.toml b/tuxedo-core/Cargo.toml index bf27aee09..a90c3af79 100644 --- a/tuxedo-core/Cargo.toml +++ b/tuxedo-core/Cargo.toml @@ -12,7 +12,7 @@ log = { workspace = true } parity-scale-codec = { features = [ "derive" ], workspace = true } parity-util-mem = { optional = true, workspace = true } scale-info = { features = [ "derive" ], workspace = true } -serde = { features = [ "derive" ], optional = true, workspace = true } +serde = { features = [ "derive" ], workspace = true } aggregator = { path = "aggregator" } derive-no-bound = { path = "no_bound" } @@ -37,7 +37,7 @@ std = [ "parity-scale-codec/std", "sp-core/std", "sp-std/std", - "serde", + "serde/std", "sp-api/std", "sp-inherents/std", "sp-io/std", diff --git a/tuxedo-core/src/dynamic_typing.rs b/tuxedo-core/src/dynamic_typing.rs index b7f96c9e8..8a7b568e7 100644 --- a/tuxedo-core/src/dynamic_typing.rs +++ b/tuxedo-core/src/dynamic_typing.rs @@ -48,14 +48,12 @@ use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; -#[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_std::vec::Vec; /// A piece of encoded data with a type id associated /// Strongly typed data can be extracted -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub struct DynamicallyTypedData { pub data: Vec, pub type_id: [u8; 4], diff --git a/tuxedo-core/src/types.rs b/tuxedo-core/src/types.rs index c41860433..7050061f5 100644 --- a/tuxedo-core/src/types.rs +++ b/tuxedo-core/src/types.rs @@ -3,15 +3,13 @@ use crate::{dynamic_typing::DynamicallyTypedData, ConstraintChecker, Verifier}; use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; -#[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_core::H256; use sp_runtime::traits::Extrinsic; use sp_std::vec::Vec; /// A reference to a output that is expected to exist in the state. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub struct OutputRef { /// A hash of the transaction that created this output pub tx_hash: H256, @@ -34,8 +32,7 @@ pub struct OutputRef { /// In the future, there may be additional notions of peeks (inputs that are not consumed) /// and evictions (inputs that are forcefully consumed.) /// Existing state to be read and consumed from storage -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Default, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[derive(Serialize, Deserialize, Default, Debug, PartialEq, Eq, Clone, TypeInfo)] pub struct Transaction { /// Existing pieces of state to be read and consumed from storage pub inputs: Vec, @@ -142,8 +139,7 @@ where } /// A reference the a utxo that will be consumed along with proof that it may be consumed -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub struct Input { /// a reference to the output being consumed pub output_ref: OutputRef, @@ -174,8 +170,7 @@ pub type DispatchResult = Result<(), UtxoError>; /// the verifier is checked, strongly typed data will be extracted and passed to the constraint checker. /// In a cryptocurrency, the data represents a single coin. In Tuxedo, the type of /// the contained data is generic. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub struct Output { pub payload: DynamicallyTypedData, pub verifier: V, diff --git a/tuxedo-core/src/verifier.rs b/tuxedo-core/src/verifier.rs index 9a6bfb2d7..b9e7e0dba 100644 --- a/tuxedo-core/src/verifier.rs +++ b/tuxedo-core/src/verifier.rs @@ -7,7 +7,6 @@ use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; -#[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_core::sr25519::{Public, Signature}; use sp_core::H256; @@ -25,8 +24,7 @@ pub trait Verifier: Debug + Encode + Decode + Clone { } /// A typical verifier that checks an sr25519 signature -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub struct SigCheck { pub owner_pubkey: H256, } @@ -43,8 +41,9 @@ impl Verifier for SigCheck { } /// A simple verifier that allows anyone to consume an output at any time -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo, Default)] +#[derive( + Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo, Default, +)] pub struct UpForGrabs; impl Verifier for UpForGrabs { @@ -57,8 +56,7 @@ impl Verifier for UpForGrabs { /// guarded by this verifier. A valid redeemer must supply valid signatures by at least /// `threshold` of the signatories. If the threshold is greater than the number of signatories /// the input can never be consumed. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub struct ThresholdMultiSignature { /// The minimum number of valid signatures needed to consume this input pub threshold: u8, @@ -75,8 +73,7 @@ impl ThresholdMultiSignature { } } -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone)] /// Combination of a signature plus and index so that the signer can specify which /// index this signature pertains too of the available signatories for a `ThresholdMultiSignature` pub struct SignatureAndIndex { diff --git a/tuxedo-template-runtime/Cargo.toml b/tuxedo-template-runtime/Cargo.toml index d2a5f54ca..bf8e04a36 100644 --- a/tuxedo-template-runtime/Cargo.toml +++ b/tuxedo-template-runtime/Cargo.toml @@ -10,16 +10,16 @@ version = "1.0.0-dev" log = { workspace = true } parity-scale-codec = { features = [ "derive" ], workspace = true } parity-util-mem = { optional = true, workspace = true } -scale-info = { features = [ "derive" ], workspace = true } -serde = { features = [ "derive" ], optional = true, workspace = true } +scale-info = { features = [ "derive", "serde" ], workspace = true } +serde = { features = [ "derive" ], workspace = true } sp-api = { default_features = false, workspace = true } sp-block-builder = { default_features = false, workspace = true } -sp-core = { default_features = false, workspace = true } +sp-core = { features = [ "serde" ], default_features = false, workspace = true } sp-debug-derive = { features = [ "force-debug" ], default_features = false, workspace = true } sp-inherents = { default_features = false, workspace = true } sp-io = { features = [ "with-tracing" ], default_features = false, workspace = true } -sp-runtime = { default_features = false, workspace = true } +sp-runtime = { features = [ "serde" ], default_features = false, workspace = true } sp-session = { default_features = false, workspace = true } sp-std = { default_features = false, workspace = true } sp-storage = { default_features = false, workspace = true } @@ -57,7 +57,7 @@ std = [ "parity-scale-codec/std", "sp-core/std", "sp-std/std", - "serde", + "serde/std", "sp-api/std", "sp-session/std", "sp-io/std", diff --git a/tuxedo-template-runtime/build.rs b/tuxedo-template-runtime/build.rs index 18a76f789..b0ab6fa60 100644 --- a/tuxedo-template-runtime/build.rs +++ b/tuxedo-template-runtime/build.rs @@ -1,9 +1,13 @@ -use substrate_wasm_builder::WasmBuilder; - +#[cfg(feature = "std")] fn main() { - WasmBuilder::new() + substrate_wasm_builder::WasmBuilder::new() .with_current_project() .export_heap_base() .import_memory() .build() } + +/// The wasm builder is deactivated when compiling +/// this crate for wasm to speed up the compilation. +#[cfg(not(feature = "std"))] +fn main() {} diff --git a/tuxedo-template-runtime/src/lib.rs b/tuxedo-template-runtime/src/lib.rs index a76f88443..fa78d8d80 100644 --- a/tuxedo-template-runtime/src/lib.rs +++ b/tuxedo-template-runtime/src/lib.rs @@ -32,7 +32,6 @@ use sp_runtime::{BuildStorage, Storage}; use sp_version::NativeVersion; use sp_version::RuntimeVersion; -#[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use tuxedo_core::{ @@ -105,7 +104,7 @@ pub fn native_version() -> NativeVersion { } } -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +#[derive(Serialize, Deserialize)] pub struct GenesisConfig { pub genesis_utxos: Vec, } @@ -192,8 +191,7 @@ const BLOCK_TIME: u64 = 3000; /// A verifier checks that an individual input can be consumed. For example that it is signed properly /// To begin playing, we will have two kinds. A simple signature check, and an anyone-can-consume check. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] #[tuxedo_verifier] pub enum OuterVerifier { SigCheck(SigCheck), @@ -220,8 +218,7 @@ impl timestamp::TimestampConfig for Runtime { /// A constraint checker is a piece of logic that can be used to check a transaction. /// For any given Tuxedo runtime there is a finite set of such constraint checkers. /// For example, this may check that input token values exceed output token values. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] #[tuxedo_constraint_checker(OuterVerifier)] pub enum OuterConstraintChecker { /// Checks monetary transactions in a basic fungible cryptocurrency diff --git a/wardrobe/amoeba/Cargo.toml b/wardrobe/amoeba/Cargo.toml index d45db057c..b77595ee9 100644 --- a/wardrobe/amoeba/Cargo.toml +++ b/wardrobe/amoeba/Cargo.toml @@ -9,7 +9,7 @@ version = "0.1.0" [dependencies] parity-scale-codec = { features = [ "derive" ], workspace = true } scale-info = { features = [ "derive" ], workspace = true } -serde = { features = [ "derive" ], optional = true, workspace = true } +serde = { features = [ "derive" ], workspace = true } sp-runtime = { default_features = false, workspace = true } tuxedo-core = { default-features = false, path = "../../tuxedo-core" } @@ -19,5 +19,5 @@ std = [ "tuxedo-core/std", "parity-scale-codec/std", "sp-runtime/std", - "serde", + "serde/std", ] diff --git a/wardrobe/amoeba/src/lib.rs b/wardrobe/amoeba/src/lib.rs index f4b36fd52..4f26adc6a 100644 --- a/wardrobe/amoeba/src/lib.rs +++ b/wardrobe/amoeba/src/lib.rs @@ -12,7 +12,6 @@ use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; -#[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_runtime::transaction_validity::TransactionPriority; use tuxedo_core::{ @@ -24,8 +23,7 @@ use tuxedo_core::{ mod tests; /// An amoeba tracked by our simple Amoeba APP -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone)] pub struct AmoebaDetails { /// How many generations after the original Eve Amoeba this one is. /// When going through mitosis, this number must increase by 1 each time. @@ -80,8 +78,7 @@ pub enum ConstraintCheckerError { /// 1. There is exactly one mother amoeba. /// 2. There are exactly two daughter amoebas /// 3. Each Daughter amoeba has a generation one higher than its mother. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub struct AmoebaMitosis; impl SimpleConstraintChecker for AmoebaMitosis { @@ -139,8 +136,7 @@ impl SimpleConstraintChecker for AmoebaMitosis { /// /// Any amoeba can be killed by providing it as the sole input to this constraint checker. No /// new outputs are ever created. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub struct AmoebaDeath; impl SimpleConstraintChecker for AmoebaDeath { @@ -179,8 +175,7 @@ impl SimpleConstraintChecker for AmoebaDeath { /// /// A new amoeba can be created by providing it as the sole output to this constraint checker. No /// inputs are ever consumed. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub struct AmoebaCreation; impl SimpleConstraintChecker for AmoebaCreation { diff --git a/wardrobe/kitties/Cargo.toml b/wardrobe/kitties/Cargo.toml index 2552a8059..b9037bdbe 100644 --- a/wardrobe/kitties/Cargo.toml +++ b/wardrobe/kitties/Cargo.toml @@ -9,7 +9,7 @@ version = "0.1.0" [dependencies] parity-scale-codec = { features = [ "derive" ], workspace = true } scale-info = { features = [ "derive" ], workspace = true } -serde = { features = [ "derive" ], optional = true, workspace = true } +serde = { features = [ "derive" ], workspace = true } sp-core = { default_features = false, workspace = true } sp-runtime = { default_features = false, workspace = true } sp-std = { default_features = false, workspace = true } @@ -23,5 +23,5 @@ std = [ "sp-runtime/std", "sp-std/std", "sp-core/std", - "serde", + "serde/std", ] diff --git a/wardrobe/kitties/src/lib.rs b/wardrobe/kitties/src/lib.rs index 127855b17..761ec3284 100644 --- a/wardrobe/kitties/src/lib.rs +++ b/wardrobe/kitties/src/lib.rs @@ -19,7 +19,6 @@ use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; -#[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_core::H256; use sp_runtime::{ @@ -35,28 +34,78 @@ use tuxedo_core::{ #[cfg(test)] mod tests; -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, Hash, Debug, TypeInfo)] +#[derive( + Serialize, + Deserialize, + PartialEq, + Eq, + PartialOrd, + Ord, + Clone, + Encode, + Decode, + Hash, + Debug, + TypeInfo, +)] pub struct FreeKittyConstraintChecker; -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(PartialEq, Eq, PartialOrd, Ord, Default, Clone, Encode, Decode, Hash, Debug, TypeInfo)] +#[derive( + Serialize, + Deserialize, + PartialEq, + Eq, + PartialOrd, + Ord, + Default, + Clone, + Encode, + Decode, + Hash, + Debug, + TypeInfo, +)] pub enum DadKittyStatus { #[default] RearinToGo, Tired, } -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(PartialEq, Eq, PartialOrd, Ord, Default, Clone, Encode, Decode, Hash, Debug, TypeInfo)] +#[derive( + Serialize, + Deserialize, + PartialEq, + Eq, + PartialOrd, + Ord, + Default, + Clone, + Encode, + Decode, + Hash, + Debug, + TypeInfo, +)] pub enum MomKittyStatus { #[default] RearinToGo, HadBirthRecently, } -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, Hash, Debug, TypeInfo)] +#[derive( + Serialize, + Deserialize, + PartialEq, + Eq, + PartialOrd, + Ord, + Clone, + Encode, + Decode, + Hash, + Debug, + TypeInfo, +)] pub enum Parent { Mom(MomKittyStatus), Dad(DadKittyStatus), @@ -68,12 +117,37 @@ impl Default for Parent { } } -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(PartialEq, Eq, PartialOrd, Ord, Default, Clone, Encode, Decode, Hash, Debug, TypeInfo)] +#[derive( + Serialize, + Deserialize, + PartialEq, + Eq, + PartialOrd, + Ord, + Default, + Clone, + Encode, + Decode, + Hash, + Debug, + TypeInfo, +)] pub struct KittyDNA(H256); -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, Hash, Debug, TypeInfo)] +#[derive( + Serialize, + Deserialize, + PartialEq, + Eq, + PartialOrd, + Ord, + Clone, + Encode, + Decode, + Hash, + Debug, + TypeInfo, +)] pub struct KittyData { pub parent: Parent, pub free_breedings: u64, // Ignore in breed for money case @@ -96,8 +170,20 @@ impl UtxoData for KittyData { const TYPE_ID: [u8; 4] = *b"Kitt"; } -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, Hash, Debug, TypeInfo)] +#[derive( + Serialize, + Deserialize, + PartialEq, + Eq, + PartialOrd, + Ord, + Clone, + Encode, + Decode, + Hash, + Debug, + TypeInfo, +)] pub enum ConstraintCheckerError { /// Dynamic typing issue. /// This error doesn't discriminate between badly typed inputs and outputs. diff --git a/wardrobe/money/Cargo.toml b/wardrobe/money/Cargo.toml index 44afdc5ba..39a489de3 100644 --- a/wardrobe/money/Cargo.toml +++ b/wardrobe/money/Cargo.toml @@ -9,7 +9,7 @@ version = "0.1.0" [dependencies] parity-scale-codec = { features = [ "derive" ], workspace = true } scale-info = { features = [ "derive" ], workspace = true } -serde = { features = [ "derive" ], optional = true, workspace = true } +serde = { features = [ "derive" ], workspace = true } sp-runtime = { default_features = false, workspace = true } sp-std = { default_features = false, workspace = true } tuxedo-core = { default-features = false, path = "../../tuxedo-core" } @@ -21,5 +21,5 @@ std = [ "parity-scale-codec/std", "sp-runtime/std", "sp-std/std", - "serde", + "serde/std", ] diff --git a/wardrobe/money/src/lib.rs b/wardrobe/money/src/lib.rs index 04f44099f..e3b714818 100644 --- a/wardrobe/money/src/lib.rs +++ b/wardrobe/money/src/lib.rs @@ -4,7 +4,6 @@ use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; -#[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_runtime::transaction_validity::TransactionPriority; use sp_std::prelude::*; @@ -29,8 +28,20 @@ impl Cash for Coin { // use log::info; /// The main constraint checker for the money piece. Allows spending and minting tokens. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, Hash, Debug, TypeInfo)] +#[derive( + Serialize, + Deserialize, + PartialEq, + Eq, + PartialOrd, + Ord, + Clone, + Encode, + Decode, + Hash, + Debug, + TypeInfo, +)] pub enum MoneyConstraintChecker { /// A typical spend transaction where some coins are consumed and others are created. /// Input value must exceed output value. The difference is burned and reflected in the @@ -44,8 +55,20 @@ pub enum MoneyConstraintChecker { /// A single coin in the fungible money system. /// A new-type wrapper around a `u128` value. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, Hash, Debug, TypeInfo)] +#[derive( + Serialize, + Deserialize, + PartialEq, + Eq, + PartialOrd, + Ord, + Clone, + Encode, + Decode, + Hash, + Debug, + TypeInfo, +)] pub struct Coin(pub u128); impl Coin { @@ -59,8 +82,20 @@ impl UtxoData for Coin { } /// Errors that can occur when checking money transactions. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, Hash, Debug, TypeInfo)] +#[derive( + Serialize, + Deserialize, + PartialEq, + Eq, + PartialOrd, + Ord, + Clone, + Encode, + Decode, + Hash, + Debug, + TypeInfo, +)] pub enum ConstraintCheckerError { /// Dynamic typing issue. /// This error doesn't discriminate between badly typed inputs and outputs. diff --git a/wardrobe/poe/Cargo.toml b/wardrobe/poe/Cargo.toml index 22e1c4be5..166abef55 100644 --- a/wardrobe/poe/Cargo.toml +++ b/wardrobe/poe/Cargo.toml @@ -9,7 +9,7 @@ version = "0.1.0" [dependencies] parity-scale-codec = { features = [ "derive" ], workspace = true } scale-info = { features = [ "derive" ], workspace = true } -serde = { features = [ "derive" ], optional = true, workspace = true } +serde = { features = [ "derive" ], workspace = true } sp-core = { default_features = false, workspace = true } sp-runtime = { default_features = false, workspace = true } sp-std = { default_features = false, workspace = true } @@ -21,7 +21,7 @@ std = [ "tuxedo-core/std", "parity-scale-codec/std", "sp-runtime/std", - "serde", + "serde/std", "sp-core/std", "sp-std/std", ] diff --git a/wardrobe/poe/src/lib.rs b/wardrobe/poe/src/lib.rs index 0cf417b6b..3b70f9ef3 100644 --- a/wardrobe/poe/src/lib.rs +++ b/wardrobe/poe/src/lib.rs @@ -21,7 +21,6 @@ use core::marker::PhantomData; use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; -#[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_core::H256; use sp_runtime::transaction_validity::TransactionPriority; @@ -37,8 +36,7 @@ use tuxedo_core::{ mod tests; // Notice this type doesn't have to be public. Cool. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone)] struct ClaimData { /// The hash of the data whose existence is being proven. claim: H256, @@ -51,8 +49,7 @@ impl UtxoData for ClaimData { } /// Errors that can occur when checking PoE Transactions -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone)] pub enum ConstraintCheckerError { // Ughhh again with these common errors. /// Wrong number of inputs were provided to the constraint checker. @@ -83,8 +80,9 @@ pub trait PoeConfig { /// This constraint checker allows the creation of many claims in a single operation /// It also allows the creation of zero claims, although such a transaction is useless and is simply a /// waste of caller fees. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, DebugNoBound, CloneNoBound, PartialEq, Eq, TypeInfo)] +#[derive( + Serialize, Deserialize, Encode, Decode, DebugNoBound, CloneNoBound, PartialEq, Eq, TypeInfo, +)] pub struct PoeClaim(PhantomData); impl SimpleConstraintChecker for PoeClaim { @@ -127,8 +125,7 @@ impl SimpleConstraintChecker for PoeClaim { /// A constraint checker to revoke claims. /// /// Like the creation constraint checker, this allows batch revocation. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub struct PoeRevoke; impl SimpleConstraintChecker for PoeRevoke { @@ -167,8 +164,7 @@ impl SimpleConstraintChecker for PoeRevoke { /// the verifier logic? This is a concrete case where the constraint checker verifier separation is not ideal. /// Another, weaker example, is when trying o implement something like sudo. Where we want a signature, /// but we want to authorized signer to come from the a different part of state. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub struct PoeDispute; impl SimpleConstraintChecker for PoeDispute { diff --git a/wardrobe/runtime_upgrade/Cargo.toml b/wardrobe/runtime_upgrade/Cargo.toml index 3e3ea4611..f273924c1 100644 --- a/wardrobe/runtime_upgrade/Cargo.toml +++ b/wardrobe/runtime_upgrade/Cargo.toml @@ -9,7 +9,7 @@ version = "0.1.0" [dependencies] parity-scale-codec = { features = [ "derive" ], workspace = true } scale-info = { features = [ "derive" ], workspace = true } -serde = { features = [ "derive" ], optional = true, workspace = true } +serde = { features = [ "derive" ], workspace = true } sp-io = { default_features = false, workspace = true } sp-runtime = { default_features = false, workspace = true } sp-std = { default_features = false, workspace = true } @@ -22,7 +22,7 @@ std = [ "tuxedo-core/std", "parity-scale-codec/std", "sp-runtime/std", - "serde", + "serde/std", "sp-std/std", "sp-io/std", "sp-storage/std", diff --git a/wardrobe/runtime_upgrade/src/lib.rs b/wardrobe/runtime_upgrade/src/lib.rs index 6850049a9..9b21a0d6c 100644 --- a/wardrobe/runtime_upgrade/src/lib.rs +++ b/wardrobe/runtime_upgrade/src/lib.rs @@ -15,7 +15,6 @@ use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; -#[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_runtime::transaction_validity::TransactionPriority; use sp_std::vec::Vec; @@ -29,8 +28,7 @@ use tuxedo_core::{ mod tests; /// A reference to a runtime wasm blob. It is just a hash. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone)] struct RuntimeRef { hash: [u8; 32], } @@ -68,8 +66,7 @@ pub enum ConstraintCheckerError { /// This constraint checker is somewhat non-standard in that it has a side-effect that /// writes the full wasm code to the well-known `:code` storage key. This is /// necessary to satisfy Substrate's assumptions that this will happen. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub struct RuntimeUpgrade { full_wasm: Vec, } diff --git a/wardrobe/timestamp/Cargo.toml b/wardrobe/timestamp/Cargo.toml index 921424306..6bf1b657a 100644 --- a/wardrobe/timestamp/Cargo.toml +++ b/wardrobe/timestamp/Cargo.toml @@ -10,7 +10,7 @@ version = "0.1.0" log = { workspace = true } parity-scale-codec = { features = [ "derive" ], workspace = true } scale-info = { features = [ "derive" ], workspace = true } -serde = { features = [ "derive" ], optional = true, workspace = true } +serde = { features = [ "derive" ], workspace = true } sp-api = { default_features = false, workspace = true } sp-core = { default_features = false, workspace = true } sp-inherents = { default_features = false, workspace = true } @@ -30,5 +30,5 @@ std = [ "sp-std/std", "sp-core/std", "sp-timestamp/std", - "serde", + "serde/std", ] diff --git a/wardrobe/timestamp/src/lib.rs b/wardrobe/timestamp/src/lib.rs index ae1ab38bc..a796b0d4a 100644 --- a/wardrobe/timestamp/src/lib.rs +++ b/wardrobe/timestamp/src/lib.rs @@ -17,7 +17,6 @@ use core::marker::PhantomData; use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; -#[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_core::H256; use sp_inherents::{CheckInherentsResult, InherentData}; @@ -137,8 +136,18 @@ pub enum TimestampError { /// On the other hand, the noted timestamps stick around in storage for a while so that other /// transactions that need to peek at them are not immediately invalidated. Noted timestamps /// can be voluntarily cleand up later by another transaction. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, DebugNoBound, DefaultNoBound, PartialEq, Eq, CloneNoBound, TypeInfo)] +#[derive( + Serialize, + Deserialize, + Encode, + Decode, + DebugNoBound, + DefaultNoBound, + PartialEq, + Eq, + CloneNoBound, + TypeInfo, +)] #[scale_info(skip_type_params(T))] pub struct SetTimestamp(PhantomData); @@ -329,8 +338,18 @@ impl, T: TimestampConfig + 'static> TuxedoInheren /// You can clean up multiple timestamps at once, but you only peek at a single /// new reference. Although it is useless to do so, it is valid for a transaction /// to clean up zero timestamps. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, DebugNoBound, DefaultNoBound, PartialEq, Eq, CloneNoBound, TypeInfo)] +#[derive( + Serialize, + Deserialize, + Encode, + Decode, + DebugNoBound, + DefaultNoBound, + PartialEq, + Eq, + CloneNoBound, + TypeInfo, +)] pub struct CleanUpTimestamp(PhantomData); impl SimpleConstraintChecker for CleanUpTimestamp {