diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index 0a3b9617fc6..637f1ac7c47 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -195,21 +195,15 @@ impl ProvideInherent for Module { Some(Call::set_author(author)) } - fn check_inherent(_call: &Self::Call, data: &InherentData) -> Result<(), Self::Error> { - let author_raw = data - .get_data::(&INHERENT_IDENTIFIER) - .expect("Gets and decodes authorship inherent data") - .ok_or_else(|| { - InherentError::Other(sp_runtime::RuntimeString::Borrowed( - "Decode authorship inherent data failed", - )) - })?; - let author = - T::AccountId::decode(&mut &author_raw[..]).expect("Decodes author raw inherent data"); - ensure!( - T::CanAuthor::can_author(&author), - InherentError::Other(sp_runtime::RuntimeString::Borrowed("Cannot Be Author")) - ); + fn check_inherent(call: &Self::Call, _data: &InherentData) -> Result<(), Self::Error> { + // This if let should always be true. This is the only call that the inherent could make. + if let Self::Call::set_author(claimed_author) = call { + ensure!( + T::CanAuthor::can_author(&claimed_author), + InherentError::Other(sp_runtime::RuntimeString::Borrowed("Cannot Be Author")) + ); + } + Ok(()) } }