Forward the result in a sudo call (#2594)

* Forward the result in a sudo call

* Print the error of the wrapped call in `sudo`
This commit is contained in:
Bastian Köcher
2019-05-15 18:14:33 +02:00
committed by Gavin Wood
parent 4eb18ef2ac
commit fcf9a46bcc
3 changed files with 16 additions and 3 deletions
+13 -3
View File
@@ -88,7 +88,10 @@
use sr_std::prelude::*;
use sr_primitives::traits::StaticLookup;
use srml_support::{StorageValue, Parameter, Dispatchable, decl_module, decl_event, decl_storage, ensure};
use srml_support::{
StorageValue, Parameter, Dispatchable, decl_module, decl_event,
decl_storage, ensure
};
use system::ensure_signed;
pub trait Trait: system::Trait {
@@ -112,8 +115,15 @@ decl_module! {
let sender = ensure_signed(origin)?;
ensure!(sender == Self::key(), "only the current sudo key can sudo");
let ok = proposal.dispatch(system::RawOrigin::Root.into()).is_ok();
Self::deposit_event(RawEvent::Sudid(ok));
let res = match proposal.dispatch(system::RawOrigin::Root.into()) {
Ok(_) => true,
Err(e) => {
sr_io::print(e);
false
}
};
Self::deposit_event(RawEvent::Sudid(res));
}
/// Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo key.