Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions node/runtime/wasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions srml/support/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,23 @@ macro_rules! decl_module {
$($rest)*
);
};
(@normalize
$(#[$attr:meta])*
pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(<I>, 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>, I: $instantiable:path $(= $module_default_instance:path)?)?>
Expand All @@ -244,6 +261,23 @@ macro_rules! decl_module {
$($rest)*
);
};
(@normalize
$(#[$attr:meta])*
pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(<I>, 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>
Expand Down
56 changes: 28 additions & 28 deletions srml/timestamp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,49 @@
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.

//! # 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<T: Trait> for enum Call where origin: T::Origin {
//! pub fn get_time(origin) -> Result {
Expand All @@ -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)
//!
Expand Down Expand Up @@ -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)?;
Expand Down