mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 15:21:08 +00:00
Throw a compile error for on_finalise and on_initialise (#2236)
This commit is contained in:
Generated
+1
@@ -2156,6 +2156,7 @@ version = "1.0.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 1.0.0",
|
||||
"sr-std 1.0.0",
|
||||
"srml-session 1.0.0",
|
||||
|
||||
@@ -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)?)?>
|
||||
@@ -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>
|
||||
|
||||
@@ -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 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 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 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 {
|
||||
@@ -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)?;
|
||||
|
||||
Reference in New Issue
Block a user