mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 09:17:58 +00:00
Implements pallet versioning (#7208)
* Start * Make macro work * Rename `ModuleToIndex` to `PalletRuntimeSetup` Besides the renaming it also adds support getting the name of a pallet as configured in the runtime. * Rename it to `PalletInfo` * Remove accidentally added files * Some work * Make everything compile * Adds a test and fixes some bugs * Implement ordering for `PalletVersion` * Apply suggestions from code review * Review feedback * Update frame/support/src/dispatch.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Update frame/support/src/dispatch.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Fix compilation * Fix test * Fix doc test Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
@@ -551,13 +551,15 @@ mod tests {
|
||||
use codec::{Encode, Decode};
|
||||
|
||||
mod system {
|
||||
pub trait Trait {
|
||||
pub trait Trait: 'static {
|
||||
type Origin;
|
||||
type BlockNumber;
|
||||
type PalletInfo: crate::traits::PalletInfo;
|
||||
type DbWeight: crate::traits::Get<crate::weights::RuntimeDbWeight>;
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {}
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {}
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
@@ -568,13 +570,15 @@ mod tests {
|
||||
}
|
||||
|
||||
mod system_renamed {
|
||||
pub trait Trait {
|
||||
pub trait Trait: 'static {
|
||||
type Origin;
|
||||
type BlockNumber;
|
||||
type PalletInfo: crate::traits::PalletInfo;
|
||||
type DbWeight: crate::traits::Get<crate::weights::RuntimeDbWeight>;
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {}
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {}
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
@@ -585,19 +589,19 @@ mod tests {
|
||||
}
|
||||
|
||||
mod event_module {
|
||||
pub trait Trait {
|
||||
type Origin;
|
||||
use super::system;
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
type Balance;
|
||||
type BlockNumber;
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {}
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=system {}
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
/// Event without renaming the generic parameter `Balance` and `Origin`.
|
||||
pub enum Event<T> where <T as Trait>::Balance, <T as Trait>::Origin
|
||||
pub enum Event<T> where <T as Trait>::Balance, <T as system::Trait>::Origin
|
||||
{
|
||||
/// Hi, I am a comment.
|
||||
TestEvent(Balance, Origin),
|
||||
@@ -608,21 +612,21 @@ mod tests {
|
||||
}
|
||||
|
||||
mod event_module2 {
|
||||
pub trait Trait {
|
||||
type Origin;
|
||||
use super::system;
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
type Balance;
|
||||
type BlockNumber;
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {}
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=system {}
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
/// Event with renamed generic parameter
|
||||
pub enum Event<T> where
|
||||
BalanceRenamed = <T as Trait>::Balance,
|
||||
OriginRenamed = <T as Trait>::Origin
|
||||
OriginRenamed = <T as system::Trait>::Origin
|
||||
{
|
||||
TestEvent(BalanceRenamed),
|
||||
TestOrigin(OriginRenamed),
|
||||
@@ -639,21 +643,21 @@ mod tests {
|
||||
}
|
||||
|
||||
mod event_module4 {
|
||||
pub trait Trait {
|
||||
type Origin;
|
||||
use super::system;
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
type Balance;
|
||||
type BlockNumber;
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {}
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=system {}
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
/// Event finish formatting on an unnamed one with trailing comma
|
||||
pub enum Event<T> where
|
||||
<T as Trait>::Balance,
|
||||
<T as Trait>::Origin,
|
||||
<T as system::Trait>::Origin,
|
||||
{
|
||||
TestEvent(Balance, Origin),
|
||||
}
|
||||
@@ -661,21 +665,21 @@ mod tests {
|
||||
}
|
||||
|
||||
mod event_module5 {
|
||||
pub trait Trait {
|
||||
type Origin;
|
||||
use super::system;
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
type Balance;
|
||||
type BlockNumber;
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {}
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=system {}
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
/// Event finish formatting on an named one with trailing comma
|
||||
pub enum Event<T> where
|
||||
BalanceRenamed = <T as Trait>::Balance,
|
||||
OriginRenamed = <T as Trait>::Origin,
|
||||
OriginRenamed = <T as system::Trait>::Origin,
|
||||
{
|
||||
TestEvent(BalanceRenamed, OriginRenamed),
|
||||
TrailingCommaInArgs(
|
||||
@@ -711,37 +715,40 @@ mod tests {
|
||||
}
|
||||
|
||||
impl event_module::Trait for TestRuntime {
|
||||
type Origin = u32;
|
||||
type Balance = u32;
|
||||
type BlockNumber = u32;
|
||||
}
|
||||
|
||||
impl event_module2::Trait for TestRuntime {
|
||||
type Origin = u32;
|
||||
type Balance = u32;
|
||||
type BlockNumber = u32;
|
||||
}
|
||||
|
||||
impl system::Trait for TestRuntime {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = ();
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
impl event_module::Trait for TestRuntime2 {
|
||||
type Origin = u32;
|
||||
type Balance = u32;
|
||||
type BlockNumber = u32;
|
||||
}
|
||||
|
||||
impl event_module2::Trait for TestRuntime2 {
|
||||
type Origin = u32;
|
||||
type Balance = u32;
|
||||
type BlockNumber = u32;
|
||||
}
|
||||
|
||||
impl system_renamed::Trait for TestRuntime2 {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = ();
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
impl system::Trait for TestRuntime2 {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = ();
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
const EXPECTED_METADATA: OuterEventMetadata = OuterEventMetadata {
|
||||
|
||||
Reference in New Issue
Block a user