mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 08:11:04 +00:00
Implement pre_dispatch for SignedExtensions (#370)
* Explicitly specify master branch for sp-keyring dev dependency * Implement pre_dispatch for `SignedExtension`s * Update macro/Cargo.toml Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
This commit is contained in:
+1
-1
@@ -34,4 +34,4 @@ pretty_assertions = "0.6.1"
|
|||||||
subxt = { path = ".." }
|
subxt = { path = ".." }
|
||||||
trybuild = "1.0.38"
|
trybuild = "1.0.38"
|
||||||
|
|
||||||
sp-keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate/" }
|
sp-keyring = { git = "https://github.com/paritytech/substrate/", branch = "master" }
|
||||||
|
|||||||
+76
-1
@@ -25,7 +25,10 @@ use core::{
|
|||||||
use scale_info::TypeInfo;
|
use scale_info::TypeInfo;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
generic::Era,
|
generic::Era,
|
||||||
traits::SignedExtension,
|
traits::{
|
||||||
|
DispatchInfoOf,
|
||||||
|
SignedExtension,
|
||||||
|
},
|
||||||
transaction_validity::TransactionValidityError,
|
transaction_validity::TransactionValidityError,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -68,6 +71,15 @@ where
|
|||||||
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
||||||
Ok(self.1)
|
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.
|
/// Ensure the transaction version registered in the transaction is the same as at present.
|
||||||
@@ -99,6 +111,15 @@ where
|
|||||||
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
||||||
Ok(self.1)
|
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
|
/// Check genesis hash
|
||||||
@@ -130,6 +151,15 @@ where
|
|||||||
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
||||||
Ok(self.1)
|
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.
|
/// Check for transaction mortality.
|
||||||
@@ -163,6 +193,15 @@ where
|
|||||||
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
||||||
Ok(self.1)
|
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.
|
/// Nonce check and increment to give replay protection for transactions.
|
||||||
@@ -184,6 +223,15 @@ where
|
|||||||
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
||||||
Ok(())
|
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.
|
/// Resource limit check.
|
||||||
@@ -205,6 +253,15 @@ where
|
|||||||
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
||||||
Ok(())
|
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
|
/// Require the transactor pay for themselves and maybe include a tip to gain additional priority
|
||||||
@@ -230,6 +287,15 @@ impl SignedExtension for ChargeAssetTxPayment {
|
|||||||
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
||||||
Ok(())
|
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.
|
/// Trait for implementing transaction extras for a runtime.
|
||||||
@@ -318,4 +384,13 @@ impl<T: Config + Clone + Debug + Eq + Send + Sync> SignedExtension for DefaultEx
|
|||||||
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
||||||
self.extra().additional_signed()
|
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(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user