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
+2 -4
View File
@@ -88,10 +88,8 @@ impl<ArgsData: EncodeAsFields, ReturnTy: DecodeWithMetadata> RuntimeApiPayload
}
fn encode_args_to(&self, metadata: &Metadata, out: &mut Vec<u8>) -> Result<(), Error> {
let api_trait = metadata
.runtime_api_trait_by_name(&self.trait_name)
.ok_or_else(|| MetadataError::RuntimeTraitNotFound((*self.trait_name).to_owned()))?;
let api_method = api_trait
let api_method = metadata
.runtime_api_trait_by_name_err(&self.trait_name)?
.method_by_name(&self.method_name)
.ok_or_else(|| MetadataError::RuntimeMethodNotFound((*self.method_name).to_owned()))?;
+1 -5
View File
@@ -70,11 +70,7 @@ where
async move {
let metadata = client.metadata();
let api_trait = metadata
.runtime_api_trait_by_name(payload.trait_name())
.ok_or_else(|| {
MetadataError::RuntimeTraitNotFound(payload.trait_name().to_owned())
})?;
let api_trait = metadata.runtime_api_trait_by_name_err(payload.trait_name())?;
let api_method = api_trait
.method_by_name(payload.method_name())
.ok_or_else(|| {