Expand description

The optional attribute #[inject_runtime_type] can be attached to RuntimeCall, RuntimeEvent, RuntimeOrigin or PalletInfo in an impl statement that has #[register_default_impl] attached to indicate that this item is generated by construct_runtime.

Attaching this attribute to such an item ensures that the combined impl generated via #[derive_impl(..)] will use the correct type auto-generated by construct_runtime!.

fn derive_impl_works_with_runtime_type_injection() {
	assert_type_eq_all!(<Runtime as Config>::RuntimeOrigin, super::RuntimeOrigin);
	assert_type_eq_all!(<Runtime as Config>::RuntimeCall, super::RuntimeCall);
	assert_type_eq_all!(<Runtime as Config>::PalletInfo, super::PalletInfo);

However, if no_aggregated_types is specified while using [#[derive_impl(..)]](frame_support::derive_impl), then these items are attached verbatim to the combined impl.

fn derive_impl_works_with_no_aggregated_types() {
	struct DummyRuntime;

        super::frame_system::config_preludes::TestDefaultConfig as super::frame_system::DefaultConfig,
	impl Config for DummyRuntime {
		type Block = super::Block;
		type AccountId = super::AccountId;
		type PalletInfo = super::PalletInfo;

	assert_type_eq_all!(<DummyRuntime as Config>::RuntimeOrigin, ());
	assert_type_eq_all!(<DummyRuntime as Config>::RuntimeCall, ());

Documentation for this macro can be found at frame_support::pallet_prelude::inject_runtime_type.