Refactor SignedExtension (#5540)

* Refactor SignedExtension

* Move DispatchInfo Associated type to Dispatchable
* Bound Call: Dispatchable
* Pass PostDispatchInfo to post_dispatch
* Pass DispatchInfo by reference to avoid clones

* Whitespace fix

Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* Style changes from code review

Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Only decalre in test mod to remove warning

* Deduplicate Call definition

* Bound frame_system::trait::Call by Dispatchable

* Introduce DispatchInfoOf type alias

* Whitespace fix from review

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

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Alexander Theißen
2020-04-08 11:12:09 +02:00
committed by GitHub
parent f8c8355ac7
commit 30ae26074c
18 changed files with 235 additions and 167 deletions
+3 -4
View File
@@ -288,7 +288,7 @@ use sp_runtime::{
curve::PiecewiseLinear,
traits::{
Convert, Zero, StaticLookup, CheckedSub, Saturating, SaturatedConversion, AtLeast32Bit,
SignedExtension,
SignedExtension, Dispatchable, DispatchInfoOf,
},
transaction_validity::{
TransactionValidityError, TransactionValidity, ValidTransaction, InvalidTransaction,
@@ -772,7 +772,7 @@ pub trait Trait: frame_system::Trait {
type ElectionLookahead: Get<Self::BlockNumber>;
/// The overarching call type.
type Call: From<Call<Self>> + IsSubType<Module<Self>, Self> + Clone;
type Call: Dispatchable + From<Call<Self>> + IsSubType<Module<Self>, Self> + Clone;
/// A transaction submitter.
type SubmitTransaction: SubmitUnsignedTransaction<Self, <Self as Trait>::Call>;
@@ -3135,7 +3135,6 @@ impl<T: Trait + Send + Sync> SignedExtension for LockStakingStatus<T> {
type AccountId = T::AccountId;
type Call = <T as Trait>::Call;
type AdditionalSigned = ();
type DispatchInfo = frame_support::weights::DispatchInfo;
type Pre = ();
fn additional_signed(&self) -> Result<(), TransactionValidityError> { Ok(()) }
@@ -3144,7 +3143,7 @@ impl<T: Trait + Send + Sync> SignedExtension for LockStakingStatus<T> {
&self,
_who: &Self::AccountId,
call: &Self::Call,
_info: Self::DispatchInfo,
_info: &DispatchInfoOf<Self::Call>,
_len: usize,
) -> TransactionValidity {
if let Some(inner_call) = call.is_sub_type() {
+1 -1
View File
@@ -2939,7 +2939,7 @@ mod offchain_phragmen {
let lock_staking: LockStakingStatus<Test> = Default::default();
assert_eq!(
lock_staking.validate(&10, &outer, Default::default(), Default::default(),),
lock_staking.validate(&10, &outer, &Default::default(), Default::default(),),
TransactionValidity::Err(InvalidTransaction::Stale.into()),
)
})