Implement storage json metadata (#670)

* `decl_storage!` exposes json metadata about the storage

The metadata can be accessed by calling `store_json_metadata()`.

* Hide internal macros in the documentation

* Include the function documentation in the store json metadata

* Adapt the storage declarations to use doc comments
This commit is contained in:
Bastian Köcher
2018-09-05 22:53:18 +02:00
committed by Gav Wood
parent 07a59621cc
commit b538733a24
12 changed files with 703 additions and 212 deletions
@@ -218,6 +218,7 @@ macro_rules! decl_dispatch {
}
#[macro_export]
#[doc(hidden)]
/// Implement a single dispatch modules to create a pairing of a dispatch trait and enum.
macro_rules! __decl_dispatch_module_without_aux {
(
@@ -262,6 +263,7 @@ macro_rules! __decl_dispatch_module_without_aux {
}
#[macro_export]
#[doc(hidden)]
/// Implement a single dispatch modules to create a pairing of a dispatch trait and enum.
macro_rules! __decl_dispatch_module_with_aux {
(
@@ -308,6 +310,7 @@ macro_rules! __decl_dispatch_module_with_aux {
/// Implement a single dispatch modules to create a pairing of a dispatch trait and enum.
#[macro_export]
#[doc(hidden)]
macro_rules! __decl_dispatch_module_common {
(
impl for $mod_type:ident<$trait_instance:ident: $trait_name:ident>;
@@ -419,6 +422,7 @@ macro_rules! __decl_dispatch_module_common {
}
#[macro_export]
#[doc(hidden)]
macro_rules! __impl_decode {
(
$input:expr;
@@ -452,6 +456,7 @@ macro_rules! __impl_decode {
}
#[macro_export]
#[doc(hidden)]
macro_rules! __impl_encode {
(
$dest:expr;
@@ -512,7 +517,7 @@ macro_rules! impl_outer_dispatch {
$camelcase ( $crate::dispatch::AuxCallableCallFor<$camelcase> )
,)*
}
impl_outer_dispatch_common! { $call_type, $($camelcase,)* }
__impl_outer_dispatch_common! { $call_type, $($camelcase,)* }
impl $crate::dispatch::AuxDispatchable for $call_type {
type Aux = $aux;
type Trait = $call_type;
@@ -552,7 +557,7 @@ macro_rules! impl_outer_dispatch {
$camelcase ( $crate::dispatch::CallableCallFor<$camelcase> )
,)*
}
impl_outer_dispatch_common! { $call_type, $($camelcase,)* }
__impl_outer_dispatch_common! { $call_type, $($camelcase,)* }
impl $crate::dispatch::Dispatchable for $call_type {
type Trait = $call_type;
fn dispatch(self) -> $crate::dispatch::Result {
@@ -580,7 +585,8 @@ macro_rules! impl_outer_dispatch {
/// Implement a meta-dispatch module to dispatch to other dispatchers.
#[macro_export]
macro_rules! impl_outer_dispatch_common {
#[doc(hidden)]
macro_rules! __impl_outer_dispatch_common {
(
$call_type:ident, $( $camelcase:ident, )*
) => {
@@ -602,6 +608,7 @@ macro_rules! impl_outer_dispatch_common {
/// Implement the `json_metadata` function.
#[macro_export]
#[doc(hidden)]
macro_rules! __impl_json_metadata {
(
impl for $mod_type:ident<$trait_instance:ident: $trait_name:ident>;
@@ -618,6 +625,7 @@ macro_rules! __impl_json_metadata {
/// Convert the list of calls into their JSON representation, joined by ",".
#[macro_export]
#[doc(hidden)]
macro_rules! __calls_to_json {
// WITHOUT AUX
(
@@ -679,6 +687,7 @@ macro_rules! __calls_to_json {
/// Convert a list of function into their JSON representation, joined by ",".
#[macro_export]
#[doc(hidden)]
macro_rules! __functions_to_json {
// WITHOUT AUX
(
@@ -736,6 +745,7 @@ macro_rules! __functions_to_json {
/// Convert a function into its JSON representation.
#[macro_export]
#[doc(hidden)]
macro_rules! __function_to_json {
(
fn $fn_name:ident(
@@ -759,6 +769,7 @@ macro_rules! __function_to_json {
/// Convert a function documentation attribute into its JSON representation.
#[macro_export]
#[doc(hidden)]
macro_rules! __function_doc_to_json {
(
$prefix_str:tt;
@@ -38,6 +38,7 @@ extern crate serde_json;
pub extern crate substrate_codec as codec;
pub use self::storage::generator::Storage as GenericStorage;
#[macro_use]
pub mod dispatch;
pub mod storage;
mod hashable;
@@ -477,6 +477,7 @@ macro_rules! decl_storage {
}
impl<$traitinstance: $traittype> $modulename<$traitinstance> {
__impl_store_fns!($traitinstance $($t)*);
__impl_store_json_metadata!($cratename; $($t)*);
}
};
(
@@ -501,103 +502,103 @@ macro_rules! decl_storage {
#[doc(hidden)]
macro_rules! __decl_storage_items {
// simple values
($cratename:ident $traittype:ident $traitinstance:ident $name:ident : $ty:ty; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* $name:ident : $ty:ty; $($t:tt)*) => {
__decl_storage_item!(() ($traittype as $traitinstance) () (Option<$ty>) (get) (take) $cratename $name: $ty);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident pub $name:ident : $ty:ty; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* pub $name:ident : $ty:ty; $($t:tt)*) => {
__decl_storage_item!((pub) ($traittype as $traitinstance) () (Option<$ty>) (get) (take) $cratename $name: $ty);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident $name:ident : default $ty:ty; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* $name:ident : default $ty:ty; $($t:tt)*) => {
__decl_storage_item!(() ($traittype as $traitinstance) () ($ty) (get_or_default) (take_or_default) $cratename $name: $ty);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident pub $name:ident : default $ty:ty; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* pub $name:ident : default $ty:ty; $($t:tt)*) => {
__decl_storage_item!((pub) ($traittype as $traitinstance) () ($ty) (get_or_default) (take_or_default) $cratename $name: $ty);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident $name:ident : required $ty:ty; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* $name:ident : required $ty:ty; $($t:tt)*) => {
__decl_storage_item!(() ($traittype as $traitinstance) () ($ty) (require) (take_or_panic) $cratename $name: $ty);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident pub $name:ident : required $ty:ty; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* pub $name:ident : required $ty:ty; $($t:tt)*) => {
__decl_storage_item!((pub) ($traittype as $traitinstance) () ($ty) (require) (take_or_panic) $cratename $name: $ty);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident $name:ident get($getfn:ident) : $ty:ty; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* $name:ident get($getfn:ident) : $ty:ty; $($t:tt)*) => {
__decl_storage_item!(() ($traittype as $traitinstance) ($getfn) (Option<$ty>) (get) (take) $cratename $name: $ty);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident pub $name:ident get($getfn:ident) : $ty:ty; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* pub $name:ident get($getfn:ident) : $ty:ty; $($t:tt)*) => {
__decl_storage_item!((pub) ($traittype as $traitinstance) ($getfn) (Option<$ty>) (get) (take) $cratename $name: $ty);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident $name:ident get($getfn:ident) : default $ty:ty; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* $name:ident get($getfn:ident) : default $ty:ty; $($t:tt)*) => {
__decl_storage_item!(() ($traittype as $traitinstance) ($getfn) ($ty) (get_or_default) (take_or_default) $cratename $name: $ty);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident pub $name:ident get($getfn:ident) : default $ty:ty; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* pub $name:ident get($getfn:ident) : default $ty:ty; $($t:tt)*) => {
__decl_storage_item!((pub) ($traittype as $traitinstance) ($getfn) ($ty) (get_or_default) (take_or_default) $cratename $name: $ty);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident $name:ident get($getfn:ident) : required $ty:ty; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* $name:ident get($getfn:ident) : required $ty:ty; $($t:tt)*) => {
__decl_storage_item!(() ($traittype as $traitinstance) ($getfn) ($ty) (require) (take_or_panic) $cratename $name: $ty);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident pub $name:ident get($getfn:ident) : required $ty:ty; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* pub $name:ident get($getfn:ident) : required $ty:ty; $($t:tt)*) => {
__decl_storage_item!((pub) ($traittype as $traitinstance) ($getfn) ($ty) (require) (take_or_panic) $cratename $name: $ty);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
// maps
($cratename:ident $traittype:ident $traitinstance:ident $name:ident : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* $name:ident : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_storage_item!(() ($traittype as $traitinstance) () (Option<$ty>) (get) (take) $cratename $name: map [$kty => $ty]);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident pub $name:ident : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* pub $name:ident : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_storage_item!((pub) ($traittype as $traitinstance) () (Option<$ty>) (get) (take) $cratename $name: map [$kty => $ty]);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident $name:ident : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* $name:ident : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_storage_item!(() ($traittype as $traitinstance) () ($ty) (get_or_default) (take_or_default) $cratename $name: map [$kty => $ty]);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident pub $name:ident : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* pub $name:ident : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_storage_item!((pub) ($traittype as $traitinstance) () ($ty) (get_or_default) (take_or_default) $cratename $name: map [$kty => $ty]);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident $name:ident : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* $name:ident : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_storage_item!(() ($traittype as $traitinstance) () ($ty) (require) (take_or_panic) $cratename $name: map [$kty => $ty]);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident pub $name:ident : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* pub $name:ident : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_storage_item!((pub) ($traittype as $traitinstance) () ($ty) (require) (take_or_panic) $cratename $name: map [$kty => $ty]);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident $name:ident get($getfn:ident) : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* $name:ident get($getfn:ident) : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_storage_item!(() ($traittype as $traitinstance) ($getfn) (Option<$ty>) (get) (take) $cratename $name: map [$kty => $ty]);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident pub $name:ident get($getfn:ident) : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* pub $name:ident get($getfn:ident) : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_storage_item!((pub) ($traittype as $traitinstance) ($getfn) (Option<$ty>) (get) (take) $cratename $name: map [$kty => $ty]);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident $name:ident get($getfn:ident) : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* $name:ident get($getfn:ident) : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_storage_item!(() ($traittype as $traitinstance) ($getfn) ($ty) (get_or_default) (take_or_default) $cratename $name: map [$kty => $ty]);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident pub $name:ident get($getfn:ident) : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* pub $name:ident get($getfn:ident) : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_storage_item!((pub) ($traittype as $traitinstance) ($getfn) ($ty) (get_or_default) (take_or_default) $cratename $name: map [$kty => $ty]);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident $name:ident get($getfn:ident) : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* $name:ident get($getfn:ident) : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_storage_item!(() ($traittype as $traitinstance) ($getfn) ($ty) (require) (take_or_panic) $cratename $name: map [$kty => $ty]);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
($cratename:ident $traittype:ident $traitinstance:ident pub $name:ident get($getfn:ident) : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($cratename:ident $traittype:ident $traitinstance:ident $(#[$doc:meta])* pub $name:ident get($getfn:ident) : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_storage_item!((pub) ($traittype as $traitinstance) ($getfn) ($ty) (require) (take_or_panic) $cratename $name: map [$kty => $ty]);
__decl_storage_items!($cratename $traittype $traitinstance $($t)*);
};
@@ -676,80 +677,80 @@ macro_rules! __decl_storage_item {
#[doc(hidden)]
macro_rules! __decl_store_items {
// simple values
($name:ident : $ty:ty; $($t:tt)*) => {
($(#[$doc:meta])* $name:ident : $ty:ty; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
(pub $name:ident : $ty:ty; $($t:tt)*) => {
($(#[$doc:meta])* pub $name:ident : $ty:ty; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
($name:ident : default $ty:ty; $($t:tt)*) => {
($(#[$doc:meta])* $name:ident : default $ty:ty; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
(pub $name:ident : default $ty:ty; $($t:tt)*) => {
($(#[$doc:meta])* pub $name:ident : default $ty:ty; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
($name:ident : required $ty:ty; $($t:tt)*) => {
($(#[$doc:meta])* $name:ident : required $ty:ty; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
(pub $name:ident : required $ty:ty; $($t:tt)*) => {
($(#[$doc:meta])* pub $name:ident : required $ty:ty; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
($name:ident get($getfn:ident) : $ty:ty; $($t:tt)*) => {
($(#[$doc:meta])* $name:ident get($getfn:ident) : $ty:ty; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
(pub $name:ident get($getfn:ident) : $ty:ty; $($t:tt)*) => {
($(#[$doc:meta])* pub $name:ident get($getfn:ident) : $ty:ty; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
($name:ident get($getfn:ident) : default $ty:ty; $($t:tt)*) => {
($(#[$doc:meta])* $name:ident get($getfn:ident) : default $ty:ty; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
(pub $name:ident get($getfn:ident) : default $ty:ty; $($t:tt)*) => {
($(#[$doc:meta])* pub $name:ident get($getfn:ident) : default $ty:ty; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
($name:ident get($getfn:ident) : required $ty:ty; $($t:tt)*) => {
($(#[$doc:meta])* $name:ident get($getfn:ident) : required $ty:ty; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
(pub $name:ident get($getfn:ident) : required $ty:ty; $($t:tt)*) => {
($(#[$doc:meta])* pub $name:ident get($getfn:ident) : required $ty:ty; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
// maps
($name:ident : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($(#[$doc:meta])* $name:ident : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
(pub $name:ident : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($(#[$doc:meta])* pub $name:ident : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
($name:ident : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($(#[$doc:meta])* $name:ident : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
(pub $name:ident : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($(#[$doc:meta])* pub $name:ident : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
($name:ident : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($(#[$doc:meta])* $name:ident : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
(pub $name:ident : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($(#[$doc:meta])* pub $name:ident : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
($name:ident get($getfn:ident) : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($(#[$doc:meta])* $name:ident get($getfn:ident) : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
(pub $name:ident get($getfn:ident) : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($(#[$doc:meta])* pub $name:ident get($getfn:ident) : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
($name:ident get($getfn:ident) : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($(#[$doc:meta])* $name:ident get($getfn:ident) : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
(pub $name:ident get($getfn:ident) : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($(#[$doc:meta])* pub $name:ident get($getfn:ident) : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
($name:ident get($getfn:ident) : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($(#[$doc:meta])* $name:ident get($getfn:ident) : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
(pub $name:ident get($getfn:ident) : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($(#[$doc:meta])* pub $name:ident get($getfn:ident) : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__decl_store_item!($name); __decl_store_items!($($t)*);
};
@@ -767,91 +768,91 @@ macro_rules! __decl_store_item {
#[doc(hidden)]
macro_rules! __impl_store_fns {
// simple values
($traitinstance:ident $name:ident : $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident : $ty:ty; $($t:tt)*) => {
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident : $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident : $ty:ty; $($t:tt)*) => {
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident : default $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident : default $ty:ty; $($t:tt)*) => {
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident : default $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident : default $ty:ty; $($t:tt)*) => {
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident : required $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident : required $ty:ty; $($t:tt)*) => {
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident : required $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident : required $ty:ty; $($t:tt)*) => {
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident get($getfn:ident) : $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident get($getfn:ident) : $ty:ty; $($t:tt)*) => {
__impl_store_fn!($traitinstance $name $getfn (Option<$ty>) $ty);
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident get($getfn:ident) : $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident get($getfn:ident) : $ty:ty; $($t:tt)*) => {
__impl_store_fn!($traitinstance $name $getfn (Option<$ty>) $ty);
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident get($getfn:ident) : default $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident get($getfn:ident) : default $ty:ty; $($t:tt)*) => {
__impl_store_fn!($traitinstance $name $getfn ($ty) $ty);
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident get($getfn:ident) : default $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident get($getfn:ident) : default $ty:ty; $($t:tt)*) => {
__impl_store_fn!($traitinstance $name $getfn ($ty) $ty);
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident get($getfn:ident) : required $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident get($getfn:ident) : required $ty:ty; $($t:tt)*) => {
__impl_store_fn!($traitinstance $name $getfn ($ty) $ty);
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident get($getfn:ident) : required $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident get($getfn:ident) : required $ty:ty; $($t:tt)*) => {
__impl_store_fn!($traitinstance $name $getfn ($ty) $ty);
__impl_store_fns!($traitinstance $($t)*);
};
// maps
($traitinstance:ident $name:ident : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident get($getfn:ident) : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident get($getfn:ident) : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_fn!($traitinstance $name $getfn (Option<$ty>) map [$kty => $ty]);
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident get($getfn:ident) : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident get($getfn:ident) : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_fn!($traitinstance $name $getfn (Option<$ty>) map [$kty => $ty]);
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident get($getfn:ident) : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident get($getfn:ident) : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_fn!($traitinstance $name $getfn ($ty) map [$kty => $ty]);
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident get($getfn:ident) : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident get($getfn:ident) : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_fn!($traitinstance $name $getfn ($ty) map [$kty => $ty]);
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident get($getfn:ident) : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident get($getfn:ident) : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_fn!($traitinstance $name $getfn ($ty) map [$kty => $ty]);
__impl_store_fns!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident get($getfn:ident) : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident get($getfn:ident) : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_fn!($traitinstance $name $getfn ($ty) map [$kty => $ty]);
__impl_store_fns!($traitinstance $($t)*);
};
@@ -879,103 +880,103 @@ macro_rules! __impl_store_fn {
#[doc(hidden)]
macro_rules! __impl_store_items {
// simple values
($traitinstance:ident $name:ident : $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident : $ty:ty; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident : $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident : $ty:ty; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident : default $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident : default $ty:ty; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident : default $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident : default $ty:ty; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident : required $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident : required $ty:ty; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident : required $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident : required $ty:ty; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident get($getfn:ident) : $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident get($getfn:ident) : $ty:ty; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident get($getfn:ident) : $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident get($getfn:ident) : $ty:ty; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident get($getfn:ident) : default $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident get($getfn:ident) : default $ty:ty; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident get($getfn:ident) : default $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident get($getfn:ident) : default $ty:ty; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident get($getfn:ident) : required $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident get($getfn:ident) : required $ty:ty; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident get($getfn:ident) : required $ty:ty; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident get($getfn:ident) : required $ty:ty; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
// maps
($traitinstance:ident $name:ident : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident get($getfn:ident) : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident get($getfn:ident) : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident get($getfn:ident) : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident get($getfn:ident) : map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident get($getfn:ident) : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident get($getfn:ident) : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident get($getfn:ident) : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident get($getfn:ident) : default map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident $name:ident get($getfn:ident) : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* $name:ident get($getfn:ident) : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
($traitinstance:ident pub $name:ident get($getfn:ident) : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
($traitinstance:ident $(#[$doc:meta])* pub $name:ident get($getfn:ident) : required map [$kty:ty => $ty:ty]; $($t:tt)*) => {
__impl_store_item!($name $traitinstance);
__impl_store_items!($traitinstance $($t)*);
};
@@ -990,12 +991,405 @@ macro_rules! __impl_store_item {
($name:ident $traitinstance:ident) => { type $name = $name<$traitinstance>; }
}
#[macro_export]
#[doc(hidden)]
macro_rules! __impl_store_json_metadata {
(
$cratename:ident;
$($rest:tt)*
) => {
pub fn store_json_metadata() -> &'static str {
concat!(r#"{ "prefix": ""#, stringify!($cratename), r#"", "items": {"#,
__store_functions_to_json!(""; $($rest)*), " } }")
}
}
}
#[macro_export]
#[doc(hidden)]
macro_rules! __store_functions_to_json {
// simple values
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
$name:ident :
$ty:ty; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($ty)
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
pub $name:ident :
$ty:ty; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($ty)
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
$name:ident :
default $ty:ty; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($ty), default
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
pub $name:ident :
default $ty:ty; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($ty), default
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
$name:ident :
required $ty:ty; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($ty), required
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
pub $name:ident :
required $ty:ty; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($ty), required
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
$name:ident get($getfn:ident) :
$ty:ty; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($ty)
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
pub $name:ident get($getfn:ident) :
$ty:ty; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($ty)
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
$name:ident get($getfn:ident) :
default $ty:ty; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($ty), default
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
pub $name:ident get($getfn:ident) :
default $ty:ty; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($ty), default
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
$name:ident get($getfn:ident) :
required $ty:ty; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($ty), required
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
pub $name:ident get($getfn:ident) :
required $ty:ty; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($ty), required
),
__store_functions_to_json!(","; $($t)*)
)
};
// maps
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
$name:ident :
map [$kty:ty => $ty:ty]; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($kty, $ty)
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
pub $name:ident :
map [$kty:ty => $ty:ty]; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($kty, $ty)
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
$name:ident :
default map [$kty:ty => $ty:ty]; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($kty, $ty), default
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
pub $name:ident :
default map [$kty:ty => $ty:ty]; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($kty, $ty), default
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
$name:ident :
required map [$kty:ty => $ty:ty]; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($kty, $ty), required
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
pub $name:ident :
required map [$kty:ty => $ty:ty]; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($kty, $ty), required
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
$name:ident get($getfn:ident) :
map [$kty:ty => $ty:ty]; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($kty, $ty)
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
pub $name:ident get($getfn:ident) :
map [$kty:ty => $ty:ty]; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($kty, $ty)
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])* $name:ident get($getfn:ident) :
default map [$kty:ty => $ty:ty]; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($kty, $ty), default
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
pub $name:ident get($getfn:ident) :
default map [$kty:ty => $ty:ty]; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($kty, $ty), default
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])* $name:ident get($getfn:ident) :
required map [$kty:ty => $ty:ty]; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($kty, $ty), required
),
__store_functions_to_json!(","; $($t)*)
)
};
(
$prefix_str:tt;
$(#[doc = $doc_attr:tt])*
pub $name:ident get($getfn:ident) :
required map [$kty:ty => $ty:ty]; $($t:tt)*
) => {
concat!(
__store_function_to_json!($prefix_str,
__function_doc_to_json!(""; $($doc_attr)*),
$name, __store_type_to_json!($kty, $ty), required
),
__store_functions_to_json!(","; $($t)*)
)
};
($prefix_str:tt;) => { "" }
}
#[macro_export]
#[doc(hidden)]
macro_rules! __store_function_to_json {
($prefix_str:tt, $fn_doc:expr, $name:ident, $type:expr, $modifier:ident) => {
__store_function_to_json!($prefix_str; $fn_doc; $name; $type;
concat!("\"", stringify!($modifier), "\""))
};
($prefix_str:tt, $fn_doc:expr, $name:ident, $type:expr) => {
__store_function_to_json!($prefix_str; $fn_doc; $name; $type; "null")
};
($prefix_str:tt; $fn_doc:expr; $name:ident; $type:expr; $modifier:expr) => {
concat!($prefix_str, " \"", stringify!($name), "\": { ",
r#""description": ["#, $fn_doc, " ], ",
r#""modifier": "#, $modifier, r#", "type": "#, $type, r#" }"#
)
}
}
#[macro_export]
#[doc(hidden)]
macro_rules! __store_type_to_json {
($name:ty) => {
concat!("\"", stringify!($name), "\"")
};
($key: ty, $value:ty) => {
concat!(r#"{ "key": ""#, stringify!($key), r#"", "value": ""#,
stringify!($value), "\" }")
}
}
#[cfg(test)]
// Do not complain about unused `dispatch` and `dispatch_aux`.
#[allow(dead_code)]
mod tests {
use std::collections::HashMap;
use std::cell::RefCell;
use codec::Codec;
use super::*;
use serde;
use serde_json;
impl Storage for RefCell<HashMap<Vec<u8>, Vec<u8>>> {
fn exists(&self, key: &[u8]) -> bool {
@@ -1060,4 +1454,89 @@ mod tests {
assert!(Map::get(&5, &storage).is_none());
assert!(Map::get(&999, &storage).is_none());
}
pub trait Trait {
type PublicAux;
}
decl_module! {
pub struct Module<T: Trait>;
}
decl_storage! {
trait Store for Module<T: Trait> as TestStorage {
/// Hello, this is doc!
U32 : u32;
GETU32 get(u32_getter): u32;
pub PUBU32 : u32;
pub GETPUBU32 get(pub_u32_getter): u32;
U32Default : default u32;
GETU32Default get(get_u32_default): default u32;
pub PUBU32Default : default u32;
pub GETPUBU32Default get(pub_get_u32_default): default u32;
U32Required : required u32;
GETU32Required get(get_u32_required): required u32;
pub PUBU32Required : required u32;
pub GETPUBU32Required get(pub_get_u32_required): required u32;
MAPU32 : map [ u32 => String ];
/// Hello, this is doc!
/// Hello, this is doc 2!
GETMAPU32 get(map_u32_getter): map [ u32 => String ];
pub PUBMAPU32 : map [ u32 => String ];
pub GETPUBMAPU32 get(map_pub_u32_getter): map [ u32 => String ];
MAPU32Default : default map [ u32 => String ];
GETMAPU32Default get(map_get_u32_default): default map [ u32 => String ];
pub PUBMAPU32Default : default map [ u32 => String ];
pub GETPUBMAPU32Default get(map_pub_get_u32_default): default map [ u32 => String ];
MAPU32Required : required map [ u32 => String ];
GETMAPU32Required get(map_get_u32_required): required map [ u32 => String ];
pub PUBMAPU32Required : required map [ u32 => String ];
pub GETPUBMAPU32Required get(map_pub_get_u32_required): required map [ u32 => String ];
}
}
struct TraitImpl {}
impl Trait for TraitImpl {
type PublicAux = u32;
}
const EXPECTED_METADATA: &str = concat!(
r#"{ "prefix": "TestStorage", "items": { "#,
r#""U32": { "description": [ " Hello, this is doc!" ], "modifier": null, "type": "u32" }, "#,
r#""GETU32": { "description": [ ], "modifier": null, "type": "u32" }, "#,
r#""PUBU32": { "description": [ ], "modifier": null, "type": "u32" }, "#,
r#""GETPUBU32": { "description": [ ], "modifier": null, "type": "u32" }, "#,
r#""U32Default": { "description": [ ], "modifier": "default", "type": "u32" }, "#,
r#""GETU32Default": { "description": [ ], "modifier": "default", "type": "u32" }, "#,
r#""PUBU32Default": { "description": [ ], "modifier": "default", "type": "u32" }, "#,
r#""GETPUBU32Default": { "description": [ ], "modifier": "default", "type": "u32" }, "#,
r#""U32Required": { "description": [ ], "modifier": "required", "type": "u32" }, "#,
r#""GETU32Required": { "description": [ ], "modifier": "required", "type": "u32" }, "#,
r#""PUBU32Required": { "description": [ ], "modifier": "required", "type": "u32" }, "#,
r#""GETPUBU32Required": { "description": [ ], "modifier": "required", "type": "u32" }, "#,
r#""MAPU32": { "description": [ ], "modifier": null, "type": { "key": "u32", "value": "String" } }, "#,
r#""GETMAPU32": { "description": [ " Hello, this is doc!", " Hello, this is doc 2!" ], "modifier": null, "type": { "key": "u32", "value": "String" } }, "#,
r#""PUBMAPU32": { "description": [ ], "modifier": null, "type": { "key": "u32", "value": "String" } }, "#,
r#""GETPUBMAPU32": { "description": [ ], "modifier": null, "type": { "key": "u32", "value": "String" } }, "#,
r#""MAPU32Default": { "description": [ ], "modifier": "default", "type": { "key": "u32", "value": "String" } }, "#,
r#""GETMAPU32Default": { "description": [ ], "modifier": "default", "type": { "key": "u32", "value": "String" } }, "#,
r#""PUBMAPU32Default": { "description": [ ], "modifier": "default", "type": { "key": "u32", "value": "String" } }, "#,
r#""GETPUBMAPU32Default": { "description": [ ], "modifier": "default", "type": { "key": "u32", "value": "String" } }, "#,
r#""MAPU32Required": { "description": [ ], "modifier": "required", "type": { "key": "u32", "value": "String" } }, "#,
r#""GETMAPU32Required": { "description": [ ], "modifier": "required", "type": { "key": "u32", "value": "String" } }, "#,
r#""PUBMAPU32Required": { "description": [ ], "modifier": "required", "type": { "key": "u32", "value": "String" } }, "#,
r#""GETPUBMAPU32Required": { "description": [ ], "modifier": "required", "type": { "key": "u32", "value": "String" } }"#,
" } }"
);
#[test]
fn store_json_metadata() {
let metadata = Module::<TraitImpl>::store_json_metadata();
assert_eq!(EXPECTED_METADATA, metadata);
let _: serde::de::IgnoredAny =
serde_json::from_str(metadata).expect("Is valid json syntax");
}
}
+32 -32
View File
@@ -161,55 +161,55 @@ impl<A, I> From<RawEvent<A, I>> for () {
decl_storage! {
trait Store for Module<T: Trait> as Balances {
// The total amount of stake on the system.
/// The total amount of stake on the system.
pub TotalIssuance get(total_stake): required T::Balance;
// The minimum amount allowed to keep an account open.
/// The minimum amount allowed to keep an account open.
pub ExistentialDeposit get(existential_deposit): required T::Balance;
// The amount credited to a destination's account whose index was reclaimed.
/// The amount credited to a destination's account whose index was reclaimed.
pub ReclaimRebate get(reclaim_rebate): required T::Balance;
// The fee required to make a transfer.
/// The fee required to make a transfer.
pub TransferFee get(transfer_fee): required T::Balance;
// The fee required to create an account. At least as big as ReclaimRebate.
/// The fee required to create an account. At least as big as ReclaimRebate.
pub CreationFee get(creation_fee): required T::Balance;
// The next free enumeration set.
/// The next free enumeration set.
pub NextEnumSet get(next_enum_set): required T::AccountIndex;
// The enumeration sets.
/// The enumeration sets.
pub EnumSet get(enum_set): default map [ T::AccountIndex => Vec<T::AccountId> ];
// The "free" balance of a given account.
//
// This is the only balance that matters in terms of most operations on tokens. It is
// alone used to determine the balance when in the contract execution environment. When this
// balance falls below the value of `ExistentialDeposit`, then the "current account" is
// deleted: specifically `FreeBalance`. Furthermore, `OnFreeBalanceZero` callback
// is invoked, giving a chance to external modules to cleanup data associated with
// the deleted account.
//
// `system::AccountNonce` is also deleted if `ReservedBalance` is also zero (it also gets
// collapsed to zero if it ever becomes less than `ExistentialDeposit`.
/// The 'free' balance of a given account.
///
/// This is the only balance that matters in terms of most operations on tokens. It is
/// alone used to determine the balance when in the contract execution environment. When this
/// balance falls below the value of `ExistentialDeposit`, then the 'current account' is
/// deleted: specifically `FreeBalance`. Furthermore, `OnFreeBalanceZero` callback
/// is invoked, giving a chance to external modules to cleanup data associated with
/// the deleted account.
///
/// `system::AccountNonce` is also deleted if `ReservedBalance` is also zero (it also gets
/// collapsed to zero if it ever becomes less than `ExistentialDeposit`.
pub FreeBalance get(free_balance): default map [ T::AccountId => T::Balance ];
// The amount of the balance of a given account that is exterally reserved; this can still get
// slashed, but gets slashed last of all.
//
// This balance is a "reserve" balance that other subsystems use in order to set aside tokens
// that are still "owned" by the account holder, but which are unspendable. (This is different
// and wholly unrelated to the `Bondage` system used in the staking module.)
//
// When this balance falls below the value of `ExistentialDeposit`, then this "reserve account"
// is deleted: specifically, `ReservedBalance`.
//
// `system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets
// collapsed to zero if it ever becomes less than `ExistentialDeposit`.
/// The amount of the balance of a given account that is exterally reserved; this can still get
/// slashed, but gets slashed last of all.
///
/// This balance is a 'reserve' balance that other subsystems use in order to set aside tokens
/// that are still 'owned' by the account holder, but which are unspendable. (This is different
/// and wholly unrelated to the `Bondage` system used in the staking module.)
///
/// When this balance falls below the value of `ExistentialDeposit`, then this 'reserve account'
/// is deleted: specifically, `ReservedBalance`.
///
/// `system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets
/// collapsed to zero if it ever becomes less than `ExistentialDeposit`.
pub ReservedBalance get(reserved_balance): default map [ T::AccountId => T::Balance ];
// Payment stuff.
// The fee to be paid for making a transaction; the base.
/// The fee to be paid for making a transaction; the base.
pub TransactionBaseFee get(transaction_base_fee): required T::Balance;
// The fee to be paid for making a transaction; the per-byte portion.
/// The fee to be paid for making a transaction; the per-byte portion.
pub TransactionByteFee get(transaction_byte_fee): required T::Balance;
}
}
@@ -144,22 +144,22 @@ decl_module! {
decl_storage! {
trait Store for Module<T: Trait> as Contract {
// The fee required to create a contract. At least as big as staking's ReclaimRebate.
/// The fee required to create a contract. At least as big as staking's ReclaimRebate.
ContractFee get(contract_fee): required T::Balance;
// The fee charged for a call into a contract.
/// The fee charged for a call into a contract.
CallBaseFee get(call_base_fee): required T::Gas;
// The fee charged for a create of a contract.
/// The fee charged for a create of a contract.
CreateBaseFee get(create_base_fee): required T::Gas;
// The price of one unit of gas.
/// The price of one unit of gas.
GasPrice get(gas_price): required T::Balance;
// The maximum nesting level of a call/create stack.
/// The maximum nesting level of a call/create stack.
MaxDepth get(max_depth): required u32;
// The maximum amount of gas that could be expended per block.
/// The maximum amount of gas that could be expended per block.
BlockGasLimit get(block_gas_limit): required T::Gas;
// Gas spent so far in this block.
/// Gas spent so far in this block.
GasSpent get(gas_spent): default T::Gas;
// The code associated with an account.
/// The code associated with an account.
pub CodeOf: default map [ T::AccountId => Vec<u8> ]; // TODO Vec<u8> values should be optimised to not do a length prefix.
}
}
+22 -22
View File
@@ -130,53 +130,53 @@ decl_storage! {
trait Store for Module<T: Trait> as Council {
// parameters
// How much should be locked up in order to submit one's candidacy.
/// How much should be locked up in order to submit one's candidacy.
pub CandidacyBond get(candidacy_bond): required T::Balance;
// How much should be locked up in order to be able to submit votes.
/// How much should be locked up in order to be able to submit votes.
pub VotingBond get(voting_bond): required T::Balance;
// The punishment, per voter, if you provide an invalid presentation.
/// The punishment, per voter, if you provide an invalid presentation.
pub PresentSlashPerVoter get(present_slash_per_voter): required T::Balance;
// How many runners-up should have their approvals persist until the next vote.
/// How many runners-up should have their approvals persist until the next vote.
pub CarryCount get(carry_count): required u32;
// How long to give each top candidate to present themselves after the vote ends.
/// How long to give each top candidate to present themselves after the vote ends.
pub PresentationDuration get(presentation_duration): required T::BlockNumber;
// How many votes need to go by after a voter's last vote before they can be reaped if their
// approvals are moot.
/// How many votes need to go by after a voter's last vote before they can be reaped if their
/// approvals are moot.
pub InactiveGracePeriod get(inactivity_grace_period): required VoteIndex;
// How often (in blocks) to check for new votes.
/// How often (in blocks) to check for new votes.
pub VotingPeriod get(voting_period): required T::BlockNumber;
// How long each position is active for.
/// How long each position is active for.
pub TermDuration get(term_duration): required T::BlockNumber;
// Number of accounts that should be sitting on the council.
/// Number of accounts that should be sitting on the council.
pub DesiredSeats get(desired_seats): required u32;
// permanent state (always relevant, changes only at the finalisation of voting)
// The current council. When there's a vote going on, this should still be used for executive
// matters.
/// The current council. When there's a vote going on, this should still be used for executive
/// matters.
pub ActiveCouncil get(active_council): default Vec<(T::AccountId, T::BlockNumber)>;
// The total number of votes that have happened or are in progress.
/// The total number of votes that have happened or are in progress.
pub VoteCount get(vote_index): default VoteIndex;
// persistent state (always relevant, changes constantly)
// The last cleared vote index that this voter was last active at.
/// The last cleared vote index that this voter was last active at.
pub ApprovalsOf get(approvals_of): default map [ T::AccountId => Vec<bool> ];
// The vote index and list slot that the candidate `who` was registered or `None` if they are not
// currently registered.
/// The vote index and list slot that the candidate `who` was registered or `None` if they are not
/// currently registered.
pub RegisterInfoOf get(candidate_reg_info): map [ T::AccountId => (VoteIndex, u32) ];
// The last cleared vote index that this voter was last active at.
/// The last cleared vote index that this voter was last active at.
pub LastActiveOf get(voter_last_active): map [ T::AccountId => VoteIndex ];
// The present voter list.
/// The present voter list.
pub Voters get(voters): default Vec<T::AccountId>;
// The present candidate list.
/// The present candidate list.
pub Candidates get(candidates): default Vec<T::AccountId>; // has holes
pub CandidateCount get(candidate_count): default u32;
// temporary state (only relevant during finalisation/presentation)
// The accounts holding the seats that will become free on the next tally.
/// The accounts holding the seats that will become free on the next tally.
pub NextFinalise get(next_finalise): (T::BlockNumber, u32, Vec<T::AccountId>);
// The stakes as they were at the point that the vote ended.
/// The stakes as they were at the point that the vote ended.
pub SnapshotedStakes get(snapshoted_stakes): required Vec<T::Balance>;
// Get the leaderboard if we;re in the presentation phase.
/// Get the leaderboard if we;re in the presentation phase.
pub Leaderboard get(leaderboard): Vec<(T::Balance, T::AccountId)>; // ORDERED low -> high
}
}
@@ -82,31 +82,31 @@ decl_module! {
decl_storage! {
trait Store for Module<T: Trait> as Democracy {
// The number of (public) proposals that have been made so far.
/// The number of (public) proposals that have been made so far.
pub PublicPropCount get(public_prop_count): default PropIndex;
// The public proposals. Unsorted.
/// The public proposals. Unsorted.
pub PublicProps get(public_props): default Vec<(PropIndex, T::Proposal, T::AccountId)>;
// Those who have locked a deposit.
/// Those who have locked a deposit.
pub DepositOf get(deposit_of): map [ PropIndex => (T::Balance, Vec<T::AccountId>) ];
// How often (in blocks) new public referenda are launched.
/// How often (in blocks) new public referenda are launched.
pub LaunchPeriod get(launch_period): required T::BlockNumber;
// The minimum amount to be used as a deposit for a public referendum proposal.
/// The minimum amount to be used as a deposit for a public referendum proposal.
pub MinimumDeposit get(minimum_deposit): required T::Balance;
// How often (in blocks) to check for new votes.
/// How often (in blocks) to check for new votes.
pub VotingPeriod get(voting_period): required T::BlockNumber;
// The next free referendum index, aka the number of referendums started so far.
/// The next free referendum index, aka the number of referendums started so far.
pub ReferendumCount get(referendum_count): required ReferendumIndex;
// The next referendum index that should be tallied.
/// The next referendum index that should be tallied.
pub NextTally get(next_tally): required ReferendumIndex;
// Information concerning any given referendum.
/// Information concerning any given referendum.
pub ReferendumInfoOf get(referendum_info): map [ ReferendumIndex => (T::BlockNumber, T::Proposal, VoteThreshold) ];
// Get the voters for the current proposal.
/// Get the voters for the current proposal.
pub VotersFor get(voters_for): default map [ ReferendumIndex => Vec<T::AccountId> ];
// Get the vote, if Some, of `who`.
/// Get the vote, if Some, of `who`.
pub VoteOf get(vote_of): map [ (ReferendumIndex, T::AccountId) => bool ];
}
}
@@ -105,23 +105,23 @@ impl<N> From<RawEvent<N>> for () {
decl_storage! {
trait Store for Module<T: Trait> as Session {
// The current set of validators.
/// The current set of validators.
pub Validators get(validators): required Vec<T::AccountId>;
// Current length of the session.
/// Current length of the session.
pub SessionLength get(length): required T::BlockNumber;
// Current index of the session.
/// Current index of the session.
pub CurrentIndex get(current_index): required T::BlockNumber;
// Timestamp when current session started.
/// Timestamp when current session started.
pub CurrentStart get(current_start): required T::Moment;
// New session is being forced is this entry exists; in which case, the boolean value is whether
// the new session should be considered a normal rotation (rewardable) or exceptional (slashable).
/// New session is being forced is this entry exists; in which case, the boolean value is whether
/// the new session should be considered a normal rotation (rewardable) or exceptional (slashable).
pub ForcingNewSession get(forcing_new_session): bool;
// Block at which the session length last changed.
/// Block at which the session length last changed.
LastLengthChange: T::BlockNumber;
// The next key for a given validator.
/// The next key for a given validator.
NextKeyFor: map [ T::AccountId => T::SessionKey ];
// The next session length.
/// The next session length.
NextSessionLength: T::BlockNumber;
}
}
+19 -19
View File
@@ -145,47 +145,47 @@ impl<B, A> From<RawEvent<B, A>> for () {
decl_storage! {
trait Store for Module<T: Trait> as Staking {
// The ideal number of staking participants.
/// The ideal number of staking participants.
pub ValidatorCount get(validator_count): required u32;
// Minimum number of staking participants before emergency conditions are imposed.
/// Minimum number of staking participants before emergency conditions are imposed.
pub MinimumValidatorCount: u32;
// The length of a staking era in sessions.
/// The length of a staking era in sessions.
pub SessionsPerEra get(sessions_per_era): required T::BlockNumber;
// Maximum reward, per validator, that is provided per acceptable session.
/// Maximum reward, per validator, that is provided per acceptable session.
pub SessionReward get(session_reward): required T::Balance;
// Slash, per validator that is taken per abnormal era end.
/// Slash, per validator that is taken per abnormal era end.
pub EarlyEraSlash get(early_era_slash): required T::Balance;
// Number of instances of offline reports before slashing begins for validators.
/// Number of instances of offline reports before slashing begins for validators.
pub OfflineSlashGrace get(offline_slash_grace): default u32;
// The length of the bonding duration in blocks.
/// The length of the bonding duration in blocks.
pub BondingDuration get(bonding_duration): required T::BlockNumber;
// The current era index.
/// The current era index.
pub CurrentEra get(current_era): required T::BlockNumber;
// Preferences that a validator has.
/// Preferences that a validator has.
pub ValidatorPreferences get(validator_preferences): default map [ T::AccountId => ValidatorPrefs<T::Balance> ];
// All the accounts with a desire to stake.
/// All the accounts with a desire to stake.
pub Intentions get(intentions): default Vec<T::AccountId>;
// All nominator -> nominee relationships.
/// All nominator -> nominee relationships.
pub Nominating get(nominating): map [ T::AccountId => T::AccountId ];
// Nominators for a particular account.
/// Nominators for a particular account.
pub NominatorsFor get(nominators_for): default map [ T::AccountId => Vec<T::AccountId> ];
// Nominators for a particular account that is in action right now.
/// Nominators for a particular account that is in action right now.
pub CurrentNominatorsFor get(current_nominators_for): default map [ T::AccountId => Vec<T::AccountId> ];
// The next value of sessions per era.
/// The next value of sessions per era.
pub NextSessionsPerEra get(next_sessions_per_era): T::BlockNumber;
// The session index at which the era length last changed.
/// The session index at which the era length last changed.
pub LastEraLengthChange get(last_era_length_change): default T::BlockNumber;
// The current era stake threshold - unused at present. Consider for removal.
/// The current era stake threshold - unused at present. Consider for removal.
pub StakeThreshold get(stake_threshold): required T::Balance;
// The block at which the `who`'s funds become entirely liquid.
/// The block at which the `who`'s funds become entirely liquid.
pub Bondage get(bondage): default map [ T::AccountId => T::BlockNumber ];
// The number of times a given validator has been reported offline. This gets decremented by one each era that passes.
/// The number of times a given validator has been reported offline. This gets decremented by one each era that passes.
pub SlashCount get(slash_count): default map [ T::AccountId => u32 ];
// We are forcing a new era.
/// We are forcing a new era.
pub ForcingNewEra get(forcing_new_era): ();
}
}
@@ -136,7 +136,7 @@ decl_storage! {
pub ExtrinsicIndex get(extrinsic_index): u32;
ExtrinsicData get(extrinsic_data): required map [ u32 => Vec<u8> ];
RandomSeed get(random_seed): required T::Hash;
// The current block number being processed. Set by `execute_block`.
/// The current block number being processed. Set by `execute_block`.
Number get(block_number): required T::BlockNumber;
ParentHash get(parent_hash): required T::Hash;
ExtrinsicsRoot get(extrinsics_root): required T::Hash;
@@ -63,10 +63,10 @@ decl_module! {
decl_storage! {
trait Store for Module<T: Trait> as Timestamp {
pub Now get(now): required T::Moment;
// The minimum (and advised) period between blocks.
/// The minimum (and advised) period between blocks.
pub BlockPeriod get(block_period): required T::Moment;
// Did the timestamp get updated in this block?
/// Did the timestamp get updated in this block?
DidUpdate: default bool;
}
}
@@ -122,31 +122,31 @@ decl_storage! {
trait Store for Module<T: Trait> as Treasury {
// Config...
// Proportion of funds that should be bonded in order to place a proposal. An accepted
// proposal gets these back. A rejected proposal doesn't.
/// Proportion of funds that should be bonded in order to place a proposal. An accepted
/// proposal gets these back. A rejected proposal doesn't.
ProposalBond get(proposal_bond): required Permill;
// Minimum amount of funds that should be placed ina deposit for making a proposal.
/// Minimum amount of funds that should be placed ina deposit for making a proposal.
ProposalBondMinimum get(proposal_bond_minimum): required T::Balance;
// Period between successive spends.
/// Period between successive spends.
SpendPeriod get(spend_period): required T::BlockNumber;
// Percentage of spare funds (if any) that are burnt per spend period.
/// Percentage of spare funds (if any) that are burnt per spend period.
Burn get(burn): required Permill;
// State...
// Total funds available to this module for spending.
/// Total funds available to this module for spending.
Pot get(pot): default T::Balance;
// Number of proposals that have been made.
/// Number of proposals that have been made.
ProposalCount get(proposal_count): default ProposalIndex;
// Proposals that have been made.
/// Proposals that have been made.
Proposals get(proposals): map [ ProposalIndex => Proposal<T::AccountId, T::Balance> ];
// Proposal indices that have been approved but not yet awarded.
/// Proposal indices that have been approved but not yet awarded.
Approvals get(approvals): default Vec<ProposalIndex>;
}
}