Stabilize V15 Metadata (#14481)

* Update frame-metadata to latest branch

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

* Stabilize V15

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

* Update frame-metadata

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

* Use frame-metadata from crates.io

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

* Adjust testing

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

* test: Adjust frame-support metadata docs

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

* Update primitives/metadata-ir/src/lib.rs

Co-authored-by: James Wilson <james@jsdw.me>

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Co-authored-by: James Wilson <james@jsdw.me>
Co-authored-by: parity-processbot <>
This commit is contained in:
Alexandru Vasile
2023-06-30 12:33:35 +03:00
committed by GitHub
parent 448989f5ec
commit de52e76d52
8 changed files with 64 additions and 30 deletions
+12 -13
View File
@@ -25,7 +25,7 @@
pub use frame_metadata;
mod types;
use frame_metadata::{RuntimeMetadataPrefixed, RuntimeMetadataV14};
use frame_metadata::RuntimeMetadataPrefixed;
pub use types::*;
mod v14;
@@ -35,25 +35,18 @@ mod v15;
const V14: u32 = 14;
/// Metadata V15.
///
/// Not yet stable, thus we set it to `u32::MAX`.
const V15: u32 = u32::MAX;
const V15: u32 = 15;
/// Transform the IR to the specified version.
///
/// Use [`supported_versions`] to find supported versions.
pub fn into_version(metadata: MetadataIR, version: u32) -> Option<RuntimeMetadataPrefixed> {
// Note: Unstable metadata version is `u32::MAX` until stabilized.
match version {
// Latest stable version.
V14 => {
let v14: frame_metadata::v14::RuntimeMetadataV14 = metadata.into();
Some(v14.into())
},
V14 => Some(into_v14(metadata)),
// Unstable metadata.
V15 => {
let v15: frame_metadata::v15::RuntimeMetadataV15 = metadata.into();
Some(v15.into())
},
V15 => Some(into_latest(metadata)),
_ => None,
}
}
@@ -65,7 +58,13 @@ pub fn supported_versions() -> sp_std::vec::Vec<u32> {
/// Transform the IR to the latest stable metadata version.
pub fn into_latest(metadata: MetadataIR) -> RuntimeMetadataPrefixed {
let latest: RuntimeMetadataV14 = metadata.into();
let latest: frame_metadata::v15::RuntimeMetadataV15 = metadata.into();
latest.into()
}
/// Transform the IR to metadata version 14.
pub fn into_v14(metadata: MetadataIR) -> RuntimeMetadataPrefixed {
let latest: frame_metadata::v14::RuntimeMetadataV14 = metadata.into();
latest.into()
}