Skip to content

Commit

Permalink
fix(fc-pallet-pass): invalid data handling for extension Pre
Browse files Browse the repository at this point in the history
  • Loading branch information
pandres95 committed Nov 19, 2024
1 parent d6b77ae commit 0ac7af8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pallets/pass/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ where
type AccountId = S::AccountId;
type Call = S::Call;
type AdditionalSigned = S::AdditionalSigned;
type Pre = S::Pre;
type Pre = Option<S::Pre>;

fn additional_signed(&self) -> Result<Self::AdditionalSigned, TransactionValidityError> {
self.0.additional_signed()
Expand All @@ -191,9 +191,12 @@ where
len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
if Pallet::<T, I>::signer_from_session_key(who).is_some() {
return Ok((None, Default::default()));
return Ok(None);
}
self.0.pre_dispatch(&who, call, info, len)

self.0
.pre_dispatch(&who, call, info, len)

Check warning on line 198 in pallets/pass/src/extension.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> pallets/pass/src/extension.rs:198:27 | 198 | .pre_dispatch(&who, call, info, len) | ^^^^ help: change this to: `who` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
.map(|pre| Some(pre))

Check warning on line 199 in pallets/pass/src/extension.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant closure

warning: redundant closure --> pallets/pass/src/extension.rs:199:18 | 199 | .map(|pre| Some(pre)) | ^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `Some` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure = note: `#[warn(clippy::redundant_closure)]` on by default
}

fn post_dispatch(
Expand All @@ -203,8 +206,8 @@ where
len: usize,
result: &sp_runtime::DispatchResult,
) -> Result<(), frame_support::pallet_prelude::TransactionValidityError> {
if let Some(pre) = pre {
S::post_dispatch(pre, info, post_info, len, result)
if let Some(Some(pre)) = pre {
S::post_dispatch(Some(pre), info, post_info, len, result)
} else {
Ok(())
}
Expand Down

0 comments on commit 0ac7af8

Please sign in to comment.