Remove Filter and use Contains instead (#9514)

* Remove Filter and use Contains instead

* Fixes

* Formatting

* Update docs/Upgrading-2.0-to-3.0.md

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Typo

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
Gavin Wood
2021-08-07 21:26:40 +02:00
committed by GitHub
parent e251d1cedb
commit bdda3ed612
79 changed files with 199 additions and 199 deletions
+2 -2
View File
@@ -26,7 +26,7 @@ use frame_support::{
dispatch::{DispatchError, DispatchResult, DispatchResultWithPostInfo, Dispatchable},
ensure,
storage::{with_transaction, TransactionOutcome},
traits::{Currency, ExistenceRequirement, Filter, Get, OriginTrait, Randomness, Time},
traits::{Contains, Currency, ExistenceRequirement, Get, OriginTrait, Randomness, Time},
weights::Weight,
DefaultNoBound,
};
@@ -1255,7 +1255,7 @@ where
fn call_runtime(&self, call: <Self::T as Config>::Call) -> DispatchResultWithPostInfo {
let mut origin: T::Origin = RawOrigin::Signed(self.address().clone()).into();
origin.add_filter(T::CallFilter::filter);
origin.add_filter(T::CallFilter::contains);
call.dispatch(origin)
}
}
+2 -2
View File
@@ -111,7 +111,7 @@ use crate::{
};
use frame_support::{
dispatch::Dispatchable,
traits::{Currency, Filter, Get, OnUnbalanced, Randomness, StorageVersion, Time},
traits::{Contains, Currency, Get, OnUnbalanced, Randomness, StorageVersion, Time},
weights::{GetDispatchInfo, PostDispatchInfo, Weight, WithPostDispatchInfo},
};
use frame_system::Pallet as System;
@@ -189,7 +189,7 @@ pub mod pallet {
/// Therefore please make sure to be restrictive about which dispatchables are allowed
/// in order to not introduce a new DoS vector like memory allocation patterns that can
/// be exploited to drive the runtime into a panic.
type CallFilter: Filter<<Self as frame_system::Config>::Call>;
type CallFilter: Contains<<Self as frame_system::Config>::Call>;
/// Handler for rent payments.
type RentPayment: OnUnbalanced<NegativeImbalanceOf<Self>>;
+4 -4
View File
@@ -33,7 +33,7 @@ use frame_support::{
dispatch::DispatchErrorWithPostInfo,
parameter_types,
storage::child,
traits::{Currency, Filter, OnInitialize, ReservableCurrency},
traits::{Contains, Currency, OnInitialize, ReservableCurrency},
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, PostDispatchInfo, Weight},
};
use frame_system::{self as system, EventRecord, Phase};
@@ -197,7 +197,7 @@ parameter_types! {
pub static ExistentialDeposit: u64 = 0;
}
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::AllowAll;
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = BlockWeights;
type BlockLength = ();
type DbWeight = ();
@@ -282,8 +282,8 @@ impl TestFilter {
}
}
impl Filter<Call> for TestFilter {
fn filter(call: &Call) -> bool {
impl Contains<Call> for TestFilter {
fn contains(call: &Call) -> bool {
CALL_FILTER.with(|fltr| fltr.borrow()(call))
}
}