Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
pallet-sudo: Store DispatchResult in Sudid event (#5804)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkchr authored Apr 28, 2020
1 parent 64ea9ab commit 8b9a56c
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions frame/sudo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 8b9a56c

Please sign in to comment.