mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 16:21:06 +00:00
srml-utility: Store errors as DispatchError to make the decodable (#3766)
This commit is contained in:
committed by
Gavin Wood
parent
954e980ae3
commit
1a327cd894
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user