6

Are there examples how to set up a call filter in Substrate to allow only certain calls of a particular pallet to be executed?

2 Answers 2

7

The overarching Call enum has the following structure

enum Call {
    PalletOne(pallet_one::Call),
    PalletTwo(pallet_two::Call),
    // ... and so on
}

The implementation of Contains<Call> for a call filter can do pattern-matching on the inner values as well. For example,

impl Contains<Call> for SomeFilter {
    fn contains(call: &Call) -> bool {
        match *call {
            Call::PalletOne(pallet_one::Call::CallA(_)) => true,
            _ => false,
        }
    }
}
4

Here's an example of how we were using a BaseCallFilter in the statemint parachain to filter out calls that we did not want enabled yet:

https://github.com/paritytech/cumulus/blob/2fe7a2edba05155c6a5f0f3527e1001aad7aee2e/polkadot-parachains/statemint/src/lib.rs#L126

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.