Skip to content
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

feat: add extrinsics filter #44

Merged
merged 3 commits into from May 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 24 additions & 2 deletions runtime/src/lib.rs
Expand Up @@ -26,7 +26,7 @@ use sp_version::RuntimeVersion;
// A few exports that help ease life for downstream crates.
pub use frame_support::{
construct_runtime, parameter_types,
traits::{Get, KeyOwnerProofSystem, LockIdentifier, Randomness},
traits::{Filter, Get, KeyOwnerProofSystem, LockIdentifier, Randomness},
weights::{
constants::{BlockExecutionWeight, RocksDbWeight, WEIGHT_PER_SECOND},
DispatchClass, IdentityFee, Pays, Weight,
Expand Down Expand Up @@ -145,6 +145,28 @@ pub fn native_version() -> NativeVersion {
}
}

pub struct BaseFilter;
impl Filter<Call> for BaseFilter {
fn filter(call: &Call) -> bool {
match call {
Call::System(_)
| Call::Timestamp(_)
| Call::RandomnessCollectiveFlip(_)
| Call::ParachainSystem(_)
| Call::Sudo(_) => true,

Call::XYK(_)
| Call::Balances(_)
| Call::AssetRegistry(_)
| Call::Currencies(_)
| Call::Exchange(_)
| Call::Faucet(_)
| Call::MultiTransactionPayment(_)
| Call::Tokens(_) => false,
}
}
}

parameter_types! {
pub const BlockHashCount: BlockNumber = 250;
pub const Version: RuntimeVersion = VERSION;
Expand Down Expand Up @@ -179,7 +201,7 @@ parameter_types! {

impl frame_system::Config for Runtime {
/// The basic call filter to use in dispatchable.
type BaseCallFilter = ();
type BaseCallFilter = BaseFilter;
type BlockWeights = BlockWeights;
type BlockLength = BlockLength;
/// The ubiquitous origin type.
Expand Down