Migrate away from SimpleDispatchInfo (#5686)

* Migrate away from SimpleDispatchInfo

* Fix imports

* Better doc

* Update lib.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Kian Paimani
2020-04-22 09:20:28 +02:00
committed by GitHub
parent 25c3ab2c1e
commit 50a7e12b3f
40 changed files with 458 additions and 405 deletions
+4 -4
View File
@@ -52,14 +52,14 @@
//!
//! ```
//! use frame_support::{decl_module, dispatch};
//! use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
//! use frame_support::weights::MINIMUM_WEIGHT;
//! use frame_system::{self as system, ensure_root};
//!
//! pub trait Trait: frame_system::Trait {}
//!
//! decl_module! {
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
//! #[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
//! #[weight = MINIMUM_WEIGHT]
//! pub fn privileged_function(origin) -> dispatch::DispatchResult {
//! ensure_root(origin)?;
//!
@@ -93,7 +93,7 @@ use sp_runtime::traits::{StaticLookup, Dispatchable};
use frame_support::{
Parameter, decl_module, decl_event, decl_storage, decl_error, ensure,
};
use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT, GetDispatchInfo, FunctionOf};
use frame_support::weights::{MINIMUM_WEIGHT, GetDispatchInfo, FunctionOf};
use frame_system::{self as system, ensure_signed};
pub trait Trait: frame_system::Trait {
@@ -151,7 +151,7 @@ decl_module! {
/// - Limited storage reads.
/// - One DB change.
/// # </weight>
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
#[weight = MINIMUM_WEIGHT]
fn set_key(origin, new: <T::Lookup as StaticLookup>::Source) {
// This is a public call, so we ensure that the origin is some signed account.
let sender = ensure_signed(origin)?;