Skip to content

Commit

Permalink
Add dispatchable filter: SudoOnlyFilter (paritytech#34)
Browse files Browse the repository at this point in the history
* [launch-runtime] add sudo only filter

* [launch-runtime] fix negated dispatchable filter

* [GA] cancel previous runs and add cargo cache

* [launch-runtime] fix filter

Co-authored-by: brenzi <brenzi@users.noreply.github.com>
  • Loading branch information
clangenb and brenzi authored Oct 27, 2021
1 parent 4fbb1c1 commit f308bd8
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion polkadot-parachains/launch-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,27 @@ parameter_types! {
pub const SS58Prefix: u8 = 42;
}

pub struct SudoOnly;
impl Contains<Call> for SudoOnly {
fn contains(call: &Call) -> bool {
// the system relevant pallets have either:
//
// * `ensure_root(origin)`
// * `ensure_none(origin)`
//
// So effectively, this is a `SudoOnly` filter.
!matches!(
call,
// only enable force_transfer/set_balance, which are root calls.
Call::Balances(
pallet_balances::Call::transfer { .. } |
pallet_balances::Call::transfer_all { .. } |
pallet_balances::Call::transfer_keep_alive { .. }
) | Call::Treasury(_)
)
}
}

impl frame_system::Config for Runtime {
/// The identifier used to distinguish between accounts.
type AccountId = AccountId;
Expand Down Expand Up @@ -189,7 +210,7 @@ impl frame_system::Config for Runtime {
type OnNewAccount = ();
type OnKilledAccount = ();
type DbWeight = ();
type BaseCallFilter = frame_support::traits::Everything;
type BaseCallFilter = SudoOnly;
type SystemWeightInfo = ();
type BlockWeights = RuntimeBlockWeights;
type BlockLength = RuntimeBlockLength;
Expand Down

0 comments on commit f308bd8

Please sign in to comment.