mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-10 11:07:30 +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:
@@ -27,12 +27,14 @@ pub use frame_metadata::{
|
||||
/// Example:
|
||||
/// ```
|
||||
///# mod module0 {
|
||||
///# pub trait Trait {
|
||||
///# pub trait Trait: 'static {
|
||||
///# type Origin;
|
||||
///# type BlockNumber;
|
||||
///# type PalletInfo: frame_support::traits::PalletInfo;
|
||||
///# type DbWeight: frame_support::traits::Get<frame_support::weights::RuntimeDbWeight>;
|
||||
///# }
|
||||
///# frame_support::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 {}
|
||||
///# }
|
||||
///#
|
||||
///# frame_support::decl_storage! {
|
||||
@@ -44,6 +46,8 @@ pub use frame_metadata::{
|
||||
///# impl module0::Trait for Runtime {
|
||||
///# type Origin = u32;
|
||||
///# type BlockNumber = u32;
|
||||
///# type PalletInfo = ();
|
||||
///# type DbWeight = ();
|
||||
///# }
|
||||
///#
|
||||
///# type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic<(), (), (), ()>;
|
||||
@@ -302,11 +306,12 @@ mod tests {
|
||||
type BlockNumber: From<u32> + Encode;
|
||||
type SomeValue: Get<u32>;
|
||||
type PalletInfo: crate::traits::PalletInfo;
|
||||
type DbWeight: crate::traits::Get<crate::weights::RuntimeDbWeight>;
|
||||
type Call;
|
||||
}
|
||||
|
||||
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 {
|
||||
/// Hi, I am a comment.
|
||||
const BlockNumber: T::BlockNumber = 100.into();
|
||||
const GetType: T::AccountId = T::SomeValue::get().into();
|
||||
@@ -341,8 +346,9 @@ mod tests {
|
||||
|
||||
mod event_module {
|
||||
use crate::dispatch::DispatchResult;
|
||||
use super::system;
|
||||
|
||||
pub trait Trait: super::system::Trait {
|
||||
pub trait Trait: system::Trait {
|
||||
type Balance;
|
||||
}
|
||||
|
||||
@@ -355,7 +361,7 @@ mod tests {
|
||||
);
|
||||
|
||||
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 {
|
||||
type Error = Error<T>;
|
||||
|
||||
#[weight = 0]
|
||||
@@ -375,10 +381,10 @@ mod tests {
|
||||
}
|
||||
|
||||
mod event_module2 {
|
||||
pub trait Trait {
|
||||
type Origin;
|
||||
use super::system;
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
type Balance;
|
||||
type BlockNumber;
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
@@ -389,7 +395,7 @@ mod tests {
|
||||
);
|
||||
|
||||
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 {}
|
||||
}
|
||||
|
||||
crate::decl_storage! {
|
||||
@@ -432,9 +438,7 @@ mod tests {
|
||||
}
|
||||
|
||||
impl event_module2::Trait for TestRuntime {
|
||||
type Origin = Origin;
|
||||
type Balance = u32;
|
||||
type BlockNumber = u32;
|
||||
}
|
||||
|
||||
crate::parameter_types! {
|
||||
@@ -448,6 +452,7 @@ mod tests {
|
||||
type BlockNumber = u32;
|
||||
type SomeValue = SystemValue;
|
||||
type PalletInfo = ();
|
||||
type DbWeight = ();
|
||||
type Call = Call;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user