mirror of
https://github.com/pezkuwichain/pezframe-metadata.git
synced 2026-04-28 23:48:02 +00:00
Document all v14, v13 and most of v8 items (#33)
* Document all v14, v13 and most of v8 items * Clarify what a `StorageEntryModifier` is.
This commit is contained in:
@@ -20,6 +20,7 @@ use codec::{Encode, Output};
|
|||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(feature = "std")] {
|
if #[cfg(feature = "std")] {
|
||||||
use codec::{Decode, Error, Input};
|
use codec::{Decode, Error, Input};
|
||||||
|
/// On `std` the `StringBuf` used by [`DecodeDifferent`] is just a `String`.
|
||||||
pub type StringBuf = String;
|
pub type StringBuf = String;
|
||||||
} else {
|
} else {
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
@@ -41,7 +42,9 @@ where
|
|||||||
B: 'static,
|
B: 'static,
|
||||||
O: 'static,
|
O: 'static,
|
||||||
{
|
{
|
||||||
|
/// Encodable variant of the value (doesn't need to be decodeable).
|
||||||
Encode(B),
|
Encode(B),
|
||||||
|
/// Encodable & decodeable variant of the value.
|
||||||
Decoded(O),
|
Decoded(O),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,8 +126,10 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An array type that decodes as a `Vec`.
|
||||||
pub type DecodeDifferentArray<B, O = B> = DecodeDifferent<&'static [B], Vec<O>>;
|
pub type DecodeDifferentArray<B, O = B> = DecodeDifferent<&'static [B], Vec<O>>;
|
||||||
|
|
||||||
|
/// A string type that decodes as a [`StringBuf`].
|
||||||
pub type DecodeDifferentStr = DecodeDifferent<&'static str, StringBuf>;
|
pub type DecodeDifferentStr = DecodeDifferent<&'static str, StringBuf>;
|
||||||
|
|
||||||
/// Newtype wrapper for support encoding functions (actual the result of the function).
|
/// Newtype wrapper for support encoding functions (actual the result of the function).
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
//! Decodable variant of the RuntimeMetadata.
|
//! Decodable variant of the RuntimeMetadata.
|
||||||
|
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
#![warn(missing_docs)]
|
||||||
|
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(feature = "std")] {
|
if #[cfg(feature = "std")] {
|
||||||
@@ -34,6 +35,7 @@ cfg_if::cfg_if! {
|
|||||||
|
|
||||||
use codec::{Encode, Output};
|
use codec::{Encode, Output};
|
||||||
|
|
||||||
|
/// A type that decodes to a different type than it encodes.
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
feature = "v13",
|
feature = "v13",
|
||||||
feature = "v12",
|
feature = "v12",
|
||||||
@@ -45,24 +47,31 @@ use codec::{Encode, Output};
|
|||||||
))]
|
))]
|
||||||
pub mod decode_different;
|
pub mod decode_different;
|
||||||
|
|
||||||
|
/// Metadata v8
|
||||||
#[cfg(feature = "v8")]
|
#[cfg(feature = "v8")]
|
||||||
pub mod v8;
|
pub mod v8;
|
||||||
|
|
||||||
|
/// Metadata v9
|
||||||
#[cfg(feature = "v9")]
|
#[cfg(feature = "v9")]
|
||||||
pub mod v9;
|
pub mod v9;
|
||||||
|
|
||||||
|
/// Metadata v10
|
||||||
#[cfg(feature = "v10")]
|
#[cfg(feature = "v10")]
|
||||||
pub mod v10;
|
pub mod v10;
|
||||||
|
|
||||||
|
/// Metadata v11
|
||||||
#[cfg(feature = "v11")]
|
#[cfg(feature = "v11")]
|
||||||
pub mod v11;
|
pub mod v11;
|
||||||
|
|
||||||
|
/// Metadata v12
|
||||||
#[cfg(feature = "v12")]
|
#[cfg(feature = "v12")]
|
||||||
pub mod v12;
|
pub mod v12;
|
||||||
|
|
||||||
|
/// Metadata v13
|
||||||
#[cfg(feature = "v13")]
|
#[cfg(feature = "v13")]
|
||||||
pub mod v13;
|
pub mod v13;
|
||||||
|
|
||||||
|
/// Metadata v14
|
||||||
#[cfg(feature = "v14")]
|
#[cfg(feature = "v14")]
|
||||||
pub mod v14;
|
pub mod v14;
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
//! Metadata Version 10. Networks like Kusama contain this version on-chain.
|
//! Metadata Version 10. Networks like Kusama contain this version on-chain.
|
||||||
//! Chains old enough to contain this metadata need a way to decode it.
|
//! Chains old enough to contain this metadata need a way to decode it.
|
||||||
|
|
||||||
|
#![allow(missing_docs)]
|
||||||
|
|
||||||
use crate::decode_different::*;
|
use crate::decode_different::*;
|
||||||
use codec::{Encode, Output};
|
use codec::{Encode, Output};
|
||||||
|
|
||||||
@@ -195,7 +197,11 @@ pub enum StorageEntryType {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A storage entry modifier.
|
/// A storage entry modifier indicates how a storage entry is returned when fetched and what the value will be if the key is not present.
|
||||||
|
/// Specifically this refers to the "return type" when fetching a storage entry, and what the value will be if the key is not present.
|
||||||
|
///
|
||||||
|
/// `Optional` means you should expect an `Option<T>`, with `None` returned if the key is not present.
|
||||||
|
/// `Default` means you should expect a `T` with the default value of default if the key is not present.
|
||||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||||
pub enum StorageEntryModifier {
|
pub enum StorageEntryModifier {
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
//! Metadata Version 11. Networks like Kusama contain this version on-chain.
|
//! Metadata Version 11. Networks like Kusama contain this version on-chain.
|
||||||
//! Chains old enough to contain this metadata need a way to decode it.
|
//! Chains old enough to contain this metadata need a way to decode it.
|
||||||
|
|
||||||
|
#![allow(missing_docs)]
|
||||||
|
|
||||||
use crate::decode_different::*;
|
use crate::decode_different::*;
|
||||||
use codec::{Encode, Output};
|
use codec::{Encode, Output};
|
||||||
|
|
||||||
@@ -197,7 +199,11 @@ pub enum StorageEntryType {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A storage entry modifier.
|
/// A storage entry modifier indicates how a storage entry is returned when fetched and what the value will be if the key is not present.
|
||||||
|
/// Specifically this refers to the "return type" when fetching a storage entry, and what the value will be if the key is not present.
|
||||||
|
///
|
||||||
|
/// `Optional` means you should expect an `Option<T>`, with `None` returned if the key is not present.
|
||||||
|
/// `Default` means you should expect a `T` with the default value of default if the key is not present.
|
||||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||||
pub enum StorageEntryModifier {
|
pub enum StorageEntryModifier {
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
//! Metadata Version 12. Networks like Kusama contain this version on-chain.
|
//! Metadata Version 12. Networks like Kusama contain this version on-chain.
|
||||||
//! Chains old enough to contain this metadata need a way to decode it.
|
//! Chains old enough to contain this metadata need a way to decode it.
|
||||||
|
|
||||||
|
#![allow(missing_docs)]
|
||||||
|
|
||||||
use crate::decode_different::*;
|
use crate::decode_different::*;
|
||||||
use codec::{Encode, Output};
|
use codec::{Encode, Output};
|
||||||
|
|
||||||
@@ -197,7 +199,11 @@ pub enum StorageEntryType {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A storage entry modifier.
|
/// A storage entry modifier indicates how a storage entry is returned when fetched and what the value will be if the key is not present.
|
||||||
|
/// Specifically this refers to the "return type" when fetching a storage entry, and what the value will be if the key is not present.
|
||||||
|
///
|
||||||
|
/// `Optional` means you should expect an `Option<T>`, with `None` returned if the key is not present.
|
||||||
|
/// `Default` means you should expect a `T` with the default value of default if the key is not present.
|
||||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||||
pub enum StorageEntryModifier {
|
pub enum StorageEntryModifier {
|
||||||
|
|||||||
@@ -38,8 +38,11 @@ pub const META_RESERVED: u32 = 0x6174656d; // 'meta' warn endianness
|
|||||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||||
pub struct FunctionMetadata {
|
pub struct FunctionMetadata {
|
||||||
|
/// Function name.
|
||||||
pub name: DecodeDifferentStr,
|
pub name: DecodeDifferentStr,
|
||||||
|
/// A list of arguments this function takes.
|
||||||
pub arguments: DecodeDifferentArray<FunctionArgumentMetadata>,
|
pub arguments: DecodeDifferentArray<FunctionArgumentMetadata>,
|
||||||
|
/// Function documentation.
|
||||||
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +50,9 @@ pub struct FunctionMetadata {
|
|||||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||||
pub struct FunctionArgumentMetadata {
|
pub struct FunctionArgumentMetadata {
|
||||||
|
/// Name of the variable for the argument.
|
||||||
pub name: DecodeDifferentStr,
|
pub name: DecodeDifferentStr,
|
||||||
|
/// Type of the parameter.
|
||||||
pub ty: DecodeDifferentStr,
|
pub ty: DecodeDifferentStr,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +60,9 @@ pub struct FunctionArgumentMetadata {
|
|||||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||||
pub struct OuterEventMetadata {
|
pub struct OuterEventMetadata {
|
||||||
|
/// Name of the event.
|
||||||
pub name: DecodeDifferentStr,
|
pub name: DecodeDifferentStr,
|
||||||
|
/// A list of event details.
|
||||||
pub events: DecodeDifferentArray<
|
pub events: DecodeDifferentArray<
|
||||||
(&'static str, FnEncode<&'static [EventMetadata]>),
|
(&'static str, FnEncode<&'static [EventMetadata]>),
|
||||||
(StringBuf, Vec<EventMetadata>),
|
(StringBuf, Vec<EventMetadata>),
|
||||||
@@ -66,8 +73,11 @@ pub struct OuterEventMetadata {
|
|||||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||||
pub struct EventMetadata {
|
pub struct EventMetadata {
|
||||||
|
/// Name of the event.
|
||||||
pub name: DecodeDifferentStr,
|
pub name: DecodeDifferentStr,
|
||||||
|
/// Arguments of the event.
|
||||||
pub arguments: DecodeDifferentArray<&'static str, StringBuf>,
|
pub arguments: DecodeDifferentArray<&'static str, StringBuf>,
|
||||||
|
/// Documentation of the event.
|
||||||
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,10 +85,15 @@ pub struct EventMetadata {
|
|||||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||||
pub struct StorageEntryMetadata {
|
pub struct StorageEntryMetadata {
|
||||||
|
/// Variable name of the storage entry.
|
||||||
pub name: DecodeDifferentStr,
|
pub name: DecodeDifferentStr,
|
||||||
|
/// A storage modifier of the storage entry (is it optional? does it have a default value?).
|
||||||
pub modifier: StorageEntryModifier,
|
pub modifier: StorageEntryModifier,
|
||||||
|
/// Type of the value stored in the entry.
|
||||||
pub ty: StorageEntryType,
|
pub ty: StorageEntryType,
|
||||||
|
/// Default value (SCALE encoded).
|
||||||
pub default: ByteGetter,
|
pub default: ByteGetter,
|
||||||
|
/// Storage entry documentation.
|
||||||
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,9 +101,13 @@ pub struct StorageEntryMetadata {
|
|||||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||||
pub struct ModuleConstantMetadata {
|
pub struct ModuleConstantMetadata {
|
||||||
|
/// Name of the module constant.
|
||||||
pub name: DecodeDifferentStr,
|
pub name: DecodeDifferentStr,
|
||||||
|
/// Type of the module constant.
|
||||||
pub ty: DecodeDifferentStr,
|
pub ty: DecodeDifferentStr,
|
||||||
|
/// Value stored in the constant (SCALE encoded).
|
||||||
pub value: ByteGetter,
|
pub value: ByteGetter,
|
||||||
|
/// Documentation of the constant.
|
||||||
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,12 +115,15 @@ pub struct ModuleConstantMetadata {
|
|||||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||||
pub struct ErrorMetadata {
|
pub struct ErrorMetadata {
|
||||||
|
/// Name of the error.
|
||||||
pub name: DecodeDifferentStr,
|
pub name: DecodeDifferentStr,
|
||||||
|
/// Error variant documentation.
|
||||||
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Metadata about errors in a module.
|
/// Metadata about errors in a module.
|
||||||
pub trait ModuleErrorMetadata {
|
pub trait ModuleErrorMetadata {
|
||||||
|
/// Returns the error metadata.
|
||||||
fn metadata() -> &'static [ErrorMetadata];
|
fn metadata() -> &'static [ErrorMetadata];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +135,7 @@ impl ModuleErrorMetadata for &'static str {
|
|||||||
|
|
||||||
/// A technical trait to store lazy initiated vec value as static dyn pointer.
|
/// A technical trait to store lazy initiated vec value as static dyn pointer.
|
||||||
pub trait DefaultByte: Send + Sync {
|
pub trait DefaultByte: Send + Sync {
|
||||||
|
/// A default value (SCALE encoded).
|
||||||
fn default_byte(&self) -> Vec<u8>;
|
fn default_byte(&self) -> Vec<u8>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,12 +184,19 @@ impl core::fmt::Debug for DefaultByteGetter {
|
|||||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||||
pub enum StorageHasher {
|
pub enum StorageHasher {
|
||||||
|
/// 128-bit Blake2 hash.
|
||||||
Blake2_128,
|
Blake2_128,
|
||||||
|
/// 256-bit Blake2 hash.
|
||||||
Blake2_256,
|
Blake2_256,
|
||||||
|
/// Multiple 128-bit Blake2 hashes concatenated.
|
||||||
Blake2_128Concat,
|
Blake2_128Concat,
|
||||||
|
/// 128-bit XX hash.
|
||||||
Twox128,
|
Twox128,
|
||||||
|
/// 256-bit XX hash.
|
||||||
Twox256,
|
Twox256,
|
||||||
|
/// Multiple 64-bit XX hashes concatenated.
|
||||||
Twox64Concat,
|
Twox64Concat,
|
||||||
|
/// Identity hashing (no hashing).
|
||||||
Identity,
|
Identity,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,33 +204,54 @@ pub enum StorageHasher {
|
|||||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||||
pub enum StorageEntryType {
|
pub enum StorageEntryType {
|
||||||
|
/// Plain storage entry (just the value).
|
||||||
Plain(DecodeDifferentStr),
|
Plain(DecodeDifferentStr),
|
||||||
|
/// A storage map.
|
||||||
Map {
|
Map {
|
||||||
|
/// Hasher type for the keys.
|
||||||
hasher: StorageHasher,
|
hasher: StorageHasher,
|
||||||
|
/// Key type.
|
||||||
key: DecodeDifferentStr,
|
key: DecodeDifferentStr,
|
||||||
|
/// Value type.
|
||||||
value: DecodeDifferentStr,
|
value: DecodeDifferentStr,
|
||||||
// is_linked flag previously, unused now to keep backwards compat
|
/// is_linked flag previously, unused now to keep backwards compat
|
||||||
unused: bool,
|
unused: bool,
|
||||||
},
|
},
|
||||||
|
/// Storage Double Map.
|
||||||
DoubleMap {
|
DoubleMap {
|
||||||
|
/// Hasher type for the keys.
|
||||||
hasher: StorageHasher,
|
hasher: StorageHasher,
|
||||||
|
/// First key type.
|
||||||
key1: DecodeDifferentStr,
|
key1: DecodeDifferentStr,
|
||||||
|
/// Second key type.
|
||||||
key2: DecodeDifferentStr,
|
key2: DecodeDifferentStr,
|
||||||
|
/// Value type.
|
||||||
value: DecodeDifferentStr,
|
value: DecodeDifferentStr,
|
||||||
|
/// Hasher for the second key.
|
||||||
key2_hasher: StorageHasher,
|
key2_hasher: StorageHasher,
|
||||||
},
|
},
|
||||||
|
/// Storage multi map.
|
||||||
NMap {
|
NMap {
|
||||||
|
/// Key types.
|
||||||
keys: DecodeDifferentArray<&'static str, StringBuf>,
|
keys: DecodeDifferentArray<&'static str, StringBuf>,
|
||||||
|
/// Key hashers.
|
||||||
hashers: DecodeDifferentArray<StorageHasher>,
|
hashers: DecodeDifferentArray<StorageHasher>,
|
||||||
|
/// Value type.
|
||||||
value: DecodeDifferentStr,
|
value: DecodeDifferentStr,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A storage entry modifier.
|
/// A storage entry modifier indicates how a storage entry is returned when fetched and what the value will be if the key is not present.
|
||||||
|
/// Specifically this refers to the "return type" when fetching a storage entry, and what the value will be if the key is not present.
|
||||||
|
///
|
||||||
|
/// `Optional` means you should expect an `Option<T>`, with `None` returned if the key is not present.
|
||||||
|
/// `Default` means you should expect a `T` with the default value of default if the key is not present.
|
||||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||||
pub enum StorageEntryModifier {
|
pub enum StorageEntryModifier {
|
||||||
|
/// The storage entry returns an `Option<T>`, with `None` if the key is not present.
|
||||||
Optional,
|
Optional,
|
||||||
|
/// The storage entry returns `T::Default` if the key is not present.
|
||||||
Default,
|
Default,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,6 +261,7 @@ pub enum StorageEntryModifier {
|
|||||||
pub struct StorageMetadata {
|
pub struct StorageMetadata {
|
||||||
/// The common prefix used by all storage entries.
|
/// The common prefix used by all storage entries.
|
||||||
pub prefix: DecodeDifferent<&'static str, StringBuf>,
|
pub prefix: DecodeDifferent<&'static str, StringBuf>,
|
||||||
|
/// Storage entries.
|
||||||
pub entries: DecodeDifferent<&'static [StorageEntryMetadata], Vec<StorageEntryMetadata>>,
|
pub entries: DecodeDifferent<&'static [StorageEntryMetadata], Vec<StorageEntryMetadata>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,15 +285,21 @@ pub struct RuntimeMetadataV13 {
|
|||||||
pub extrinsic: ExtrinsicMetadata,
|
pub extrinsic: ExtrinsicMetadata,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// All metadata about an runtime module.
|
/// All metadata about a runtime module.
|
||||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||||
pub struct ModuleMetadata {
|
pub struct ModuleMetadata {
|
||||||
|
/// Module name.
|
||||||
pub name: DecodeDifferentStr,
|
pub name: DecodeDifferentStr,
|
||||||
|
/// Module storage.
|
||||||
pub storage: Option<DecodeDifferent<FnEncode<StorageMetadata>, StorageMetadata>>,
|
pub storage: Option<DecodeDifferent<FnEncode<StorageMetadata>, StorageMetadata>>,
|
||||||
|
/// Module calls.
|
||||||
pub calls: ODFnA<FunctionMetadata>,
|
pub calls: ODFnA<FunctionMetadata>,
|
||||||
|
/// Module Event type.
|
||||||
pub event: ODFnA<EventMetadata>,
|
pub event: ODFnA<EventMetadata>,
|
||||||
|
/// Module constants.
|
||||||
pub constants: DFnA<ModuleConstantMetadata>,
|
pub constants: DFnA<ModuleConstantMetadata>,
|
||||||
|
/// Module errors.
|
||||||
pub errors: DFnA<ErrorMetadata>,
|
pub errors: DFnA<ErrorMetadata>,
|
||||||
/// Define the index of the module, this index will be used for the encoding of module event,
|
/// Define the index of the module, this index will be used for the encoding of module event,
|
||||||
/// call and origin variants.
|
/// call and origin variants.
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ use scale_info::{
|
|||||||
/// Current prefix of metadata
|
/// Current prefix of metadata
|
||||||
pub const META_RESERVED: u32 = 0x6174656d; // 'meta' warn endianness
|
pub const META_RESERVED: u32 = 0x6174656d; // 'meta' warn endianness
|
||||||
|
|
||||||
|
/// Latest runtime metadata
|
||||||
pub type RuntimeMetadataLastVersion = RuntimeMetadataV14;
|
pub type RuntimeMetadataLastVersion = RuntimeMetadataV14;
|
||||||
|
|
||||||
impl From<RuntimeMetadataLastVersion> for super::RuntimeMetadataPrefixed {
|
impl From<RuntimeMetadataLastVersion> for super::RuntimeMetadataPrefixed {
|
||||||
@@ -45,6 +46,7 @@ impl From<RuntimeMetadataLastVersion> for super::RuntimeMetadataPrefixed {
|
|||||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||||
pub struct RuntimeMetadataV14 {
|
pub struct RuntimeMetadataV14 {
|
||||||
|
/// Type registry containing all types used in the metadata.
|
||||||
pub types: PortableRegistry,
|
pub types: PortableRegistry,
|
||||||
/// Metadata of all the pallets.
|
/// Metadata of all the pallets.
|
||||||
pub pallets: Vec<PalletMetadata<PortableForm>>,
|
pub pallets: Vec<PalletMetadata<PortableForm>>,
|
||||||
@@ -55,6 +57,7 @@ pub struct RuntimeMetadataV14 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RuntimeMetadataV14 {
|
impl RuntimeMetadataV14 {
|
||||||
|
/// Create a new instance of [`RuntimeMetadataV14`].
|
||||||
pub fn new(
|
pub fn new(
|
||||||
pallets: Vec<PalletMetadata>,
|
pallets: Vec<PalletMetadata>,
|
||||||
extrinsic: ExtrinsicMetadata,
|
extrinsic: ExtrinsicMetadata,
|
||||||
@@ -137,11 +140,17 @@ impl IntoPortable for SignedExtensionMetadata {
|
|||||||
serde(bound(serialize = "T::Type: Serialize, T::String: Serialize"))
|
serde(bound(serialize = "T::Type: Serialize, T::String: Serialize"))
|
||||||
)]
|
)]
|
||||||
pub struct PalletMetadata<T: Form = MetaForm> {
|
pub struct PalletMetadata<T: Form = MetaForm> {
|
||||||
|
/// Pallet name.
|
||||||
pub name: T::String,
|
pub name: T::String,
|
||||||
|
/// Pallet storage metadata.
|
||||||
pub storage: Option<PalletStorageMetadata<T>>,
|
pub storage: Option<PalletStorageMetadata<T>>,
|
||||||
|
/// Pallet calls metadata.
|
||||||
pub calls: Option<PalletCallMetadata<T>>,
|
pub calls: Option<PalletCallMetadata<T>>,
|
||||||
|
/// Pallet event metadata.
|
||||||
pub event: Option<PalletEventMetadata<T>>,
|
pub event: Option<PalletEventMetadata<T>>,
|
||||||
|
/// Pallet constants metadata.
|
||||||
pub constants: Vec<PalletConstantMetadata<T>>,
|
pub constants: Vec<PalletConstantMetadata<T>>,
|
||||||
|
/// Pallet error metadata.
|
||||||
pub error: Option<PalletErrorMetadata<T>>,
|
pub error: Option<PalletErrorMetadata<T>>,
|
||||||
/// Define the index of the pallet, this index will be used for the encoding of pallet event,
|
/// Define the index of the pallet, this index will be used for the encoding of pallet event,
|
||||||
/// call and origin variants.
|
/// call and origin variants.
|
||||||
@@ -174,6 +183,7 @@ impl IntoPortable for PalletMetadata {
|
|||||||
pub struct PalletStorageMetadata<T: Form = MetaForm> {
|
pub struct PalletStorageMetadata<T: Form = MetaForm> {
|
||||||
/// The common prefix used by all storage entries.
|
/// The common prefix used by all storage entries.
|
||||||
pub prefix: T::String,
|
pub prefix: T::String,
|
||||||
|
/// Metadata for all storage entries.
|
||||||
pub entries: Vec<StorageEntryMetadata<T>>,
|
pub entries: Vec<StorageEntryMetadata<T>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,10 +206,15 @@ impl IntoPortable for PalletStorageMetadata {
|
|||||||
serde(bound(serialize = "T::Type: Serialize, T::String: Serialize"))
|
serde(bound(serialize = "T::Type: Serialize, T::String: Serialize"))
|
||||||
)]
|
)]
|
||||||
pub struct StorageEntryMetadata<T: Form = MetaForm> {
|
pub struct StorageEntryMetadata<T: Form = MetaForm> {
|
||||||
|
/// Variable name of the storage entry.
|
||||||
pub name: T::String,
|
pub name: T::String,
|
||||||
|
/// An `Option` modifier of that storage entry.
|
||||||
pub modifier: StorageEntryModifier,
|
pub modifier: StorageEntryModifier,
|
||||||
|
/// Type of the value stored in the entry.
|
||||||
pub ty: StorageEntryType<T>,
|
pub ty: StorageEntryType<T>,
|
||||||
|
/// Default value (SCALE encoded).
|
||||||
pub default: Vec<u8>,
|
pub default: Vec<u8>,
|
||||||
|
/// Storage entry documentation.
|
||||||
pub docs: Vec<T::String>,
|
pub docs: Vec<T::String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,11 +232,17 @@ impl IntoPortable for StorageEntryMetadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A storage entry modifier.
|
/// A storage entry modifier indicates how a storage entry is returned when fetched and what the value will be if the key is not present.
|
||||||
|
/// Specifically this refers to the "return type" when fetching a storage entry, and what the value will be if the key is not present.
|
||||||
|
///
|
||||||
|
/// `Optional` means you should expect an `Option<T>`, with `None` returned if the key is not present.
|
||||||
|
/// `Default` means you should expect a `T` with the default value of default if the key is not present.
|
||||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||||
pub enum StorageEntryModifier {
|
pub enum StorageEntryModifier {
|
||||||
|
/// The storage entry returns an `Option<T>`, with `None` if the key is not present.
|
||||||
Optional,
|
Optional,
|
||||||
|
/// The storage entry returns `T::Default` if the key is not present.
|
||||||
Default,
|
Default,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,16 +250,23 @@ pub enum StorageEntryModifier {
|
|||||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||||
pub enum StorageHasher {
|
pub enum StorageHasher {
|
||||||
|
/// 128-bit Blake2 hash.
|
||||||
Blake2_128,
|
Blake2_128,
|
||||||
|
/// 256-bit Blake2 hash.
|
||||||
Blake2_256,
|
Blake2_256,
|
||||||
|
/// Multiple 128-bit Blake2 hashes concatenated.
|
||||||
Blake2_128Concat,
|
Blake2_128Concat,
|
||||||
|
/// 128-bit XX hash.
|
||||||
Twox128,
|
Twox128,
|
||||||
|
/// 256-bit XX hash.
|
||||||
Twox256,
|
Twox256,
|
||||||
|
/// Multiple 64-bit XX hashes concatenated.
|
||||||
Twox64Concat,
|
Twox64Concat,
|
||||||
|
/// Identity hashing (no hashing).
|
||||||
Identity,
|
Identity,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A storage entry type.
|
/// A type of storage value.
|
||||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
@@ -246,7 +274,9 @@ pub enum StorageHasher {
|
|||||||
serde(bound(serialize = "T::Type: Serialize, T::String: Serialize"))
|
serde(bound(serialize = "T::Type: Serialize, T::String: Serialize"))
|
||||||
)]
|
)]
|
||||||
pub enum StorageEntryType<T: Form = MetaForm> {
|
pub enum StorageEntryType<T: Form = MetaForm> {
|
||||||
|
/// Plain storage entry (just the value).
|
||||||
Plain(T::Type),
|
Plain(T::Type),
|
||||||
|
/// A storage map.
|
||||||
Map {
|
Map {
|
||||||
/// One or more hashers, should be one hasher per key element.
|
/// One or more hashers, should be one hasher per key element.
|
||||||
hashers: Vec<StorageHasher>,
|
hashers: Vec<StorageHasher>,
|
||||||
@@ -304,10 +334,11 @@ impl From<MetaType> for PalletCallMetadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Metadata about the pallet event type.
|
/// Metadata about the pallet Event type.
|
||||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||||
pub struct PalletEventMetadata<T: Form = MetaForm> {
|
pub struct PalletEventMetadata<T: Form = MetaForm> {
|
||||||
|
/// The Event type.
|
||||||
pub ty: T::Type,
|
pub ty: T::Type,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,9 +366,13 @@ impl From<MetaType> for PalletEventMetadata {
|
|||||||
serde(bound(serialize = "T::Type: Serialize, T::String: Serialize"))
|
serde(bound(serialize = "T::Type: Serialize, T::String: Serialize"))
|
||||||
)]
|
)]
|
||||||
pub struct PalletConstantMetadata<T: Form = MetaForm> {
|
pub struct PalletConstantMetadata<T: Form = MetaForm> {
|
||||||
|
/// Name of the pallet constant.
|
||||||
pub name: T::String,
|
pub name: T::String,
|
||||||
|
/// Type of the pallet constant.
|
||||||
pub ty: T::Type,
|
pub ty: T::Type,
|
||||||
|
/// Value stored in the constant (SCALE encoded).
|
||||||
pub value: Vec<u8>,
|
pub value: Vec<u8>,
|
||||||
|
/// Documentation of the constant.
|
||||||
pub docs: Vec<T::String>,
|
pub docs: Vec<T::String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
//! Metadata Version 8. Chains old enough to contain this metadata need a way to decode it.
|
//! Metadata Version 8. Chains old enough to contain this metadata need a way to decode it.
|
||||||
|
|
||||||
|
#![allow(missing_docs)]
|
||||||
|
|
||||||
use crate::decode_different::*;
|
use crate::decode_different::*;
|
||||||
use codec::{Encode, Output};
|
use codec::{Encode, Output};
|
||||||
|
|
||||||
@@ -43,8 +45,11 @@ pub const META_RESERVED: u32 = 0x6174656d; // 'meta' warn endianness
|
|||||||
#[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 FunctionMetadata {
|
pub struct FunctionMetadata {
|
||||||
|
/// Function name.
|
||||||
pub name: DecodeDifferentStr,
|
pub name: DecodeDifferentStr,
|
||||||
|
/// A list of arguments this function takes.
|
||||||
pub arguments: DecodeDifferentArray<FunctionArgumentMetadata>,
|
pub arguments: DecodeDifferentArray<FunctionArgumentMetadata>,
|
||||||
|
/// Function documentation.
|
||||||
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +57,9 @@ pub struct FunctionMetadata {
|
|||||||
#[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 FunctionArgumentMetadata {
|
pub struct FunctionArgumentMetadata {
|
||||||
|
/// Name of the variable for the argument.
|
||||||
pub name: DecodeDifferentStr,
|
pub name: DecodeDifferentStr,
|
||||||
|
/// Type of the parameter.
|
||||||
pub ty: DecodeDifferentStr,
|
pub ty: DecodeDifferentStr,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +67,9 @@ pub struct FunctionArgumentMetadata {
|
|||||||
#[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 OuterEventMetadata {
|
pub struct OuterEventMetadata {
|
||||||
|
/// Name of the event.
|
||||||
pub name: DecodeDifferentStr,
|
pub name: DecodeDifferentStr,
|
||||||
|
/// A list of event details.
|
||||||
pub events: DecodeDifferentArray<
|
pub events: DecodeDifferentArray<
|
||||||
(&'static str, FnEncode<&'static [EventMetadata]>),
|
(&'static str, FnEncode<&'static [EventMetadata]>),
|
||||||
(StringBuf, Vec<EventMetadata>),
|
(StringBuf, Vec<EventMetadata>),
|
||||||
@@ -71,8 +80,11 @@ pub struct OuterEventMetadata {
|
|||||||
#[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 EventMetadata {
|
pub struct EventMetadata {
|
||||||
|
/// Name of the event.
|
||||||
pub name: DecodeDifferentStr,
|
pub name: DecodeDifferentStr,
|
||||||
|
/// Arguments of the event.
|
||||||
pub arguments: DecodeDifferentArray<&'static str, StringBuf>,
|
pub arguments: DecodeDifferentArray<&'static str, StringBuf>,
|
||||||
|
/// Documentation of the event.
|
||||||
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,10 +92,15 @@ pub struct EventMetadata {
|
|||||||
#[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 StorageEntryMetadata {
|
pub struct StorageEntryMetadata {
|
||||||
|
/// Variable name of the storage entry.
|
||||||
pub name: DecodeDifferentStr,
|
pub name: DecodeDifferentStr,
|
||||||
|
/// A storage modifier of the storage entry (is it optional? does it have a default value?).
|
||||||
pub modifier: StorageEntryModifier,
|
pub modifier: StorageEntryModifier,
|
||||||
|
/// Type of the value stored in the entry.
|
||||||
pub ty: StorageEntryType,
|
pub ty: StorageEntryType,
|
||||||
|
/// Default value (SCALE encoded).
|
||||||
pub default: ByteGetter,
|
pub default: ByteGetter,
|
||||||
|
/// Storage entry documentation.
|
||||||
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,9 +108,13 @@ pub struct StorageEntryMetadata {
|
|||||||
#[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 ModuleConstantMetadata {
|
pub struct ModuleConstantMetadata {
|
||||||
|
/// Name of the module constant.
|
||||||
pub name: DecodeDifferentStr,
|
pub name: DecodeDifferentStr,
|
||||||
|
/// Type of the module constant.
|
||||||
pub ty: DecodeDifferentStr,
|
pub ty: DecodeDifferentStr,
|
||||||
|
/// Value stored in the constant (SCALE encoded).
|
||||||
pub value: ByteGetter,
|
pub value: ByteGetter,
|
||||||
|
/// Documentation of the constant.
|
||||||
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,12 +122,15 @@ pub struct ModuleConstantMetadata {
|
|||||||
#[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 ErrorMetadata {
|
pub struct ErrorMetadata {
|
||||||
|
/// Name of the error.
|
||||||
pub name: DecodeDifferentStr,
|
pub name: DecodeDifferentStr,
|
||||||
|
/// Error variant documentation.
|
||||||
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// All the metadata about errors in a module.
|
/// All the metadata about errors in a module.
|
||||||
pub trait ModuleErrorMetadata {
|
pub trait ModuleErrorMetadata {
|
||||||
|
/// Returns error metadata.
|
||||||
fn metadata() -> &'static [ErrorMetadata];
|
fn metadata() -> &'static [ErrorMetadata];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,6 +142,7 @@ impl ModuleErrorMetadata for &'static str {
|
|||||||
|
|
||||||
/// A technical trait to store lazy initiated vec value as static dyn pointer.
|
/// A technical trait to store lazy initiated vec value as static dyn pointer.
|
||||||
pub trait DefaultByte: Send + Sync {
|
pub trait DefaultByte: Send + Sync {
|
||||||
|
/// A default value (SCALE encoded).
|
||||||
fn default_byte(&self) -> Vec<u8>;
|
fn default_byte(&self) -> Vec<u8>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,10 +192,15 @@ impl std::fmt::Debug for DefaultByteGetter {
|
|||||||
#[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 StorageHasher {
|
pub enum StorageHasher {
|
||||||
|
/// 128-bit Blake2 hash.
|
||||||
Blake2_128,
|
Blake2_128,
|
||||||
|
/// 256-bit Blake2 hash.
|
||||||
Blake2_256,
|
Blake2_256,
|
||||||
|
/// 128-bit XX hash.
|
||||||
Twox128,
|
Twox128,
|
||||||
|
/// 256-bit XX hash.
|
||||||
Twox256,
|
Twox256,
|
||||||
|
/// 64-bit XX hashes concatentation.
|
||||||
Twox64Concat,
|
Twox64Concat,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,27 +208,44 @@ pub enum StorageHasher {
|
|||||||
#[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 StorageEntryType {
|
pub enum StorageEntryType {
|
||||||
|
/// Plain storage entry (just the value).
|
||||||
Plain(DecodeDifferentStr),
|
Plain(DecodeDifferentStr),
|
||||||
|
/// A storage map.
|
||||||
Map {
|
Map {
|
||||||
|
/// Hasher type for the keys.
|
||||||
hasher: StorageHasher,
|
hasher: StorageHasher,
|
||||||
|
/// Key type.
|
||||||
key: DecodeDifferentStr,
|
key: DecodeDifferentStr,
|
||||||
|
/// Value type.
|
||||||
value: DecodeDifferentStr,
|
value: DecodeDifferentStr,
|
||||||
is_linked: bool,
|
is_linked: bool,
|
||||||
},
|
},
|
||||||
|
/// Storage Double Map.
|
||||||
DoubleMap {
|
DoubleMap {
|
||||||
|
/// Hasher type for the keys.
|
||||||
hasher: StorageHasher,
|
hasher: StorageHasher,
|
||||||
|
/// First key type.
|
||||||
key1: DecodeDifferentStr,
|
key1: DecodeDifferentStr,
|
||||||
|
/// Second key type.
|
||||||
key2: DecodeDifferentStr,
|
key2: DecodeDifferentStr,
|
||||||
|
/// Value type.
|
||||||
value: DecodeDifferentStr,
|
value: DecodeDifferentStr,
|
||||||
|
/// Hasher for the second key.
|
||||||
key2_hasher: StorageHasher,
|
key2_hasher: StorageHasher,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A storage entry modifier.
|
/// A storage entry modifier indicates how a storage entry is returned when fetched and what the value will be if the key is not present.
|
||||||
|
/// Specifically this refers to the "return type" when fetching a storage entry, and what the value will be if the key is not present.
|
||||||
|
///
|
||||||
|
/// `Optional` means you should expect an `Option<T>`, with `None` returned if the key is not present.
|
||||||
|
/// `Default` means you should expect a `T` with the default value of default if the key is not present.
|
||||||
#[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 StorageEntryModifier {
|
pub enum StorageEntryModifier {
|
||||||
|
/// The storage entry returns an `Option<T>`, with `None` if the key is not present.
|
||||||
Optional,
|
Optional,
|
||||||
|
/// The storage entry returns `T::Default` if the key is not present.
|
||||||
Default,
|
Default,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,10 +268,11 @@ pub struct RuntimeMetadataV8 {
|
|||||||
/// The latest version of the metadata.
|
/// The latest version of the metadata.
|
||||||
pub type RuntimeMetadataLastVersion = RuntimeMetadataV8;
|
pub type RuntimeMetadataLastVersion = RuntimeMetadataV8;
|
||||||
|
|
||||||
/// All metadata about an runtime module.
|
/// All metadata about a runtime module.
|
||||||
#[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 ModuleMetadata {
|
pub struct ModuleMetadata {
|
||||||
|
/// Module name.
|
||||||
pub name: DecodeDifferentStr,
|
pub name: DecodeDifferentStr,
|
||||||
pub storage: Option<DecodeDifferent<FnEncode<StorageMetadata>, StorageMetadata>>,
|
pub storage: Option<DecodeDifferent<FnEncode<StorageMetadata>, StorageMetadata>>,
|
||||||
pub calls: ODFnA<FunctionMetadata>,
|
pub calls: ODFnA<FunctionMetadata>,
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
//! Metadata Version 9. Networks like/as old as Kusama start here.
|
//! Metadata Version 9. Networks like/as old as Kusama start here.
|
||||||
//! Chains old enough to contain this metadata need a way to decode it.
|
//! Chains old enough to contain this metadata need a way to decode it.
|
||||||
|
|
||||||
|
#![allow(missing_docs)]
|
||||||
|
|
||||||
use crate::decode_different::*;
|
use crate::decode_different::*;
|
||||||
use codec::{Encode, Output};
|
use codec::{Encode, Output};
|
||||||
|
|
||||||
@@ -195,7 +197,11 @@ pub enum StorageEntryType {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A storage entry modifier.
|
/// A storage entry modifier indicates how a storage entry is returned when fetched and what the value will be if the key is not present.
|
||||||
|
/// Specifically this refers to the "return type" when fetching a storage entry, and what the value will be if the key is not present.
|
||||||
|
///
|
||||||
|
/// `Optional` means you should expect an `Option<T>`, with `None` returned if the key is not present.
|
||||||
|
/// `Default` means you should expect a `T` with the default value of default if the key is not present.
|
||||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||||
pub enum StorageEntryModifier {
|
pub enum StorageEntryModifier {
|
||||||
|
|||||||
Reference in New Issue
Block a user