Skip to content

Commit

Permalink
Simplify feature-flag and use common types (#62)
Browse files Browse the repository at this point in the history
* Add common types between v14 and v15

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Use common types

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Guard common types by feature flags

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Use feature flags on the imports

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Revert "Use feature flags on the imports"

This reverts commit 5988d8a.

Revert "Guard common types by feature flags"

This reverts commit f12cdc6.

Revert "Use common types"

This reverts commit a012d1c.

Revert "Add common types between v14 and v15"

This reverts commit 718c9d3.

* Adjust feature flags

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Use v14 types for v15

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Rename `module_error_ty` to be consisten with `event`/`call`

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Mark V15 as unstable

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Adjust feature flags

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
  • Loading branch information
lexnv committed Jun 27, 2023
1 parent d6d2276 commit fc36bec
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 307 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:
version: 0.5

- name: Checking wasm32 (v14)
run: cargo hack check --manifest-path ./frame-metadata/Cargo.toml --feature-powerset --no-dev-deps --features v14 --skip legacy,v8,v9,v10,v11,v12,v13 --depth 4 --target wasm32-unknown-unknown
run: cargo hack check --manifest-path ./frame-metadata/Cargo.toml --feature-powerset --no-dev-deps --features current --skip legacy --depth 4 --target wasm32-unknown-unknown

- name: Checking wasm32 (all features)
run: cargo hack check --manifest-path ./frame-metadata/Cargo.toml --feature-powerset --no-dev-deps --skip decode,serde_full --depth 4 --target wasm32-unknown-unknown
Expand Down Expand Up @@ -167,7 +167,7 @@ jobs:
version: 0.5

- name: Checking v14 feature combinations (native)
run: cargo hack check --manifest-path ./frame-metadata/Cargo.toml --feature-powerset --no-dev-deps --features v14 --skip legacy,v8,v9,v10,v11,v12,v13 --depth 4
run: cargo hack check --manifest-path ./frame-metadata/Cargo.toml --feature-powerset --no-dev-deps --features current --skip legacy --depth 4

- name: Checking feature combinations excluding decode/serde_full (native)
run: cargo hack check --manifest-path ./frame-metadata/Cargo.toml --feature-powerset --no-dev-deps --skip decode,serde_full --depth 4
21 changes: 11 additions & 10 deletions frame-metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@ scale-info = { version = "2.0.0", default-features = false, optional = true, fea
serde = { version = "1.0.101", default-features = false, optional = true, features = ["derive"] }

[features]
default = ["std", "v14"]
v8 = []
v9 = []
v10 = []
v11 = []
v12 = []
v13 = []
legacy = ["v13", "v12", "v11", "v10", "v9", "v8"]
v14 = ["scale-info"]
v15-unstable = ["scale-info"]
default = ["std", "current"]

# Feature flag for pre-V14 versions.
legacy = []

# The current stable metadata versions.
current = ["scale-info"]

# Unstable next metadata version.
unstable = ["current"]

# Serde support without relying on std features
serde_full = [
"scale-info/serde",
"serde",
"serde/alloc",
]

# Scale decode support without relying on std features
decode = ["scale-info/decode"]

Expand Down
70 changes: 27 additions & 43 deletions frame-metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,7 @@
#![warn(missing_docs)]
#[cfg(all(
any(feature = "decode", feature = "serde_full"),
any(
feature = "v13",
feature = "v12",
feature = "v11",
feature = "v10",
feature = "v9",
feature = "v8",
feature = "legacy"
),
feature = "legacy",
not(feature = "std")
))]
compile_error!("decode and serde_full features prior to v14 require std");
Expand All @@ -48,53 +40,45 @@ cfg_if::cfg_if! {
use codec::{Encode, Output};

/// A type that decodes to a different type than it encodes.
#[cfg(any(
feature = "v13",
feature = "v12",
feature = "v11",
feature = "v10",
feature = "v9",
feature = "v8",
feature = "legacy"
))]
#[cfg(feature = "legacy")]
pub mod decode_different;

/// Metadata v8
#[cfg(feature = "v8")]
#[cfg(feature = "legacy")]
pub mod v8;

/// Metadata v9
#[cfg(feature = "v9")]
#[cfg(feature = "legacy")]
pub mod v9;

/// Metadata v10
#[cfg(feature = "v10")]
#[cfg(feature = "legacy")]
pub mod v10;

/// Metadata v11
#[cfg(feature = "v11")]
#[cfg(feature = "legacy")]
pub mod v11;

/// Metadata v12
#[cfg(feature = "v12")]
#[cfg(feature = "legacy")]
pub mod v12;

/// Metadata v13
#[cfg(feature = "v13")]
#[cfg(feature = "legacy")]
pub mod v13;

/// Metadata v14
#[cfg(feature = "v14")]
#[cfg(feature = "current")]
pub mod v14;

/// Metadata v15
#[cfg(feature = "v15-unstable")]
#[cfg(feature = "unstable")]
pub mod v15;

// Reexport all the types from the latest version.
//
// When a new version becomes available, update this.
#[cfg(feature = "v14")]
#[cfg(feature = "current")]
pub use self::v14::*;

/// Metadata prefix.
Expand Down Expand Up @@ -136,52 +120,52 @@ pub enum RuntimeMetadata {
/// Version 7 for runtime metadata. No longer used.
V7(RuntimeMetadataDeprecated),
/// Version 8 for runtime metadata.
#[cfg(any(feature = "v8", feature = "legacy"))]
#[cfg(feature = "legacy")]
V8(v8::RuntimeMetadataV8),
/// Version 8 for runtime metadata, as raw encoded bytes.
#[cfg(not(feature = "v8"))]
#[cfg(not(feature = "legacy"))]
V8(OpaqueMetadata),
/// Version 9 for runtime metadata.
#[cfg(any(feature = "v9", feature = "legacy"))]
#[cfg(feature = "legacy")]
V9(v9::RuntimeMetadataV9),
/// Version 9 for runtime metadata, as raw encoded bytes.
#[cfg(not(feature = "v9"))]
#[cfg(not(feature = "legacy"))]
V9(OpaqueMetadata),
/// Version 10 for runtime metadata.
#[cfg(any(feature = "v10", feature = "legacy"))]
#[cfg(feature = "legacy")]
V10(v10::RuntimeMetadataV10),
/// Version 10 for runtime metadata, as raw encoded bytes.
#[cfg(not(feature = "v10"))]
#[cfg(not(feature = "legacy"))]
V10(OpaqueMetadata),
/// Version 11 for runtime metadata.
#[cfg(any(feature = "v11", feature = "legacy"))]
#[cfg(feature = "legacy")]
V11(v11::RuntimeMetadataV11),
/// Version 11 for runtime metadata, as raw encoded bytes.
#[cfg(not(feature = "v11"))]
#[cfg(not(feature = "legacy"))]
V11(OpaqueMetadata),
/// Version 12 for runtime metadata
#[cfg(any(feature = "v12", feature = "legacy"))]
#[cfg(feature = "legacy")]
V12(v12::RuntimeMetadataV12),
/// Version 12 for runtime metadata, as raw encoded bytes.
#[cfg(not(feature = "v12"))]
#[cfg(not(feature = "legacy"))]
V12(OpaqueMetadata),
/// Version 13 for runtime metadata.
#[cfg(any(feature = "v13", feature = "legacy"))]
#[cfg(feature = "legacy")]
V13(v13::RuntimeMetadataV13),
/// Version 13 for runtime metadata, as raw encoded bytes.
#[cfg(not(feature = "v13"))]
#[cfg(not(feature = "legacy"))]
V13(OpaqueMetadata),
/// Version 14 for runtime metadata.
#[cfg(feature = "v14")]
#[cfg(feature = "current")]
V14(v14::RuntimeMetadataV14),
/// Version 14 for runtime metadata, as raw encoded bytes.
#[cfg(not(feature = "v14"))]
#[cfg(not(feature = "current"))]
V14(OpaqueMetadata),
/// Version 15 for runtime metadata.
#[cfg(feature = "v15-unstable")]
#[cfg(feature = "unstable")]
V15(v15::RuntimeMetadataV15),
/// Version 15 for runtime metadata, as raw encoded bytes.
#[cfg(not(feature = "v15-unstable"))]
#[cfg(not(feature = "unstable"))]
V15(OpaqueMetadata),
}

Expand Down
Loading

0 comments on commit fc36bec

Please sign in to comment.