mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 00:01:09 +00:00
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:
@@ -68,14 +68,14 @@
|
||||
//! ### Example - Get extrinsic count and parent hash for the current block
|
||||
//!
|
||||
//! ```
|
||||
//! use frame_support::{decl_module, dispatch, weights::{SimpleDispatchInfo, MINIMUM_WEIGHT}};
|
||||
//! use frame_support::{decl_module, dispatch, weights::MINIMUM_WEIGHT};
|
||||
//! use frame_system::{self as system, ensure_signed};
|
||||
//!
|
||||
//! pub trait Trait: 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 system_module_example(origin) -> dispatch::DispatchResult {
|
||||
//! let _sender = ensure_signed(origin)?;
|
||||
//! let _extrinsic_count = <system::Module<T>>::extrinsic_count();
|
||||
@@ -120,7 +120,7 @@ use frame_support::{
|
||||
Contains, Get, ModuleToIndex, OnNewAccount, OnKilledAccount, IsDeadAccount, Happened,
|
||||
StoredMap, EnsureOrigin,
|
||||
},
|
||||
weights::{Weight, MINIMUM_WEIGHT, RuntimeDbWeight, DispatchInfo, PostDispatchInfo, DispatchClass, SimpleDispatchInfo, FunctionOf}
|
||||
weights::{Weight, MINIMUM_WEIGHT, RuntimeDbWeight, DispatchInfo, PostDispatchInfo, DispatchClass, FunctionOf}
|
||||
};
|
||||
use codec::{Encode, Decode, FullCodec, EncodeLike};
|
||||
|
||||
@@ -485,20 +485,20 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Make some on-chain remark.
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
#[weight = MINIMUM_WEIGHT]
|
||||
fn remark(origin, _remark: Vec<u8>) {
|
||||
ensure_signed(origin)?;
|
||||
}
|
||||
|
||||
/// Set the number of pages in the WebAssembly environment's heap.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(MINIMUM_WEIGHT)]
|
||||
#[weight = (MINIMUM_WEIGHT, DispatchClass::Operational)]
|
||||
fn set_heap_pages(origin, pages: u64) {
|
||||
ensure_root(origin)?;
|
||||
storage::unhashed::put_raw(well_known_keys::HEAP_PAGES, &pages.encode());
|
||||
}
|
||||
|
||||
/// Set the new runtime code.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(200_000_000)]
|
||||
#[weight = (200_000_000, DispatchClass::Operational)]
|
||||
pub fn set_code(origin, code: Vec<u8>) {
|
||||
Self::can_set_code(origin, &code)?;
|
||||
|
||||
@@ -507,7 +507,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Set the new runtime code without doing any checks of the given `code`.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(200_000_000)]
|
||||
#[weight = (200_000_000, DispatchClass::Operational)]
|
||||
pub fn set_code_without_checks(origin, code: Vec<u8>) {
|
||||
ensure_root(origin)?;
|
||||
storage::unhashed::put_raw(well_known_keys::CODE, &code);
|
||||
@@ -515,7 +515,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Set the new changes trie configuration.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(20_000_000)]
|
||||
#[weight = (20_000_000, DispatchClass::Operational)]
|
||||
pub fn set_changes_trie_config(origin, changes_trie_config: Option<ChangesTrieConfiguration>) {
|
||||
ensure_root(origin)?;
|
||||
match changes_trie_config.clone() {
|
||||
@@ -533,7 +533,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Set some items of storage.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(MINIMUM_WEIGHT)]
|
||||
#[weight = (MINIMUM_WEIGHT, DispatchClass::Operational)]
|
||||
fn set_storage(origin, items: Vec<KeyValue>) {
|
||||
ensure_root(origin)?;
|
||||
for i in &items {
|
||||
@@ -542,7 +542,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Kill some items from storage.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(MINIMUM_WEIGHT)]
|
||||
#[weight = (MINIMUM_WEIGHT, DispatchClass::Operational)]
|
||||
fn kill_storage(origin, keys: Vec<Key>) {
|
||||
ensure_root(origin)?;
|
||||
for key in &keys {
|
||||
@@ -551,7 +551,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Kill all storage items with a key that starts with the given prefix.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(MINIMUM_WEIGHT)]
|
||||
#[weight = (MINIMUM_WEIGHT, DispatchClass::Operational)]
|
||||
fn kill_prefix(origin, prefix: Key) {
|
||||
ensure_root(origin)?;
|
||||
storage::unhashed::kill_prefix(&prefix);
|
||||
@@ -559,7 +559,7 @@ decl_module! {
|
||||
|
||||
/// Kill the sending account, assuming there are no references outstanding and the composite
|
||||
/// data is equal to its default value.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(25_000_000)]
|
||||
#[weight = (25_000_000, DispatchClass::Operational)]
|
||||
fn suicide(origin) {
|
||||
let who = ensure_signed(origin)?;
|
||||
let account = Account::<T>::get(&who);
|
||||
|
||||
Reference in New Issue
Block a user