diff --git a/srml/support/src/dispatch.rs b/srml/support/src/dispatch.rs index 64ea5938c48c0..c03b6e7afda2b 100644 --- a/srml/support/src/dispatch.rs +++ b/srml/support/src/dispatch.rs @@ -219,6 +219,23 @@ macro_rules! decl_module { $($rest)* ); }; + (@normalize + $(#[$attr:meta])* + pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)?> + for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident + { $( $deposit_event:tt )* } + { $( $on_initialize:tt )* } + {} + { $( $offchain:tt )* } + [ $($t:tt)* ] + $(#[doc = $doc_attr:tt])* + fn on_finalise($($param_name:ident : $param:ty),* ) { $( $impl:tt )* } + $($rest:tt)* + ) => { + compile_error!( + "`on_finalise` was renamed to `on_finalize`. Please rename your function accordingly." + ); + }; (@normalize $(#[$attr:meta])* pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)?> @@ -244,6 +261,23 @@ macro_rules! decl_module { $($rest)* ); }; + (@normalize + $(#[$attr:meta])* + pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)?> + for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident + { $( $deposit_event:tt )* } + {} + { $( $on_finalize:tt )* } + { $( $offchain:tt )* } + [ $($t:tt)* ] + $(#[doc = $doc_attr:tt])* + fn on_initialise($($param_name:ident : $param:ty),* ) { $( $impl:tt )* } + $($rest:tt)* + ) => { + compile_error!( + "`on_initialise` was renamed to `on_initialize`. Please rename your function accordingly." + ); + }; (@normalize $(#[$attr:meta])* pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident> diff --git a/srml/timestamp/src/lib.rs b/srml/timestamp/src/lib.rs index 43cf669e7e701..6c7492c1dcf77 100644 --- a/srml/timestamp/src/lib.rs +++ b/srml/timestamp/src/lib.rs @@ -15,49 +15,49 @@ // along with Substrate. If not, see . //! # Timestamp Module -//! -//! The timestamp module provides functionality to get and set the on-chain time. -//! To use it in your module, you need to implement the timestamp [`Trait`]. +//! +//! The timestamp module provides functionality to get and set the on-chain time. +//! To use it in your module, you need to implement the timestamp [`Trait`]. //! The supported dispatchable functions are documented as part of the [`Call`] enum. -//! +//! //! ## Overview -//! -//! The timestamp module allows the validators to set and validate a timestamp with each block. //! -//! It uses inherents for timestamp data, which is provided by the block author and validated/verified by other validators. +//! The timestamp module allows the validators to set and validate a timestamp with each block. +//! +//! It uses inherents for timestamp data, which is provided by the block author and validated/verified by other validators. //! The timestamp can be set only once per block and must be set each block. There could be a constraint on how much time must pass before setting the new timestamp. -//! -//! **NOTE:** The timestamp module is the recommended way to query the on-chain time instead of using an approach based on block numbers. +//! +//! **NOTE:** The timestamp module is the recommended way to query the on-chain time instead of using an approach based on block numbers. //! The block numbers based time measurement can cause issues because of cummulative calculation errors and hence it should be avoided. -//! +//! //! ## Interface -//! +//! //! ### Dispatchable functions ([`Call`]) -//! +//! //! * `set` - Sets the current time. -//! +//! //! ### Public functions ([`Module`]) -//! +//! //! * `get` - Gets the current time for the current block. If this function is called prior the setting to timestamp, it will return the timestamp of the previous block. -//! +//! //! * `minimum_period` - Gets the minimum (and advised) period between blocks for the chain. -//! +//! //! ## Usage -//! +//! //! The following example shows how to use the timestamp module in your custom module to query the current timestamp. -//! +//! //! ### Prerequisites -//! +//! //! Import the `timestamp` module in your custom module and derive the module configuration trait from the `timestamp` trait. -//! +//! //! ### Get current timestamp -//! +//! //! ```ignore //! use support::{decl_module, dispatch::Result}; //! use system::ensure_signed; -//! +//! //! pub trait Trait: timestamp::Trait {} -//! +//! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { //! pub fn get_time(origin) -> Result { @@ -68,13 +68,13 @@ //! } //! } //! ``` -//! +//! //! ### Example from SRML -//! +//! //! The [`Session` module](https://github.com/paritytech/substrate/blob/master/srml/session/src/lib.rs) uses the `timestamp` module for session management. -//! +//! //! ## Related Modules -//! +//! //! * [`System`](https://crates.parity.io/srml_system/index.html) //! * [`Session`](https://crates.parity.io/srml_session/index.html) //! @@ -212,7 +212,7 @@ decl_module! { /// if this call hasn't been invoked by that time. /// /// The timestamp should be greater than the previous one by the amount specified by `minimum_period`. - /// + /// /// The dispatch origin for this call must be `Inherent`. fn set(origin, #[compact] now: T::Moment) { ensure_inherent(origin)?;