mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 12:41:07 +00:00
Make constants exposable in metadata (#2975)
* Some cleanup * Add module constant metadata declaration * Begin to integrate the constants in `decl_module` * Fixes tests * Fix compilation and add tests * Remove duplicate code * Expose constants in democracy and staking + further fixes * Update srml/metadata/src/lib.rs Co-Authored-By: YJ <yjkimjunior@gmail.com> * Hide `RawEvent` metadata function * Prevent whitespaces in types * Fix `offchain_worker` and `constants` with instances * Up the `impl_version` * Fix macro * Incrase impl_version
This commit is contained in:
@@ -59,7 +59,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
impl_name: create_runtime_str!("substrate-node"),
|
impl_name: create_runtime_str!("substrate-node"),
|
||||||
authoring_version: 10,
|
authoring_version: 10,
|
||||||
spec_version: 99,
|
spec_version: 99,
|
||||||
impl_version: 105,
|
impl_version: 106,
|
||||||
apis: RUNTIME_API_VERSIONS,
|
apis: RUNTIME_API_VERSIONS,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -176,6 +176,7 @@ parameter_types! {
|
|||||||
pub const EnactmentPeriod: BlockNumber = 30 * 24 * 60 * MINUTES;
|
pub const EnactmentPeriod: BlockNumber = 30 * 24 * 60 * MINUTES;
|
||||||
pub const CooloffPeriod: BlockNumber = 30 * 24 * 60 * MINUTES;
|
pub const CooloffPeriod: BlockNumber = 30 * 24 * 60 * MINUTES;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl democracy::Trait for Runtime {
|
impl democracy::Trait for Runtime {
|
||||||
type Proposal = Call;
|
type Proposal = Call;
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
|
|||||||
@@ -497,9 +497,7 @@ mod tests {
|
|||||||
author_a,
|
author_a,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert!(
|
assert!(Authorship::verify_and_import_uncles(vec![uncle_a.clone()]).is_ok());
|
||||||
Authorship::verify_and_import_uncles(vec![uncle_a.clone()]).is_ok()
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Authorship::verify_and_import_uncles(vec![uncle_a.clone()]),
|
Authorship::verify_and_import_uncles(vec![uncle_a.clone()]),
|
||||||
@@ -549,9 +547,7 @@ mod tests {
|
|||||||
author_a,
|
author_a,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert!(
|
assert!(Authorship::verify_and_import_uncles(vec![other_8]).is_ok());
|
||||||
Authorship::verify_and_import_uncles(vec![other_8]).is_ok()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -241,7 +241,6 @@ impl<BlockNumber: Parameter, Proposal: Parameter> ReferendumInfo<BlockNumber, Pr
|
|||||||
|
|
||||||
decl_storage! {
|
decl_storage! {
|
||||||
trait Store for Module<T: Trait> as Democracy {
|
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) build(|_| 0 as PropIndex) : PropIndex;
|
pub PublicPropCount get(public_prop_count) build(|_| 0 as PropIndex) : PropIndex;
|
||||||
/// The public proposals. Unsorted.
|
/// The public proposals. Unsorted.
|
||||||
@@ -318,6 +317,28 @@ decl_event!(
|
|||||||
|
|
||||||
decl_module! {
|
decl_module! {
|
||||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||||
|
/// The minimum period of locking and the period between a proposal being approved and enacted.
|
||||||
|
///
|
||||||
|
/// It should generally be a little more than the unstake period to ensure that
|
||||||
|
/// voting stakers have an opportunity to remove themselves from the system in the case where
|
||||||
|
/// they are on the losing side of a vote.
|
||||||
|
const EnactmentPeriod: T::BlockNumber = T::EnactmentPeriod::get();
|
||||||
|
|
||||||
|
/// How often (in blocks) new public referenda are launched.
|
||||||
|
const LaunchPeriod: T::BlockNumber = T::LaunchPeriod::get();
|
||||||
|
|
||||||
|
/// How often (in blocks) to check for new votes.
|
||||||
|
const VotingPeriod: T::BlockNumber = T::VotingPeriod::get();
|
||||||
|
|
||||||
|
/// The minimum amount to be used as a deposit for a public referendum proposal.
|
||||||
|
const MinimumDeposit: BalanceOf<T> = T::MinimumDeposit::get();
|
||||||
|
|
||||||
|
/// Minimum voting period allowed for an emergency referendum.
|
||||||
|
const EmergencyVotingPeriod: T::BlockNumber = T::EmergencyVotingPeriod::get();
|
||||||
|
|
||||||
|
/// Period in blocks where an external proposal may not be re-submitted after being vetoed.
|
||||||
|
const CooloffPeriod: T::BlockNumber = T::CooloffPeriod::get();
|
||||||
|
|
||||||
fn deposit_event<T>() = default;
|
fn deposit_event<T>() = default;
|
||||||
|
|
||||||
/// Propose a sensitive action to be taken.
|
/// Propose a sensitive action to be taken.
|
||||||
|
|||||||
@@ -102,10 +102,7 @@ impl<B, O> serde::Serialize for DecodeDifferent<B, O>
|
|||||||
B: serde::Serialize + 'static,
|
B: serde::Serialize + 'static,
|
||||||
O: serde::Serialize + 'static,
|
O: serde::Serialize + 'static,
|
||||||
{
|
{
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
|
||||||
where
|
|
||||||
S: serde::Serializer,
|
|
||||||
{
|
|
||||||
match self {
|
match self {
|
||||||
DecodeDifferent::Encode(b) => b.serialize(serializer),
|
DecodeDifferent::Encode(b) => b.serialize(serializer),
|
||||||
DecodeDifferent::Decoded(o) => o.serialize(serializer),
|
DecodeDifferent::Decoded(o) => o.serialize(serializer),
|
||||||
@@ -162,10 +159,7 @@ impl<E: Encode + ::std::fmt::Debug> std::fmt::Debug for FnEncode<E> {
|
|||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
impl<E: Encode + serde::Serialize> serde::Serialize for FnEncode<E> {
|
impl<E: Encode + serde::Serialize> serde::Serialize for FnEncode<E> {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
|
||||||
where
|
|
||||||
S: serde::Serializer,
|
|
||||||
{
|
|
||||||
self.0().serialize(serializer)
|
self.0().serialize(serializer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,21 +184,24 @@ pub struct EventMetadata {
|
|||||||
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// All the metadata about a storage.
|
/// All the metadata about one storage entry.
|
||||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||||
pub struct StorageMetadata {
|
pub struct StorageEntryMetadata {
|
||||||
pub functions: DecodeDifferentArray<StorageFunctionMetadata>,
|
pub name: DecodeDifferentStr,
|
||||||
|
pub modifier: StorageEntryModifier,
|
||||||
|
pub ty: StorageEntryType,
|
||||||
|
pub default: ByteGetter,
|
||||||
|
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// All the metadata about a storage function.
|
/// All the metadata about one module constant.
|
||||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||||
pub struct StorageFunctionMetadata {
|
pub struct ModuleConstantMetadata {
|
||||||
pub name: DecodeDifferentStr,
|
pub name: DecodeDifferentStr,
|
||||||
pub modifier: StorageFunctionModifier,
|
pub ty: DecodeDifferentStr,
|
||||||
pub ty: StorageFunctionType,
|
pub value: ByteGetter,
|
||||||
pub default: ByteGetter,
|
|
||||||
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,10 +235,7 @@ impl Eq for DefaultByteGetter { }
|
|||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
impl serde::Serialize for DefaultByteGetter {
|
impl serde::Serialize for DefaultByteGetter {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
|
||||||
where
|
|
||||||
S: serde::Serializer,
|
|
||||||
{
|
|
||||||
self.0.default_byte().serialize(serializer)
|
self.0.default_byte().serialize(serializer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -264,10 +258,10 @@ pub enum StorageHasher {
|
|||||||
Twox64Concat,
|
Twox64Concat,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A storage function type.
|
/// A storage entry type.
|
||||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||||
pub enum StorageFunctionType {
|
pub enum StorageEntryType {
|
||||||
Plain(DecodeDifferentStr),
|
Plain(DecodeDifferentStr),
|
||||||
Map {
|
Map {
|
||||||
hasher: StorageHasher,
|
hasher: StorageHasher,
|
||||||
@@ -284,10 +278,10 @@ pub enum StorageFunctionType {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A storage function modifier.
|
/// A storage entry modifier.
|
||||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||||
pub enum StorageFunctionModifier {
|
pub enum StorageEntryModifier {
|
||||||
Optional,
|
Optional,
|
||||||
Default,
|
Default,
|
||||||
}
|
}
|
||||||
@@ -313,8 +307,10 @@ pub enum RuntimeMetadata {
|
|||||||
V3(RuntimeMetadataDeprecated),
|
V3(RuntimeMetadataDeprecated),
|
||||||
/// Version 4 for runtime metadata. No longer used.
|
/// Version 4 for runtime metadata. No longer used.
|
||||||
V4(RuntimeMetadataDeprecated),
|
V4(RuntimeMetadataDeprecated),
|
||||||
/// Version 5 for runtime metadata.
|
/// Version 5 for runtime metadata. No longer used.
|
||||||
V5(RuntimeMetadataV5),
|
V5(RuntimeMetadataDeprecated),
|
||||||
|
/// Version 6 for runtime metadata.
|
||||||
|
V6(RuntimeMetadataV6),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enum that should fail.
|
/// Enum that should fail.
|
||||||
@@ -323,8 +319,7 @@ pub enum RuntimeMetadata {
|
|||||||
pub enum RuntimeMetadataDeprecated { }
|
pub enum RuntimeMetadataDeprecated { }
|
||||||
|
|
||||||
impl Encode for RuntimeMetadataDeprecated {
|
impl Encode for RuntimeMetadataDeprecated {
|
||||||
fn encode_to<W: Output>(&self, _dest: &mut W) {
|
fn encode_to<W: Output>(&self, _dest: &mut W) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
@@ -337,7 +332,7 @@ impl Decode for RuntimeMetadataDeprecated {
|
|||||||
/// The metadata of a runtime.
|
/// The metadata of a runtime.
|
||||||
#[derive(Eq, Encode, PartialEq)]
|
#[derive(Eq, Encode, PartialEq)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||||
pub struct RuntimeMetadataV5 {
|
pub struct RuntimeMetadataV6 {
|
||||||
pub modules: DecodeDifferentArray<ModuleMetadata>,
|
pub modules: DecodeDifferentArray<ModuleMetadata>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,12 +342,14 @@ pub struct RuntimeMetadataV5 {
|
|||||||
pub struct ModuleMetadata {
|
pub struct ModuleMetadata {
|
||||||
pub name: DecodeDifferentStr,
|
pub name: DecodeDifferentStr,
|
||||||
pub prefix: DecodeDifferent<FnEncode<&'static str>, StringBuf>,
|
pub prefix: DecodeDifferent<FnEncode<&'static str>, StringBuf>,
|
||||||
pub storage: ODFnA<StorageFunctionMetadata>,
|
pub storage: ODFnA<StorageEntryMetadata>,
|
||||||
pub calls: ODFnA<FunctionMetadata>,
|
pub calls: ODFnA<FunctionMetadata>,
|
||||||
pub event: ODFnA<EventMetadata>,
|
pub event: ODFnA<EventMetadata>,
|
||||||
|
pub constants: DFnA<ModuleConstantMetadata>,
|
||||||
}
|
}
|
||||||
|
|
||||||
type ODFnA<T> = Option<DecodeDifferent<FnEncode<&'static [T]>, Vec<T>>>;
|
type ODFnA<T> = Option<DFnA<T>>;
|
||||||
|
type DFnA<T> = DecodeDifferent<FnEncode<&'static [T]>, Vec<T>>;
|
||||||
|
|
||||||
impl Into<primitives::OpaqueMetadata> for RuntimeMetadataPrefixed {
|
impl Into<primitives::OpaqueMetadata> for RuntimeMetadataPrefixed {
|
||||||
fn into(self) -> primitives::OpaqueMetadata {
|
fn into(self) -> primitives::OpaqueMetadata {
|
||||||
|
|||||||
@@ -607,6 +607,12 @@ decl_event!(
|
|||||||
|
|
||||||
decl_module! {
|
decl_module! {
|
||||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||||
|
/// Number of sessions per era.
|
||||||
|
const SessionsPerEra: SessionIndex = T::SessionsPerEra::get();
|
||||||
|
|
||||||
|
/// Number of eras that staked funds must remain bonded for.
|
||||||
|
const BondingDuration: EraIndex = T::BondingDuration::get();
|
||||||
|
|
||||||
fn deposit_event<T>() = default;
|
fn deposit_event<T>() = default;
|
||||||
|
|
||||||
/// Take the origin account as a stash and lock up `value` of its balance. `controller` will
|
/// Take the origin account as a stash and lock up `value` of its balance. `controller` will
|
||||||
|
|||||||
@@ -162,13 +162,7 @@ pub fn decl_storage_impl(input: TokenStream) -> TokenStream {
|
|||||||
impl<#traitinstance: 'static + #traittype, #instance #bound_instantiable> #module_ident<#traitinstance, #instance> {
|
impl<#traitinstance: 'static + #traittype, #instance #bound_instantiable> #module_ident<#traitinstance, #instance> {
|
||||||
#impl_store_fns
|
#impl_store_fns
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub fn store_metadata() -> #scrate::metadata::StorageMetadata {
|
pub fn store_metadata_functions() -> &'static [#scrate::metadata::StorageEntryMetadata] {
|
||||||
#scrate::metadata::StorageMetadata {
|
|
||||||
functions: #scrate::metadata::DecodeDifferent::Encode(#store_functions_to_metadata) ,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub fn store_metadata_functions() -> &'static [#scrate::metadata::StorageFunctionMetadata] {
|
|
||||||
#store_functions_to_metadata
|
#store_functions_to_metadata
|
||||||
}
|
}
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
@@ -934,7 +928,7 @@ fn store_functions_to_metadata (
|
|||||||
let stype = match type_infos.kind {
|
let stype = match type_infos.kind {
|
||||||
DeclStorageTypeInfosKind::Simple => {
|
DeclStorageTypeInfosKind::Simple => {
|
||||||
quote!{
|
quote!{
|
||||||
#scrate::metadata::StorageFunctionType::Plain(
|
#scrate::metadata::StorageEntryType::Plain(
|
||||||
#scrate::metadata::DecodeDifferent::Encode(#styp),
|
#scrate::metadata::DecodeDifferent::Encode(#styp),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -943,7 +937,7 @@ fn store_functions_to_metadata (
|
|||||||
let hasher = hasher.into_metadata();
|
let hasher = hasher.into_metadata();
|
||||||
let kty = clean_type_string("e!(#key_type).to_string());
|
let kty = clean_type_string("e!(#key_type).to_string());
|
||||||
quote!{
|
quote!{
|
||||||
#scrate::metadata::StorageFunctionType::Map {
|
#scrate::metadata::StorageEntryType::Map {
|
||||||
hasher: #scrate::metadata::#hasher,
|
hasher: #scrate::metadata::#hasher,
|
||||||
key: #scrate::metadata::DecodeDifferent::Encode(#kty),
|
key: #scrate::metadata::DecodeDifferent::Encode(#kty),
|
||||||
value: #scrate::metadata::DecodeDifferent::Encode(#styp),
|
value: #scrate::metadata::DecodeDifferent::Encode(#styp),
|
||||||
@@ -957,7 +951,7 @@ fn store_functions_to_metadata (
|
|||||||
let k2ty = clean_type_string("e!(#key2_type).to_string());
|
let k2ty = clean_type_string("e!(#key2_type).to_string());
|
||||||
let k2_hasher = key2_hasher.into_metadata();
|
let k2_hasher = key2_hasher.into_metadata();
|
||||||
quote!{
|
quote!{
|
||||||
#scrate::metadata::StorageFunctionType::DoubleMap {
|
#scrate::metadata::StorageEntryType::DoubleMap {
|
||||||
hasher: #scrate::metadata::#hasher,
|
hasher: #scrate::metadata::#hasher,
|
||||||
key1: #scrate::metadata::DecodeDifferent::Encode(#k1ty),
|
key1: #scrate::metadata::DecodeDifferent::Encode(#k1ty),
|
||||||
key2: #scrate::metadata::DecodeDifferent::Encode(#k2ty),
|
key2: #scrate::metadata::DecodeDifferent::Encode(#k2ty),
|
||||||
@@ -969,11 +963,11 @@ fn store_functions_to_metadata (
|
|||||||
};
|
};
|
||||||
let modifier = if type_infos.is_option {
|
let modifier = if type_infos.is_option {
|
||||||
quote!{
|
quote!{
|
||||||
#scrate::metadata::StorageFunctionModifier::Optional
|
#scrate::metadata::StorageEntryModifier::Optional
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
quote!{
|
quote!{
|
||||||
#scrate::metadata::StorageFunctionModifier::Default
|
#scrate::metadata::StorageEntryModifier::Default
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let default = default_value.inner.as_ref().map(|d| &d.expr)
|
let default = default_value.inner.as_ref().map(|d| &d.expr)
|
||||||
@@ -998,7 +992,7 @@ fn store_functions_to_metadata (
|
|||||||
let cache_name = proc_macro2::Ident::new(&("__CACHE_GET_BYTE_STRUCT_".to_string() + &str_name), name.span());
|
let cache_name = proc_macro2::Ident::new(&("__CACHE_GET_BYTE_STRUCT_".to_string() + &str_name), name.span());
|
||||||
|
|
||||||
let item = quote! {
|
let item = quote! {
|
||||||
#scrate::metadata::StorageFunctionMetadata {
|
#scrate::metadata::StorageEntryMetadata {
|
||||||
name: #scrate::metadata::DecodeDifferent::Encode(#str_name),
|
name: #scrate::metadata::DecodeDifferent::Encode(#str_name),
|
||||||
modifier: #modifier,
|
modifier: #modifier,
|
||||||
ty: #stype,
|
ty: #stype,
|
||||||
|
|||||||
@@ -17,12 +17,14 @@
|
|||||||
//! Dispatch system. Contains a macro for defining runtime modules and
|
//! Dispatch system. Contains a macro for defining runtime modules and
|
||||||
//! generating values representing lazy module function calls.
|
//! generating values representing lazy module function calls.
|
||||||
|
|
||||||
pub use crate::rstd::prelude::{Vec, Clone, Eq, PartialEq};
|
pub use crate::rstd::{result, prelude::{Vec, Clone, Eq, PartialEq}, marker};
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
pub use std::fmt;
|
pub use std::fmt;
|
||||||
pub use crate::rstd::result;
|
|
||||||
pub use crate::codec::{Codec, Decode, Encode, Input, Output, HasCompact, EncodeAsRef};
|
pub use crate::codec::{Codec, Decode, Encode, Input, Output, HasCompact, EncodeAsRef};
|
||||||
pub use srml_metadata::{FunctionMetadata, DecodeDifferent, DecodeDifferentArray, FunctionArgumentMetadata};
|
pub use srml_metadata::{
|
||||||
|
FunctionMetadata, DecodeDifferent, DecodeDifferentArray, FunctionArgumentMetadata,
|
||||||
|
ModuleConstantMetadata, DefaultByte, DefaultByteGetter,
|
||||||
|
};
|
||||||
pub use sr_primitives::weights::{TransactionWeight, Weighable, Weight};
|
pub use sr_primitives::weights::{TransactionWeight, Weighable, Weight};
|
||||||
|
|
||||||
/// A type that cannot be instantiated.
|
/// A type that cannot be instantiated.
|
||||||
@@ -217,6 +219,7 @@ macro_rules! decl_module {
|
|||||||
{}
|
{}
|
||||||
{}
|
{}
|
||||||
{}
|
{}
|
||||||
|
{}
|
||||||
[]
|
[]
|
||||||
$($t)*
|
$($t)*
|
||||||
);
|
);
|
||||||
@@ -237,6 +240,7 @@ macro_rules! decl_module {
|
|||||||
{}
|
{}
|
||||||
{}
|
{}
|
||||||
{}
|
{}
|
||||||
|
{}
|
||||||
[]
|
[]
|
||||||
$($t)*
|
$($t)*
|
||||||
);
|
);
|
||||||
@@ -251,7 +255,8 @@ macro_rules! decl_module {
|
|||||||
{ $( $on_initialize:tt )* }
|
{ $( $on_initialize:tt )* }
|
||||||
{ $( $on_finalize:tt )* }
|
{ $( $on_finalize:tt )* }
|
||||||
{ $( $offchain:tt )* }
|
{ $( $offchain:tt )* }
|
||||||
[ $($t:tt)* ]
|
{ $( $constants:tt )* }
|
||||||
|
[ $( $dispatchables:tt )* ]
|
||||||
$(#[doc = $doc_attr:tt])*
|
$(#[doc = $doc_attr:tt])*
|
||||||
$vis:vis fn deposit_event $(<$dpeg:ident $(, $dpeg_instance:ident)?>)* () = default;
|
$vis:vis fn deposit_event $(<$dpeg:ident $(, $dpeg_instance:ident)?>)* () = default;
|
||||||
$($rest:tt)*
|
$($rest:tt)*
|
||||||
@@ -264,7 +269,8 @@ macro_rules! decl_module {
|
|||||||
{ $( $on_initialize )* }
|
{ $( $on_initialize )* }
|
||||||
{ $( $on_finalize )* }
|
{ $( $on_finalize )* }
|
||||||
{ $( $offchain )* }
|
{ $( $offchain )* }
|
||||||
[ $($t)* ]
|
{ $( $constants )* }
|
||||||
|
[ $( $dispatchables )* ]
|
||||||
$($rest)*
|
$($rest)*
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -276,7 +282,8 @@ macro_rules! decl_module {
|
|||||||
{ $( $on_initialize:tt )* }
|
{ $( $on_initialize:tt )* }
|
||||||
{ $( $on_finalize:tt )* }
|
{ $( $on_finalize:tt )* }
|
||||||
{ $( $offchain:tt )* }
|
{ $( $offchain:tt )* }
|
||||||
[ $($t:tt)* ]
|
{ $( $constants:tt )* }
|
||||||
|
[ $( $dispatchables:tt )* ]
|
||||||
$(#[doc = $doc_attr:tt])*
|
$(#[doc = $doc_attr:tt])*
|
||||||
$vis:vis fn deposit_event $(<$dpeg:ident $(, $dpeg_instance:ident)?>)* (
|
$vis:vis fn deposit_event $(<$dpeg:ident $(, $dpeg_instance:ident)?>)* (
|
||||||
$($param_name:ident : $param:ty),*
|
$($param_name:ident : $param:ty),*
|
||||||
@@ -291,7 +298,8 @@ macro_rules! decl_module {
|
|||||||
{ $( $on_initialize )* }
|
{ $( $on_initialize )* }
|
||||||
{ $( $on_finalize )* }
|
{ $( $on_finalize )* }
|
||||||
{ $( $offchain )* }
|
{ $( $offchain )* }
|
||||||
[ $($t)* ]
|
{ $( $constants )* }
|
||||||
|
[ $( $dispatchables )* ]
|
||||||
$($rest)*
|
$($rest)*
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -303,7 +311,8 @@ macro_rules! decl_module {
|
|||||||
{ $( $on_initialize:tt )* }
|
{ $( $on_initialize:tt )* }
|
||||||
{}
|
{}
|
||||||
{ $( $offchain:tt )* }
|
{ $( $offchain:tt )* }
|
||||||
[ $($t:tt)* ]
|
{ $( $constants:tt )* }
|
||||||
|
[ $( $dispatchables:tt )* ]
|
||||||
$(#[doc = $doc_attr:tt])*
|
$(#[doc = $doc_attr:tt])*
|
||||||
fn on_finalize($($param_name:ident : $param:ty),* ) { $( $impl:tt )* }
|
fn on_finalize($($param_name:ident : $param:ty),* ) { $( $impl:tt )* }
|
||||||
$($rest:tt)*
|
$($rest:tt)*
|
||||||
@@ -316,7 +325,8 @@ macro_rules! decl_module {
|
|||||||
{ $( $on_initialize )* }
|
{ $( $on_initialize )* }
|
||||||
{ fn on_finalize( $( $param_name : $param ),* ) { $( $impl )* } }
|
{ fn on_finalize( $( $param_name : $param ),* ) { $( $impl )* } }
|
||||||
{ $( $offchain )* }
|
{ $( $offchain )* }
|
||||||
[ $($t)* ]
|
{ $( $constants )* }
|
||||||
|
[ $( $dispatchables )* ]
|
||||||
$($rest)*
|
$($rest)*
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -328,7 +338,8 @@ macro_rules! decl_module {
|
|||||||
{ $( $on_initialize:tt )* }
|
{ $( $on_initialize:tt )* }
|
||||||
{}
|
{}
|
||||||
{ $( $offchain:tt )* }
|
{ $( $offchain:tt )* }
|
||||||
[ $($t:tt)* ]
|
{ $( $constants:tt )* }
|
||||||
|
[ $( $dispatchables:tt )* ]
|
||||||
$(#[doc = $doc_attr:tt])*
|
$(#[doc = $doc_attr:tt])*
|
||||||
fn on_finalise($($param_name:ident : $param:ty),* ) { $( $impl:tt )* }
|
fn on_finalise($($param_name:ident : $param:ty),* ) { $( $impl:tt )* }
|
||||||
$($rest:tt)*
|
$($rest:tt)*
|
||||||
@@ -345,7 +356,8 @@ macro_rules! decl_module {
|
|||||||
{}
|
{}
|
||||||
{ $( $on_finalize:tt )* }
|
{ $( $on_finalize:tt )* }
|
||||||
{ $( $offchain:tt )* }
|
{ $( $offchain:tt )* }
|
||||||
[ $($t:tt)* ]
|
{ $( $constants:tt )* }
|
||||||
|
[ $( $dispatchables:tt )* ]
|
||||||
$(#[doc = $doc_attr:tt])*
|
$(#[doc = $doc_attr:tt])*
|
||||||
fn on_initialize($($param_name:ident : $param:ty),* ) { $( $impl:tt )* }
|
fn on_initialize($($param_name:ident : $param:ty),* ) { $( $impl:tt )* }
|
||||||
$($rest:tt)*
|
$($rest:tt)*
|
||||||
@@ -358,7 +370,8 @@ macro_rules! decl_module {
|
|||||||
{ fn on_initialize( $( $param_name : $param ),* ) { $( $impl )* } }
|
{ fn on_initialize( $( $param_name : $param ),* ) { $( $impl )* } }
|
||||||
{ $( $on_finalize )* }
|
{ $( $on_finalize )* }
|
||||||
{ $( $offchain )* }
|
{ $( $offchain )* }
|
||||||
[ $($t)* ]
|
{ $( $constants )* }
|
||||||
|
[ $( $dispatchables )* ]
|
||||||
$($rest)*
|
$($rest)*
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -370,7 +383,8 @@ macro_rules! decl_module {
|
|||||||
{}
|
{}
|
||||||
{ $( $on_finalize:tt )* }
|
{ $( $on_finalize:tt )* }
|
||||||
{ $( $offchain:tt )* }
|
{ $( $offchain:tt )* }
|
||||||
[ $($t:tt)* ]
|
{ $( $constants:tt )* }
|
||||||
|
[ $( $dispatchables:tt )* ]
|
||||||
$(#[doc = $doc_attr:tt])*
|
$(#[doc = $doc_attr:tt])*
|
||||||
fn on_initialise($($param_name:ident : $param:ty),* ) { $( $impl:tt )* }
|
fn on_initialise($($param_name:ident : $param:ty),* ) { $( $impl:tt )* }
|
||||||
$($rest:tt)*
|
$($rest:tt)*
|
||||||
@@ -381,42 +395,90 @@ macro_rules! decl_module {
|
|||||||
};
|
};
|
||||||
(@normalize
|
(@normalize
|
||||||
$(#[$attr:meta])*
|
$(#[$attr:meta])*
|
||||||
pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident>
|
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
|
for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident
|
||||||
{ $( $deposit_event:tt )* }
|
{ $( $deposit_event:tt )* }
|
||||||
{ $( $on_initialize:tt )* }
|
{ $( $on_initialize:tt )* }
|
||||||
{ $( $on_finalize:tt )* }
|
{ $( $on_finalize:tt )* }
|
||||||
{ }
|
{ }
|
||||||
[ $($t:tt)* ]
|
{ $( $constants:tt )* }
|
||||||
|
[ $( $dispatchables:tt )* ]
|
||||||
$(#[doc = $doc_attr:tt])*
|
$(#[doc = $doc_attr:tt])*
|
||||||
fn offchain_worker($($param_name:ident : $param:ty),* ) { $( $impl:tt )* }
|
fn offchain_worker($($param_name:ident : $param:ty),* ) { $( $impl:tt )* }
|
||||||
$($rest:tt)*
|
$($rest:tt)*
|
||||||
) => {
|
) => {
|
||||||
$crate::decl_module!(@normalize
|
$crate::decl_module!(@normalize
|
||||||
$(#[$attr])*
|
$(#[$attr])*
|
||||||
pub struct $mod_type<$trait_instance: $trait_name>
|
pub struct $mod_type<
|
||||||
|
$trait_instance: $trait_name$(<I>, I: $instantiable $(= $module_default_instance)?)?
|
||||||
|
>
|
||||||
for enum $call_type where origin: $origin_type, system = $system
|
for enum $call_type where origin: $origin_type, system = $system
|
||||||
{ $( $deposit_event )* }
|
{ $( $deposit_event )* }
|
||||||
{ $( $on_initialize )* }
|
{ $( $on_initialize )* }
|
||||||
{ $( $on_finalize )* }
|
{ $( $on_finalize )* }
|
||||||
{ fn offchain_worker( $( $param_name : $param ),* ) { $( $impl )* } }
|
{ fn offchain_worker( $( $param_name : $param ),* ) { $( $impl )* } }
|
||||||
[ $($t)* ]
|
{ $( $constants )* }
|
||||||
|
[ $( $dispatchables )* ]
|
||||||
$($rest)*
|
$($rest)*
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// This puts a constant in the parsed constants list.
|
||||||
|
(@normalize
|
||||||
|
$(#[$attr:meta])*
|
||||||
|
pub struct $mod_type:ident<
|
||||||
|
$trait_instance:ident: $trait_name:ident
|
||||||
|
$(<I>, $instance:ident: $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 )* }
|
||||||
|
{ $( $on_finalize:tt )* }
|
||||||
|
{ $( $offchain:tt )* }
|
||||||
|
{ $( $constants:tt )* }
|
||||||
|
[ $( $dispatchables:tt )* ]
|
||||||
|
$( #[doc = $doc_attr:tt] )*
|
||||||
|
const $name:ident: $ty:ty = $value:expr;
|
||||||
|
$( $rest:tt )*
|
||||||
|
) => {
|
||||||
|
$crate::decl_module!(@normalize
|
||||||
|
$(#[$attr])*
|
||||||
|
pub struct $mod_type<
|
||||||
|
$trait_instance: $trait_name
|
||||||
|
$( <I>, $instance: $instantiable $(= $module_default_instance)? )?
|
||||||
|
>
|
||||||
|
for enum $call_type where origin: $origin_type, system = $system
|
||||||
|
{ $( $deposit_event )* }
|
||||||
|
{ $( $on_initialize )* }
|
||||||
|
{ $( $on_finalize )* }
|
||||||
|
{ $( $offchain )* }
|
||||||
|
{
|
||||||
|
$( $constants )*
|
||||||
|
$( #[doc = $doc_attr ] )*
|
||||||
|
$name: $ty = $value;
|
||||||
|
}
|
||||||
|
[ $( $dispatchables )* ]
|
||||||
|
$($rest)*
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// This puts the function statement into the [], decreasing `$rest` and moving toward finishing the parse.
|
// This puts the function statement into the [], decreasing `$rest` and moving toward finishing the parse.
|
||||||
(@normalize
|
(@normalize
|
||||||
$(#[$attr:meta])*
|
$(#[$attr:meta])*
|
||||||
pub struct $mod_type:ident<
|
pub struct $mod_type:ident<
|
||||||
$trait_instance:ident:
|
$trait_instance:ident: $trait_name:ident
|
||||||
$trait_name:ident$(<I>, $instance:ident: $instantiable:path $(= $module_default_instance:path)?)?
|
$(<I>, $instance:ident: $instantiable:path $(= $module_default_instance:path)?)?
|
||||||
>
|
>
|
||||||
for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident
|
for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident
|
||||||
{ $( $deposit_event:tt )* }
|
{ $( $deposit_event:tt )* }
|
||||||
{ $( $on_initialize:tt )* }
|
{ $( $on_initialize:tt )* }
|
||||||
{ $( $on_finalize:tt )* }
|
{ $( $on_finalize:tt )* }
|
||||||
{ $( $offchain:tt )* }
|
{ $( $offchain:tt )* }
|
||||||
[ $($t:tt)* ]
|
{ $( $constants:tt )* }
|
||||||
|
[ $( $dispatchables:tt )* ]
|
||||||
$(#[doc = $doc_attr:tt])*
|
$(#[doc = $doc_attr:tt])*
|
||||||
#[weight = $weight:expr]
|
#[weight = $weight:expr]
|
||||||
$fn_vis:vis fn $fn_name:ident(
|
$fn_vis:vis fn $fn_name:ident(
|
||||||
@@ -434,8 +496,9 @@ macro_rules! decl_module {
|
|||||||
{ $( $on_initialize )* }
|
{ $( $on_initialize )* }
|
||||||
{ $( $on_finalize )* }
|
{ $( $on_finalize )* }
|
||||||
{ $( $offchain )* }
|
{ $( $offchain )* }
|
||||||
|
{ $( $constants )* }
|
||||||
[
|
[
|
||||||
$($t)*
|
$( $dispatchables )*
|
||||||
$(#[doc = $doc_attr])*
|
$(#[doc = $doc_attr])*
|
||||||
#[weight = $weight]
|
#[weight = $weight]
|
||||||
$fn_vis fn $fn_name(
|
$fn_vis fn $fn_name(
|
||||||
@@ -458,7 +521,8 @@ macro_rules! decl_module {
|
|||||||
{ $( $on_initialize:tt )* }
|
{ $( $on_initialize:tt )* }
|
||||||
{ $( $on_finalize:tt )* }
|
{ $( $on_finalize:tt )* }
|
||||||
{ $( $offchain:tt )* }
|
{ $( $offchain:tt )* }
|
||||||
[ $($t:tt)* ]
|
{ $( $constants:tt )* }
|
||||||
|
[ $( $dispatchables:tt )* ]
|
||||||
$(#[doc = $doc_attr:tt])*
|
$(#[doc = $doc_attr:tt])*
|
||||||
$fn_vis:vis fn $fn_name:ident(
|
$fn_vis:vis fn $fn_name:ident(
|
||||||
$from:ident $(, $(#[$codec_attr:ident])* $param_name:ident : $param:ty)*
|
$from:ident $(, $(#[$codec_attr:ident])* $param_name:ident : $param:ty)*
|
||||||
@@ -475,7 +539,8 @@ macro_rules! decl_module {
|
|||||||
{ $( $on_initialize )* }
|
{ $( $on_initialize )* }
|
||||||
{ $( $on_finalize )* }
|
{ $( $on_finalize )* }
|
||||||
{ $( $offchain )* }
|
{ $( $offchain )* }
|
||||||
[ $($t)* ]
|
{ $( $constants )* }
|
||||||
|
[ $( $dispatchables )* ]
|
||||||
$(#[doc = $doc_attr])*
|
$(#[doc = $doc_attr])*
|
||||||
#[weight = $crate::dispatch::TransactionWeight::default()]
|
#[weight = $crate::dispatch::TransactionWeight::default()]
|
||||||
$fn_vis fn $fn_name(
|
$fn_vis fn $fn_name(
|
||||||
@@ -493,7 +558,8 @@ macro_rules! decl_module {
|
|||||||
{ $( $on_initialize:tt )* }
|
{ $( $on_initialize:tt )* }
|
||||||
{ $( $on_finalize:tt )* }
|
{ $( $on_finalize:tt )* }
|
||||||
{ $( $offchain:tt )* }
|
{ $( $offchain:tt )* }
|
||||||
[ $($t:tt)* ]
|
{ $( $constants:tt )* }
|
||||||
|
[ $( $dispatchables:tt )* ]
|
||||||
$(#[doc = $doc_attr:tt])*
|
$(#[doc = $doc_attr:tt])*
|
||||||
$(#[weight = $weight:expr])?
|
$(#[weight = $weight:expr])?
|
||||||
$fn_vis:vis fn $fn_name:ident(
|
$fn_vis:vis fn $fn_name:ident(
|
||||||
@@ -516,7 +582,8 @@ macro_rules! decl_module {
|
|||||||
{ $( $on_initialize:tt )* }
|
{ $( $on_initialize:tt )* }
|
||||||
{ $( $on_finalize:tt )* }
|
{ $( $on_finalize:tt )* }
|
||||||
{ $( $offchain:tt )* }
|
{ $( $offchain:tt )* }
|
||||||
[ $($t:tt)* ]
|
{ $( $constants:tt )* }
|
||||||
|
[ $( $dispatchables:tt )* ]
|
||||||
$(#[doc = $doc_attr:tt])*
|
$(#[doc = $doc_attr:tt])*
|
||||||
$(#[weight = $weight:expr])?
|
$(#[weight = $weight:expr])?
|
||||||
$fn_vis:vis fn $fn_name:ident(
|
$fn_vis:vis fn $fn_name:ident(
|
||||||
@@ -539,7 +606,8 @@ macro_rules! decl_module {
|
|||||||
{ $( $on_initialize:tt )* }
|
{ $( $on_initialize:tt )* }
|
||||||
{ $( $on_finalize:tt )* }
|
{ $( $on_finalize:tt )* }
|
||||||
{ $( $offchain:tt )* }
|
{ $( $offchain:tt )* }
|
||||||
[ $($t:tt)* ]
|
{ $( $constants:tt )* }
|
||||||
|
[ $( $dispatchables:tt )* ]
|
||||||
$(#[doc = $doc_attr:tt])*
|
$(#[doc = $doc_attr:tt])*
|
||||||
$(#[weight = $weight:expr])?
|
$(#[weight = $weight:expr])?
|
||||||
$fn_vis:vis fn $fn_name:ident(
|
$fn_vis:vis fn $fn_name:ident(
|
||||||
@@ -555,7 +623,8 @@ macro_rules! decl_module {
|
|||||||
{ $( $on_initialize )* }
|
{ $( $on_initialize )* }
|
||||||
{ $( $on_finalize )* }
|
{ $( $on_finalize )* }
|
||||||
{ $( $offchain )* }
|
{ $( $offchain )* }
|
||||||
[ $($t)* ]
|
{ $( $constants )* }
|
||||||
|
[ $( $dispatchables )* ]
|
||||||
|
|
||||||
$(#[doc = $doc_attr])*
|
$(#[doc = $doc_attr])*
|
||||||
$(#[weight = $weight])?
|
$(#[weight = $weight])?
|
||||||
@@ -575,18 +644,20 @@ macro_rules! decl_module {
|
|||||||
{ $( $on_initialize:tt )* }
|
{ $( $on_initialize:tt )* }
|
||||||
{ $( $on_finalize:tt )* }
|
{ $( $on_finalize:tt )* }
|
||||||
{ $( $offchain:tt )* }
|
{ $( $offchain:tt )* }
|
||||||
[ $($t:tt)* ]
|
{ $( $constants:tt )* }
|
||||||
|
[ $( $dispatchables:tt )* ]
|
||||||
) => {
|
) => {
|
||||||
$crate::decl_module!(@imp
|
$crate::decl_module!(@imp
|
||||||
$(#[$attr])*
|
$(#[$attr])*
|
||||||
pub struct $mod_type<$trait_instance: $trait_name$(<I>, I: $instantiable $(= $module_default_instance)?)?>
|
pub struct $mod_type<$trait_instance: $trait_name$(<I>, I: $instantiable $(= $module_default_instance)?)?>
|
||||||
for enum $call_type where origin: $origin_type, system = $system {
|
for enum $call_type where origin: $origin_type, system = $system {
|
||||||
$($t)*
|
$( $dispatchables )*
|
||||||
}
|
}
|
||||||
{ $( $deposit_event )* }
|
{ $( $deposit_event )* }
|
||||||
{ $( $on_initialize )* }
|
{ $( $on_initialize )* }
|
||||||
{ $( $on_finalize )* }
|
{ $( $on_finalize )* }
|
||||||
{ $( $offchain )* }
|
{ $( $offchain )* }
|
||||||
|
{ $( $constants )* }
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -939,10 +1010,9 @@ macro_rules! decl_module {
|
|||||||
{ $( $on_initialize:tt )* }
|
{ $( $on_initialize:tt )* }
|
||||||
{ $( $on_finalize:tt )* }
|
{ $( $on_finalize:tt )* }
|
||||||
{ $( $offchain:tt )* }
|
{ $( $offchain:tt )* }
|
||||||
|
{ $( $constants:tt )* }
|
||||||
) => {
|
) => {
|
||||||
$crate::__check_reserved_fn_name! {
|
$crate::__check_reserved_fn_name! { $( $fn_name )* }
|
||||||
$($fn_name)*
|
|
||||||
}
|
|
||||||
|
|
||||||
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
|
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
|
||||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||||
@@ -1068,7 +1138,10 @@ macro_rules! decl_module {
|
|||||||
impl<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?> $crate::dispatch::fmt::Debug
|
impl<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?> $crate::dispatch::fmt::Debug
|
||||||
for $call_type<$trait_instance $(, $instance)?>
|
for $call_type<$trait_instance $(, $instance)?>
|
||||||
{
|
{
|
||||||
fn fmt(&self, _f: &mut $crate::dispatch::fmt::Formatter) -> $crate::dispatch::result::Result<(), $crate::dispatch::fmt::Error> {
|
fn fmt(
|
||||||
|
&self,
|
||||||
|
_f: &mut $crate::dispatch::fmt::Formatter,
|
||||||
|
) -> $crate::dispatch::result::Result<(), $crate::dispatch::fmt::Error> {
|
||||||
match *self {
|
match *self {
|
||||||
$(
|
$(
|
||||||
$call_type::$fn_name( $( ref $param_name ),* ) =>
|
$call_type::$fn_name( $( ref $param_name ),* ) =>
|
||||||
@@ -1110,7 +1183,10 @@ macro_rules! decl_module {
|
|||||||
|
|
||||||
impl<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?> $mod_type<$trait_instance $(, $instance)?> {
|
impl<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?> $mod_type<$trait_instance $(, $instance)?> {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub fn dispatch<D: $crate::dispatch::Dispatchable<Trait = $trait_instance>>(d: D, origin: D::Origin) -> $crate::dispatch::Result {
|
pub fn dispatch<D: $crate::dispatch::Dispatchable<Trait = $trait_instance>>(
|
||||||
|
d: D,
|
||||||
|
origin: D::Origin,
|
||||||
|
) -> $crate::dispatch::Result {
|
||||||
d.dispatch(origin)
|
d.dispatch(origin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1118,6 +1194,10 @@ macro_rules! decl_module {
|
|||||||
$mod_type<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?> $call_type $origin_type
|
$mod_type<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?> $call_type $origin_type
|
||||||
{$( $(#[doc = $doc_attr])* fn $fn_name($from $(, $(#[$codec_attr])* $param_name : $param )*); )*}
|
{$( $(#[doc = $doc_attr])* fn $fn_name($from $(, $(#[$codec_attr])* $param_name : $param )*); )*}
|
||||||
}
|
}
|
||||||
|
$crate::__impl_module_constants_metadata ! {
|
||||||
|
$mod_type<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?>
|
||||||
|
$( $constants )*
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1191,6 +1271,115 @@ macro_rules! __dispatch_impl_metadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Implement metadata for module constants.
|
||||||
|
#[macro_export]
|
||||||
|
#[doc(hidden)]
|
||||||
|
macro_rules! __impl_module_constants_metadata {
|
||||||
|
// Without instance
|
||||||
|
(
|
||||||
|
$mod_type:ident<$trait_instance:ident: $trait_name:ident>
|
||||||
|
$(
|
||||||
|
$( #[doc = $doc_attr:tt] )*
|
||||||
|
$name:ident: $type:ty = $value:expr;
|
||||||
|
)*
|
||||||
|
) => {
|
||||||
|
$crate::paste::item! {
|
||||||
|
$crate::__impl_module_constants_metadata! {
|
||||||
|
GENERATE_CODE
|
||||||
|
$mod_type<$trait_instance: $trait_name>
|
||||||
|
$(
|
||||||
|
$( #[doc = $doc_attr] )*
|
||||||
|
[< $name DefaultByteGetter >]
|
||||||
|
$name<$trait_instance: $trait_name>: $type = $value;
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// With instance
|
||||||
|
(
|
||||||
|
$mod_type:ident<$trait_instance:ident: $trait_name:ident<I>, $instance:ident: $instantiable:path>
|
||||||
|
$(
|
||||||
|
$( #[doc = $doc_attr:tt] )*
|
||||||
|
$name:ident: $type:ty = $value:expr;
|
||||||
|
)*
|
||||||
|
) => {
|
||||||
|
$crate::paste::item! {
|
||||||
|
$crate::__impl_module_constants_metadata! {
|
||||||
|
GENERATE_CODE
|
||||||
|
$mod_type<$trait_instance: $trait_name<I>, $instance: $instantiable>
|
||||||
|
$(
|
||||||
|
$( #[doc = $doc_attr] )*
|
||||||
|
[< $name DefaultByteGetter >]
|
||||||
|
$name<$trait_instance: $trait_name<I>, $instance: $instantiable>: $type = $value;
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// Do the code generation
|
||||||
|
(GENERATE_CODE
|
||||||
|
$mod_type:ident<$trait_instance:ident: $trait_name:ident $(<I>, $instance:ident: $instantiable:path)?>
|
||||||
|
$(
|
||||||
|
$( #[doc = $doc_attr:tt] )*
|
||||||
|
$default_byte_name:ident
|
||||||
|
$name:ident<
|
||||||
|
$const_trait_instance:ident: $const_trait_name:ident $(
|
||||||
|
<I>, $const_instance:ident: $const_instantiable:path
|
||||||
|
)*
|
||||||
|
>: $type:ty = $value:expr;
|
||||||
|
)*
|
||||||
|
) => {
|
||||||
|
impl<$trait_instance: 'static + $trait_name $(<I>, $instance: $instantiable)?>
|
||||||
|
$mod_type<$trait_instance $(, $instance)?>
|
||||||
|
{
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub fn module_constants_metadata() -> &'static [$crate::dispatch::ModuleConstantMetadata] {
|
||||||
|
// Create the `ByteGetter`s
|
||||||
|
$(
|
||||||
|
#[allow(non_upper_case_types)]
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
struct $default_byte_name<
|
||||||
|
$const_trait_instance: $const_trait_name $(
|
||||||
|
<I>, $const_instance: $const_instantiable
|
||||||
|
)?
|
||||||
|
>($crate::dispatch::marker::PhantomData<
|
||||||
|
($const_trait_instance $(, $const_instance)?)
|
||||||
|
>);
|
||||||
|
impl<$const_trait_instance: 'static + $const_trait_name $(
|
||||||
|
<I>, $const_instance: $const_instantiable)?
|
||||||
|
> $crate::dispatch::DefaultByte
|
||||||
|
for $default_byte_name <$const_trait_instance $(, $const_instance)?>
|
||||||
|
{
|
||||||
|
fn default_byte(&self) -> $crate::dispatch::Vec<u8> {
|
||||||
|
let value: $type = $value;
|
||||||
|
$crate::dispatch::Encode::encode(&value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)*
|
||||||
|
&[
|
||||||
|
$(
|
||||||
|
$crate::dispatch::ModuleConstantMetadata {
|
||||||
|
name: $crate::dispatch::DecodeDifferent::Encode(stringify!($name)),
|
||||||
|
ty: $crate::dispatch::DecodeDifferent::Encode(stringify!($type)),
|
||||||
|
value: $crate::dispatch::DecodeDifferent::Encode(
|
||||||
|
$crate::dispatch::DefaultByteGetter(
|
||||||
|
&$default_byte_name::<
|
||||||
|
$const_trait_instance $(, $const_instance)?
|
||||||
|
>(
|
||||||
|
$crate::dispatch::marker::PhantomData
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
documentation: $crate::dispatch::DecodeDifferent::Encode(
|
||||||
|
&[ $( $doc_attr ),* ]
|
||||||
|
),
|
||||||
|
}
|
||||||
|
),*
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Convert the list of calls into their JSON representation, joined by ",".
|
/// Convert the list of calls into their JSON representation, joined by ",".
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ macro_rules! decl_event {
|
|||||||
}
|
}
|
||||||
impl Event {
|
impl Event {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
#[doc(hidden)]
|
||||||
pub fn metadata() -> &'static [ $crate::event::EventMetadata ] {
|
pub fn metadata() -> &'static [ $crate::event::EventMetadata ] {
|
||||||
$crate::__events_to_metadata!(; $( $events )* )
|
$crate::__events_to_metadata!(; $( $events )* )
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,8 +242,8 @@ mod tests {
|
|||||||
use codec::Codec;
|
use codec::Codec;
|
||||||
use runtime_io::{with_externalities, Blake2Hasher};
|
use runtime_io::{with_externalities, Blake2Hasher};
|
||||||
pub use srml_metadata::{
|
pub use srml_metadata::{
|
||||||
DecodeDifferent, StorageMetadata, StorageFunctionMetadata,
|
DecodeDifferent, StorageEntryMetadata,
|
||||||
StorageFunctionType, StorageFunctionModifier,
|
StorageEntryType, StorageEntryModifier,
|
||||||
DefaultByte, DefaultByteGetter, StorageHasher
|
DefaultByte, DefaultByteGetter, StorageHasher
|
||||||
};
|
};
|
||||||
pub use rstd::marker::PhantomData;
|
pub use rstd::marker::PhantomData;
|
||||||
@@ -422,114 +422,112 @@ mod tests {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const EXPECTED_METADATA: StorageMetadata = StorageMetadata {
|
const EXPECTED_METADATA: &[StorageEntryMetadata] = &[
|
||||||
functions: DecodeDifferent::Encode(&[
|
StorageEntryMetadata {
|
||||||
StorageFunctionMetadata {
|
name: DecodeDifferent::Encode("Data"),
|
||||||
name: DecodeDifferent::Encode("Data"),
|
modifier: StorageEntryModifier::Default,
|
||||||
modifier: StorageFunctionModifier::Default,
|
ty: StorageEntryType::Map{
|
||||||
ty: StorageFunctionType::Map{
|
hasher: StorageHasher::Twox64Concat,
|
||||||
hasher: StorageHasher::Twox64Concat,
|
key: DecodeDifferent::Encode("u32"), value: DecodeDifferent::Encode("u64"), is_linked: true
|
||||||
key: DecodeDifferent::Encode("u32"), value: DecodeDifferent::Encode("u64"), is_linked: true
|
|
||||||
},
|
|
||||||
default: DecodeDifferent::Encode(
|
|
||||||
DefaultByteGetter(&__GetByteStructData(PhantomData::<Test>))
|
|
||||||
),
|
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
|
||||||
},
|
},
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("GenericData"),
|
DefaultByteGetter(&__GetByteStructData(PhantomData::<Test>))
|
||||||
modifier: StorageFunctionModifier::Default,
|
),
|
||||||
ty: StorageFunctionType::Map{
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
hasher: StorageHasher::Twox128,
|
},
|
||||||
key: DecodeDifferent::Encode("T::BlockNumber"),
|
StorageEntryMetadata {
|
||||||
value: DecodeDifferent::Encode("T::BlockNumber"),
|
name: DecodeDifferent::Encode("GenericData"),
|
||||||
is_linked: true
|
modifier: StorageEntryModifier::Default,
|
||||||
},
|
ty: StorageEntryType::Map{
|
||||||
default: DecodeDifferent::Encode(
|
hasher: StorageHasher::Twox128,
|
||||||
DefaultByteGetter(&__GetByteStructGenericData(PhantomData::<Test>))
|
key: DecodeDifferent::Encode("T::BlockNumber"),
|
||||||
),
|
value: DecodeDifferent::Encode("T::BlockNumber"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
is_linked: true
|
||||||
},
|
},
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("GenericData2"),
|
DefaultByteGetter(&__GetByteStructGenericData(PhantomData::<Test>))
|
||||||
modifier: StorageFunctionModifier::Optional,
|
),
|
||||||
ty: StorageFunctionType::Map{
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
hasher: StorageHasher::Blake2_256,
|
},
|
||||||
key: DecodeDifferent::Encode("T::BlockNumber"),
|
StorageEntryMetadata {
|
||||||
value: DecodeDifferent::Encode("T::BlockNumber"),
|
name: DecodeDifferent::Encode("GenericData2"),
|
||||||
is_linked: true
|
modifier: StorageEntryModifier::Optional,
|
||||||
},
|
ty: StorageEntryType::Map{
|
||||||
default: DecodeDifferent::Encode(
|
hasher: StorageHasher::Blake2_256,
|
||||||
DefaultByteGetter(&__GetByteStructGenericData2(PhantomData::<Test>))
|
key: DecodeDifferent::Encode("T::BlockNumber"),
|
||||||
),
|
value: DecodeDifferent::Encode("T::BlockNumber"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
is_linked: true
|
||||||
},
|
},
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("DataDM"),
|
DefaultByteGetter(&__GetByteStructGenericData2(PhantomData::<Test>))
|
||||||
modifier: StorageFunctionModifier::Default,
|
),
|
||||||
ty: StorageFunctionType::DoubleMap{
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
hasher: StorageHasher::Twox64Concat,
|
},
|
||||||
key1: DecodeDifferent::Encode("u32"),
|
StorageEntryMetadata {
|
||||||
key2: DecodeDifferent::Encode("u32"),
|
name: DecodeDifferent::Encode("DataDM"),
|
||||||
value: DecodeDifferent::Encode("u64"),
|
modifier: StorageEntryModifier::Default,
|
||||||
key2_hasher: StorageHasher::Blake2_256,
|
ty: StorageEntryType::DoubleMap{
|
||||||
},
|
hasher: StorageHasher::Twox64Concat,
|
||||||
default: DecodeDifferent::Encode(
|
key1: DecodeDifferent::Encode("u32"),
|
||||||
DefaultByteGetter(&__GetByteStructDataDM(PhantomData::<Test>))
|
key2: DecodeDifferent::Encode("u32"),
|
||||||
),
|
value: DecodeDifferent::Encode("u64"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
key2_hasher: StorageHasher::Blake2_256,
|
||||||
},
|
},
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("GenericDataDM"),
|
DefaultByteGetter(&__GetByteStructDataDM(PhantomData::<Test>))
|
||||||
modifier: StorageFunctionModifier::Default,
|
),
|
||||||
ty: StorageFunctionType::DoubleMap{
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
hasher: StorageHasher::Blake2_256,
|
},
|
||||||
key1: DecodeDifferent::Encode("T::BlockNumber"),
|
StorageEntryMetadata {
|
||||||
key2: DecodeDifferent::Encode("T::BlockNumber"),
|
name: DecodeDifferent::Encode("GenericDataDM"),
|
||||||
value: DecodeDifferent::Encode("T::BlockNumber"),
|
modifier: StorageEntryModifier::Default,
|
||||||
key2_hasher: StorageHasher::Twox128,
|
ty: StorageEntryType::DoubleMap{
|
||||||
},
|
hasher: StorageHasher::Blake2_256,
|
||||||
default: DecodeDifferent::Encode(
|
key1: DecodeDifferent::Encode("T::BlockNumber"),
|
||||||
DefaultByteGetter(&__GetByteStructGenericDataDM(PhantomData::<Test>))
|
key2: DecodeDifferent::Encode("T::BlockNumber"),
|
||||||
),
|
value: DecodeDifferent::Encode("T::BlockNumber"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
key2_hasher: StorageHasher::Twox128,
|
||||||
},
|
},
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("GenericData2DM"),
|
DefaultByteGetter(&__GetByteStructGenericDataDM(PhantomData::<Test>))
|
||||||
modifier: StorageFunctionModifier::Optional,
|
),
|
||||||
ty: StorageFunctionType::DoubleMap{
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
hasher: StorageHasher::Blake2_256,
|
},
|
||||||
key1: DecodeDifferent::Encode("T::BlockNumber"),
|
StorageEntryMetadata {
|
||||||
key2: DecodeDifferent::Encode("T::BlockNumber"),
|
name: DecodeDifferent::Encode("GenericData2DM"),
|
||||||
value: DecodeDifferent::Encode("T::BlockNumber"),
|
modifier: StorageEntryModifier::Optional,
|
||||||
key2_hasher: StorageHasher::Twox256,
|
ty: StorageEntryType::DoubleMap{
|
||||||
},
|
hasher: StorageHasher::Blake2_256,
|
||||||
default: DecodeDifferent::Encode(
|
key1: DecodeDifferent::Encode("T::BlockNumber"),
|
||||||
DefaultByteGetter(&__GetByteStructGenericData2DM(PhantomData::<Test>))
|
key2: DecodeDifferent::Encode("T::BlockNumber"),
|
||||||
),
|
value: DecodeDifferent::Encode("T::BlockNumber"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
key2_hasher: StorageHasher::Twox256,
|
||||||
},
|
},
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("AppendableDM"),
|
DefaultByteGetter(&__GetByteStructGenericData2DM(PhantomData::<Test>))
|
||||||
modifier: StorageFunctionModifier::Default,
|
),
|
||||||
ty: StorageFunctionType::DoubleMap{
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
hasher: StorageHasher::Blake2_256,
|
},
|
||||||
key1: DecodeDifferent::Encode("u32"),
|
StorageEntryMetadata {
|
||||||
key2: DecodeDifferent::Encode("T::BlockNumber"),
|
name: DecodeDifferent::Encode("AppendableDM"),
|
||||||
value: DecodeDifferent::Encode("Vec<u32>"),
|
modifier: StorageEntryModifier::Default,
|
||||||
key2_hasher: StorageHasher::Blake2_256,
|
ty: StorageEntryType::DoubleMap{
|
||||||
},
|
hasher: StorageHasher::Blake2_256,
|
||||||
default: DecodeDifferent::Encode(
|
key1: DecodeDifferent::Encode("u32"),
|
||||||
DefaultByteGetter(&__GetByteStructGenericData2DM(PhantomData::<Test>))
|
key2: DecodeDifferent::Encode("T::BlockNumber"),
|
||||||
),
|
value: DecodeDifferent::Encode("Vec<u32>"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
key2_hasher: StorageHasher::Blake2_256,
|
||||||
},
|
},
|
||||||
])
|
default: DecodeDifferent::Encode(
|
||||||
};
|
DefaultByteGetter(&__GetByteStructGenericData2DM(PhantomData::<Test>))
|
||||||
|
),
|
||||||
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn store_metadata() {
|
fn store_metadata() {
|
||||||
let metadata = Module::<Test>::store_metadata();
|
let metadata = Module::<Test>::store_metadata_functions();
|
||||||
assert_eq!(EXPECTED_METADATA, metadata);
|
assert_eq!(EXPECTED_METADATA, metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,15 +15,11 @@
|
|||||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pub use srml_metadata::{
|
pub use srml_metadata::{
|
||||||
DecodeDifferent, FnEncode, RuntimeMetadata,
|
DecodeDifferent, FnEncode, RuntimeMetadata, ModuleMetadata, RuntimeMetadataV6,
|
||||||
ModuleMetadata, RuntimeMetadataV5,
|
DefaultByteGetter, RuntimeMetadataPrefixed, StorageEntryMetadata,
|
||||||
DefaultByteGetter, RuntimeMetadataPrefixed,
|
StorageEntryType, StorageEntryModifier, DefaultByte, StorageHasher
|
||||||
StorageMetadata, StorageFunctionMetadata,
|
|
||||||
StorageFunctionType, StorageFunctionModifier,
|
|
||||||
DefaultByte, StorageHasher
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// Implements the metadata support for the given runtime and all its modules.
|
/// Implements the metadata support for the given runtime and all its modules.
|
||||||
///
|
///
|
||||||
/// Example:
|
/// Example:
|
||||||
@@ -40,8 +36,8 @@ macro_rules! impl_runtime_metadata {
|
|||||||
) => {
|
) => {
|
||||||
impl $runtime {
|
impl $runtime {
|
||||||
pub fn metadata() -> $crate::metadata::RuntimeMetadataPrefixed {
|
pub fn metadata() -> $crate::metadata::RuntimeMetadataPrefixed {
|
||||||
$crate::metadata::RuntimeMetadata::V5 (
|
$crate::metadata::RuntimeMetadata::V6 (
|
||||||
$crate::metadata::RuntimeMetadataV5 {
|
$crate::metadata::RuntimeMetadataV6 {
|
||||||
modules: $crate::__runtime_modules_to_metadata!($runtime;; $( $rest )*),
|
modules: $crate::__runtime_modules_to_metadata!($runtime;; $( $rest )*),
|
||||||
}
|
}
|
||||||
).into()
|
).into()
|
||||||
@@ -67,6 +63,11 @@ macro_rules! __runtime_modules_to_metadata {
|
|||||||
storage: $crate::__runtime_modules_to_metadata_calls_storage!($mod, $module $( <$instance> )?, $runtime, $(with $kw)*),
|
storage: $crate::__runtime_modules_to_metadata_calls_storage!($mod, $module $( <$instance> )?, $runtime, $(with $kw)*),
|
||||||
calls: $crate::__runtime_modules_to_metadata_calls_call!($mod, $module $( <$instance> )?, $runtime, $(with $kw)*),
|
calls: $crate::__runtime_modules_to_metadata_calls_call!($mod, $module $( <$instance> )?, $runtime, $(with $kw)*),
|
||||||
event: $crate::__runtime_modules_to_metadata_calls_event!($mod, $module $( <$instance> )?, $runtime, $(with $kw)*),
|
event: $crate::__runtime_modules_to_metadata_calls_event!($mod, $module $( <$instance> )?, $runtime, $(with $kw)*),
|
||||||
|
constants: $crate::metadata::DecodeDifferent::Encode(
|
||||||
|
$crate::metadata::FnEncode(
|
||||||
|
$mod::$module::<$runtime $(, $mod::$instance )?>::module_constants_metadata
|
||||||
|
)
|
||||||
|
)
|
||||||
};
|
};
|
||||||
$( $rest )*
|
$( $rest )*
|
||||||
)
|
)
|
||||||
@@ -227,23 +228,31 @@ macro_rules! __runtime_modules_to_metadata_calls_storage {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use srml_metadata::{
|
use srml_metadata::{
|
||||||
EventMetadata,
|
EventMetadata, StorageEntryModifier, StorageEntryType, FunctionMetadata, StorageEntryMetadata,
|
||||||
StorageFunctionModifier, StorageFunctionType, FunctionMetadata,
|
ModuleMetadata, RuntimeMetadataPrefixed, DefaultByte, ModuleConstantMetadata, DefaultByteGetter,
|
||||||
StorageFunctionMetadata,
|
|
||||||
ModuleMetadata, RuntimeMetadataPrefixed
|
|
||||||
};
|
};
|
||||||
use crate::codec::{Encode, Decode};
|
use codec::{Encode, Decode};
|
||||||
|
use crate::traits::Get;
|
||||||
|
|
||||||
mod system {
|
mod system {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
pub trait Trait {
|
pub trait Trait {
|
||||||
|
const ASSOCIATED_CONST: u64 = 500;
|
||||||
type Origin: Into<Result<RawOrigin<Self::AccountId>, Self::Origin>>
|
type Origin: Into<Result<RawOrigin<Self::AccountId>, Self::Origin>>
|
||||||
+ From<RawOrigin<Self::AccountId>>;
|
+ From<RawOrigin<Self::AccountId>>;
|
||||||
type AccountId;
|
type AccountId: From<u32> + Encode;
|
||||||
type BlockNumber;
|
type BlockNumber: From<u32> + Encode;
|
||||||
|
type SomeValue: Get<u32>;
|
||||||
}
|
}
|
||||||
|
|
||||||
decl_module! {
|
decl_module! {
|
||||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {}
|
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||||
|
/// Hi, I am a comment.
|
||||||
|
const BlockNumber: T::BlockNumber = 100.into();
|
||||||
|
const GetType: T::AccountId = T::SomeValue::get().into();
|
||||||
|
const ASSOCIATED_CONST: u64 = T::ASSOCIATED_CONST.into();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
decl_event!(
|
decl_event!(
|
||||||
@@ -359,10 +368,15 @@ mod tests {
|
|||||||
type BlockNumber = u32;
|
type BlockNumber = u32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
crate::parameter_types! {
|
||||||
|
pub const SystemValue: u32 = 600;
|
||||||
|
}
|
||||||
|
|
||||||
impl system::Trait for TestRuntime {
|
impl system::Trait for TestRuntime {
|
||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
type AccountId = u32;
|
type AccountId = u32;
|
||||||
type BlockNumber = u32;
|
type BlockNumber = u32;
|
||||||
|
type SomeValue = SystemValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_runtime_metadata!(
|
impl_runtime_metadata!(
|
||||||
@@ -372,76 +386,130 @@ mod tests {
|
|||||||
event_module2::Module with Event Storage Call,
|
event_module2::Module with Event Storage Call,
|
||||||
);
|
);
|
||||||
|
|
||||||
const EXPECTED_METADATA: RuntimeMetadata = RuntimeMetadata::V5(
|
struct ConstantBlockNumberByteGetter;
|
||||||
RuntimeMetadataV5 {
|
impl DefaultByte for ConstantBlockNumberByteGetter {
|
||||||
modules: DecodeDifferent::Encode(&[
|
fn default_byte(&self) -> Vec<u8> {
|
||||||
ModuleMetadata {
|
100u32.encode()
|
||||||
name: DecodeDifferent::Encode("system"),
|
}
|
||||||
prefix: DecodeDifferent::Encode(FnEncode(||"")),
|
}
|
||||||
storage: None,
|
|
||||||
calls: None,
|
struct ConstantGetTypeByteGetter;
|
||||||
event: Some(DecodeDifferent::Encode(
|
impl DefaultByte for ConstantGetTypeByteGetter {
|
||||||
FnEncode(||&[
|
fn default_byte(&self) -> Vec<u8> {
|
||||||
EventMetadata {
|
SystemValue::get().encode()
|
||||||
name: DecodeDifferent::Encode("SystemEvent"),
|
}
|
||||||
arguments: DecodeDifferent::Encode(&[]),
|
}
|
||||||
documentation: DecodeDifferent::Encode(&[])
|
|
||||||
}
|
struct ConstantAssociatedConstByteGetter;
|
||||||
])
|
impl DefaultByte for ConstantAssociatedConstByteGetter {
|
||||||
)),
|
fn default_byte(&self) -> Vec<u8> {
|
||||||
},
|
<TestRuntime as system::Trait>::ASSOCIATED_CONST.encode()
|
||||||
ModuleMetadata {
|
}
|
||||||
name: DecodeDifferent::Encode("event_module"),
|
}
|
||||||
prefix: DecodeDifferent::Encode(FnEncode(||"")),
|
|
||||||
storage: None,
|
const EXPECTED_METADATA: RuntimeMetadata = RuntimeMetadata::V6(
|
||||||
calls: Some(
|
RuntimeMetadataV6 {
|
||||||
DecodeDifferent::Encode(FnEncode(||&[
|
modules: DecodeDifferent::Encode(&[
|
||||||
FunctionMetadata {
|
ModuleMetadata {
|
||||||
name: DecodeDifferent::Encode("aux_0"),
|
name: DecodeDifferent::Encode("system"),
|
||||||
arguments: DecodeDifferent::Encode(&[]),
|
prefix: DecodeDifferent::Encode(FnEncode(|| "")),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
storage: None,
|
||||||
}
|
calls: None,
|
||||||
]))),
|
event: Some(DecodeDifferent::Encode(
|
||||||
event: Some(DecodeDifferent::Encode(
|
FnEncode(||&[
|
||||||
FnEncode(||&[
|
EventMetadata {
|
||||||
EventMetadata {
|
name: DecodeDifferent::Encode("SystemEvent"),
|
||||||
name: DecodeDifferent::Encode("TestEvent"),
|
arguments: DecodeDifferent::Encode(&[]),
|
||||||
arguments: DecodeDifferent::Encode(&["Balance"]),
|
documentation: DecodeDifferent::Encode(&[])
|
||||||
documentation: DecodeDifferent::Encode(&[" Hi, I am a comment."])
|
}
|
||||||
}
|
])
|
||||||
])
|
)),
|
||||||
)),
|
constants: DecodeDifferent::Encode(
|
||||||
},
|
FnEncode(|| &[
|
||||||
ModuleMetadata {
|
ModuleConstantMetadata {
|
||||||
name: DecodeDifferent::Encode("event_module2"),
|
name: DecodeDifferent::Encode("BlockNumber"),
|
||||||
prefix: DecodeDifferent::Encode(FnEncode(||"TestStorage")),
|
ty: DecodeDifferent::Encode("T::BlockNumber"),
|
||||||
storage: Some(DecodeDifferent::Encode(
|
value: DecodeDifferent::Encode(
|
||||||
FnEncode(||&[
|
DefaultByteGetter(&ConstantBlockNumberByteGetter)
|
||||||
StorageFunctionMetadata {
|
),
|
||||||
name: DecodeDifferent::Encode("StorageMethod"),
|
documentation: DecodeDifferent::Encode(&[" Hi, I am a comment."]),
|
||||||
modifier: StorageFunctionModifier::Optional,
|
},
|
||||||
ty: StorageFunctionType::Plain(DecodeDifferent::Encode("u32")),
|
ModuleConstantMetadata {
|
||||||
default: DecodeDifferent::Encode(
|
name: DecodeDifferent::Encode("GetType"),
|
||||||
DefaultByteGetter(
|
ty: DecodeDifferent::Encode("T::AccountId"),
|
||||||
&event_module2::__GetByteStructStorageMethod(::std::marker::PhantomData::<TestRuntime>)
|
value: DecodeDifferent::Encode(
|
||||||
)
|
DefaultByteGetter(&ConstantGetTypeByteGetter)
|
||||||
),
|
),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
}
|
},
|
||||||
])
|
ModuleConstantMetadata {
|
||||||
)),
|
name: DecodeDifferent::Encode("ASSOCIATED_CONST"),
|
||||||
calls: Some(DecodeDifferent::Encode(FnEncode(||&[ ]))),
|
ty: DecodeDifferent::Encode("u64"),
|
||||||
event: Some(DecodeDifferent::Encode(
|
value: DecodeDifferent::Encode(
|
||||||
FnEncode(||&[
|
DefaultByteGetter(&ConstantAssociatedConstByteGetter)
|
||||||
EventMetadata {
|
),
|
||||||
name: DecodeDifferent::Encode("TestEvent"),
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
arguments: DecodeDifferent::Encode(&["Balance"]),
|
}
|
||||||
documentation: DecodeDifferent::Encode(&[])
|
])
|
||||||
}
|
),
|
||||||
])
|
},
|
||||||
)),
|
ModuleMetadata {
|
||||||
},
|
name: DecodeDifferent::Encode("event_module"),
|
||||||
])}
|
prefix: DecodeDifferent::Encode(FnEncode(|| "")),
|
||||||
|
storage: None,
|
||||||
|
calls: Some(
|
||||||
|
DecodeDifferent::Encode(FnEncode(|| &[
|
||||||
|
FunctionMetadata {
|
||||||
|
name: DecodeDifferent::Encode("aux_0"),
|
||||||
|
arguments: DecodeDifferent::Encode(&[]),
|
||||||
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
|
}
|
||||||
|
]))),
|
||||||
|
event: Some(DecodeDifferent::Encode(
|
||||||
|
FnEncode(||&[
|
||||||
|
EventMetadata {
|
||||||
|
name: DecodeDifferent::Encode("TestEvent"),
|
||||||
|
arguments: DecodeDifferent::Encode(&["Balance"]),
|
||||||
|
documentation: DecodeDifferent::Encode(&[" Hi, I am a comment."])
|
||||||
|
}
|
||||||
|
])
|
||||||
|
)),
|
||||||
|
constants: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||||
|
},
|
||||||
|
ModuleMetadata {
|
||||||
|
name: DecodeDifferent::Encode("event_module2"),
|
||||||
|
prefix: DecodeDifferent::Encode(FnEncode(||"TestStorage")),
|
||||||
|
storage: Some(DecodeDifferent::Encode(
|
||||||
|
FnEncode(||&[
|
||||||
|
StorageEntryMetadata {
|
||||||
|
name: DecodeDifferent::Encode("StorageMethod"),
|
||||||
|
modifier: StorageEntryModifier::Optional,
|
||||||
|
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||||
|
default: DecodeDifferent::Encode(
|
||||||
|
DefaultByteGetter(
|
||||||
|
&event_module2::__GetByteStructStorageMethod(
|
||||||
|
std::marker::PhantomData::<TestRuntime>
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
|
}
|
||||||
|
])
|
||||||
|
)),
|
||||||
|
calls: Some(DecodeDifferent::Encode(FnEncode(|| &[]))),
|
||||||
|
event: Some(DecodeDifferent::Encode(
|
||||||
|
FnEncode(||&[
|
||||||
|
EventMetadata {
|
||||||
|
name: DecodeDifferent::Encode("TestEvent"),
|
||||||
|
arguments: DecodeDifferent::Encode(&["Balance"]),
|
||||||
|
documentation: DecodeDifferent::Encode(&[])
|
||||||
|
}
|
||||||
|
])
|
||||||
|
)),
|
||||||
|
constants: DecodeDifferent::Encode(FnEncode(|| &[])),
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -450,6 +518,6 @@ mod tests {
|
|||||||
let metadata_decoded = RuntimeMetadataPrefixed::decode(&mut &metadata_encoded[..]);
|
let metadata_decoded = RuntimeMetadataPrefixed::decode(&mut &metadata_encoded[..]);
|
||||||
let expected_metadata: RuntimeMetadataPrefixed = EXPECTED_METADATA.into();
|
let expected_metadata: RuntimeMetadataPrefixed = EXPECTED_METADATA.into();
|
||||||
|
|
||||||
assert_eq!(expected_metadata, metadata_decoded.unwrap());
|
pretty_assertions::assert_eq!(expected_metadata, metadata_decoded.unwrap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -390,327 +390,325 @@ mod tests {
|
|||||||
type BlockNumber = u32;
|
type BlockNumber = u32;
|
||||||
}
|
}
|
||||||
|
|
||||||
const EXPECTED_METADATA: StorageMetadata = StorageMetadata {
|
const EXPECTED_METADATA: &[StorageEntryMetadata] = &[
|
||||||
functions: DecodeDifferent::Encode(&[
|
StorageEntryMetadata {
|
||||||
StorageFunctionMetadata {
|
name: DecodeDifferent::Encode("U32"),
|
||||||
name: DecodeDifferent::Encode("U32"),
|
modifier: StorageEntryModifier::Optional,
|
||||||
modifier: StorageFunctionModifier::Optional,
|
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||||
ty: StorageFunctionType::Plain(DecodeDifferent::Encode("u32")),
|
default: DecodeDifferent::Encode(
|
||||||
default: DecodeDifferent::Encode(
|
DefaultByteGetter(&__GetByteStructU32(PhantomData::<TraitImpl>))
|
||||||
DefaultByteGetter(&__GetByteStructU32(PhantomData::<TraitImpl>))
|
),
|
||||||
),
|
documentation: DecodeDifferent::Encode(&[ " Hello, this is doc!" ]),
|
||||||
documentation: DecodeDifferent::Encode(&[ " Hello, this is doc!" ]),
|
},
|
||||||
},
|
StorageEntryMetadata {
|
||||||
StorageFunctionMetadata {
|
name: DecodeDifferent::Encode("PUBU32"),
|
||||||
name: DecodeDifferent::Encode("PUBU32"),
|
modifier: StorageEntryModifier::Optional,
|
||||||
modifier: StorageFunctionModifier::Optional,
|
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||||
ty: StorageFunctionType::Plain(DecodeDifferent::Encode("u32")),
|
default: DecodeDifferent::Encode(
|
||||||
default: DecodeDifferent::Encode(
|
DefaultByteGetter(&__GetByteStructPUBU32(PhantomData::<TraitImpl>))
|
||||||
DefaultByteGetter(&__GetByteStructPUBU32(PhantomData::<TraitImpl>))
|
),
|
||||||
),
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
},
|
||||||
},
|
StorageEntryMetadata {
|
||||||
StorageFunctionMetadata {
|
name: DecodeDifferent::Encode("U32MYDEF"),
|
||||||
name: DecodeDifferent::Encode("U32MYDEF"),
|
modifier: StorageEntryModifier::Optional,
|
||||||
modifier: StorageFunctionModifier::Optional,
|
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||||
ty: StorageFunctionType::Plain(DecodeDifferent::Encode("u32")),
|
default: DecodeDifferent::Encode(
|
||||||
default: DecodeDifferent::Encode(
|
DefaultByteGetter(&__GetByteStructU32MYDEF(PhantomData::<TraitImpl>))
|
||||||
DefaultByteGetter(&__GetByteStructU32MYDEF(PhantomData::<TraitImpl>))
|
),
|
||||||
),
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
},
|
||||||
},
|
StorageEntryMetadata {
|
||||||
StorageFunctionMetadata {
|
name: DecodeDifferent::Encode("PUBU32MYDEF"),
|
||||||
name: DecodeDifferent::Encode("PUBU32MYDEF"),
|
modifier: StorageEntryModifier::Optional,
|
||||||
modifier: StorageFunctionModifier::Optional,
|
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||||
ty: StorageFunctionType::Plain(DecodeDifferent::Encode("u32")),
|
default: DecodeDifferent::Encode(
|
||||||
default: DecodeDifferent::Encode(
|
DefaultByteGetter(&__GetByteStructPUBU32MYDEF(PhantomData::<TraitImpl>))
|
||||||
DefaultByteGetter(&__GetByteStructPUBU32MYDEF(PhantomData::<TraitImpl>))
|
),
|
||||||
),
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
},
|
||||||
},
|
StorageEntryMetadata {
|
||||||
StorageFunctionMetadata {
|
name: DecodeDifferent::Encode("GETU32"),
|
||||||
name: DecodeDifferent::Encode("GETU32"),
|
modifier: StorageEntryModifier::Default,
|
||||||
modifier: StorageFunctionModifier::Default,
|
ty: StorageEntryType::Plain(DecodeDifferent::Encode("T::Origin")),
|
||||||
ty: StorageFunctionType::Plain(DecodeDifferent::Encode("T::Origin")),
|
default: DecodeDifferent::Encode(
|
||||||
default: DecodeDifferent::Encode(
|
DefaultByteGetter(&__GetByteStructGETU32(PhantomData::<TraitImpl>))
|
||||||
DefaultByteGetter(&__GetByteStructGETU32(PhantomData::<TraitImpl>))
|
),
|
||||||
),
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
},
|
||||||
},
|
StorageEntryMetadata {
|
||||||
StorageFunctionMetadata {
|
name: DecodeDifferent::Encode("PUBGETU32"),
|
||||||
name: DecodeDifferent::Encode("PUBGETU32"),
|
modifier: StorageEntryModifier::Default,
|
||||||
modifier: StorageFunctionModifier::Default,
|
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||||
ty: StorageFunctionType::Plain(DecodeDifferent::Encode("u32")),
|
default: DecodeDifferent::Encode(
|
||||||
default: DecodeDifferent::Encode(
|
DefaultByteGetter(&__GetByteStructPUBGETU32(PhantomData::<TraitImpl>))
|
||||||
DefaultByteGetter(&__GetByteStructPUBGETU32(PhantomData::<TraitImpl>))
|
),
|
||||||
),
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
},
|
||||||
},
|
StorageEntryMetadata {
|
||||||
StorageFunctionMetadata {
|
name: DecodeDifferent::Encode("GETU32WITHCONFIG"),
|
||||||
name: DecodeDifferent::Encode("GETU32WITHCONFIG"),
|
modifier: StorageEntryModifier::Default,
|
||||||
modifier: StorageFunctionModifier::Default,
|
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||||
ty: StorageFunctionType::Plain(DecodeDifferent::Encode("u32")),
|
default: DecodeDifferent::Encode(
|
||||||
default: DecodeDifferent::Encode(
|
DefaultByteGetter(&__GetByteStructGETU32WITHCONFIG(PhantomData::<TraitImpl>))
|
||||||
DefaultByteGetter(&__GetByteStructGETU32WITHCONFIG(PhantomData::<TraitImpl>))
|
),
|
||||||
),
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
},
|
||||||
},
|
StorageEntryMetadata {
|
||||||
StorageFunctionMetadata {
|
name: DecodeDifferent::Encode("PUBGETU32WITHCONFIG"),
|
||||||
name: DecodeDifferent::Encode("PUBGETU32WITHCONFIG"),
|
modifier: StorageEntryModifier::Default,
|
||||||
modifier: StorageFunctionModifier::Default,
|
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||||
ty: StorageFunctionType::Plain(DecodeDifferent::Encode("u32")),
|
default: DecodeDifferent::Encode(
|
||||||
default: DecodeDifferent::Encode(
|
DefaultByteGetter(&__GetByteStructPUBGETU32WITHCONFIG(PhantomData::<TraitImpl>))
|
||||||
DefaultByteGetter(&__GetByteStructPUBGETU32WITHCONFIG(PhantomData::<TraitImpl>))
|
),
|
||||||
),
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
},
|
||||||
},
|
StorageEntryMetadata {
|
||||||
StorageFunctionMetadata {
|
name: DecodeDifferent::Encode("GETU32MYDEF"),
|
||||||
name: DecodeDifferent::Encode("GETU32MYDEF"),
|
modifier: StorageEntryModifier::Optional,
|
||||||
modifier: StorageFunctionModifier::Optional,
|
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||||
ty: StorageFunctionType::Plain(DecodeDifferent::Encode("u32")),
|
default: DecodeDifferent::Encode(
|
||||||
default: DecodeDifferent::Encode(
|
DefaultByteGetter(&__GetByteStructGETU32MYDEF(PhantomData::<TraitImpl>))
|
||||||
DefaultByteGetter(&__GetByteStructGETU32MYDEF(PhantomData::<TraitImpl>))
|
),
|
||||||
),
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
},
|
||||||
},
|
StorageEntryMetadata {
|
||||||
StorageFunctionMetadata {
|
name: DecodeDifferent::Encode("PUBGETU32MYDEF"),
|
||||||
name: DecodeDifferent::Encode("PUBGETU32MYDEF"),
|
modifier: StorageEntryModifier::Default,
|
||||||
modifier: StorageFunctionModifier::Default,
|
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||||
ty: StorageFunctionType::Plain(DecodeDifferent::Encode("u32")),
|
default: DecodeDifferent::Encode(
|
||||||
default: DecodeDifferent::Encode(
|
DefaultByteGetter(&__GetByteStructPUBGETU32MYDEF(PhantomData::<TraitImpl>))
|
||||||
DefaultByteGetter(&__GetByteStructPUBGETU32MYDEF(PhantomData::<TraitImpl>))
|
),
|
||||||
),
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
},
|
||||||
},
|
StorageEntryMetadata {
|
||||||
StorageFunctionMetadata {
|
name: DecodeDifferent::Encode("GETU32WITHCONFIGMYDEF"),
|
||||||
name: DecodeDifferent::Encode("GETU32WITHCONFIGMYDEF"),
|
modifier: StorageEntryModifier::Default,
|
||||||
modifier: StorageFunctionModifier::Default,
|
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||||
ty: StorageFunctionType::Plain(DecodeDifferent::Encode("u32")),
|
default: DecodeDifferent::Encode(
|
||||||
default: DecodeDifferent::Encode(
|
DefaultByteGetter(&__GetByteStructGETU32WITHCONFIGMYDEF(PhantomData::<TraitImpl>))
|
||||||
DefaultByteGetter(&__GetByteStructGETU32WITHCONFIGMYDEF(PhantomData::<TraitImpl>))
|
),
|
||||||
),
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
},
|
||||||
},
|
StorageEntryMetadata {
|
||||||
StorageFunctionMetadata {
|
name: DecodeDifferent::Encode("PUBGETU32WITHCONFIGMYDEF"),
|
||||||
name: DecodeDifferent::Encode("PUBGETU32WITHCONFIGMYDEF"),
|
modifier: StorageEntryModifier::Default,
|
||||||
modifier: StorageFunctionModifier::Default,
|
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||||
ty: StorageFunctionType::Plain(DecodeDifferent::Encode("u32")),
|
default: DecodeDifferent::Encode(
|
||||||
default: DecodeDifferent::Encode(
|
DefaultByteGetter(&__GetByteStructPUBGETU32WITHCONFIGMYDEF(PhantomData::<TraitImpl>))
|
||||||
DefaultByteGetter(&__GetByteStructPUBGETU32WITHCONFIGMYDEF(PhantomData::<TraitImpl>))
|
),
|
||||||
),
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
},
|
||||||
},
|
StorageEntryMetadata {
|
||||||
StorageFunctionMetadata {
|
name: DecodeDifferent::Encode("PUBGETU32WITHCONFIGMYDEFOPT"),
|
||||||
name: DecodeDifferent::Encode("PUBGETU32WITHCONFIGMYDEFOPT"),
|
modifier: StorageEntryModifier::Optional,
|
||||||
modifier: StorageFunctionModifier::Optional,
|
ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")),
|
||||||
ty: StorageFunctionType::Plain(DecodeDifferent::Encode("u32")),
|
default: DecodeDifferent::Encode(
|
||||||
default: DecodeDifferent::Encode(
|
DefaultByteGetter(&__GetByteStructPUBGETU32WITHCONFIGMYDEFOPT(PhantomData::<TraitImpl>))
|
||||||
DefaultByteGetter(&__GetByteStructPUBGETU32WITHCONFIGMYDEFOPT(PhantomData::<TraitImpl>))
|
),
|
||||||
),
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
},
|
||||||
},
|
|
||||||
|
|
||||||
StorageFunctionMetadata {
|
StorageEntryMetadata {
|
||||||
name: DecodeDifferent::Encode("MAPU32"),
|
name: DecodeDifferent::Encode("MAPU32"),
|
||||||
modifier: StorageFunctionModifier::Optional,
|
modifier: StorageEntryModifier::Optional,
|
||||||
ty: StorageFunctionType::Map {
|
ty: StorageEntryType::Map {
|
||||||
hasher: StorageHasher::Blake2_256,
|
hasher: StorageHasher::Blake2_256,
|
||||||
key: DecodeDifferent::Encode("u32"),
|
key: DecodeDifferent::Encode("u32"),
|
||||||
value: DecodeDifferent::Encode("String"),
|
value: DecodeDifferent::Encode("String"),
|
||||||
is_linked: false,
|
is_linked: false,
|
||||||
},
|
|
||||||
default: DecodeDifferent::Encode(
|
|
||||||
DefaultByteGetter(&__GetByteStructMAPU32(PhantomData::<TraitImpl>))
|
|
||||||
),
|
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
|
||||||
},
|
},
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("PUBMAPU32"),
|
DefaultByteGetter(&__GetByteStructMAPU32(PhantomData::<TraitImpl>))
|
||||||
modifier: StorageFunctionModifier::Optional,
|
),
|
||||||
ty: StorageFunctionType::Map {
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
hasher: StorageHasher::Blake2_256,
|
},
|
||||||
key: DecodeDifferent::Encode("u32"),
|
StorageEntryMetadata {
|
||||||
value: DecodeDifferent::Encode("String"),
|
name: DecodeDifferent::Encode("PUBMAPU32"),
|
||||||
is_linked: false,
|
modifier: StorageEntryModifier::Optional,
|
||||||
},
|
ty: StorageEntryType::Map {
|
||||||
default: DecodeDifferent::Encode(
|
hasher: StorageHasher::Blake2_256,
|
||||||
DefaultByteGetter(&__GetByteStructPUBMAPU32(PhantomData::<TraitImpl>))
|
key: DecodeDifferent::Encode("u32"),
|
||||||
),
|
value: DecodeDifferent::Encode("String"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
is_linked: false,
|
||||||
},
|
},
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("MAPU32MYDEF"),
|
DefaultByteGetter(&__GetByteStructPUBMAPU32(PhantomData::<TraitImpl>))
|
||||||
modifier: StorageFunctionModifier::Optional,
|
),
|
||||||
ty: StorageFunctionType::Map {
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
hasher: StorageHasher::Blake2_256,
|
},
|
||||||
key: DecodeDifferent::Encode("u32"),
|
StorageEntryMetadata {
|
||||||
value: DecodeDifferent::Encode("String"),
|
name: DecodeDifferent::Encode("MAPU32MYDEF"),
|
||||||
is_linked: false,
|
modifier: StorageEntryModifier::Optional,
|
||||||
},
|
ty: StorageEntryType::Map {
|
||||||
default: DecodeDifferent::Encode(
|
hasher: StorageHasher::Blake2_256,
|
||||||
DefaultByteGetter(&__GetByteStructMAPU32MYDEF(PhantomData::<TraitImpl>))
|
key: DecodeDifferent::Encode("u32"),
|
||||||
),
|
value: DecodeDifferent::Encode("String"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
is_linked: false,
|
||||||
},
|
},
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("PUBMAPU32MYDEF"),
|
DefaultByteGetter(&__GetByteStructMAPU32MYDEF(PhantomData::<TraitImpl>))
|
||||||
modifier: StorageFunctionModifier::Optional,
|
),
|
||||||
ty: StorageFunctionType::Map {
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
hasher: StorageHasher::Blake2_256,
|
},
|
||||||
key: DecodeDifferent::Encode("u32"),
|
StorageEntryMetadata {
|
||||||
value: DecodeDifferent::Encode("String"),
|
name: DecodeDifferent::Encode("PUBMAPU32MYDEF"),
|
||||||
is_linked: false,
|
modifier: StorageEntryModifier::Optional,
|
||||||
},
|
ty: StorageEntryType::Map {
|
||||||
default: DecodeDifferent::Encode(
|
hasher: StorageHasher::Blake2_256,
|
||||||
DefaultByteGetter(&__GetByteStructPUBMAPU32MYDEF(PhantomData::<TraitImpl>))
|
key: DecodeDifferent::Encode("u32"),
|
||||||
),
|
value: DecodeDifferent::Encode("String"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
is_linked: false,
|
||||||
},
|
},
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("GETMAPU32"),
|
DefaultByteGetter(&__GetByteStructPUBMAPU32MYDEF(PhantomData::<TraitImpl>))
|
||||||
modifier: StorageFunctionModifier::Default,
|
),
|
||||||
ty: StorageFunctionType::Map {
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
hasher: StorageHasher::Blake2_256,
|
},
|
||||||
key: DecodeDifferent::Encode("u32"),
|
StorageEntryMetadata {
|
||||||
value: DecodeDifferent::Encode("String"),
|
name: DecodeDifferent::Encode("GETMAPU32"),
|
||||||
is_linked: false,
|
modifier: StorageEntryModifier::Default,
|
||||||
},
|
ty: StorageEntryType::Map {
|
||||||
default: DecodeDifferent::Encode(
|
hasher: StorageHasher::Blake2_256,
|
||||||
DefaultByteGetter(&__GetByteStructGETMAPU32(PhantomData::<TraitImpl>))
|
key: DecodeDifferent::Encode("u32"),
|
||||||
),
|
value: DecodeDifferent::Encode("String"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
is_linked: false,
|
||||||
},
|
},
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("PUBGETMAPU32"),
|
DefaultByteGetter(&__GetByteStructGETMAPU32(PhantomData::<TraitImpl>))
|
||||||
modifier: StorageFunctionModifier::Default,
|
),
|
||||||
ty: StorageFunctionType::Map {
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
hasher: StorageHasher::Blake2_256,
|
},
|
||||||
key: DecodeDifferent::Encode("u32"),
|
StorageEntryMetadata {
|
||||||
value: DecodeDifferent::Encode("String"),
|
name: DecodeDifferent::Encode("PUBGETMAPU32"),
|
||||||
is_linked: false,
|
modifier: StorageEntryModifier::Default,
|
||||||
},
|
ty: StorageEntryType::Map {
|
||||||
default: DecodeDifferent::Encode(
|
hasher: StorageHasher::Blake2_256,
|
||||||
DefaultByteGetter(&__GetByteStructPUBGETMAPU32(PhantomData::<TraitImpl>))
|
key: DecodeDifferent::Encode("u32"),
|
||||||
),
|
value: DecodeDifferent::Encode("String"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
is_linked: false,
|
||||||
},
|
},
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("GETMAPU32MYDEF"),
|
DefaultByteGetter(&__GetByteStructPUBGETMAPU32(PhantomData::<TraitImpl>))
|
||||||
modifier: StorageFunctionModifier::Default,
|
),
|
||||||
ty: StorageFunctionType::Map {
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
hasher: StorageHasher::Blake2_256,
|
},
|
||||||
key: DecodeDifferent::Encode("u32"),
|
StorageEntryMetadata {
|
||||||
value: DecodeDifferent::Encode("String"),
|
name: DecodeDifferent::Encode("GETMAPU32MYDEF"),
|
||||||
is_linked: false,
|
modifier: StorageEntryModifier::Default,
|
||||||
},
|
ty: StorageEntryType::Map {
|
||||||
default: DecodeDifferent::Encode(
|
hasher: StorageHasher::Blake2_256,
|
||||||
DefaultByteGetter(&__GetByteStructGETMAPU32MYDEF(PhantomData::<TraitImpl>))
|
key: DecodeDifferent::Encode("u32"),
|
||||||
),
|
value: DecodeDifferent::Encode("String"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
is_linked: false,
|
||||||
},
|
},
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("PUBGETMAPU32MYDEF"),
|
DefaultByteGetter(&__GetByteStructGETMAPU32MYDEF(PhantomData::<TraitImpl>))
|
||||||
modifier: StorageFunctionModifier::Default,
|
),
|
||||||
ty: StorageFunctionType::Map {
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
hasher: StorageHasher::Blake2_256,
|
},
|
||||||
key: DecodeDifferent::Encode("u32"),
|
StorageEntryMetadata {
|
||||||
value: DecodeDifferent::Encode("String"),
|
name: DecodeDifferent::Encode("PUBGETMAPU32MYDEF"),
|
||||||
is_linked: false,
|
modifier: StorageEntryModifier::Default,
|
||||||
},
|
ty: StorageEntryType::Map {
|
||||||
default: DecodeDifferent::Encode(
|
hasher: StorageHasher::Blake2_256,
|
||||||
DefaultByteGetter(&__GetByteStructPUBGETMAPU32MYDEF(PhantomData::<TraitImpl>))
|
key: DecodeDifferent::Encode("u32"),
|
||||||
),
|
value: DecodeDifferent::Encode("String"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
is_linked: false,
|
||||||
},
|
},
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("LINKEDMAPU32"),
|
DefaultByteGetter(&__GetByteStructPUBGETMAPU32MYDEF(PhantomData::<TraitImpl>))
|
||||||
modifier: StorageFunctionModifier::Optional,
|
),
|
||||||
ty: StorageFunctionType::Map {
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
hasher: StorageHasher::Blake2_256,
|
},
|
||||||
key: DecodeDifferent::Encode("u32"),
|
StorageEntryMetadata {
|
||||||
value: DecodeDifferent::Encode("String"),
|
name: DecodeDifferent::Encode("LINKEDMAPU32"),
|
||||||
is_linked: true,
|
modifier: StorageEntryModifier::Optional,
|
||||||
},
|
ty: StorageEntryType::Map {
|
||||||
default: DecodeDifferent::Encode(
|
hasher: StorageHasher::Blake2_256,
|
||||||
DefaultByteGetter(&__GetByteStructLINKEDMAPU32(PhantomData::<TraitImpl>))
|
key: DecodeDifferent::Encode("u32"),
|
||||||
),
|
value: DecodeDifferent::Encode("String"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
is_linked: true,
|
||||||
},
|
},
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("PUBLINKEDMAPU32MYDEF"),
|
DefaultByteGetter(&__GetByteStructLINKEDMAPU32(PhantomData::<TraitImpl>))
|
||||||
modifier: StorageFunctionModifier::Optional,
|
),
|
||||||
ty: StorageFunctionType::Map {
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
hasher: StorageHasher::Blake2_256,
|
},
|
||||||
key: DecodeDifferent::Encode("u32"),
|
StorageEntryMetadata {
|
||||||
value: DecodeDifferent::Encode("String"),
|
name: DecodeDifferent::Encode("PUBLINKEDMAPU32MYDEF"),
|
||||||
is_linked: true,
|
modifier: StorageEntryModifier::Optional,
|
||||||
},
|
ty: StorageEntryType::Map {
|
||||||
default: DecodeDifferent::Encode(
|
hasher: StorageHasher::Blake2_256,
|
||||||
DefaultByteGetter(&__GetByteStructPUBLINKEDMAPU32MYDEF(PhantomData::<TraitImpl>))
|
key: DecodeDifferent::Encode("u32"),
|
||||||
),
|
value: DecodeDifferent::Encode("String"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
is_linked: true,
|
||||||
},
|
},
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("GETLINKEDMAPU32"),
|
DefaultByteGetter(&__GetByteStructPUBLINKEDMAPU32MYDEF(PhantomData::<TraitImpl>))
|
||||||
modifier: StorageFunctionModifier::Default,
|
),
|
||||||
ty: StorageFunctionType::Map {
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
hasher: StorageHasher::Blake2_256,
|
},
|
||||||
key: DecodeDifferent::Encode("u32"),
|
StorageEntryMetadata {
|
||||||
value: DecodeDifferent::Encode("String"),
|
name: DecodeDifferent::Encode("GETLINKEDMAPU32"),
|
||||||
is_linked: true,
|
modifier: StorageEntryModifier::Default,
|
||||||
},
|
ty: StorageEntryType::Map {
|
||||||
default: DecodeDifferent::Encode(
|
hasher: StorageHasher::Blake2_256,
|
||||||
DefaultByteGetter(&__GetByteStructGETLINKEDMAPU32(PhantomData::<TraitImpl>))
|
key: DecodeDifferent::Encode("u32"),
|
||||||
),
|
value: DecodeDifferent::Encode("String"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
is_linked: true,
|
||||||
},
|
},
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("PUBGETLINKEDMAPU32MYDEF"),
|
DefaultByteGetter(&__GetByteStructGETLINKEDMAPU32(PhantomData::<TraitImpl>))
|
||||||
modifier: StorageFunctionModifier::Default,
|
),
|
||||||
ty: StorageFunctionType::Map {
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
hasher: StorageHasher::Blake2_256,
|
},
|
||||||
key: DecodeDifferent::Encode("u32"),
|
StorageEntryMetadata {
|
||||||
value: DecodeDifferent::Encode("String"),
|
name: DecodeDifferent::Encode("PUBGETLINKEDMAPU32MYDEF"),
|
||||||
is_linked: true,
|
modifier: StorageEntryModifier::Default,
|
||||||
},
|
ty: StorageEntryType::Map {
|
||||||
default: DecodeDifferent::Encode(
|
hasher: StorageHasher::Blake2_256,
|
||||||
DefaultByteGetter(&__GetByteStructPUBGETLINKEDMAPU32MYDEF(PhantomData::<TraitImpl>))
|
key: DecodeDifferent::Encode("u32"),
|
||||||
),
|
value: DecodeDifferent::Encode("String"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
is_linked: true,
|
||||||
},
|
},
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("COMPLEXTYPE1"),
|
DefaultByteGetter(&__GetByteStructPUBGETLINKEDMAPU32MYDEF(PhantomData::<TraitImpl>))
|
||||||
modifier: StorageFunctionModifier::Default,
|
),
|
||||||
ty: StorageFunctionType::Plain(DecodeDifferent::Encode("::std::vec::Vec<<T as Trait>::Origin>")),
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
default: DecodeDifferent::Encode(
|
},
|
||||||
DefaultByteGetter(&__GetByteStructCOMPLEXTYPE1(PhantomData::<TraitImpl>))
|
StorageEntryMetadata {
|
||||||
),
|
name: DecodeDifferent::Encode("COMPLEXTYPE1"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
modifier: StorageEntryModifier::Default,
|
||||||
},
|
ty: StorageEntryType::Plain(DecodeDifferent::Encode("::std::vec::Vec<<T as Trait>::Origin>")),
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("COMPLEXTYPE2"),
|
DefaultByteGetter(&__GetByteStructCOMPLEXTYPE1(PhantomData::<TraitImpl>))
|
||||||
modifier: StorageFunctionModifier::Default,
|
),
|
||||||
ty: StorageFunctionType::Plain(DecodeDifferent::Encode("(Vec<Vec<(u16, Box<()>)>>, u32)")),
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
default: DecodeDifferent::Encode(
|
},
|
||||||
DefaultByteGetter(&__GetByteStructCOMPLEXTYPE2(PhantomData::<TraitImpl>))
|
StorageEntryMetadata {
|
||||||
),
|
name: DecodeDifferent::Encode("COMPLEXTYPE2"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
modifier: StorageEntryModifier::Default,
|
||||||
},
|
ty: StorageEntryType::Plain(DecodeDifferent::Encode("(Vec<Vec<(u16, Box<()>)>>, u32)")),
|
||||||
StorageFunctionMetadata {
|
default: DecodeDifferent::Encode(
|
||||||
name: DecodeDifferent::Encode("COMPLEXTYPE3"),
|
DefaultByteGetter(&__GetByteStructCOMPLEXTYPE2(PhantomData::<TraitImpl>))
|
||||||
modifier: StorageFunctionModifier::Default,
|
),
|
||||||
ty: StorageFunctionType::Plain(DecodeDifferent::Encode("([u32; 25])")),
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
default: DecodeDifferent::Encode(
|
},
|
||||||
DefaultByteGetter(&__GetByteStructCOMPLEXTYPE3(PhantomData::<TraitImpl>))
|
StorageEntryMetadata {
|
||||||
),
|
name: DecodeDifferent::Encode("COMPLEXTYPE3"),
|
||||||
documentation: DecodeDifferent::Encode(&[]),
|
modifier: StorageEntryModifier::Default,
|
||||||
},
|
ty: StorageEntryType::Plain(DecodeDifferent::Encode("([u32; 25])")),
|
||||||
])
|
default: DecodeDifferent::Encode(
|
||||||
};
|
DefaultByteGetter(&__GetByteStructCOMPLEXTYPE3(PhantomData::<TraitImpl>))
|
||||||
|
),
|
||||||
|
documentation: DecodeDifferent::Encode(&[]),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn store_metadata() {
|
fn store_metadata() {
|
||||||
let metadata = Module::<TraitImpl>::store_metadata();
|
let metadata = Module::<TraitImpl>::store_metadata_functions();
|
||||||
assert_eq!(EXPECTED_METADATA, metadata);
|
assert_eq!(EXPECTED_METADATA, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
use runtime_io::{with_externalities, Blake2Hasher};
|
use runtime_io::{with_externalities, Blake2Hasher};
|
||||||
use srml_support::{
|
use srml_support::{
|
||||||
Parameter,
|
Parameter, traits::Get, parameter_types,
|
||||||
runtime_primitives::{generic, BuildStorage, traits::{BlakeTwo256, Block as _, Verify}},
|
runtime_primitives::{generic, BuildStorage, traits::{BlakeTwo256, Block as _, Verify}},
|
||||||
};
|
};
|
||||||
use inherents::{
|
use inherents::{
|
||||||
@@ -40,10 +40,13 @@ mod module1 {
|
|||||||
pub trait Trait<I>: system::Trait {
|
pub trait Trait<I>: system::Trait {
|
||||||
type Event: From<Event<Self, I>> + Into<<Self as system::Trait>::Event>;
|
type Event: From<Event<Self, I>> + Into<<Self as system::Trait>::Event>;
|
||||||
type Origin: From<Origin<Self, I>>;
|
type Origin: From<Origin<Self, I>>;
|
||||||
|
type SomeParameter: Get<u32>;
|
||||||
}
|
}
|
||||||
|
|
||||||
srml_support::decl_module! {
|
srml_support::decl_module! {
|
||||||
pub struct Module<T: Trait<I>, I: InstantiableThing> for enum Call where origin: <T as system::Trait>::Origin {
|
pub struct Module<T: Trait<I>, I: InstantiableThing> for enum Call where origin: <T as system::Trait>::Origin {
|
||||||
|
fn offchain_worker() {}
|
||||||
|
|
||||||
fn deposit_event<T, I>() = default;
|
fn deposit_event<T, I>() = default;
|
||||||
|
|
||||||
fn one() {
|
fn one() {
|
||||||
@@ -165,13 +168,19 @@ mod module3 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parameter_types! {
|
||||||
|
pub const SomeValue: u32 = 100;
|
||||||
|
}
|
||||||
|
|
||||||
impl module1::Trait<module1::Instance1> for Runtime {
|
impl module1::Trait<module1::Instance1> for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
|
type SomeParameter = SomeValue;
|
||||||
}
|
}
|
||||||
impl module1::Trait<module1::Instance2> for Runtime {
|
impl module1::Trait<module1::Instance2> for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
|
type SomeParameter = SomeValue;
|
||||||
}
|
}
|
||||||
impl module2::Trait for Runtime {
|
impl module2::Trait for Runtime {
|
||||||
type Amount = u16;
|
type Amount = u16;
|
||||||
|
|||||||
Reference in New Issue
Block a user