Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
  • Loading branch information
ggwpez committed Jan 26, 2023
1 parent 696e9a5 commit 50bb03f
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions frame/support/src/traits/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,40 @@ pub trait GetStorageVersion {
fn on_chain_storage_version() -> StorageVersion;
}

pub trait GetStorageVersions {
/// Returns the current storage version as supported by the pallet.
fn current_storage_versions() -> Vec<StorageVersion>;
/// Returns the on-chain storage version of the pallet as stored in the storage.
fn on_chain_storage_versions() -> Vec<StorageVersion>;
}

impl<T: GetStorageVersion> GetStorageVersions for T {
fn current_storage_versions() -> Vec<StorageVersion> {
vec![T::current_storage_version()]
}

fn on_chain_storage_versions() -> Vec<StorageVersion> {
vec![T::on_chain_storage_version()]
}
}

#[cfg_attr(all(not(feature = "tuples-96"), not(feature = "tuples-128")), impl_for_tuples(64))]
#[cfg_attr(all(feature = "tuples-96", not(feature = "tuples-128")), impl_for_tuples(96))]
#[cfg_attr(feature = "tuples-128", impl_for_tuples(128))]
impl GetStorageVersions for Tuple {
fn current_storage_versions() -> Vec<StorageVersion> {
let mut res = vec![];
for_tuples!( #( res.extend_from_slice(&Tuple::current_storage_versions()); )* );
res
}

fn on_chain_storage_versions() -> Vec<StorageVersion> {
let mut res = vec![];
for_tuples!( #( res.extend_from_slice(&Tuple::on_chain_storage_versions()); )* );
res
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit 50bb03f

Please sign in to comment.