mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 21:37:56 +00:00
Extend PalletInfoAccess with module_name and crate_version method (#9690)
* Record pallet indices in CallMetadata * Resurrect PalletVersion infrastructure and rename as CrateVersion * cargo fmt * Add missing runtime generics to pallet struct * Fix path to instance * Fix test * Fix UI test expectations * Fix UI test expectations * Move crate_version function to PalletInfoAccess * Update UI test expectations * Add crate_name method to PalletInfo * Convert path to module name instead of exposing crate name * cargo fmt * Keep the double colons when constructing the module name * Remove unused import * Update UI test expectations * Update frame/support/src/traits/metadata.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Update UI test expectations Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
@@ -2151,6 +2151,18 @@ macro_rules! decl_module {
|
||||
.expect("Pallet is part of the runtime because pallet `Config` trait is \
|
||||
implemented by the runtime")
|
||||
}
|
||||
|
||||
fn module_name() -> &'static str {
|
||||
<
|
||||
<$trait_instance as $system::Config>::PalletInfo as $crate::traits::PalletInfo
|
||||
>::module_name::<Self>()
|
||||
.expect("Pallet is part of the runtime because pallet `Config` trait is \
|
||||
implemented by the runtime")
|
||||
}
|
||||
|
||||
fn crate_version() -> $crate::traits::CrateVersion {
|
||||
$crate::crate_to_crate_version!()
|
||||
}
|
||||
}
|
||||
|
||||
// Implement GetCallName for the Call.
|
||||
@@ -2529,8 +2541,8 @@ mod tests {
|
||||
use crate::{
|
||||
metadata::*,
|
||||
traits::{
|
||||
Get, GetCallName, IntegrityTest, OnFinalize, OnIdle, OnInitialize, OnRuntimeUpgrade,
|
||||
PalletInfo,
|
||||
CrateVersion, Get, GetCallName, IntegrityTest, OnFinalize, OnIdle, OnInitialize,
|
||||
OnRuntimeUpgrade, PalletInfo,
|
||||
},
|
||||
weights::{DispatchClass, DispatchInfo, Pays, RuntimeDbWeight},
|
||||
};
|
||||
@@ -2631,6 +2643,22 @@ mod tests {
|
||||
return Some("Test")
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
fn module_name<P: 'static>() -> Option<&'static str> {
|
||||
let type_id = sp_std::any::TypeId::of::<P>();
|
||||
if type_id == sp_std::any::TypeId::of::<Test>() {
|
||||
return Some("tests")
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
fn crate_version<P: 'static>() -> Option<CrateVersion> {
|
||||
let type_id = sp_std::any::TypeId::of::<P>();
|
||||
if type_id == sp_std::any::TypeId::of::<Test>() {
|
||||
return Some(frame_support::crate_to_crate_version!())
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user