Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement pre_dispatch for SignedExtensions #370

Merged
merged 3 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ pretty_assertions = "0.6.1"
subxt = { path = ".." }
trybuild = "1.0.38"

sp-keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate/" }
sp-keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate/", branch = "master" }
77 changes: 76 additions & 1 deletion src/extrinsic/extra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ use core::{
use scale_info::TypeInfo;
use sp_runtime::{
generic::Era,
traits::SignedExtension,
traits::{
DispatchInfoOf,
SignedExtension,
},
transaction_validity::TransactionValidityError,
};

Expand Down Expand Up @@ -68,6 +71,15 @@ where
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
Ok(self.1)
}
fn pre_dispatch(
self,
_who: &Self::AccountId,
_call: &Self::Call,
_info: &DispatchInfoOf<Self::Call>,
_len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
Ok(())
}
}

/// Ensure the transaction version registered in the transaction is the same as at present.
Expand Down Expand Up @@ -99,6 +111,15 @@ where
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
Ok(self.1)
}
fn pre_dispatch(
self,
_who: &Self::AccountId,
_call: &Self::Call,
_info: &DispatchInfoOf<Self::Call>,
_len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
Ok(())
}
}

/// Check genesis hash
Expand Down Expand Up @@ -130,6 +151,15 @@ where
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
Ok(self.1)
}
fn pre_dispatch(
self,
_who: &Self::AccountId,
_call: &Self::Call,
_info: &DispatchInfoOf<Self::Call>,
_len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
Ok(())
}
}

/// Check for transaction mortality.
Expand Down Expand Up @@ -163,6 +193,15 @@ where
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
Ok(self.1)
}
fn pre_dispatch(
self,
_who: &Self::AccountId,
_call: &Self::Call,
_info: &DispatchInfoOf<Self::Call>,
_len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
Ok(())
}
}

/// Nonce check and increment to give replay protection for transactions.
Expand All @@ -184,6 +223,15 @@ where
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
Ok(())
}
fn pre_dispatch(
self,
_who: &Self::AccountId,
_call: &Self::Call,
_info: &DispatchInfoOf<Self::Call>,
_len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
Ok(())
}
}

/// Resource limit check.
Expand All @@ -205,6 +253,15 @@ where
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
Ok(())
}
fn pre_dispatch(
self,
_who: &Self::AccountId,
_call: &Self::Call,
_info: &DispatchInfoOf<Self::Call>,
_len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
Ok(())
}
}

/// Require the transactor pay for themselves and maybe include a tip to gain additional priority
Expand All @@ -230,6 +287,15 @@ impl SignedExtension for ChargeAssetTxPayment {
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
Ok(())
}
fn pre_dispatch(
self,
_who: &Self::AccountId,
_call: &Self::Call,
_info: &DispatchInfoOf<Self::Call>,
_len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
Ok(())
}
}

/// Trait for implementing transaction extras for a runtime.
Expand Down Expand Up @@ -318,4 +384,13 @@ impl<T: Config + Clone + Debug + Eq + Send + Sync> SignedExtension for DefaultEx
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
self.extra().additional_signed()
}
fn pre_dispatch(
self,
_who: &Self::AccountId,
_call: &Self::Call,
_info: &DispatchInfoOf<Self::Call>,
_len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
Ok(())
}
}