Added GetCallMetadata for extrinsic calls. (#4791)

* Added GetCallMetadata for extrinsic calls.

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Improved test for outer call metadata.

* fixed review comments

* removed dead code

* fixed review suggestions

* Update frame/support/src/dispatch.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Gautam Dhameja
2020-02-04 11:25:04 +01:00
committed by GitHub
parent febb6e29b2
commit 78006d0523
2 changed files with 91 additions and 35 deletions
+22
View File
@@ -22,6 +22,7 @@ use sp_std::{prelude::*, result, marker::PhantomData, ops::Div, fmt::Debug};
use codec::{FullCodec, Codec, Encode, Decode};
use sp_core::u32_trait::Value as U32;
use sp_runtime::{
RuntimeDebug,
ConsensusEngineId, DispatchResult, DispatchError,
traits::{MaybeSerializeDeserialize, SimpleArithmetic, Saturating, TrailingZeroInput},
};
@@ -800,3 +801,24 @@ pub trait ModuleToIndex {
impl ModuleToIndex for () {
fn module_to_index<M: 'static>() -> Option<usize> { Some(0) }
}
/// The function and pallet name of the Call.
#[derive(Clone, Eq, PartialEq, Default, RuntimeDebug)]
pub struct CallMetadata {
/// Name of the function.
pub function_name: &'static str,
/// Name of the pallet to which the function belongs.
pub pallet_name: &'static str,
}
/// Gets the function name of the Call.
pub trait GetCallName {
/// Return the function name of the Call.
fn get_call_name(&self) -> &'static str;
}
/// Gets the metadata for the Call - function name and pallet name.
pub trait GetCallMetadata {
/// Return a [`CallMetadata`], containing function and pallet name of the Call.
fn get_call_metadata(&self) -> CallMetadata;
}