pallet-sudo: Store DispatchResult in Sudid event (#5804)

This commit is contained in:
Bastian Köcher
2020-04-28 12:25:36 +02:00
committed by GitHub
parent 00378d4092
commit 02f1772023
+4 -11
View File
@@ -87,7 +87,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
use sp_std::prelude::*;
use sp_runtime::traits::{StaticLookup, Dispatchable};
use sp_runtime::{DispatchResult, traits::{StaticLookup, Dispatchable}};
use frame_support::{
Parameter, decl_module, decl_event, decl_storage, decl_error, ensure,
@@ -130,15 +130,8 @@ decl_module! {
let sender = ensure_signed(origin)?;
ensure!(sender == Self::key(), Error::<T>::RequireSudo);
let res = match call.dispatch(frame_system::RawOrigin::Root.into()) {
Ok(_) => true,
Err(e) => {
sp_runtime::print(e);
false
}
};
Self::deposit_event(RawEvent::Sudid(res));
let res = call.dispatch(frame_system::RawOrigin::Root.into());
Self::deposit_event(RawEvent::Sudid(res.map(|_| ()).map_err(|e| e.error)));
}
/// Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo key.
@@ -204,7 +197,7 @@ decl_module! {
decl_event!(
pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId {
/// A sudo just took place.
Sudid(bool),
Sudid(DispatchResult),
/// The sudoer just switched identity; the old key is supplied.
KeyChanged(AccountId),
/// A sudo just took place.