1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#[frame_support::pallet(dev_mode)]
pub mod pallet {
	use cfg_traits::liquidity_pools::MessageQueue;
	use frame_support::pallet_prelude::*;
	use mock_builder::{execute_call, register_call, CallHandler};

	#[pallet::config]
	pub trait Config: frame_system::Config {
		type Message;
	}

	#[pallet::pallet]
	pub struct Pallet<T>(_);

	#[pallet::storage]
	type CallIds<T: Config> = StorageMap<_, _, String, mock_builder::CallId>;

	impl<T: Config> Pallet<T> {
		pub fn mock_queue(f: impl Fn(T::Message) -> DispatchResult + 'static) -> CallHandler {
			register_call!(f)
		}
	}

	impl<T: Config> MessageQueue for Pallet<T> {
		type Message = T::Message;

		fn queue(msg: Self::Message) -> DispatchResult {
			execute_call!(msg)
		}
	}
}