mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 23:57:56 +00:00
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:
committed by
Gavin Wood
parent
4eb18ef2ac
commit
fcf9a46bcc
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user