1

Trying to implement some filter/checker for «subcalls» based on Dispatchable trait in my pallet. I can get metadata: pallet name and function name, but I can't get the arguments values.

How should I properly filter calls by argument values with my custom logic?

#[frame_support::pallet]
pub mod pallet {
    ...
    #[pallet::config]
    pub trait Config<I: 'static = ()>: frame_system::Config {
        ...
        type Call:
              Parameter
            + Dispatchable<Origin = Self::Origin, PostInfo = PostDispatchInfo>
            + GetDispatchInfo
            + GetCallMetadata
            + From<frame_system::Call<Self>>
            + UnfilteredDispatchable<Origin = Self::Origin>
            + IsType<<Self as frame_system::Config>::Call>;
        ...
    #[pallet::call]
    impl<T: Config<I>, I: 'static> Pallet<T, I> {
        ...
        #[pallet::weight(xxx)]
        pub fn submit(
            origin: OriginFor<T>,
            calls: Vec<<T as Config<I>>::Call>,
        ) -> DispatchResult {
            let origin_address = ensure_signed(origin)?;

            // process calls one by one
            for call in calls {
                log::info!(">>>>>> {:?}", call.get_call_metadata());
                // check arguments values?
            }
        }
    }
}
2
  • A Call does not contain the arguments, so you cannot filter by that. Sep 16, 2022 at 15:15
  • But they should be stored somewhere. When I call an extrinsic, I pass all arguments.
    – broomrider
    Sep 17, 2022 at 15:31

1 Answer 1

0

If you dive into the construct_runtime! macro, you'll find metadata contains only pallet name and function name.

If you want to dispatch by parameters, I think you should try to convert the <T as Config>::Call to Call. Call is an enum generated by #[pallet::call] macro. For now, i can't find a convert way, keep trying.

If you just want to batch calls of one pallet, you can use Call as the input parameter directly. At last, why you want to do this, can you give some context ?

2
  • I want to batch and filter calls by arguments. The idea was to not modify the original pallets, so I can sync with dev branch. So, I want to change some «rules» of transactions, but I don't want to change their pallets code.
    – broomrider
    Sep 15, 2022 at 16:14
  • 1
    @broomrider I think the most simple way is to fork these pallets. Sep 16, 2022 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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