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

Commit

Permalink
Warn if pallet provided to try-state does not exist (#13858)
Browse files Browse the repository at this point in the history
* Warn if pallet does not exist in try-state

* unwrap_or_default
  • Loading branch information
Szegoo authored Apr 8, 2023
1 parent 72dd574 commit 82e824b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions frame/support/src/traits/try_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,19 @@ impl<BlockNumber: Clone + sp_std::fmt::Debug + AtLeast32BitUnsigned> TryState<Bl
#( (<Tuple as crate::traits::PalletInfoAccess>::name(), Tuple::try_state) ),*
)];
let mut result = Ok(());
for (name, try_state_fn) in try_state_fns {
if pallet_names.iter().any(|n| n == name.as_bytes()) {
pallet_names.iter().for_each(|pallet_name| {
if let Some((name, try_state_fn)) =
try_state_fns.iter().find(|(name, _)| name.as_bytes() == pallet_name)
{
result = result.and(try_state_fn(n.clone(), targets.clone()));
} else {
crate::log::warn!(
"Pallet {:?} not found",
sp_std::str::from_utf8(pallet_name).unwrap_or_default()
);
}
}
});

result
},
}
Expand Down

0 comments on commit 82e824b

Please sign in to comment.