Make priviledged functions explicity use origin (#3045)

* Make priviledged functions explicity use `origin`

* Fix typo in docs

* Fix more tests

* Remove `root` pathway, add semicolons
This commit is contained in:
Shawn Tabrizi
2019-07-08 15:51:54 +02:00
committed by Bastian Köcher
parent 29311e98b4
commit 3d72844710
11 changed files with 71 additions and 114 deletions
+4 -3
View File
@@ -254,7 +254,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
use srml_support::{StorageValue, dispatch::Result, decl_module, decl_storage, decl_event};
use system::ensure_signed;
use system::{ensure_signed, ensure_root};
use sr_primitives::weights::TransactionWeight;
/// Our module's configuration trait. All our types and consts go in here. If the
@@ -440,7 +440,7 @@ decl_module! {
}
/// A privileged call; in this case it resets our dummy value to something new.
// Implementation of a privileged call. This doesn't have an `origin` parameter because
// Implementation of a privileged call. The `origin` parameter is ROOT because
// it's not (directly) from an extrinsic, but rather the system as a whole has decided
// to execute it. Different runtimes have different reasons for allow privileged
// calls to be executed - we don't need to care why. Because it's privileged, we can
@@ -448,7 +448,8 @@ decl_module! {
// without worrying about gameability or attack scenarios.
// If you not specify `Result` explicitly as return value, it will be added automatically
// for you and `Ok(())` will be returned.
fn set_dummy(#[compact] new_value: T::Balance) {
fn set_dummy(origin, #[compact] new_value: T::Balance) {
ensure_root(origin)?;
// Put the new value into storage.
<Dummy<T>>::put(new_value);
}