mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-16 22:31:03 +00:00
Remove unwrap and format code (#62)
* Remove unwrap from metadata fetch * Format code
This commit is contained in:
+6
-1
@@ -140,7 +140,12 @@ impl<T: System + Balances + 'static> EventsDecoder<T> {
|
||||
&& !self.type_sizes.contains_key(&primitive)
|
||||
&& !primitive.contains("PhantomData")
|
||||
{
|
||||
missing.insert(format!("{}::{}::{}", module.name(), event.name, primitive));
|
||||
missing.insert(format!(
|
||||
"{}::{}::{}",
|
||||
module.name(),
|
||||
event.name,
|
||||
primitive
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-2
@@ -72,7 +72,10 @@ pub use self::{
|
||||
runtimes::*,
|
||||
};
|
||||
use self::{
|
||||
events::{EventsDecoder, EventsError},
|
||||
events::{
|
||||
EventsDecoder,
|
||||
EventsError,
|
||||
},
|
||||
extrinsic::{
|
||||
DefaultExtra,
|
||||
SignedExtra,
|
||||
@@ -400,7 +403,12 @@ where
|
||||
T::Address: From<T::AccountId>,
|
||||
{
|
||||
/// Access the events decoder for registering custom type sizes
|
||||
pub fn events_decoder<F: FnOnce(&mut EventsDecoder<T>) -> Result<usize, EventsError>>(self, f: F) -> Self {
|
||||
pub fn events_decoder<
|
||||
F: FnOnce(&mut EventsDecoder<T>) -> Result<usize, EventsError>,
|
||||
>(
|
||||
self,
|
||||
f: F,
|
||||
) -> Self {
|
||||
let mut this = self;
|
||||
if let Ok(ref mut decoder) = this.decoder {
|
||||
if let Err(err) = f(decoder) {
|
||||
|
||||
+7
-3
@@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user