mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 05:47:58 +00:00
Ensure inherent are first (#8173)
* impl * fix tests * impl in execute_block * fix tests * add a test in frame-executive * fix some panic warning * use trait to get call from extrinsic * remove unused * fix test * fix testing * fix tests * return index of extrinsic on error * fix test * Update primitives/inherents/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * address comments rename trait, and refactor * refactor + doc improvment * fix tests Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
6679b88af8
commit
a4ed9bb9b2
@@ -284,3 +284,40 @@ pub trait GetBacking {
|
||||
/// implicit motion. `None` if it does not.
|
||||
fn get_backing(&self) -> Option<Backing>;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// A trait to ensure the inherent are before non-inherent in a block.
|
||||
///
|
||||
/// This is typically implemented on runtime, through `construct_runtime!`.
|
||||
pub trait EnsureInherentsAreFirst<Block> {
|
||||
/// Ensure the position of inherent is correct, i.e. they are before non-inherents.
|
||||
///
|
||||
/// On error return the index of the inherent with invalid position (counting from 0).
|
||||
fn ensure_inherents_are_first(block: &Block) -> Result<(), u32>;
|
||||
}
|
||||
|
||||
/// An extrinsic on which we can get access to call.
|
||||
pub trait ExtrinsicCall: sp_runtime::traits::Extrinsic {
|
||||
/// Get the call of the extrinsic.
|
||||
fn call(&self) -> &Self::Call;
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<Call, Extra> ExtrinsicCall for sp_runtime::testing::TestXt<Call, Extra> where
|
||||
Call: codec::Codec + Sync + Send,
|
||||
{
|
||||
fn call(&self) -> &Self::Call {
|
||||
&self.call
|
||||
}
|
||||
}
|
||||
|
||||
impl<Address, Call, Signature, Extra> ExtrinsicCall
|
||||
for sp_runtime::generic::UncheckedExtrinsic<Address, Call, Signature, Extra>
|
||||
where
|
||||
Extra: sp_runtime::traits::SignedExtension,
|
||||
{
|
||||
fn call(&self) -> &Self::Call {
|
||||
&self.function
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user