diff --git a/cumulus/parachains/pallets/collective-content/src/tests.rs b/cumulus/parachains/pallets/collective-content/src/tests.rs index 4910b30b89af..7fee5eea101d 100644 --- a/cumulus/parachains/pallets/collective-content/src/tests.rs +++ b/cumulus/parachains/pallets/collective-content/src/tests.rs @@ -16,7 +16,8 @@ //! Tests. use super::{mock::*, *}; -use frame_support::{assert_noop, assert_ok, error::BadOrigin, pallet_prelude::Pays}; +use frame_support::{assert_noop, assert_ok, pallet_prelude::Pays}; +use sp_runtime::traits::BadOrigin; /// returns CID hash of 68 bytes of given `i`. fn create_cid(i: u8) -> OpaqueCid { diff --git a/polkadot/runtime/common/src/paras_registrar/mod.rs b/polkadot/runtime/common/src/paras_registrar/mod.rs index f2751803a413..6a076ceaf94e 100644 --- a/polkadot/runtime/common/src/paras_registrar/mod.rs +++ b/polkadot/runtime/common/src/paras_registrar/mod.rs @@ -699,9 +699,7 @@ mod tests { mock::conclude_pvf_checking, paras_registrar, traits::Registrar as RegistrarTrait, }; use frame_support::{ - assert_noop, assert_ok, - error::BadOrigin, - parameter_types, + assert_noop, assert_ok, parameter_types, traits::{ConstU32, OnFinalize, OnInitialize}, }; use frame_system::limits; @@ -712,7 +710,7 @@ mod tests { use sp_io::TestExternalities; use sp_keyring::Sr25519Keyring; use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, + traits::{BadOrigin, BlakeTwo256, IdentityLookup}, transaction_validity::TransactionPriority, BuildStorage, Perbill, }; diff --git a/polkadot/runtime/parachains/src/assigner_on_demand/tests.rs b/polkadot/runtime/parachains/src/assigner_on_demand/tests.rs index d07964b69165..543d716def84 100644 --- a/polkadot/runtime/parachains/src/assigner_on_demand/tests.rs +++ b/polkadot/runtime/parachains/src/assigner_on_demand/tests.rs @@ -26,9 +26,10 @@ use crate::{ paras::{ParaGenesisArgs, ParaKind}, scheduler::common::Assignment, }; -use frame_support::{assert_noop, assert_ok, error::BadOrigin}; +use frame_support::{assert_noop, assert_ok}; use pallet_balances::Error as BalancesError; use primitives::{BlockNumber, SessionIndex, ValidationCode}; +use sp_runtime::traits::BadOrigin; use sp_std::collections::btree_map::BTreeMap; fn schedule_blank_para(id: ParaId, parakind: ParaKind) { diff --git a/substrate/frame/alliance/src/tests.rs b/substrate/frame/alliance/src/tests.rs index 098fd86bbae1..30ed7bb18603 100644 --- a/substrate/frame/alliance/src/tests.rs +++ b/substrate/frame/alliance/src/tests.rs @@ -17,8 +17,9 @@ //! Tests for the alliance pallet. -use frame_support::{assert_noop, assert_ok, error::BadOrigin}; +use frame_support::{assert_noop, assert_ok}; use frame_system::{EventRecord, Phase}; +use sp_runtime::traits::BadOrigin; use super::*; use crate::mock::*; diff --git a/substrate/frame/contracts/src/lib.rs b/substrate/frame/contracts/src/lib.rs index 7d516fbe2496..d731cdb07af9 100644 --- a/substrate/frame/contracts/src/lib.rs +++ b/substrate/frame/contracts/src/lib.rs @@ -115,7 +115,6 @@ use environmental::*; use frame_support::{ dispatch::{GetDispatchInfo, Pays, PostDispatchInfo, RawOrigin, WithPostDispatchInfo}, ensure, - error::BadOrigin, traits::{ fungible::{Inspect, Mutate, MutateHold}, ConstU32, Contains, Get, Randomness, Time, @@ -136,7 +135,7 @@ use pallet_contracts_primitives::{ use scale_info::TypeInfo; use smallvec::Array; use sp_runtime::{ - traits::{Convert, Dispatchable, Hash, Saturating, StaticLookup, Zero}, + traits::{BadOrigin, Convert, Dispatchable, Hash, Saturating, StaticLookup, Zero}, DispatchError, RuntimeDebug, }; use sp_std::{fmt::Debug, prelude::*}; diff --git a/substrate/frame/democracy/src/lib.rs b/substrate/frame/democracy/src/lib.rs index 089556191cd1..5d59b5fa7fb5 100644 --- a/substrate/frame/democracy/src/lib.rs +++ b/substrate/frame/democracy/src/lib.rs @@ -155,7 +155,6 @@ use codec::{Decode, Encode}; use frame_support::{ ensure, - error::BadOrigin, traits::{ defensive_prelude::*, schedule::{v3::Named as ScheduleNamed, DispatchTime}, @@ -166,7 +165,7 @@ use frame_support::{ }; use frame_system::pallet_prelude::{BlockNumberFor, OriginFor}; use sp_runtime::{ - traits::{Bounded as ArithBounded, One, Saturating, StaticLookup, Zero}, + traits::{BadOrigin, Bounded as ArithBounded, One, Saturating, StaticLookup, Zero}, ArithmeticError, DispatchError, DispatchResult, }; use sp_std::prelude::*; diff --git a/substrate/frame/nomination-pools/src/lib.rs b/substrate/frame/nomination-pools/src/lib.rs index 909a930e3821..6f7e924ed309 100644 --- a/substrate/frame/nomination-pools/src/lib.rs +++ b/substrate/frame/nomination-pools/src/lib.rs @@ -2519,7 +2519,7 @@ pub mod pallet { ) -> DispatchResult { let mut bonded_pool = match ensure_root(origin.clone()) { Ok(()) => BondedPool::::get(pool_id).ok_or(Error::::PoolNotFound)?, - Err(frame_support::error::BadOrigin) => { + Err(sp_runtime::traits::BadOrigin) => { let who = ensure_signed(origin)?; let bonded_pool = BondedPool::::get(pool_id).ok_or(Error::::PoolNotFound)?; diff --git a/substrate/frame/ranked-collective/src/tests.rs b/substrate/frame/ranked-collective/src/tests.rs index ba8c5a0f937b..61772b82aa97 100644 --- a/substrate/frame/ranked-collective/src/tests.rs +++ b/substrate/frame/ranked-collective/src/tests.rs @@ -20,14 +20,12 @@ use std::collections::BTreeMap; use frame_support::{ - assert_noop, assert_ok, - error::BadOrigin, - parameter_types, + assert_noop, assert_ok, parameter_types, traits::{ConstU16, ConstU32, ConstU64, EitherOf, Everything, MapSuccess, Polling}, }; use sp_core::{Get, H256}; use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup, ReduceBy}, + traits::{BadOrigin, BlakeTwo256, IdentityLookup, ReduceBy}, BuildStorage, }; diff --git a/substrate/frame/support/src/lib.rs b/substrate/frame/support/src/lib.rs index 8c4b3de49b5d..61afc94019d7 100644 --- a/substrate/frame/support/src/lib.rs +++ b/substrate/frame/support/src/lib.rs @@ -2264,12 +2264,6 @@ pub mod pallet_macros { pub use frame_support_procedural::genesis_build; } -#[deprecated(note = "Will be removed after July 2023; Use `sp_runtime::traits` directly instead.")] -pub mod error { - #[doc(hidden)] - pub use sp_runtime::traits::{BadOrigin, LookupError}; -} - #[doc(inline)] pub use frame_support_procedural::register_default_impl; diff --git a/substrate/frame/support/src/storage/migration.rs b/substrate/frame/support/src/storage/migration.rs index 568c475bdc69..3d51846b4dda 100644 --- a/substrate/frame/support/src/storage/migration.rs +++ b/substrate/frame/support/src/storage/migration.rs @@ -27,140 +27,6 @@ use sp_std::prelude::*; use super::PrefixIterator; -/// Utility to iterate through raw items in storage. -pub struct StorageIterator { - prefix: Vec, - previous_key: Vec, - drain: bool, - _phantom: ::sp_std::marker::PhantomData, -} - -impl StorageIterator { - /// Construct iterator to iterate over map items in `module` for the map called `item`. - #[deprecated(note = "Will be removed after July 2023; Please use the storage_iter or \ - storage_iter_with_suffix functions instead")] - pub fn new(module: &[u8], item: &[u8]) -> Self { - #[allow(deprecated)] - Self::with_suffix(module, item, &[][..]) - } - - /// Construct iterator to iterate over map items in `module` for the map called `item`. - #[deprecated(note = "Will be removed after July 2023; Please use the storage_iter or \ - storage_iter_with_suffix functions instead")] - pub fn with_suffix(module: &[u8], item: &[u8], suffix: &[u8]) -> Self { - let mut prefix = Vec::new(); - let storage_prefix = storage_prefix(module, item); - prefix.extend_from_slice(&storage_prefix); - prefix.extend_from_slice(suffix); - let previous_key = prefix.clone(); - Self { prefix, previous_key, drain: false, _phantom: Default::default() } - } - - /// Mutate this iterator into a draining iterator; items iterated are removed from storage. - pub fn drain(mut self) -> Self { - self.drain = true; - self - } -} - -impl Iterator for StorageIterator { - type Item = (Vec, T); - - fn next(&mut self) -> Option<(Vec, T)> { - loop { - let maybe_next = sp_io::storage::next_key(&self.previous_key) - .filter(|n| n.starts_with(&self.prefix)); - break match maybe_next { - Some(next) => { - self.previous_key = next.clone(); - let maybe_value = frame_support::storage::unhashed::get::(&next); - match maybe_value { - Some(value) => { - if self.drain { - frame_support::storage::unhashed::kill(&next); - } - Some((self.previous_key[self.prefix.len()..].to_vec(), value)) - }, - None => continue, - } - }, - None => None, - } - } - } -} - -/// Utility to iterate through raw items in storage. -pub struct StorageKeyIterator { - prefix: Vec, - previous_key: Vec, - drain: bool, - _phantom: ::sp_std::marker::PhantomData<(K, T, H)>, -} - -impl StorageKeyIterator { - /// Construct iterator to iterate over map items in `module` for the map called `item`. - #[deprecated(note = "Will be removed after July 2023; Please use the storage_key_iter or \ - storage_key_iter_with_suffix functions instead")] - pub fn new(module: &[u8], item: &[u8]) -> Self { - #[allow(deprecated)] - Self::with_suffix(module, item, &[][..]) - } - - /// Construct iterator to iterate over map items in `module` for the map called `item`. - #[deprecated(note = "Will be removed after July 2023; Please use the storage_key_iter or \ - storage_key_iter_with_suffix functions instead")] - pub fn with_suffix(module: &[u8], item: &[u8], suffix: &[u8]) -> Self { - let mut prefix = Vec::new(); - let storage_prefix = storage_prefix(module, item); - prefix.extend_from_slice(&storage_prefix); - prefix.extend_from_slice(suffix); - let previous_key = prefix.clone(); - Self { prefix, previous_key, drain: false, _phantom: Default::default() } - } - - /// Mutate this iterator into a draining iterator; items iterated are removed from storage. - pub fn drain(mut self) -> Self { - self.drain = true; - self - } -} - -impl Iterator - for StorageKeyIterator -{ - type Item = (K, T); - - fn next(&mut self) -> Option<(K, T)> { - loop { - let maybe_next = sp_io::storage::next_key(&self.previous_key) - .filter(|n| n.starts_with(&self.prefix)); - break match maybe_next { - Some(next) => { - self.previous_key = next.clone(); - let mut key_material = H::reverse(&next[self.prefix.len()..]); - match K::decode(&mut key_material) { - Ok(key) => { - let maybe_value = frame_support::storage::unhashed::get::(&next); - match maybe_value { - Some(value) => { - if self.drain { - frame_support::storage::unhashed::kill(&next); - } - Some((key, value)) - }, - None => continue, - } - }, - Err(_) => continue, - } - }, - None => None, - } - } - } -} - /// Construct iterator to iterate over map items in `module` for the map called `item`. pub fn storage_iter(module: &[u8], item: &[u8]) -> PrefixIterator<(Vec, T)> { storage_iter_with_suffix(module, item, &[][..]) @@ -254,11 +120,7 @@ pub fn put_storage_value(module: &[u8], item: &[u8], hash: &[u8], val /// `hash`. #[deprecated = "Use `clear_storage_prefix` instead"] pub fn remove_storage_prefix(module: &[u8], item: &[u8], hash: &[u8]) { - let mut key = vec![0u8; 32 + hash.len()]; - let storage_prefix = storage_prefix(module, item); - key[0..32].copy_from_slice(&storage_prefix); - key[32..].copy_from_slice(hash); - let _ = frame_support::storage::unhashed::clear_prefix(&key, None, None); + let _ = clear_storage_prefix(module, item, hash, None, None); } /// Attempt to remove all values under a storage prefix by the `module`, the map's `item` name and @@ -288,7 +150,7 @@ pub fn clear_storage_prefix( let storage_prefix = storage_prefix(module, item); key[0..32].copy_from_slice(&storage_prefix); key[32..].copy_from_slice(hash); - frame_support::storage::unhashed::clear_prefix(&key, maybe_limit, maybe_cursor) + unhashed::clear_prefix(&key, maybe_limit, maybe_cursor) } /// Take a particular item in storage by the `module`, the map's `item` name and the key `hash`. diff --git a/substrate/frame/support/src/traits.rs b/substrate/frame/support/src/traits.rs index 2179ee38f848..448ccdb0b346 100644 --- a/substrate/frame/support/src/traits.rs +++ b/substrate/frame/support/src/traits.rs @@ -31,8 +31,6 @@ pub use tokens::{ }; mod members; -#[allow(deprecated)] -pub use members::{AllowAll, DenyAll, Filter}; pub use members::{ AsContains, ChangeMembers, Contains, ContainsLengthBound, ContainsPair, Everything, EverythingBut, FromContainsPair, InitializeMembers, InsideBoth, IsInVec, Nothing, diff --git a/substrate/frame/support/src/traits/members.rs b/substrate/frame/support/src/traits/members.rs index fbba742ebeb4..480d478dd3d7 100644 --- a/substrate/frame/support/src/traits/members.rs +++ b/substrate/frame/support/src/traits/members.rs @@ -172,29 +172,6 @@ macro_rules! match_types { () => {} } -/// Create a type which implements the `Contains` trait for a particular type with syntax similar -/// to `matches!`. -#[macro_export] -#[deprecated = "Use `match_types!` instead"] -macro_rules! match_type { - ($( $x:tt )*) => { $crate::match_types!( $( $x )* ); } -} - -#[deprecated = "Use `Everything` instead"] -pub type AllowAll = Everything; -#[deprecated = "Use `Nothing` instead"] -pub type DenyAll = Nothing; -#[deprecated = "Use `Contains` instead"] -pub trait Filter { - fn filter(t: &T) -> bool; -} -#[allow(deprecated)] -impl> Filter for C { - fn filter(t: &T) -> bool { - Self::contains(t) - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/substrate/frame/system/src/lib.rs b/substrate/frame/system/src/lib.rs index 84b6dc031457..488fe76fe74e 100644 --- a/substrate/frame/system/src/lib.rs +++ b/substrate/frame/system/src/lib.rs @@ -1065,31 +1065,6 @@ impl Pallet { Ok(()) } - /// Increment the reference counter on an account. - #[deprecated = "Use `inc_consumers` instead"] - pub fn inc_ref(who: &T::AccountId) { - let _ = Self::inc_consumers(who); - } - - /// Decrement the reference counter on an account. This *MUST* only be done once for every time - /// you called `inc_consumers` on `who`. - #[deprecated = "Use `dec_consumers` instead"] - pub fn dec_ref(who: &T::AccountId) { - let _ = Self::dec_consumers(who); - } - - /// The number of outstanding references for the account `who`. - #[deprecated = "Use `consumers` instead"] - pub fn refs(who: &T::AccountId) -> RefCount { - Self::consumers(who) - } - - /// True if the account has no outstanding references. - #[deprecated = "Use `!is_provider_required` instead"] - pub fn allow_death(who: &T::AccountId) -> bool { - !Self::is_provider_required(who) - } - /// Increment the provider reference counter on an account. pub fn inc_providers(who: &T::AccountId) -> IncRefStatus { Account::::mutate(who, |a| { @@ -1514,7 +1489,7 @@ impl Pallet { /// Should only be called if you know what you are doing and outside of the runtime block /// execution else it can have a large impact on the PoV size of a block. pub fn read_events_no_consensus( - ) -> impl sp_std::iter::Iterator>> { + ) -> impl Iterator>> { Events::::stream_iter() } diff --git a/substrate/frame/utility/src/tests.rs b/substrate/frame/utility/src/tests.rs index 183853c4e8ac..d1d10a06965d 100644 --- a/substrate/frame/utility/src/tests.rs +++ b/substrate/frame/utility/src/tests.rs @@ -25,7 +25,6 @@ use crate as utility; use frame_support::{ assert_err_ignore_postinfo, assert_noop, assert_ok, dispatch::{DispatchErrorWithPostInfo, Pays}, - error::BadOrigin, parameter_types, storage, traits::{ConstU32, ConstU64, Contains}, weights::Weight, @@ -33,7 +32,7 @@ use frame_support::{ use pallet_collective::{EnsureProportionAtLeast, Instance1}; use sp_core::H256; use sp_runtime::{ - traits::{BlakeTwo256, Dispatchable, Hash, IdentityLookup}, + traits::{BadOrigin, BlakeTwo256, Dispatchable, Hash, IdentityLookup}, BuildStorage, DispatchError, TokenError, }; diff --git a/substrate/primitives/arithmetic/src/per_things.rs b/substrate/primitives/arithmetic/src/per_things.rs index fe88b72e24c2..9d59a5cbe250 100644 --- a/substrate/primitives/arithmetic/src/per_things.rs +++ b/substrate/primitives/arithmetic/src/per_things.rs @@ -310,13 +310,6 @@ pub trait PerThing: #[cfg(feature = "std")] fn from_float(x: f64) -> Self; - /// Same as `Self::from_float`. - #[deprecated = "Use from_float instead"] - #[cfg(feature = "std")] - fn from_fraction(x: f64) -> Self { - Self::from_float(x) - } - /// Approximate the fraction `p/q` into a per-thing fraction. This will never overflow. /// /// The computation of this approximation is performed in the generic type `N`. Given @@ -401,16 +394,6 @@ pub trait PerThing: where N: RationalArg + TryInto + TryInto, Self::Inner: Into; - - /// Same as `Self::from_rational`. - #[deprecated = "Use from_rational instead"] - fn from_rational_approximation(p: N, q: N) -> Self - where - N: RationalArg + TryInto + TryInto, - Self::Inner: Into, - { - Self::from_rational(p, q) - } } /// The rounding method to use for unsigned quantities. @@ -727,16 +710,6 @@ macro_rules! implement_per_thing { ::from_float(x) } - /// See [`PerThing::from_rational`]. - #[deprecated = "Use `PerThing::from_rational` instead"] - pub fn from_rational_approximation(p: N, q: N) -> Self - where - N: RationalArg+ TryInto<$type> + TryInto<$upper_type>, - $type: Into - { - ::from_rational(p, q) - } - /// See [`PerThing::from_rational`]. pub fn from_rational(p: N, q: N) -> Self where