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

Removes without_storage_info macro from pallets #1122

Merged
merged 15 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
tests: fix
  • Loading branch information
wischli committed Jan 10, 2023
commit cfb546b53756d5fd7ae2618a714723de3f2391b0
5 changes: 3 additions & 2 deletions libs/types/src/permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ mod tests {

parameter_types! {
pub const MinDelay: u64 = 4;
pub const MaxTranches: u32 = 5;
}

struct Now(core::time::Duration);
Expand Down Expand Up @@ -497,9 +498,9 @@ mod tests {

#[test]
fn permission_roles_work() {
assert!(PermissionRoles::<Now, MinDelay, TrancheId>::default().empty());
assert!(PermissionRoles::<Now, MinDelay, TrancheId, MaxTranches>::default().empty());

let mut roles = PermissionRoles::<Now, MinDelay, TrancheId>::default();
let mut roles = PermissionRoles::<Now, MinDelay, TrancheId, MaxTranches>::default();

// Updating works only when increasing permissions
assert!(roles
Expand Down
3 changes: 2 additions & 1 deletion pallets/investments/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use cfg_types::{
orders::{FulfillmentWithPrice, TotalOrder},
tokens::CurrencyId,
};
use codec::{Decode, Encode};
use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::{
dispatch::DispatchResultWithPostInfo,
parameter_types,
Expand Down Expand Up @@ -183,6 +183,7 @@ impl<T> PreConditions<T> for Always {
TypeInfo,
Serialize,
Deserialize,
MaxEncodedLen,
)]
pub enum InvestmentId {
PoolTranche {
Expand Down
5 changes: 3 additions & 2 deletions pallets/loans/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ impl PoolUpdateGuard for UpdateGuard {
TrancheWeight,
TrancheId,
PoolId,
MaxTranches,
>;
type ScheduledUpdateDetails =
ScheduledUpdateDetails<Rate, MaxTokenNameLength, MaxTokenSymbolLength, MaxTranches>;
Expand Down Expand Up @@ -326,8 +327,8 @@ impl pallet_interest_accrual::Config for Runtime {
}

parameter_types! {
#[derive(Debug, Eq, PartialEq, scale_info::TypeInfo, Clone)]
pub const MaxTranches: u8 = 5;
#[derive(Debug, Eq, PartialEq, PartialOrd, scale_info::TypeInfo, Clone)]
pub const MaxTranches: u32 = 5;

#[derive(Debug, Eq, PartialEq, scale_info::TypeInfo, Clone)]
pub const MinDelay: Moment = 0;
Expand Down
16 changes: 11 additions & 5 deletions pallets/permissions/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

use codec::{Decode, Encode};
use codec::{Decode, Encode, MaxEncodedLen};
pub use dummy::pallet as pallet_dummy;
use frame_support::{
parameter_types,
Expand Down Expand Up @@ -50,7 +50,7 @@ pub enum Role {

bitflags::bitflags! {
/// The current admin roles we support
#[derive(codec::Encode, codec::Decode, scale_info::TypeInfo)]
#[derive(codec::Encode, codec::Decode, scale_info::TypeInfo, MaxEncodedLen)]
pub struct OrgStorage: u32 {
const SENIOR_EXEC = 0b00000001;
const HEAD_OF_SAUBERMACHING = 0b00000010;
Expand All @@ -60,14 +60,16 @@ bitflags::bitflags! {

bitflags::bitflags! {
/// The current admin roles we support
#[derive(codec::Encode, codec::Decode, scale_info::TypeInfo)]
#[derive(codec::Encode, codec::Decode, scale_info::TypeInfo, MaxEncodedLen)]
pub struct XcmStorage: u32 {
const SENDER = 0b00000001;
const RECEIVER = 0b00000010;
}
}

#[derive(codec::Encode, codec::Decode, scale_info::TypeInfo, Debug, Clone, Eq, PartialEq)]
#[derive(
codec::Encode, codec::Decode, scale_info::TypeInfo, Debug, Clone, Eq, PartialEq, MaxEncodedLen,
)]
pub struct Storage {
org: OrgStorage,
xcm: XcmStorage,
Expand All @@ -82,7 +84,9 @@ impl Default for Storage {
}
}

#[derive(codec::Encode, codec::Decode, scale_info::TypeInfo, Debug, Clone, Eq, PartialEq)]
#[derive(
codec::Encode, codec::Decode, scale_info::TypeInfo, Debug, Clone, Eq, PartialEq, MaxEncodedLen,
)]
pub enum Scope {
PalletA,
PalletB,
Expand Down Expand Up @@ -281,6 +285,7 @@ impl frame_system::Config for Runtime {
parameter_types! {
pub const One: u64 = 1;
pub const MaxRoles: u32 = 10;
pub const MaxTranches: u32 = 5;
}

type AdminOrigin = EitherOfDiverse<EnsureRoot<u64>, EnsureSignedBy<One, u64>>;
Expand All @@ -290,6 +295,7 @@ impl pallet_permissions::Config for Runtime {
type Editors = Editors;
type Event = Event;
type MaxRolesPerScope = MaxRoles;
type MaxTranches = MaxTranches;
type Role = Role;
type Scope = Scope;
type Storage = Storage;
Expand Down
7 changes: 6 additions & 1 deletion pallets/pool-registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ pub mod pallet {
+ MaxEncodedLen
+ core::fmt::Debug;

type Rate: Parameter + Member + MaybeSerializeDeserialize + FixedPointNumber + TypeInfo;
type Rate: Parameter
+ Member
+ MaybeSerializeDeserialize
+ FixedPointNumber
+ TypeInfo
+ MaxEncodedLen;

/// A fixed-point number which represents an
/// interest rate.
Expand Down
9 changes: 2 additions & 7 deletions pallets/pool-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub type EpochExecutionTranchesOf<T> = EpochExecutionTranches<
<T as Config>::Rate,
<T as Config>::TrancheWeight,
<T as Config>::TrancheCurrency,
<T as Config>::MaxEpocExecutionTranches,
<T as Config>::MaxTranches,
>;

/// Types alias for Tranches
Expand Down Expand Up @@ -133,7 +133,6 @@ type EpochExecutionInfoOf<T> = EpochExecutionInfo<
<T as Config>::TrancheWeight,
<T as frame_system::Config>::BlockNumber,
<T as Config>::TrancheCurrency,
<T as Config>::MaxEpocExecutionTranches,
<T as Config>::MaxTranches,
>;

Expand Down Expand Up @@ -328,10 +327,6 @@ pub mod pallet {
#[pallet::constant]
type PoolDeposit: Get<Self::Balance>;

/// The maximum amount of execution tranches of an epoch.
#[pallet::constant]
type MaxEpocExecutionTranches: Get<u32> + scale_info::TypeInfo;

/// The origin permitted to create pools
type PoolCreateOrigin: EnsureOrigin<Self::Origin>;

Expand Down Expand Up @@ -938,7 +933,7 @@ pub mod pallet {
T::Rate,
_,
T::TrancheCurrency,
T::MaxEpocExecutionTranches,
T::MaxTranches,
>(&epoch.tranches, solution)
.map_err(|e| {
// In case we have an underflow in the calculation, there
Expand Down
3 changes: 2 additions & 1 deletion pallets/pool-system/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ parameter_types! {
/// The index with which this pallet is instantiated in this runtime.
pub PoolPalletIndex: u8 = <PoolSystem as PalletInfoAccess>::index() as u8;

#[derive(scale_info::TypeInfo, Eq, PartialEq, Debug, Clone, Copy )]
#[derive(scale_info::TypeInfo, Eq, PartialEq, PartialOrd, Debug, Clone, Copy )]
pub const MaxTranches: u32 = 5;

pub const MinUpdateDelay: u64 = 0; // no delay
Expand Down Expand Up @@ -370,6 +370,7 @@ impl PoolUpdateGuard for UpdateGuard {
TrancheWeight,
TrancheId,
u64,
MaxTranches,
>;
type ScheduledUpdateDetails =
ScheduledUpdateDetails<Rate, MaxTokenNameLength, MaxTokenSymbolLength, MaxTranches>;
Expand Down
Loading