Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce StorageVersion #472

Merged
merged 1 commit into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion zrml/authorized/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mod pallet {
use frame_support::{
dispatch::DispatchResult,
pallet_prelude::StorageDoubleMap,
traits::{Currency, Get, Hooks, IsType},
traits::{Currency, Get, Hooks, IsType, StorageVersion},
Blake2_128Concat, PalletId,
};
use frame_system::{ensure_signed, pallet_prelude::OriginFor};
Expand All @@ -31,6 +31,9 @@ mod pallet {
};
use zrml_market_commons::MarketCommonsPalletApi;

/// The current storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(0);

pub(crate) type BalanceOf<T> =
<CurrencyOf<T> as Currency<<T as frame_system::Config>::AccountId>>::Balance;
pub(crate) type CurrencyOf<T> =
Expand Down Expand Up @@ -114,6 +117,7 @@ mod pallet {
impl<T: Config> Hooks<T::BlockNumber> for Pallet<T> {}

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(PhantomData<T>);

impl<T> Pallet<T> where T: Config {}
Expand Down
4 changes: 4 additions & 0 deletions zrml/court/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ mod pallet {
pallet_prelude::{StorageDoubleMap, StorageMap, StorageValue, ValueQuery},
traits::{
BalanceStatus, Currency, Get, Hooks, IsType, NamedReservableCurrency, Randomness,
StorageVersion,
},
Blake2_128Concat, PalletId,
};
Expand All @@ -56,6 +57,8 @@ mod pallet {
// Number of jurors for an initial market dispute
const INITIAL_JURORS_NUM: usize = 3;
const MAX_RANDOM_JURORS: usize = 13;
/// The current storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(0);
// Weight used to increase the number of jurors for subsequent disputes
// of the same market
const SUBSEQUENT_JURORS_FACTOR: usize = 2;
Expand Down Expand Up @@ -185,6 +188,7 @@ mod pallet {
impl<T: Config> Hooks<T::BlockNumber> for Pallet<T> {}

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(PhantomData<T>);

impl<T> Pallet<T>
Expand Down
8 changes: 7 additions & 1 deletion zrml/liquidity-mining/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ mod pallet {
types::{StorageDoubleMap, StorageValue, ValueQuery},
with_transaction,
},
traits::{Currency, ExistenceRequirement, Get, Hooks, IsType, WithdrawReasons},
traits::{
Currency, ExistenceRequirement, Get, Hooks, IsType, StorageVersion, WithdrawReasons,
},
Blake2_128Concat, PalletId, Twox64Concat,
};
use frame_system::{ensure_root, pallet_prelude::OriginFor};
Expand All @@ -64,6 +66,9 @@ mod pallet {
};
use zrml_market_commons::MarketCommonsPalletApi;

/// The current storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(0);

pub(crate) type BalanceOf<T> =
<CurrencyOf<T> as Currency<<T as frame_system::Config>::AccountId>>::Balance;
pub(crate) type CurrencyOf<T> =
Expand Down Expand Up @@ -182,6 +187,7 @@ mod pallet {
}

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(PhantomData<T>);

impl<T> Pallet<T>
Expand Down
6 changes: 5 additions & 1 deletion zrml/market-commons/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mod pallet {
use frame_support::{
dispatch::DispatchResult,
pallet_prelude::{StorageMap, StorageValue, ValueQuery},
traits::{Hooks, NamedReservableCurrency, Time},
traits::{Hooks, NamedReservableCurrency, StorageVersion, Time},
Blake2_128Concat, Parameter,
};
use sp_runtime::{
Expand All @@ -29,6 +29,9 @@ mod pallet {
};
use zeitgeist_primitives::types::{Market, PoolId, Report};

/// The current storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(0);

type MomentOf<T> = <<T as Config>::Timestamp as frame_support::traits::Time>::Moment;

#[pallet::call]
Expand Down Expand Up @@ -70,6 +73,7 @@ mod pallet {
impl<T: Config> Hooks<T::BlockNumber> for Pallet<T> {}

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(PhantomData<T>);

impl<T> Pallet<T>
Expand Down
7 changes: 6 additions & 1 deletion zrml/orderbook-v1/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ mod pallet {
ensure,
pallet_prelude::{StorageMap, StorageValue, ValueQuery},
traits::{
Currency, ExistenceRequirement, Hooks, IsType, ReservableCurrency, WithdrawReasons,
Currency, ExistenceRequirement, Hooks, IsType, ReservableCurrency, StorageVersion,
WithdrawReasons,
},
Blake2_128Concat, Identity,
};
Expand All @@ -53,6 +54,9 @@ mod pallet {
};
use zeitgeist_primitives::{traits::MarketId, types::Asset};

/// The current storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(0);

pub(crate) type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;

Expand Down Expand Up @@ -285,6 +289,7 @@ mod pallet {
impl<T: Config> Hooks<T::BlockNumber> for Pallet<T> {}

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(PhantomData<T>);

#[pallet::storage]
Expand Down
6 changes: 5 additions & 1 deletion zrml/prediction-markets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ mod pallet {
storage::{with_transaction, TransactionOutcome},
traits::{
Currency, EnsureOrigin, ExistenceRequirement, Get, Hooks, Imbalance, IsType,
NamedReservableCurrency, OnUnbalanced,
NamedReservableCurrency, OnUnbalanced, StorageVersion,
},
transactional, Blake2_128Concat, PalletId, Twox64Concat,
};
Expand All @@ -101,6 +101,9 @@ mod pallet {

pub(crate) const RESERVE_ID: [u8; 8] = PmPalletId::get().0;

/// The current storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(0);

pub(crate) type BalanceOf<T> =
<CurrencyOf<T> as Currency<<T as frame_system::Config>::AccountId>>::Balance;
pub(crate) type CurrencyOf<T> =
Expand Down Expand Up @@ -1324,6 +1327,7 @@ mod pallet {
}

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(PhantomData<T>);

/// For each market, this holds the dispute information for each dispute that's
Expand Down
6 changes: 5 additions & 1 deletion zrml/rikiddo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub mod pallet {
debug,
dispatch::DispatchResult,
pallet_prelude::StorageMap,
traits::{Get, Hooks, Time},
traits::{Get, Hooks, StorageVersion, Time},
Twox64Concat,
};
use parity_scale_codec::{Decode, Encode, FullCodec, FullEncode};
Expand All @@ -78,6 +78,9 @@ pub mod pallet {
FixedI128, FixedI32, FixedU128, FixedU32,
};

/// The current storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(0);

#[pallet::config]
pub trait Config<I: 'static = ()>: frame_system::Config {
/// Defines the type of traded amounts.
Expand Down Expand Up @@ -140,6 +143,7 @@ pub mod pallet {
impl<T: Config<I>, I: 'static> Hooks<T::BlockNumber> for Pallet<T, I> {}

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T, I = ()>(PhantomData<T>, PhantomData<I>);

#[pallet::call]
Expand Down
6 changes: 5 additions & 1 deletion zrml/swaps/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ mod pallet {
ensure, log,
pallet_prelude::{StorageDoubleMap, StorageMap, StorageValue, ValueQuery},
storage::{with_transaction, TransactionOutcome},
traits::{Get, IsType},
traits::{Get, IsType, StorageVersion},
Blake2_128Concat, PalletId, Twox64Concat,
};
use frame_system::{ensure_root, ensure_signed, pallet_prelude::OriginFor};
Expand Down Expand Up @@ -76,6 +76,9 @@ mod pallet {
types::{EmaMarketVolume, FeeSigmoid, RikiddoSigmoidMV},
};

/// The current storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(0);

pub(crate) type BalanceOf<T> =
<<T as Config>::Shares as MultiCurrency<<T as frame_system::Config>::AccountId>>::Balance;

Expand Down Expand Up @@ -845,6 +848,7 @@ mod pallet {
}

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
#[pallet::generate_store(pub(super) trait Store)]
pub struct Pallet<T>(PhantomData<T>);

Expand Down