1

I'm trying to build a somewhat generic, somewhat specific call dispatcher that allows me to inspect metadata about the call in order to constrain it by either

  • call index / pallet index
  • call name / pallet name

Here is an example trait implemented in my trait Config

/// Proposed dispatchable call
type Proposal: Parameter
    + Dispatchable<Origin = Self::Origin>
    + EncodeLike
    + Decode
    + GetDispatchInfo;

I'm aware of the traits GetCallName and GetCallMetadata but they don't seem to be implemented on a generic Call instantiated at the runtime level. For clarity, my runtime implementation is

impl Config for Test {
    ...
    type Proposal = Call;
}

I don't want to allow just any call to be processed in some functions. My intention is to do something like:

ensure!(call.get_call_metadata().function_name() === "hardcoded_function_name")

or

ensure!(valid_calls.contains(call.get_call_metadata().function_name()))

Is there an easy or thoughtful way to approach this in Substrate-style that allows me to keep generality. For example, it would be interesting if the call was filterable somehow so that 10 calls were allowed and I can define these at runtime (I had tried to add a tuple and implement a trait for tuples but it seemed too hacky).

1 Answer 1

1

You can filter the call in runtime. Here is how proxy do:

Provide a filter configuration here https://github.com/paritytech/substrate/blob/master/frame/proxy/src/lib.rs#L124-L134.

Configure it here https://github.com/paritytech/substrate/blob/master/bin/node/runtime/src/lib.rs#L264-L319.

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.