Skip to content

Commit

Permalink
Function to return version from metadata (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsdw authored Nov 4, 2021
1 parent 5a822bb commit f814ecb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions frame-metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,29 @@ pub enum RuntimeMetadata {
V14(OpaqueMetadata),
}

impl RuntimeMetadata {
/// Get the version number of the metadata.
pub fn version(&self) -> u32 {
match self {
RuntimeMetadata::V0(_) => 0,
RuntimeMetadata::V1(_) => 1,
RuntimeMetadata::V2(_) => 2,
RuntimeMetadata::V3(_) => 3,
RuntimeMetadata::V4(_) => 4,
RuntimeMetadata::V5(_) => 5,
RuntimeMetadata::V6(_) => 6,
RuntimeMetadata::V7(_) => 7,
RuntimeMetadata::V8(_) => 8,
RuntimeMetadata::V9(_) => 9,
RuntimeMetadata::V10(_) => 10,
RuntimeMetadata::V11(_) => 11,
RuntimeMetadata::V12(_) => 12,
RuntimeMetadata::V13(_) => 13,
RuntimeMetadata::V14(_) => 14,
}
}
}

/// Stores the encoded `RuntimeMetadata` as raw bytes.
#[derive(Encode, Eq, PartialEq)]
#[cfg_attr(feature = "std", derive(Decode, Serialize, Deserialize, Debug))]
Expand Down

0 comments on commit f814ecb

Please sign in to comment.