mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 06:57:58 +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:
@@ -702,6 +702,21 @@ pub use frame_support_procedural::DefaultNoBound;
|
||||
/// ```
|
||||
pub use frame_support_procedural::require_transactional;
|
||||
|
||||
/// Convert the current crate version into a [`CrateVersion`](crate::traits::CrateVersion).
|
||||
///
|
||||
/// It uses the `CARGO_PKG_VERSION_MAJOR`, `CARGO_PKG_VERSION_MINOR` and
|
||||
/// `CARGO_PKG_VERSION_PATCH` environment variables to fetch the crate version.
|
||||
/// This means that the [`CrateVersion`](crate::traits::CrateVersion)
|
||||
/// object will correspond to the version of the crate the macro is called in!
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// # use frame_support::{traits::CrateVersion, crate_to_crate_version};
|
||||
/// const Version: CrateVersion = crate_to_crate_version!();
|
||||
/// ```
|
||||
pub use frame_support_procedural::crate_to_crate_version;
|
||||
|
||||
/// Return Err of the expression: `return Err($expression);`.
|
||||
///
|
||||
/// Used as `fail!(expression)`.
|
||||
@@ -819,6 +834,7 @@ pub mod tests {
|
||||
StorageHasher,
|
||||
};
|
||||
use codec::{Codec, EncodeLike};
|
||||
use frame_support::traits::CrateVersion;
|
||||
use sp_io::TestExternalities;
|
||||
use sp_std::result;
|
||||
|
||||
@@ -832,6 +848,12 @@ pub mod tests {
|
||||
fn name<P: 'static>() -> Option<&'static str> {
|
||||
unimplemented!("PanicPalletInfo mustn't be triggered by tests");
|
||||
}
|
||||
fn module_name<P: 'static>() -> Option<&'static str> {
|
||||
unimplemented!("PanicPalletInfo mustn't be triggered by tests");
|
||||
}
|
||||
fn crate_version<P: 'static>() -> Option<CrateVersion> {
|
||||
unimplemented!("PanicPalletInfo mustn't be triggered by tests");
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Config: 'static {
|
||||
|
||||
Reference in New Issue
Block a user