Skip to content
Snippets Groups Projects
Commit 1a327cd8 authored by Bastian Köcher's avatar Bastian Köcher Committed by Gavin Wood
Browse files

srml-utility: Store errors as `DispatchError` to make the decodable (#3766)

parent 954e980a
No related merge requests found
...@@ -84,8 +84,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { ...@@ -84,8 +84,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// and set impl_version to equal spec_version. If only runtime // and set impl_version to equal spec_version. If only runtime
// implementation changes and behavior does not, then leave spec_version as // implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version. // is and increment impl_version.
spec_version: 171, spec_version: 172,
impl_version: 171, impl_version: 172,
apis: RUNTIME_API_VERSIONS, apis: RUNTIME_API_VERSIONS,
}; };
...@@ -497,7 +497,7 @@ construct_runtime!( ...@@ -497,7 +497,7 @@ construct_runtime!(
UncheckedExtrinsic = UncheckedExtrinsic UncheckedExtrinsic = UncheckedExtrinsic
{ {
System: system::{Module, Call, Storage, Config, Event}, System: system::{Module, Call, Storage, Config, Event},
Utility: utility::{Module, Call, Event<T>}, Utility: utility::{Module, Call, Event},
Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp)}, Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp)},
Timestamp: timestamp::{Module, Call, Storage, Inherent}, Timestamp: timestamp::{Module, Call, Storage, Inherent},
Authorship: authorship::{Module, Call, Storage, Inherent}, Authorship: authorship::{Module, Call, Storage, Inherent},
......
...@@ -23,27 +23,21 @@ ...@@ -23,27 +23,21 @@
use rstd::prelude::*; use rstd::prelude::*;
use support::{decl_module, decl_event, Parameter}; use support::{decl_module, decl_event, Parameter};
use system::ensure_root; use system::ensure_root;
use sr_primitives::{ use sr_primitives::{traits::Dispatchable, weights::SimpleDispatchInfo, DispatchError};
traits::{Dispatchable, DispatchResult}, weights::SimpleDispatchInfo
};
/// Configuration trait. /// Configuration trait.
pub trait Trait: system::Trait { pub trait Trait: system::Trait {
/// The overarching event type. /// The overarching event type.
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>; type Event: From<Event> + Into<<Self as system::Trait>::Event>;
/// The overarching call type. /// The overarching call type.
type Call: Parameter + Dispatchable<Origin=Self::Origin>; type Call: Parameter + Dispatchable<Origin=Self::Origin>;
} }
pub type DispatchResultOf<T> = DispatchResult<<<T as Trait>::Call as Dispatchable>::Error>;
decl_event!( decl_event!(
/// Events type. /// Events type.
pub enum Event<T> where pub enum Event {
DispatchResult = DispatchResultOf<T>, BatchExecuted(Vec<Result<(), DispatchError>>),
{
BatchExecuted(Vec<DispatchResult>),
} }
); );
...@@ -58,8 +52,9 @@ decl_module! { ...@@ -58,8 +52,9 @@ decl_module! {
ensure_root(origin)?; ensure_root(origin)?;
let results = calls.into_iter() let results = calls.into_iter()
.map(|call| call.dispatch(system::RawOrigin::Root.into())) .map(|call| call.dispatch(system::RawOrigin::Root.into()))
.map(|res| res.map_err(Into::into))
.collect::<Vec<_>>(); .collect::<Vec<_>>();
Self::deposit_event(RawEvent::BatchExecuted(results)); Self::deposit_event(Event::BatchExecuted(results));
} }
} }
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment