Replace parameter_types with ConstU32 &c. (#10402)

* remove parameter types and use const type

* remove parameter types and use const type

* Delete {

* Delete count,

* refractor for beefy, benchmarking, child bounties, and collective pallets

* refractor for pallet contracts

* refractor for elections

* refractor for more pallets

* fix CI issues

* fix CI issues

* fix CI issues

* fix CI issues

* remove warning to fix CI issue

* remove warning to fix CI issue
refractor for pallet preimage

* remove warning to fix CI issue
refractor for pallet proxy

* remove warning to fix CI issue
refractor for pallet recovery
refractor for pallet randomness-collective-flip

* remove warning to fix CI issue
refractor for pallet scored-pool
refractor for pallet scheduler
refractor for pallet session

* remove warning to fix CI issue
refractor for pallet society, support, system, timestamp, tips

* remove warning to fix CI issue
refractor for pallet transaction_payment, transaction_storage, treasury, uniques, utility

* remove warning to fix CI issue

* cargo +nightly fmt

* CI fix

* more param refractor on beefy-mmr

* refractor for beefy

* Update frame/babe/src/mock.rs

* Update frame/babe/src/mock.rs

* Update frame/bounties/src/tests.rs

* Update frame/tips/src/tests.rs

* Delete mock.rs

* Update frame/examples/basic/src/tests.rs

* Apply suggestions from code review

* Update frame/im-online/src/mock.rs

* Update frame/im-online/src/mock.rs

* Update frame/offences/benchmarking/src/mock.rs

* Update frame/session/benchmarking/src/mock.rs

* Update frame/support/test/tests/pallet_compatibility.rs

* Update frame/support/test/tests/pallet_compatibility_instance.rs

* Update frame/treasury/src/tests.rs

* Update test-utils/runtime/src/lib.rs

* some cleanup

* fmt

* remove unused

Co-authored-by: Damilare <dakinlose@teamapt.com>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
dharjeezy
2021-12-16 04:06:11 +01:00
committed by GitHub
parent cf1eb73046
commit 1b0be8ae06
76 changed files with 629 additions and 966 deletions
@@ -24,8 +24,7 @@ use frame_support::{
PalletStorageMetadata, StorageEntryMetadata, StorageEntryModifier, StorageEntryType,
StorageHasher,
},
parameter_types,
traits::Get,
traits::{ConstU32, Get},
Parameter, StorageDoubleMap, StorageMap, StorageValue,
};
use scale_info::TypeInfo;
@@ -229,20 +228,16 @@ mod module3 {
}
}
parameter_types! {
pub const SomeValue: u32 = 100;
}
impl module1::Config<module1::Instance1> for Runtime {
type Event = Event;
type Origin = Origin;
type SomeParameter = SomeValue;
type SomeParameter = ConstU32<100>;
type GenericType = u32;
}
impl module1::Config<module1::Instance2> for Runtime {
type Event = Event;
type Origin = Origin;
type SomeParameter = SomeValue;
type SomeParameter = ConstU32<100>;
type GenericType = u32;
}
impl module2::Config for Runtime {
+6 -9
View File
@@ -19,8 +19,8 @@ use frame_support::{
dispatch::{Parameter, UnfilteredDispatchable},
storage::unhashed,
traits::{
GetCallName, GetStorageVersion, OnFinalize, OnGenesis, OnInitialize, OnRuntimeUpgrade,
PalletInfoAccess, StorageVersion,
ConstU32, GetCallName, GetStorageVersion, OnFinalize, OnGenesis, OnInitialize,
OnRuntimeUpgrade, PalletInfoAccess, StorageVersion,
},
weights::{DispatchClass, DispatchInfo, GetDispatchInfo, Pays, RuntimeDbWeight},
};
@@ -536,10 +536,7 @@ pub mod pallet4 {
}
frame_support::parameter_types!(
pub const MyGetParam: u32 = 10;
pub const MyGetParam2: u32 = 11;
pub const MyGetParam3: u32 = 12;
pub const BlockHashCount: u32 = 250;
);
impl frame_system::Config for Runtime {
@@ -554,7 +551,7 @@ impl frame_system::Config for Runtime {
type Lookup = sp_runtime::traits::IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU32<250>;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
@@ -566,12 +563,12 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
impl pallet::Config for Runtime {
type Event = Event;
type MyGetParam = MyGetParam;
type MyGetParam2 = MyGetParam2;
type MyGetParam = ConstU32<10>;
type MyGetParam2 = ConstU32<11>;
type MyGetParam3 = MyGetParam3;
type Balance = u64;
}
@@ -15,6 +15,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use frame_support::traits::{ConstU32, ConstU64};
pub trait SomeAssociation {
type A: frame_support::dispatch::Parameter + Default;
}
@@ -217,11 +219,6 @@ pub mod pallet {
}
}
frame_support::parameter_types!(
pub const SomeConst: u64 = 10;
pub const BlockHashCount: u32 = 250;
);
impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type Origin = Origin;
@@ -234,7 +231,7 @@ impl frame_system::Config for Runtime {
type Lookup = sp_runtime::traits::IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU32<250>;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
@@ -246,16 +243,16 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
impl pallet::Config for Runtime {
type Event = Event;
type SomeConst = SomeConst;
type SomeConst = ConstU64<10>;
type Balance = u64;
}
impl pallet_old::Config for Runtime {
type Event = Event;
type SomeConst = SomeConst;
type SomeConst = ConstU64<10>;
type Balance = u64;
}
@@ -15,6 +15,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use frame_support::traits::{ConstU32, ConstU64};
mod pallet_old {
use frame_support::{
decl_error, decl_event, decl_module, decl_storage, traits::Get, weights::Weight, Parameter,
@@ -197,11 +199,6 @@ pub mod pallet {
}
}
frame_support::parameter_types!(
pub const SomeConst: u64 = 10;
pub const BlockHashCount: u32 = 250;
);
impl frame_system::Config for Runtime {
type BlockWeights = ();
type BlockLength = ();
@@ -217,7 +214,7 @@ impl frame_system::Config for Runtime {
type Lookup = sp_runtime::traits::IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU32<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
@@ -226,36 +223,36 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
impl pallet::Config for Runtime {
type Event = Event;
type SomeConst = SomeConst;
type SomeConst = ConstU64<10>;
type Balance = u64;
}
impl pallet::Config<pallet::Instance2> for Runtime {
type Event = Event;
type SomeConst = SomeConst;
type SomeConst = ConstU64<10>;
type Balance = u64;
}
impl pallet::Config<pallet::Instance3> for Runtime {
type Event = Event;
type SomeConst = SomeConst;
type SomeConst = ConstU64<10>;
type Balance = u64;
}
impl pallet_old::Config for Runtime {
type Event = Event;
type SomeConst = SomeConst;
type SomeConst = ConstU64<10>;
type Balance = u64;
}
impl pallet_old::Config<pallet_old::Instance2> for Runtime {
type Event = Event;
type SomeConst = SomeConst;
type SomeConst = ConstU64<10>;
type Balance = u64;
}
impl pallet_old::Config<pallet_old::Instance3> for Runtime {
type Event = Event;
type SomeConst = SomeConst;
type SomeConst = ConstU64<10>;
type Balance = u64;
}
@@ -18,7 +18,7 @@
use frame_support::{
dispatch::UnfilteredDispatchable,
storage::unhashed,
traits::{GetCallName, OnFinalize, OnGenesis, OnInitialize, OnRuntimeUpgrade},
traits::{ConstU32, GetCallName, OnFinalize, OnGenesis, OnInitialize, OnRuntimeUpgrade},
weights::{DispatchClass, DispatchInfo, GetDispatchInfo, Pays},
};
use sp_io::{
@@ -245,11 +245,6 @@ pub mod pallet2 {
}
}
frame_support::parameter_types!(
pub const MyGetParam: u32 = 10;
pub const BlockHashCount: u32 = 250;
);
impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type Origin = Origin;
@@ -262,7 +257,7 @@ impl frame_system::Config for Runtime {
type Lookup = sp_runtime::traits::IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU32<250>;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
@@ -274,16 +269,16 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
impl pallet::Config for Runtime {
type Event = Event;
type MyGetParam = MyGetParam;
type MyGetParam = ConstU32<10>;
type Balance = u64;
}
impl pallet::Config<pallet::Instance1> for Runtime {
type Event = Event;
type MyGetParam = MyGetParam;
type MyGetParam = ConstU32<10>;
type Balance = u64;
}
impl pallet2::Config for Runtime {
@@ -97,7 +97,7 @@ impl<T: Trait> frame_support::inherent::ProvideInherent for Module<T> {
mod tests {
use crate as pallet_test;
use frame_support::parameter_types;
use frame_support::traits::ConstU64;
type SignedExtra = (
frame_system::CheckEra<Runtime>,
@@ -124,10 +124,6 @@ mod tests {
}
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
}
impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type Origin = Origin;
@@ -140,7 +136,7 @@ mod tests {
type Lookup = sp_runtime::traits::IdentityLookup<Self::AccountId>;
type Header = TestHeader;
type Event = ();
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type DbWeight = ();
type BlockWeights = ();
type BlockLength = ();