mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 18:57:57 +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
Generated
+1
@@ -2481,6 +2481,7 @@ version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
"sr-std 2.0.0",
|
||||
"srml-support 2.0.0",
|
||||
|
||||
@@ -8,6 +8,7 @@ edition = "2018"
|
||||
serde = { version = "1.0", optional = true }
|
||||
parity-codec = { version = "3.3", default-features = false, features = ["derive"] }
|
||||
sr-std = { path = "../../core/sr-std", default-features = false }
|
||||
sr-io = { path = "../../core/sr-io", default-features = false }
|
||||
sr-primitives = { path = "../../core/sr-primitives", default-features = false }
|
||||
srml-support = { path = "../support", default-features = false }
|
||||
srml-support-procedural = { path = "../support/procedural" }
|
||||
@@ -23,6 +24,7 @@ std = [
|
||||
"serde",
|
||||
"parity-codec/std",
|
||||
"sr-std/std",
|
||||
"sr-io/std",
|
||||
"sr-primitives/std",
|
||||
"srml-support/std",
|
||||
"system/std",
|
||||
|
||||
@@ -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