diff --git a/pallet/account-migration/src/lib.rs b/pallet/account-migration/src/lib.rs index a4810d202..cebaa79c5 100644 --- a/pallet/account-migration/src/lib.rs +++ b/pallet/account-migration/src/lib.rs @@ -177,11 +177,7 @@ pub mod pallet { let wt = T::DbWeight::get().writes(1); let mut consumer = >::iter().drain(); - for i in 0..MAX_TASKS { - if i >= MAX_TASKS { - break; - } - + for _ in 0..MAX_TASKS { if let Some(rw) = remaining_weight.checked_sub(&wt) { remaining_weight = rw; } else { diff --git a/pallet/staking/src/lib.rs b/pallet/staking/src/lib.rs index 3a53e3c5f..057f24adb 100644 --- a/pallet/staking/src/lib.rs +++ b/pallet/staking/src/lib.rs @@ -429,11 +429,7 @@ pub mod pallet { let wt = T::WeightInfo::allocate_ring_staking_reward_of(); let mut consumer = >::iter().drain(); - for i in 0..MAX_TASKS { - if i >= MAX_TASKS { - break; - } - + for _ in 0..MAX_TASKS { if let Some(rw) = remaining_weight.checked_sub(&wt) { *remaining_weight = rw; } else { @@ -459,11 +455,7 @@ pub mod pallet { let wt = T::WeightInfo::unstake_all_for(); let mut consumer = >::iter().drain(); - for i in 0..MAX_TASKS { - if i >= MAX_TASKS { - break; - } - + for _ in 0..MAX_TASKS { if let Some(rw) = remaining_weight.checked_sub(&wt) { *remaining_weight = rw; } else { diff --git a/runtime/common/src/gov_origin.rs b/runtime/common/src/gov_origin.rs index 7be481c86..77c77e249 100644 --- a/runtime/common/src/gov_origin.rs +++ b/runtime/common/src/gov_origin.rs @@ -21,8 +21,6 @@ pub use frame_support::{ traits::{EitherOf, EitherOfDiverse, EnsureOrigin, Get}, }; -// core -use core::marker::PhantomData; // darwinia use dc_primitives::AccountId; // frontier @@ -61,27 +59,3 @@ pub const ROOT: AccountId20 = pub const KTON_ADMIN: AccountId20 = AccountId20([ 70, 39, 93, 41, 17, 63, 6, 92, 42, 172, 38, 47, 52, 199, 163, 216, 168, 183, 55, 125, ]); - -/// Ensure the origin is RingDAO. -pub struct RingDao(PhantomData) -where - RingDaoAccount: Get; -impl EnsureOrigin for RingDao -where - O: Into, O>> + From>, - RingDaoAccount: Get, -{ - type Success = (); - - fn try_origin(o: O) -> Result { - o.into().and_then(|o| match o { - RawOrigin::Signed(who) if who == RingDaoAccount::get() => Ok(()), - r => Err(O::from(r)), - }) - } - - #[cfg(feature = "runtime-benchmarks")] - fn try_successful_origin() -> Result { - Ok(O::from(RawOrigin::Root)) - } -} diff --git a/runtime/koi/src/pallets/governance.rs b/runtime/koi/src/pallets/governance.rs index d24bb6cc5..9d222f422 100644 --- a/runtime/koi/src/pallets/governance.rs +++ b/runtime/koi/src/pallets/governance.rs @@ -80,16 +80,20 @@ impl pallet_referenda::Config for Runtime { impl custom_origins::Config for Runtime {} -frame_support::parameter_types! { +frame_support::ord_parameter_types! { // 0x005493b5658e6201F06FE2adF492610635505F4C. - pub RingDaoAccount: AccountId = [0, 84, 147, 181, 101, 142, 98, 1, 240, 111, 226, 173, 244, 146, 97, 6, 53, 80, 95, 76].into(); + pub const RingDaoAccount: AccountId = AccountId::from([0, 84, 147, 181, 101, 142, 98, 1, 240, 111, 226, 173, 244, 146, 97, 6, 53, 80, 95, 76]); } // The purpose of this pallet is to queue calls to be dispatched as by root later => the Dispatch // origin corresponds to the Gov2 Whitelist track. impl pallet_whitelist::Config for Runtime { - type DispatchWhitelistedOrigin = - RootOr>>; + type DispatchWhitelistedOrigin = RootOrDiverse< + frame_support::traits::EitherOfDiverse< + WhitelistedCaller, + frame_system::EnsureSignedBy, + >, + >; type Preimages = Preimage; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent;