Skip to content

Refactor/paramter types #725

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

Merged
merged 3 commits into from
Apr 5, 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
13 changes: 6 additions & 7 deletions auction/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
#![cfg(test)]

use super::*;
use frame_support::{construct_runtime, parameter_types, traits::Everything};
use frame_support::{
construct_runtime,
traits::{ConstU64, Everything},
};
use orml_traits::OnNewBidResult;
use sp_core::H256;
use sp_runtime::{testing::Header, traits::IdentityLookup};

use crate as auction;

parameter_types! {
pub const BlockHashCount: u64 = 250;
}

pub type AccountId = u128;
pub type Balance = u64;
pub type BlockNumber = u64;
Expand All @@ -30,7 +29,7 @@ impl frame_system::Config for Runtime {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type BlockWeights = ();
type BlockLength = ();
type Version = ();
Expand All @@ -43,7 +42,7 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}

pub struct Handler;
Expand Down
7 changes: 3 additions & 4 deletions authority/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::*;
use codec::{Decode, Encode};
use frame_support::{
parameter_types,
traits::{EqualPrivilegeOnly, Everything},
traits::{ConstU64, EqualPrivilegeOnly, Everything},
weights::Weight,
};
use frame_system::{ensure_root, ensure_signed, EnsureRoot};
Expand All @@ -23,7 +23,6 @@ pub type AccountId = u128;
pub type BlockNumber = u64;

parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(2_000_000_000_000);
}
Expand All @@ -39,7 +38,7 @@ impl frame_system::Config for Runtime {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type BlockWeights = ();
type BlockLength = ();
type Version = ();
Expand All @@ -52,7 +51,7 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}

parameter_types! {
Expand Down
2 changes: 1 addition & 1 deletion bencher/test/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}

impl crate::pallet::Config for Runtime {}
Expand Down
7 changes: 5 additions & 2 deletions benchmarking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

use super::*;
use frame_benchmarking::account;
use frame_support::{assert_err, assert_ok, construct_runtime, ensure, traits::Everything};
use frame_support::{
assert_err, assert_ok, construct_runtime, ensure,
traits::{ConstU32, Everything},
};
use frame_system::RawOrigin;
use sp_runtime::{
testing::{Header, H256},
Expand Down Expand Up @@ -72,7 +75,7 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}

impl Config for Test {}
Expand Down
19 changes: 5 additions & 14 deletions currencies/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use super::*;
use frame_support::{
construct_runtime, parameter_types,
traits::{Everything, Nothing},
traits::{ConstU32, ConstU64, Everything, Nothing},
PalletId,
};
use orml_traits::parameter_type_with_key;
Expand All @@ -18,10 +18,6 @@ use sp_runtime::{

use crate as currencies;

parameter_types! {
pub const BlockHashCount: u64 = 250;
}

pub type AccountId = AccountId32;
impl frame_system::Config for Runtime {
type Origin = Origin;
Expand All @@ -34,7 +30,7 @@ impl frame_system::Config for Runtime {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type BlockWeights = ();
type BlockLength = ();
type Version = ();
Expand All @@ -47,21 +43,17 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}

type CurrencyId = u32;
type Balance = u64;

parameter_types! {
pub const ExistentialDeposit: u64 = 2;
}

impl pallet_balances::Config for Runtime {
type Balance = Balance;
type DustRemoval = ();
type Event = Event;
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<2>;
type AccountStore = frame_system::Pallet<Runtime>;
type MaxLocks = ();
type MaxReserves = ();
Expand All @@ -77,7 +69,6 @@ parameter_type_with_key! {

parameter_types! {
pub DustAccount: AccountId = PalletId(*b"orml/dst").into_account();
pub MaxLocks: u32 = 100_000;
}

impl orml_tokens::Config for Runtime {
Expand All @@ -88,7 +79,7 @@ impl orml_tokens::Config for Runtime {
type WeightInfo = ();
type ExistentialDeposits = ExistentialDeposits;
type OnDust = orml_tokens::TransferDust<Runtime, DustAccount>;
type MaxLocks = MaxLocks;
type MaxLocks = ConstU32<100_000>;
type DustRemovalWhitelist = Nothing;
}

Expand Down
28 changes: 10 additions & 18 deletions gradually-update/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
#![cfg(test)]

use super::*;
use frame_support::{construct_runtime, parameter_types, traits::Everything};
use frame_support::{
construct_runtime,
traits::{ConstU32, ConstU64, Everything},
};
use sp_core::H256;
use sp_runtime::{testing::Header, traits::IdentityLookup};

use crate as gradually_update;

parameter_types! {
pub const BlockHashCount: u64 = 250;
}

pub type AccountId = u128;
pub type BlockNumber = u64;

Expand All @@ -27,7 +26,7 @@ impl frame_system::Config for Runtime {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type BlockWeights = ();
type BlockLength = ();
type Version = ();
Expand All @@ -40,24 +39,17 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}

parameter_types! {
pub const UpdateFrequency: BlockNumber = 10;
pub MaxGraduallyUpdate: u32 = 3;
pub MaxStorageKeyBytes: u32 = 100_000;
pub MaxStorageValueBytes: u32 = 100_000;
type MaxConsumers = ConstU32<16>;
}

impl Config for Runtime {
type Event = Event;
type UpdateFrequency = UpdateFrequency;
type UpdateFrequency = ConstU64<10>;
type DispatchOrigin = frame_system::EnsureRoot<AccountId>;
type WeightInfo = ();
type MaxGraduallyUpdate = MaxGraduallyUpdate;
type MaxStorageKeyBytes = MaxStorageKeyBytes;
type MaxStorageValueBytes = MaxStorageValueBytes;
type MaxGraduallyUpdate = ConstU32<3>;
type MaxStorageKeyBytes = ConstU32<100_000>;
type MaxStorageValueBytes = ConstU32<100_000>;
}

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Runtime>;
Expand Down
22 changes: 8 additions & 14 deletions nft/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

#![cfg(test)]

use frame_support::{construct_runtime, parameter_types, traits::Everything};
use frame_support::{
construct_runtime,
traits::{ConstU32, ConstU64, Everything},
};
use sp_core::H256;
use sp_runtime::{testing::Header, traits::IdentityLookup};

use super::*;

use crate as nft;

parameter_types! {
pub const BlockHashCount: u64 = 250;
}

pub type AccountId = u128;
pub type BlockNumber = u64;

Expand All @@ -28,7 +27,7 @@ impl frame_system::Config for Runtime {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type BlockWeights = ();
type BlockLength = ();
type Version = ();
Expand All @@ -41,21 +40,16 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}

parameter_types! {
pub const MaxClassMetadata: u32 = 1;
pub const MaxTokenMetadata: u32 = 1;
type MaxConsumers = ConstU32<16>;
}

impl Config for Runtime {
type ClassId = u64;
type TokenId = u64;
type ClassData = ();
type TokenData = ();
type MaxClassMetadata = MaxClassMetadata;
type MaxTokenMetadata = MaxTokenMetadata;
type MaxClassMetadata = ConstU32<1>;
type MaxTokenMetadata = ConstU32<1>;
}

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Runtime>;
Expand Down
19 changes: 5 additions & 14 deletions oracle/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::*;

use frame_support::{
construct_runtime, parameter_types,
traits::{Everything, SortedMembers},
traits::{ConstU32, ConstU64, Everything, SortedMembers},
};
use sp_core::H256;
use sp_runtime::{
Expand All @@ -22,9 +22,6 @@ pub type AccountId = u128;
type Key = u32;
type Value = u32;

parameter_types! {
pub const BlockHashCount: u64 = 250;
}
impl frame_system::Config for Test {
type Origin = Origin;
type Call = Call;
Expand All @@ -36,7 +33,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type BlockWeights = ();
type BlockLength = ();
type Version = ();
Expand All @@ -49,7 +46,7 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}

thread_local! {
Expand All @@ -72,8 +69,6 @@ impl Timestamp {
}

parameter_types! {
pub const MinimumCount: u32 = 3;
pub const ExpiresIn: u32 = 600;
pub const RootOperatorAccountId: AccountId = 4;
pub static OracleMembers: Vec<AccountId> = vec![1, 2, 3];
}
Expand All @@ -86,21 +81,17 @@ impl SortedMembers<AccountId> for Members {
}
}

parameter_types! {
pub const MaxHasDispatchedSize: u32 = 100;
}

impl Config for Test {
type Event = Event;
type OnNewData = ();
type CombineData = DefaultCombineData<Self, MinimumCount, ExpiresIn>;
type CombineData = DefaultCombineData<Self, ConstU32<3>, ConstU32<600>>;
type Time = Timestamp;
type OracleKey = Key;
type OracleValue = Value;
type RootOperatorAccountId = RootOperatorAccountId;
type Members = Members;
type WeightInfo = ();
type MaxHasDispatchedSize = MaxHasDispatchedSize;
type MaxHasDispatchedSize = ConstU32<100>;
}

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
Expand Down
Loading