Remove unwrap and format code (#62)

* Remove unwrap from metadata fetch

* Format code
This commit is contained in:
Andrew Jones
2020-01-09 17:26:50 +00:00
committed by GitHub
parent b159d0dae1
commit f998444619
4 changed files with 37 additions and 12 deletions
+7 -3
View File
@@ -145,10 +145,14 @@ impl<T: System> Rpc<T> {
pub fn metadata(&self) -> impl Future<Item = Metadata, Error = Error> {
self.state
.metadata(None)
.map(|bytes| Decode::decode(&mut &bytes[..]).unwrap())
.map_err(Into::into)
.and_then(|meta: RuntimeMetadataPrefixed| {
future::result(meta.try_into().map_err(|err| format!("{:?}", err).into()))
.and_then(|bytes| {
let result = Decode::decode(&mut &bytes[..])
.map_err(Into::into)
.and_then(|meta: RuntimeMetadataPrefixed| {
meta.try_into().map_err(|err| format!("{:?}", err).into())
});
future::result(result)
})
}