mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-21 16:45:41 +00:00
Make impl_outer_event! aware of required generic parameters (#729)
This commit is contained in:
@@ -215,15 +215,15 @@ pub type Contract = contract::Module<Runtime>;
|
|||||||
impl_outer_event! {
|
impl_outer_event! {
|
||||||
pub enum Event for Runtime {
|
pub enum Event for Runtime {
|
||||||
//consensus,
|
//consensus,
|
||||||
balances,
|
balances<T>,
|
||||||
//timetstamp,
|
//timetstamp,
|
||||||
session,
|
session<T>,
|
||||||
staking,
|
staking<T>,
|
||||||
democracy,
|
democracy<T>,
|
||||||
council,
|
council<T>,
|
||||||
council_voting,
|
council_voting<T>,
|
||||||
council_motions,
|
council_motions<T>,
|
||||||
treasury
|
treasury<T>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ mod tests {
|
|||||||
|
|
||||||
impl_outer_event! {
|
impl_outer_event! {
|
||||||
pub enum Event for Test {
|
pub enum Event for Test {
|
||||||
balances, democracy, seats, voting, motions
|
balances<T>, democracy<T>, seats<T>, voting<T>, motions<T>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,4 +235,4 @@ mod tests {
|
|||||||
pub type Council = seats::Module<Test>;
|
pub type Council = seats::Module<Test>;
|
||||||
pub type CouncilVoting = voting::Module<Test>;
|
pub type CouncilVoting = voting::Module<Test>;
|
||||||
pub type CouncilMotions = motions::Module<Test>;
|
pub type CouncilMotions = motions::Module<Test>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ mod tests {
|
|||||||
|
|
||||||
impl_outer_event!{
|
impl_outer_event!{
|
||||||
pub enum MetaEvent for Runtime {
|
pub enum MetaEvent for Runtime {
|
||||||
balances
|
balances<T>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -270,7 +270,79 @@ macro_rules! __events_to_json {
|
|||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! impl_outer_event {
|
macro_rules! impl_outer_event {
|
||||||
($(#[$attr:meta])* pub enum $name:ident for $runtime:ident { $( $module:ident ),* }) => {
|
(
|
||||||
|
$(#[$attr:meta])*
|
||||||
|
pub enum $name:ident for $runtime:ident {
|
||||||
|
$module:ident<T>,
|
||||||
|
$( $rest:tt $( <$t:ident> )*, )*
|
||||||
|
}
|
||||||
|
) => {
|
||||||
|
impl_outer_event!(
|
||||||
|
$( #[$attr] )*;
|
||||||
|
$name;
|
||||||
|
$runtime;
|
||||||
|
Modules { $( $rest $(<$t>)*, )* };
|
||||||
|
$module::Event<$runtime>,;
|
||||||
|
);
|
||||||
|
};
|
||||||
|
(
|
||||||
|
$(#[$attr:meta])*
|
||||||
|
pub enum $name:ident for $runtime:ident {
|
||||||
|
$module:ident,
|
||||||
|
$( $rest:tt $( <$t:ident> )*, )*
|
||||||
|
}
|
||||||
|
) => {
|
||||||
|
impl_outer_event!(
|
||||||
|
$( #[$attr] )*;
|
||||||
|
$name;
|
||||||
|
$runtime;
|
||||||
|
Modules { $( $rest $(<$t>)*, )* };
|
||||||
|
$module::Event,;
|
||||||
|
);
|
||||||
|
};
|
||||||
|
(
|
||||||
|
$(#[$attr:meta])*;
|
||||||
|
$name:ident;
|
||||||
|
$runtime:ident;
|
||||||
|
Modules {
|
||||||
|
$module:ident<T>,
|
||||||
|
$( $rest:tt $( <$t:ident> )*, )*
|
||||||
|
};
|
||||||
|
$( $module_name:ident::Event $( <$generic_param:ident> )*, )*;
|
||||||
|
) => {
|
||||||
|
impl_outer_event!(
|
||||||
|
$( #[$attr] )*;
|
||||||
|
$name;
|
||||||
|
$runtime;
|
||||||
|
Modules { $( $rest $(<$t>)*, )* };
|
||||||
|
$( $module_name::Event $( <$generic_param> )*, )* $module::Event<$runtime>,;
|
||||||
|
);
|
||||||
|
};
|
||||||
|
(
|
||||||
|
$(#[$attr:meta])*;
|
||||||
|
$name:ident;
|
||||||
|
$runtime:ident;
|
||||||
|
Modules {
|
||||||
|
$module:ident,
|
||||||
|
$( $rest:tt, )*
|
||||||
|
};
|
||||||
|
$( $module_name:ident::Event $( <$generic_param:ident> )*, )*;
|
||||||
|
) => {
|
||||||
|
impl_outer_event!(
|
||||||
|
$( #[$attr] )*;
|
||||||
|
$name;
|
||||||
|
$runtime;
|
||||||
|
Modules { $( $rest, )* };
|
||||||
|
$( $module_name::Event $( <$generic_param> )*, )* $module::Event,;
|
||||||
|
);
|
||||||
|
};
|
||||||
|
(
|
||||||
|
$(#[$attr:meta])*;
|
||||||
|
$name:ident;
|
||||||
|
$runtime:ident;
|
||||||
|
Modules {};
|
||||||
|
$( $module_name:ident::Event $( <$generic_param:ident> )*, )*;
|
||||||
|
) => {
|
||||||
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
|
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
|
||||||
#[derive(Clone, PartialEq, Eq, Encode, Decode)]
|
#[derive(Clone, PartialEq, Eq, Encode, Decode)]
|
||||||
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
|
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
|
||||||
@@ -279,7 +351,7 @@ macro_rules! impl_outer_event {
|
|||||||
pub enum $name {
|
pub enum $name {
|
||||||
system(system::Event),
|
system(system::Event),
|
||||||
$(
|
$(
|
||||||
$module($module::Event<$runtime>),
|
$module_name( $module_name::Event $( <$generic_param> )* ),
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
impl From<system::Event> for $name {
|
impl From<system::Event> for $name {
|
||||||
@@ -288,13 +360,17 @@ macro_rules! impl_outer_event {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$(
|
$(
|
||||||
impl From<$module::Event<$runtime>> for $name {
|
impl From<$module_name::Event $( <$generic_param> )*> for $name {
|
||||||
fn from(x: $module::Event<$runtime>) -> Self {
|
fn from(x: $module_name::Event $( <$generic_param> )*) -> Self {
|
||||||
$name::$module(x)
|
$name::$module_name(x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)*
|
)*
|
||||||
__impl_outer_event_json_metadata!($runtime; $name; $( $module )*);
|
__impl_outer_event_json_metadata!(
|
||||||
|
$runtime;
|
||||||
|
$name;
|
||||||
|
$( $module_name::Event $( <$generic_param> )*, )*;
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,7 +380,7 @@ macro_rules! __impl_outer_event_json_metadata {
|
|||||||
(
|
(
|
||||||
$runtime:ident;
|
$runtime:ident;
|
||||||
$event_name:ident;
|
$event_name:ident;
|
||||||
$( $module:ident )*
|
$( $module_name:ident::Event $( <$generic_param:ident> )*, )*;
|
||||||
) => {
|
) => {
|
||||||
impl $runtime {
|
impl $runtime {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
@@ -313,8 +389,8 @@ macro_rules! __impl_outer_event_json_metadata {
|
|||||||
("system", system::Event::event_json_metadata)
|
("system", system::Event::event_json_metadata)
|
||||||
$(
|
$(
|
||||||
, (
|
, (
|
||||||
stringify!($module),
|
stringify!($module_name),
|
||||||
$module::Event::<$runtime>::event_json_metadata
|
$module_name::Event $( ::<$generic_param> )*::event_json_metadata
|
||||||
)
|
)
|
||||||
)*
|
)*
|
||||||
];
|
];
|
||||||
@@ -393,12 +469,22 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod event_module3 {
|
||||||
|
decl_event!(
|
||||||
|
pub enum Event {
|
||||||
|
HiEvent,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode, Deserialize, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode, Deserialize, Serialize)]
|
||||||
pub struct TestRuntime;
|
pub struct TestRuntime;
|
||||||
|
|
||||||
impl_outer_event! {
|
impl_outer_event! {
|
||||||
pub enum TestEvent for TestRuntime {
|
pub enum TestEvent for TestRuntime {
|
||||||
event_module, event_module2
|
event_module<T>,
|
||||||
|
event_module2<T>,
|
||||||
|
event_module3,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,6 +521,13 @@ mod tests {
|
|||||||
" }"
|
" }"
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
("event_module3",
|
||||||
|
concat!(
|
||||||
|
"{",
|
||||||
|
r#" "HiEvent": { "params": null, "description": [ ] }"#,
|
||||||
|
" }"
|
||||||
|
)
|
||||||
|
),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -200,7 +200,8 @@ mod tests {
|
|||||||
|
|
||||||
impl_outer_event! {
|
impl_outer_event! {
|
||||||
pub enum TestEvent for TestRuntime {
|
pub enum TestEvent for TestRuntime {
|
||||||
event_module, event_module2
|
event_module<T>,
|
||||||
|
event_module2<T>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user