Tidy up some metadata accessing (#978)

* Reduce some repetition when obtaining metadata pallets/runtime_traits

* make them pub

* fix docs and clippy
This commit is contained in:
James Wilson
2023-05-26 13:51:10 +01:00
committed by GitHub
parent 870d4df2ed
commit ae0ab3e8f3
12 changed files with 43 additions and 42 deletions
+1 -5
View File
@@ -154,11 +154,7 @@ impl std::fmt::Display for ModuleError {
impl ModuleError {
/// Return more details about this error.
pub fn details(&self) -> Result<ModuleErrorDetails, MetadataError> {
let pallet = self
.metadata
.pallet_by_index(self.raw.pallet_index)
.ok_or(MetadataError::PalletIndexNotFound(self.raw.pallet_index))?;
let pallet = self.metadata.pallet_by_index_err(self.raw.pallet_index)?;
let variant = pallet
.error_variant_by_index(self.raw.error[0])
.ok_or_else(|| MetadataError::VariantIndexNotFound(self.raw.error[0]))?;