From 1a327cd89477a32f20e63007278e5d9b1cb4d173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= <bkchr@users.noreply.github.com> Date: Sat, 5 Oct 2019 13:06:38 +0200 Subject: [PATCH] srml-utility: Store errors as `DispatchError` to make the decodable (#3766) --- substrate/node/runtime/src/lib.rs | 6 +++--- substrate/srml/utility/src/lib.rs | 17 ++++++----------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/substrate/node/runtime/src/lib.rs b/substrate/node/runtime/src/lib.rs index b06ba19ee50..74951904646 100644 --- a/substrate/node/runtime/src/lib.rs +++ b/substrate/node/runtime/src/lib.rs @@ -84,8 +84,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to equal spec_version. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 171, - impl_version: 171, + spec_version: 172, + impl_version: 172, apis: RUNTIME_API_VERSIONS, }; @@ -497,7 +497,7 @@ construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic { 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)}, Timestamp: timestamp::{Module, Call, Storage, Inherent}, Authorship: authorship::{Module, Call, Storage, Inherent}, diff --git a/substrate/srml/utility/src/lib.rs b/substrate/srml/utility/src/lib.rs index 9fe34ee2d0e..c0b1954da9b 100644 --- a/substrate/srml/utility/src/lib.rs +++ b/substrate/srml/utility/src/lib.rs @@ -23,27 +23,21 @@ use rstd::prelude::*; use support::{decl_module, decl_event, Parameter}; use system::ensure_root; -use sr_primitives::{ - traits::{Dispatchable, DispatchResult}, weights::SimpleDispatchInfo -}; +use sr_primitives::{traits::Dispatchable, weights::SimpleDispatchInfo, DispatchError}; /// Configuration trait. pub trait Trait: system::Trait { /// 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. type Call: Parameter + Dispatchable<Origin=Self::Origin>; } -pub type DispatchResultOf<T> = DispatchResult<<<T as Trait>::Call as Dispatchable>::Error>; - decl_event!( /// Events type. - pub enum Event<T> where - DispatchResult = DispatchResultOf<T>, - { - BatchExecuted(Vec<DispatchResult>), + pub enum Event { + BatchExecuted(Vec<Result<(), DispatchError>>), } ); @@ -58,8 +52,9 @@ decl_module! { ensure_root(origin)?; let results = calls.into_iter() .map(|call| call.dispatch(system::RawOrigin::Root.into())) + .map(|res| res.map_err(Into::into)) .collect::<Vec<_>>(); - Self::deposit_event(RawEvent::BatchExecuted(results)); + Self::deposit_event(Event::BatchExecuted(results)); } } } -- GitLab