mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 11:07:56 +00:00
Disambiguate BlockNumber type in decl_module (#7061)
* Disambiguate `BlockNumber` type in `decl_module` * fix `frame-support-tests` * fix ui tests * fix trait order
This commit is contained in:
@@ -1265,15 +1265,16 @@ macro_rules! decl_module {
|
||||
};
|
||||
|
||||
(@impl_on_initialize
|
||||
{ $system:ident }
|
||||
$module:ident<$trait_instance:ident: $trait_name:ident$(<I>, $instance:ident: $instantiable:path)?>;
|
||||
{ $( $other_where_bounds:tt )* }
|
||||
fn on_initialize() -> $return:ty { $( $impl:tt )* }
|
||||
) => {
|
||||
impl<$trait_instance: $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnInitialize<$trait_instance::BlockNumber>
|
||||
impl<$trait_instance: $system::Trait + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnInitialize<<$trait_instance as $system::Trait>::BlockNumber>
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
fn on_initialize(_block_number_not_used: $trait_instance::BlockNumber) -> $return {
|
||||
fn on_initialize(_block_number_not_used: <$trait_instance as $system::Trait>::BlockNumber) -> $return {
|
||||
$crate::sp_tracing::enter_span!("on_initialize");
|
||||
{ $( $impl )* }
|
||||
}
|
||||
@@ -1281,12 +1282,13 @@ macro_rules! decl_module {
|
||||
};
|
||||
|
||||
(@impl_on_initialize
|
||||
{ $system:ident }
|
||||
$module:ident<$trait_instance:ident: $trait_name:ident$(<I>, $instance:ident: $instantiable:path)?>;
|
||||
{ $( $other_where_bounds:tt )* }
|
||||
fn on_initialize($param:ident : $param_ty:ty) -> $return:ty { $( $impl:tt )* }
|
||||
) => {
|
||||
impl<$trait_instance: $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnInitialize<$trait_instance::BlockNumber>
|
||||
impl<$trait_instance: $system::Trait + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnInitialize<<$trait_instance as $system::Trait>::BlockNumber>
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
fn on_initialize($param: $param_ty) -> $return {
|
||||
@@ -1297,11 +1299,12 @@ macro_rules! decl_module {
|
||||
};
|
||||
|
||||
(@impl_on_initialize
|
||||
{ $system:ident }
|
||||
$module:ident<$trait_instance:ident: $trait_name:ident$(<I>, $instance:ident: $instantiable:path)?>;
|
||||
{ $( $other_where_bounds:tt )* }
|
||||
) => {
|
||||
impl<$trait_instance: $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnInitialize<$trait_instance::BlockNumber>
|
||||
impl<$trait_instance: $system::Trait + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnInitialize<<$trait_instance as $system::Trait>::BlockNumber>
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{}
|
||||
};
|
||||
@@ -1362,15 +1365,16 @@ macro_rules! decl_module {
|
||||
};
|
||||
|
||||
(@impl_on_finalize
|
||||
{ $system:ident }
|
||||
$module:ident<$trait_instance:ident: $trait_name:ident$(<I>, $instance:ident: $instantiable:path)?>;
|
||||
{ $( $other_where_bounds:tt )* }
|
||||
fn on_finalize() { $( $impl:tt )* }
|
||||
) => {
|
||||
impl<$trait_instance: $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnFinalize<$trait_instance::BlockNumber>
|
||||
impl<$trait_instance: $system::Trait + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnFinalize<<$trait_instance as $system::Trait>::BlockNumber>
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
fn on_finalize(_block_number_not_used: $trait_instance::BlockNumber) {
|
||||
fn on_finalize(_block_number_not_used: <$trait_instance as $system::Trait>::BlockNumber) {
|
||||
$crate::sp_tracing::enter_span!("on_finalize");
|
||||
{ $( $impl )* }
|
||||
}
|
||||
@@ -1378,12 +1382,13 @@ macro_rules! decl_module {
|
||||
};
|
||||
|
||||
(@impl_on_finalize
|
||||
{ $system:ident }
|
||||
$module:ident<$trait_instance:ident: $trait_name:ident$(<I>, $instance:ident: $instantiable:path)?>;
|
||||
{ $( $other_where_bounds:tt )* }
|
||||
fn on_finalize($param:ident : $param_ty:ty) { $( $impl:tt )* }
|
||||
) => {
|
||||
impl<$trait_instance: $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnFinalize<$trait_instance::BlockNumber>
|
||||
impl<$trait_instance: $system::Trait + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnFinalize<<$trait_instance as $system::Trait>::BlockNumber>
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
fn on_finalize($param: $param_ty) {
|
||||
@@ -1394,36 +1399,39 @@ macro_rules! decl_module {
|
||||
};
|
||||
|
||||
(@impl_on_finalize
|
||||
{ $system:ident }
|
||||
$module:ident<$trait_instance:ident: $trait_name:ident$(<I>, $instance:ident: $instantiable:path)?>;
|
||||
{ $( $other_where_bounds:tt )* }
|
||||
) => {
|
||||
impl<$trait_instance: $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnFinalize<$trait_instance::BlockNumber>
|
||||
impl<$trait_instance: $system::Trait + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnFinalize<<$trait_instance as $system::Trait>::BlockNumber>
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
(@impl_offchain
|
||||
{ $system:ident }
|
||||
$module:ident<$trait_instance:ident: $trait_name:ident$(<I>, $instance:ident: $instantiable:path)?>;
|
||||
{ $( $other_where_bounds:tt )* }
|
||||
fn offchain_worker() { $( $impl:tt )* }
|
||||
) => {
|
||||
impl<$trait_instance: $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OffchainWorker<$trait_instance::BlockNumber>
|
||||
impl<$trait_instance: $system::Trait + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OffchainWorker<<$trait_instance as $system::Trait>::BlockNumber>
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
fn offchain_worker(_block_number_not_used: $trait_instance::BlockNumber) { $( $impl )* }
|
||||
fn offchain_worker(_block_number_not_used: <$trait_instance as $system::Trait>::BlockNumber) { $( $impl )* }
|
||||
}
|
||||
};
|
||||
|
||||
(@impl_offchain
|
||||
{ $system:ident }
|
||||
$module:ident<$trait_instance:ident: $trait_name:ident$(<I>, $instance:ident: $instantiable:path)?>;
|
||||
{ $( $other_where_bounds:tt )* }
|
||||
fn offchain_worker($param:ident : $param_ty:ty) { $( $impl:tt )* }
|
||||
) => {
|
||||
impl<$trait_instance: $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OffchainWorker<$trait_instance::BlockNumber>
|
||||
impl<$trait_instance: $system::Trait + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OffchainWorker<<$trait_instance as $system::Trait>::BlockNumber>
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
fn offchain_worker($param: $param_ty) { $( $impl )* }
|
||||
@@ -1431,11 +1439,12 @@ macro_rules! decl_module {
|
||||
};
|
||||
|
||||
(@impl_offchain
|
||||
{ $system:ident }
|
||||
$module:ident<$trait_instance:ident: $trait_name:ident$(<I>, $instance:ident: $instantiable:path)?>;
|
||||
{ $( $other_where_bounds:tt )* }
|
||||
) => {
|
||||
impl<$trait_instance: $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OffchainWorker<$trait_instance::BlockNumber>
|
||||
impl<$trait_instance: $system::Trait + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OffchainWorker<<$trait_instance as $system::Trait>::BlockNumber>
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{}
|
||||
};
|
||||
@@ -1635,6 +1644,7 @@ macro_rules! decl_module {
|
||||
|
||||
$crate::decl_module! {
|
||||
@impl_on_initialize
|
||||
{ $system }
|
||||
$mod_type<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?>;
|
||||
{ $( $other_where_bounds )* }
|
||||
$( $on_initialize )*
|
||||
@@ -1649,6 +1659,7 @@ macro_rules! decl_module {
|
||||
|
||||
$crate::decl_module! {
|
||||
@impl_on_finalize
|
||||
{ $system }
|
||||
$mod_type<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?>;
|
||||
{ $( $other_where_bounds )* }
|
||||
$( $on_finalize )*
|
||||
@@ -1656,6 +1667,7 @@ macro_rules! decl_module {
|
||||
|
||||
$crate::decl_module! {
|
||||
@impl_offchain
|
||||
{ $system }
|
||||
$mod_type<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?>;
|
||||
{ $( $other_where_bounds )* }
|
||||
$( $offchain )*
|
||||
@@ -2345,9 +2357,7 @@ mod tests {
|
||||
IntegrityTest,
|
||||
};
|
||||
|
||||
pub trait Trait: system::Trait + Sized where Self::AccountId: From<u32> {
|
||||
type BlockNumber: Into<u32>;
|
||||
}
|
||||
pub trait Trait: system::Trait + Sized where Self::AccountId: From<u32> { }
|
||||
|
||||
pub mod system {
|
||||
use codec::{Encode, Decode};
|
||||
@@ -2357,6 +2367,7 @@ mod tests {
|
||||
type Call;
|
||||
type BaseCallFilter;
|
||||
type Origin: crate::traits::OriginTrait<Call = Self::Call>;
|
||||
type BlockNumber: Into<u32>;
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode)]
|
||||
@@ -2480,10 +2491,7 @@ mod tests {
|
||||
];
|
||||
|
||||
pub struct TraitImpl {}
|
||||
|
||||
impl Trait for TraitImpl {
|
||||
type BlockNumber = u32;
|
||||
}
|
||||
impl Trait for TraitImpl { }
|
||||
|
||||
type Test = Module<TraitImpl>;
|
||||
|
||||
@@ -2502,6 +2510,7 @@ mod tests {
|
||||
type AccountId = u32;
|
||||
type Call = OuterCall;
|
||||
type BaseCallFilter = ();
|
||||
type BlockNumber = u32;
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user