Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Introduce CheckNonZeroSender #10413

Merged
merged 14 commits into from
Dec 8, 2021
Prev Previous commit
Next Next commit
Formatting
  • Loading branch information
gavofyork committed Dec 2, 2021
commit 09eac590e610bba98169b5a30d7ee946d34c5f9f
8 changes: 3 additions & 5 deletions frame/system/src/extensions/check_non_zero_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use sp_runtime::{
ValidTransaction,
},
};
use sp_std::{prelude::*, marker::PhantomData};
use sp_std::{marker::PhantomData, prelude::*};

/// Check to ensure that the sender is not the zero address.
#[derive(Encode, Decode, Clone, Eq, PartialEq, TypeInfo)]
Expand Down Expand Up @@ -74,7 +74,7 @@ where
_len: usize,
) -> TransactionValidity {
if who.using_encoded(|d| d.into_iter().all(|x| *x == 0)) {
return Err(TransactionValidityError::Invalid(InvalidTransaction::BadSigner));
return Err(TransactionValidityError::Invalid(InvalidTransaction::BadSigner))
}
Ok(ValidTransaction::default())
}
Expand All @@ -95,9 +95,7 @@ mod tests {
CheckNonZeroSender::<Test>::new().validate(&0, CALL, &info, len),
InvalidTransaction::BadSigner
);
assert_ok!(
CheckNonZeroSender::<Test>::new().validate(&1, CALL, &info, len),
);
assert_ok!(CheckNonZeroSender::<Test>::new().validate(&1, CALL, &info, len),);
shawntabrizi marked this conversation as resolved.
Show resolved Hide resolved
})
}
}
2 changes: 1 addition & 1 deletion frame/system/src/extensions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

pub mod check_genesis;
pub mod check_mortality;
pub mod check_nonce;
pub mod check_non_zero_sender;
pub mod check_nonce;
pub mod check_spec_version;
pub mod check_tx_version;
pub mod check_weight;
5 changes: 3 additions & 2 deletions frame/system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ mod tests;
pub mod weights;

pub use extensions::{
check_genesis::CheckGenesis, check_mortality::CheckMortality, check_nonce::CheckNonce,
check_genesis::CheckGenesis, check_mortality::CheckMortality,
check_non_zero_sender::CheckNonZeroSender, check_nonce::CheckNonce,
check_spec_version::CheckSpecVersion, check_tx_version::CheckTxVersion,
check_weight::CheckWeight, check_non_zero_sender::CheckNonZeroSender,
check_weight::CheckWeight,
};
// Backward compatible re-export.
pub use extensions::check_mortality::CheckMortality as CheckEra;
Expand Down