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).