mirror of
https://github.com/pezkuwichain/pezframe-metadata.git
synced 2026-04-22 01:57:59 +00:00
add no_std support (#42)
* Metadata supporting scale-info can be decoded and serialized in no_std (#2) * Metadata supporting scale-info can be decoded and serialized in no_std (feature flag scale_info) * Changes from review: rename feature flag into full_derive * Changes from review: std implies full-derive * Changes from review: optimization Co-authored-by: echevrier <edith.chevrier@scs.ch> * split full_derive into decode and sered_codec features. (drop new Debug impls) * cargo fmt * rename serde_codec to serde_full * Prior to v14 everything was Debug. Are there any downsides? Unused debug impls will just get optimised away won't they? * rust fmt * Debug for the masses. Make it work for no_std * check all combos of features (if this plays well with ci then we should double up, doing the same again but target wasm32) * all wasm feature combos Co-authored-by: echevrier <84318241+echevrier@users.noreply.github.com> Co-authored-by: echevrier <edith.chevrier@scs.ch>
This commit is contained in:
+19
-28
@@ -69,12 +69,20 @@ jobs:
|
||||
- name: Add WASM Utilities
|
||||
run: rustup target add wasm32-unknown-unknown --toolchain stable
|
||||
## Check Stage
|
||||
- name: Checking wasm32
|
||||
- name: Checking wasm32 (v14)
|
||||
uses: actions-rs/cargo@v1
|
||||
uses: taiki-e/install-action@cargo-hack
|
||||
with:
|
||||
command: check
|
||||
command: hack
|
||||
toolchain: stable
|
||||
args: --manifest-path ./frame-metadata/Cargo.toml --target wasm32-unknown-unknown --no-default-features
|
||||
args: check --manifest-path ./frame-metadata/Cargo.toml --feature-powerset --no-dev-deps --features v14 --skip legacy,v8,v9,v10,v11,v12,v13 --depth 4 --target wasm32-unknown-unknown
|
||||
- name: Checking wasm32 (all features)
|
||||
uses: actions-rs/cargo@v1
|
||||
uses: taiki-e/install-action@cargo-hack
|
||||
with:
|
||||
command: hack
|
||||
toolchain: stable
|
||||
args: check --manifest-path ./frame-metadata/Cargo.toml --feature-powerset --no-dev-deps --skip decode,serde_full --depth 4 --target wasm32-unknown-unknown
|
||||
|
||||
check-features:
|
||||
name: Check Features
|
||||
@@ -92,34 +100,17 @@ jobs:
|
||||
fetch-depth: 5
|
||||
submodules: recursive
|
||||
## Check Stage
|
||||
- name: Checking without any features
|
||||
- name: Checking v14 feature combinations (native)
|
||||
uses: actions-rs/cargo@v1
|
||||
uses: taiki-e/install-action@cargo-hack
|
||||
with:
|
||||
command: check
|
||||
command: hack
|
||||
toolchain: stable
|
||||
args: --manifest-path ./frame-metadata/Cargo.toml --no-default-features
|
||||
- name: Checking v12
|
||||
args: check --manifest-path ./frame-metadata/Cargo.toml --feature-powerset --no-dev-deps --features v14 --skip legacy,v8,v9,v10,v11,v12,v13 --depth 4
|
||||
- name: Checking feature combinations excluding decode/serde_full (native)
|
||||
uses: actions-rs/cargo@v1
|
||||
uses: taiki-e/install-action@cargo-hack
|
||||
with:
|
||||
command: check
|
||||
command: hack
|
||||
toolchain: stable
|
||||
args: --manifest-path ./frame-metadata/Cargo.toml --no-default-features --features v12
|
||||
- name: Checking v13
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
toolchain: stable
|
||||
args: --manifest-path ./frame-metadata/Cargo.toml --no-default-features --features v13
|
||||
- name: Checking v14
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
toolchain: stable
|
||||
args: --manifest-path ./frame-metadata/Cargo.toml --no-default-features --features v14
|
||||
- name: Checking all versions
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
toolchain: stable
|
||||
args: --manifest-path ./frame-metadata/Cargo.toml --no-default-features --features v12,v13,v14
|
||||
|
||||
args: check --manifest-path ./frame-metadata/Cargo.toml --feature-powerset --no-dev-deps --skip decode,serde_full --depth 4
|
||||
|
||||
@@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
|
||||
cfg-if = "1.0.0"
|
||||
scale-info = { version = "2.0.0", default-features = false, optional = true, features = ["derive"] }
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
serde = { version = "1.0.101", default-features = false, optional = true, features = ["derive"] }
|
||||
|
||||
[features]
|
||||
default = ["std", "v14"]
|
||||
@@ -28,10 +28,20 @@ v12 = []
|
||||
v13 = []
|
||||
legacy = ["v13", "v12", "v11", "v10", "v9", "v8"]
|
||||
v14 = ["scale-info"]
|
||||
|
||||
# Serde support without relying on std features
|
||||
serde_full = [
|
||||
"scale-info/serde",
|
||||
"serde",
|
||||
"serde/alloc",
|
||||
]
|
||||
# Scale decode support without relying on std features
|
||||
decode = ["scale-info/decode"]
|
||||
|
||||
std = [
|
||||
"decode",
|
||||
"serde_full",
|
||||
"codec/std",
|
||||
"scale-info/std",
|
||||
"scale-info/serde",
|
||||
"scale-info/decode",
|
||||
"serde",
|
||||
"serde/std",
|
||||
]
|
||||
|
||||
+33
-16
@@ -19,15 +19,29 @@
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![warn(missing_docs)]
|
||||
#[cfg(all(
|
||||
any(feature = "decode", feature = "serde_full"),
|
||||
any(
|
||||
feature = "v13",
|
||||
feature = "v12",
|
||||
feature = "v11",
|
||||
feature = "v10",
|
||||
feature = "v9",
|
||||
feature = "v8",
|
||||
feature = "legacy"
|
||||
),
|
||||
not(feature = "std")
|
||||
))]
|
||||
compile_error!("decode and serde_full features prior to v14 require std");
|
||||
|
||||
#[cfg(feature = "serde_full")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[cfg(feature = "decode")]
|
||||
use codec::{Decode, Error, Input};
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "std")] {
|
||||
use codec::{Decode, Error, Input};
|
||||
use serde::{
|
||||
Deserialize,
|
||||
Serialize,
|
||||
};
|
||||
} else {
|
||||
if #[cfg(not(feature = "std"))] {
|
||||
extern crate alloc;
|
||||
use alloc::vec::Vec;
|
||||
}
|
||||
@@ -82,8 +96,9 @@ pub mod v14;
|
||||
pub use self::v14::*;
|
||||
|
||||
/// Metadata prefixed by a u32 for reserved usage
|
||||
#[derive(Eq, Encode, PartialEq)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Eq, Encode, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "decode", derive(Decode))]
|
||||
#[cfg_attr(feature = "serde_full", derive(Serialize))]
|
||||
pub struct RuntimeMetadataPrefixed(pub u32, pub RuntimeMetadata);
|
||||
|
||||
impl Into<Vec<u8>> for RuntimeMetadataPrefixed {
|
||||
@@ -95,8 +110,9 @@ impl Into<Vec<u8>> for RuntimeMetadataPrefixed {
|
||||
/// The metadata of a runtime.
|
||||
/// The version ID encoded/decoded through
|
||||
/// the enum nature of `RuntimeMetadata`.
|
||||
#[derive(Eq, Encode, PartialEq)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Eq, Encode, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "decode", derive(Decode))]
|
||||
#[cfg_attr(feature = "serde_full", derive(Serialize))]
|
||||
pub enum RuntimeMetadata {
|
||||
/// Unused; enum filler.
|
||||
V0(RuntimeMetadataDeprecated),
|
||||
@@ -182,13 +198,14 @@ impl RuntimeMetadata {
|
||||
}
|
||||
|
||||
/// Stores the encoded `RuntimeMetadata` as raw bytes.
|
||||
#[derive(Encode, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Deserialize, Debug))]
|
||||
#[derive(Encode, Eq, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "decode", derive(Decode))]
|
||||
#[cfg_attr(feature = "serde_full", derive(Serialize, Deserialize))]
|
||||
pub struct OpaqueMetadata(pub Vec<u8>);
|
||||
|
||||
/// Enum that should fail.
|
||||
#[derive(Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
|
||||
#[derive(Eq, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "serde_full", derive(Serialize, Deserialize))]
|
||||
pub enum RuntimeMetadataDeprecated {}
|
||||
|
||||
impl Encode for RuntimeMetadataDeprecated {
|
||||
@@ -197,7 +214,7 @@ impl Encode for RuntimeMetadataDeprecated {
|
||||
|
||||
impl codec::EncodeLike for RuntimeMetadataDeprecated {}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(feature = "decode")]
|
||||
impl Decode for RuntimeMetadataDeprecated {
|
||||
fn decode<I: Input>(_input: &mut I) -> Result<Self, Error> {
|
||||
Err("Decoding is not supported".into())
|
||||
|
||||
+26
-26
@@ -43,8 +43,8 @@ cfg_if::cfg_if! {
|
||||
pub const META_RESERVED: u32 = 0x6174656d; // 'meta' warn endianness
|
||||
|
||||
/// All the metadata about a function.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct FunctionMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub arguments: DecodeDifferentArray<FunctionArgumentMetadata>,
|
||||
@@ -52,16 +52,16 @@ pub struct FunctionMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about a function argument.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct FunctionArgumentMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub ty: DecodeDifferentStr,
|
||||
}
|
||||
|
||||
/// All the metadata about an outer event.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct OuterEventMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub events: DecodeDifferentArray<
|
||||
@@ -71,8 +71,8 @@ pub struct OuterEventMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about an event.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct EventMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub arguments: DecodeDifferentArray<&'static str, StringBuf>,
|
||||
@@ -80,8 +80,8 @@ pub struct EventMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about one storage entry.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct StorageEntryMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub modifier: StorageEntryModifier,
|
||||
@@ -91,8 +91,8 @@ pub struct StorageEntryMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about one module constant.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ModuleConstantMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub ty: DecodeDifferentStr,
|
||||
@@ -101,8 +101,8 @@ pub struct ModuleConstantMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about a module error.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ErrorMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
||||
@@ -166,8 +166,8 @@ impl core::fmt::Debug for DefaultByteGetter {
|
||||
}
|
||||
|
||||
/// Hasher used by storage maps
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub enum StorageHasher {
|
||||
Blake2_128,
|
||||
Blake2_256,
|
||||
@@ -178,8 +178,8 @@ pub enum StorageHasher {
|
||||
}
|
||||
|
||||
/// A storage entry type.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub enum StorageEntryType {
|
||||
Plain(DecodeDifferentStr),
|
||||
Map {
|
||||
@@ -202,16 +202,16 @@ pub enum StorageEntryType {
|
||||
///
|
||||
/// `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)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub enum StorageEntryModifier {
|
||||
Optional,
|
||||
Default,
|
||||
}
|
||||
|
||||
/// All metadata of the storage.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct StorageMetadata {
|
||||
/// The common prefix used by all storage entries.
|
||||
pub prefix: DecodeDifferent<&'static str, StringBuf>,
|
||||
@@ -219,15 +219,15 @@ pub struct StorageMetadata {
|
||||
}
|
||||
|
||||
/// The metadata of a runtime.
|
||||
#[derive(Eq, Encode, PartialEq)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Eq, Encode, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct RuntimeMetadataV10 {
|
||||
pub modules: DecodeDifferentArray<ModuleMetadata>,
|
||||
}
|
||||
|
||||
/// All metadata about an runtime module.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ModuleMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub storage: Option<DecodeDifferent<FnEncode<StorageMetadata>, StorageMetadata>>,
|
||||
|
||||
+28
-28
@@ -43,8 +43,8 @@ cfg_if::cfg_if! {
|
||||
pub const META_RESERVED: u32 = 0x6174656d; // 'meta' warn endianness
|
||||
|
||||
/// All the metadata about a function.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct FunctionMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub arguments: DecodeDifferentArray<FunctionArgumentMetadata>,
|
||||
@@ -52,16 +52,16 @@ pub struct FunctionMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about a function argument.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct FunctionArgumentMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub ty: DecodeDifferentStr,
|
||||
}
|
||||
|
||||
/// All the metadata about an outer event.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct OuterEventMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub events: DecodeDifferentArray<
|
||||
@@ -71,8 +71,8 @@ pub struct OuterEventMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about an event.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct EventMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub arguments: DecodeDifferentArray<&'static str, StringBuf>,
|
||||
@@ -80,8 +80,8 @@ pub struct EventMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about one storage entry.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct StorageEntryMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub modifier: StorageEntryModifier,
|
||||
@@ -91,8 +91,8 @@ pub struct StorageEntryMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about one module constant.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ModuleConstantMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub ty: DecodeDifferentStr,
|
||||
@@ -101,8 +101,8 @@ pub struct ModuleConstantMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about a module error.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ErrorMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
||||
@@ -166,8 +166,8 @@ impl core::fmt::Debug for DefaultByteGetter {
|
||||
}
|
||||
|
||||
/// Hasher used by storage maps
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub enum StorageHasher {
|
||||
Blake2_128,
|
||||
Blake2_256,
|
||||
@@ -179,8 +179,8 @@ pub enum StorageHasher {
|
||||
}
|
||||
|
||||
/// A storage entry type.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub enum StorageEntryType {
|
||||
Plain(DecodeDifferentStr),
|
||||
Map {
|
||||
@@ -204,16 +204,16 @@ pub enum StorageEntryType {
|
||||
///
|
||||
/// `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)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub enum StorageEntryModifier {
|
||||
Optional,
|
||||
Default,
|
||||
}
|
||||
|
||||
/// All metadata of the storage.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct StorageMetadata {
|
||||
/// The common prefix used by all storage entries.
|
||||
pub prefix: DecodeDifferent<&'static str, StringBuf>,
|
||||
@@ -221,8 +221,8 @@ pub struct StorageMetadata {
|
||||
}
|
||||
|
||||
/// Metadata of the extrinsic used by the runtime.
|
||||
#[derive(Eq, Encode, PartialEq)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Eq, Encode, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ExtrinsicMetadata {
|
||||
/// Extrinsic version.
|
||||
pub version: u8,
|
||||
@@ -231,8 +231,8 @@ pub struct ExtrinsicMetadata {
|
||||
}
|
||||
|
||||
/// The metadata of a runtime.
|
||||
#[derive(Eq, Encode, PartialEq)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Eq, Encode, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct RuntimeMetadataV11 {
|
||||
/// Metadata of all the modules.
|
||||
pub modules: DecodeDifferentArray<ModuleMetadata>,
|
||||
@@ -241,8 +241,8 @@ pub struct RuntimeMetadataV11 {
|
||||
}
|
||||
|
||||
/// All metadata about an runtime module.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ModuleMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub storage: Option<DecodeDifferent<FnEncode<StorageMetadata>, StorageMetadata>>,
|
||||
|
||||
+28
-28
@@ -43,8 +43,8 @@ cfg_if::cfg_if! {
|
||||
pub const META_RESERVED: u32 = 0x6174656d; // 'meta' warn endianness
|
||||
|
||||
/// Metadata about a function.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct FunctionMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub arguments: DecodeDifferentArray<FunctionArgumentMetadata>,
|
||||
@@ -52,16 +52,16 @@ pub struct FunctionMetadata {
|
||||
}
|
||||
|
||||
/// Metadata about a function argument.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct FunctionArgumentMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub ty: DecodeDifferentStr,
|
||||
}
|
||||
|
||||
/// Metadata about an outer event.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct OuterEventMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub events: DecodeDifferentArray<
|
||||
@@ -71,8 +71,8 @@ pub struct OuterEventMetadata {
|
||||
}
|
||||
|
||||
/// Metadata about an event.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct EventMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub arguments: DecodeDifferentArray<&'static str, StringBuf>,
|
||||
@@ -80,8 +80,8 @@ pub struct EventMetadata {
|
||||
}
|
||||
|
||||
/// Metadata about one storage entry.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct StorageEntryMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub modifier: StorageEntryModifier,
|
||||
@@ -91,8 +91,8 @@ pub struct StorageEntryMetadata {
|
||||
}
|
||||
|
||||
/// Metadata about one module constant.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ModuleConstantMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub ty: DecodeDifferentStr,
|
||||
@@ -101,8 +101,8 @@ pub struct ModuleConstantMetadata {
|
||||
}
|
||||
|
||||
/// Metadata about a module error.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ErrorMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
||||
@@ -166,8 +166,8 @@ impl core::fmt::Debug for DefaultByteGetter {
|
||||
}
|
||||
|
||||
/// Hasher used by storage maps
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub enum StorageHasher {
|
||||
Blake2_128,
|
||||
Blake2_256,
|
||||
@@ -179,8 +179,8 @@ pub enum StorageHasher {
|
||||
}
|
||||
|
||||
/// A storage entry type.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub enum StorageEntryType {
|
||||
Plain(DecodeDifferentStr),
|
||||
Map {
|
||||
@@ -204,16 +204,16 @@ pub enum StorageEntryType {
|
||||
///
|
||||
/// `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)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub enum StorageEntryModifier {
|
||||
Optional,
|
||||
Default,
|
||||
}
|
||||
|
||||
/// All metadata of the storage.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct StorageMetadata {
|
||||
/// The common prefix used by all storage entries.
|
||||
pub prefix: DecodeDifferent<&'static str, StringBuf>,
|
||||
@@ -221,8 +221,8 @@ pub struct StorageMetadata {
|
||||
}
|
||||
|
||||
/// Metadata of the extrinsic used by the runtime.
|
||||
#[derive(Eq, Encode, PartialEq)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Eq, Encode, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ExtrinsicMetadata {
|
||||
/// Extrinsic version.
|
||||
pub version: u8,
|
||||
@@ -231,8 +231,8 @@ pub struct ExtrinsicMetadata {
|
||||
}
|
||||
|
||||
/// The metadata of a runtime.
|
||||
#[derive(Eq, Encode, PartialEq)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Eq, Encode, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct RuntimeMetadataV12 {
|
||||
/// Metadata of all the modules.
|
||||
pub modules: DecodeDifferentArray<ModuleMetadata>,
|
||||
@@ -241,8 +241,8 @@ pub struct RuntimeMetadataV12 {
|
||||
}
|
||||
|
||||
/// All metadata about an runtime module.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ModuleMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub storage: Option<DecodeDifferent<FnEncode<StorageMetadata>, StorageMetadata>>,
|
||||
|
||||
+52
-41
@@ -15,12 +15,10 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "std")] {
|
||||
use codec::Decode;
|
||||
use serde::Serialize;
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "decode")]
|
||||
use codec::Decode;
|
||||
#[cfg(feature = "serde_full")]
|
||||
use serde::Serialize;
|
||||
|
||||
use super::RuntimeMetadataPrefixed;
|
||||
use codec::Encode;
|
||||
@@ -43,8 +41,9 @@ impl From<RuntimeMetadataLastVersion> for super::RuntimeMetadataPrefixed {
|
||||
}
|
||||
|
||||
/// The metadata of a runtime.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "decode", derive(Decode))]
|
||||
#[cfg_attr(feature = "serde_full", derive(Serialize))]
|
||||
pub struct RuntimeMetadataV14 {
|
||||
/// Type registry containing all types used in the metadata.
|
||||
pub types: PortableRegistry,
|
||||
@@ -77,10 +76,11 @@ impl RuntimeMetadataV14 {
|
||||
}
|
||||
|
||||
/// Metadata of the extrinsic used by the runtime.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "decode", derive(Decode))]
|
||||
#[cfg_attr(feature = "serde_full", derive(Serialize))]
|
||||
#[cfg_attr(
|
||||
feature = "std",
|
||||
feature = "serde_full",
|
||||
serde(bound(serialize = "T::Type: Serialize, T::String: Serialize"))
|
||||
)]
|
||||
pub struct ExtrinsicMetadata<T: Form = MetaForm> {
|
||||
@@ -105,10 +105,11 @@ impl IntoPortable for ExtrinsicMetadata {
|
||||
}
|
||||
|
||||
/// Metadata of an extrinsic's signed extension.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "decode", derive(Decode))]
|
||||
#[cfg_attr(feature = "serde_full", derive(Serialize))]
|
||||
#[cfg_attr(
|
||||
feature = "std",
|
||||
feature = "serde_full",
|
||||
serde(bound(serialize = "T::Type: Serialize, T::String: Serialize"))
|
||||
)]
|
||||
pub struct SignedExtensionMetadata<T: Form = MetaForm> {
|
||||
@@ -133,10 +134,11 @@ impl IntoPortable for SignedExtensionMetadata {
|
||||
}
|
||||
|
||||
/// All metadata about an runtime pallet.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "decode", derive(Decode))]
|
||||
#[cfg_attr(feature = "serde_full", derive(Serialize))]
|
||||
#[cfg_attr(
|
||||
feature = "std",
|
||||
feature = "serde_full",
|
||||
serde(bound(serialize = "T::Type: Serialize, T::String: Serialize"))
|
||||
)]
|
||||
pub struct PalletMetadata<T: Form = MetaForm> {
|
||||
@@ -174,10 +176,11 @@ impl IntoPortable for PalletMetadata {
|
||||
}
|
||||
|
||||
/// All metadata of the pallet's storage.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "decode", derive(Decode))]
|
||||
#[cfg_attr(feature = "serde_full", derive(Serialize))]
|
||||
#[cfg_attr(
|
||||
feature = "std",
|
||||
feature = "serde_full",
|
||||
serde(bound(serialize = "T::Type: Serialize, T::String: Serialize"))
|
||||
)]
|
||||
pub struct PalletStorageMetadata<T: Form = MetaForm> {
|
||||
@@ -199,10 +202,11 @@ impl IntoPortable for PalletStorageMetadata {
|
||||
}
|
||||
|
||||
/// Metadata about one storage entry.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "decode", derive(Decode))]
|
||||
#[cfg_attr(feature = "serde_full", derive(Serialize))]
|
||||
#[cfg_attr(
|
||||
feature = "std",
|
||||
feature = "serde_full",
|
||||
serde(bound(serialize = "T::Type: Serialize, T::String: Serialize"))
|
||||
)]
|
||||
pub struct StorageEntryMetadata<T: Form = MetaForm> {
|
||||
@@ -237,8 +241,9 @@ impl IntoPortable for StorageEntryMetadata {
|
||||
///
|
||||
/// `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)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "decode", derive(Decode))]
|
||||
#[cfg_attr(feature = "serde_full", derive(Serialize))]
|
||||
pub enum StorageEntryModifier {
|
||||
/// The storage entry returns an `Option<T>`, with `None` if the key is not present.
|
||||
Optional,
|
||||
@@ -247,8 +252,9 @@ pub enum StorageEntryModifier {
|
||||
}
|
||||
|
||||
/// Hasher used by storage maps
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "decode", derive(Decode))]
|
||||
#[cfg_attr(feature = "serde_full", derive(Serialize))]
|
||||
pub enum StorageHasher {
|
||||
/// 128-bit Blake2 hash.
|
||||
Blake2_128,
|
||||
@@ -267,10 +273,11 @@ pub enum StorageHasher {
|
||||
}
|
||||
|
||||
/// A type of storage value.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "decode", derive(Decode))]
|
||||
#[cfg_attr(feature = "serde_full", derive(Serialize))]
|
||||
#[cfg_attr(
|
||||
feature = "std",
|
||||
feature = "serde_full",
|
||||
serde(bound(serialize = "T::Type: Serialize, T::String: Serialize"))
|
||||
)]
|
||||
pub enum StorageEntryType<T: Form = MetaForm> {
|
||||
@@ -307,10 +314,11 @@ impl IntoPortable for StorageEntryType {
|
||||
}
|
||||
|
||||
/// Metadata for all calls in a pallet
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "decode", derive(Decode))]
|
||||
#[cfg_attr(feature = "serde_full", derive(Serialize))]
|
||||
#[cfg_attr(
|
||||
feature = "std",
|
||||
feature = "serde_full",
|
||||
serde(bound(serialize = "T::Type: Serialize, T::String: Serialize"))
|
||||
)]
|
||||
pub struct PalletCallMetadata<T: Form = MetaForm> {
|
||||
@@ -335,8 +343,9 @@ impl From<MetaType> for PalletCallMetadata {
|
||||
}
|
||||
|
||||
/// Metadata about the pallet Event type.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "decode", derive(Decode))]
|
||||
#[cfg_attr(feature = "serde_full", derive(Serialize))]
|
||||
pub struct PalletEventMetadata<T: Form = MetaForm> {
|
||||
/// The Event type.
|
||||
pub ty: T::Type,
|
||||
@@ -359,10 +368,11 @@ impl From<MetaType> for PalletEventMetadata {
|
||||
}
|
||||
|
||||
/// Metadata about one pallet constant.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "decode", derive(Decode))]
|
||||
#[cfg_attr(feature = "serde_full", derive(Serialize))]
|
||||
#[cfg_attr(
|
||||
feature = "std",
|
||||
feature = "serde_full",
|
||||
serde(bound(serialize = "T::Type: Serialize, T::String: Serialize"))
|
||||
)]
|
||||
pub struct PalletConstantMetadata<T: Form = MetaForm> {
|
||||
@@ -390,9 +400,10 @@ impl IntoPortable for PalletConstantMetadata {
|
||||
}
|
||||
|
||||
/// Metadata about a pallet error.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[cfg_attr(feature = "std", serde(bound(serialize = "T::Type: Serialize")))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "decode", derive(Decode))]
|
||||
#[cfg_attr(feature = "serde_full", derive(Serialize))]
|
||||
#[cfg_attr(feature = "serde_full", serde(bound(serialize = "T::Type: Serialize")))]
|
||||
pub struct PalletErrorMetadata<T: Form = MetaForm> {
|
||||
/// The error type information.
|
||||
pub ty: T::Type,
|
||||
|
||||
+28
-29
@@ -42,8 +42,8 @@ cfg_if::cfg_if! {
|
||||
pub const META_RESERVED: u32 = 0x6174656d; // 'meta' warn endianness
|
||||
|
||||
/// All the metadata about a function.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct FunctionMetadata {
|
||||
/// Function name.
|
||||
pub name: DecodeDifferentStr,
|
||||
@@ -54,8 +54,8 @@ pub struct FunctionMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about a function argument.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct FunctionArgumentMetadata {
|
||||
/// Name of the variable for the argument.
|
||||
pub name: DecodeDifferentStr,
|
||||
@@ -64,8 +64,8 @@ pub struct FunctionArgumentMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about an outer event.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct OuterEventMetadata {
|
||||
/// Name of the event.
|
||||
pub name: DecodeDifferentStr,
|
||||
@@ -77,8 +77,8 @@ pub struct OuterEventMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about an event.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct EventMetadata {
|
||||
/// Name of the event.
|
||||
pub name: DecodeDifferentStr,
|
||||
@@ -89,8 +89,8 @@ pub struct EventMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about one storage entry.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct StorageEntryMetadata {
|
||||
/// Variable name of the storage entry.
|
||||
pub name: DecodeDifferentStr,
|
||||
@@ -105,8 +105,8 @@ pub struct StorageEntryMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about one module constant.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ModuleConstantMetadata {
|
||||
/// Name of the module constant.
|
||||
pub name: DecodeDifferentStr,
|
||||
@@ -119,8 +119,8 @@ pub struct ModuleConstantMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about a module error.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ErrorMetadata {
|
||||
/// Name of the error.
|
||||
pub name: DecodeDifferentStr,
|
||||
@@ -181,16 +181,15 @@ impl serde::Serialize for DefaultByteGetter {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl std::fmt::Debug for DefaultByteGetter {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
impl core::fmt::Debug for DefaultByteGetter {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||
self.0.default_byte().fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
/// Hasher used by storage maps
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub enum StorageHasher {
|
||||
/// 128-bit Blake2 hash.
|
||||
Blake2_128,
|
||||
@@ -205,8 +204,8 @@ pub enum StorageHasher {
|
||||
}
|
||||
|
||||
/// A storage entry type.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub enum StorageEntryType {
|
||||
/// Plain storage entry (just the value).
|
||||
Plain(DecodeDifferentStr),
|
||||
@@ -240,8 +239,8 @@ pub enum StorageEntryType {
|
||||
///
|
||||
/// `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)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub enum StorageEntryModifier {
|
||||
/// The storage entry returns an `Option<T>`, with `None` if the key is not present.
|
||||
Optional,
|
||||
@@ -250,8 +249,8 @@ pub enum StorageEntryModifier {
|
||||
}
|
||||
|
||||
/// All metadata of the storage.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct StorageMetadata {
|
||||
/// The common prefix used by all storage entries.
|
||||
pub prefix: DecodeDifferent<&'static str, StringBuf>,
|
||||
@@ -259,8 +258,8 @@ pub struct StorageMetadata {
|
||||
}
|
||||
|
||||
/// The metadata of a runtime.
|
||||
#[derive(Eq, Encode, PartialEq)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Eq, Encode, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct RuntimeMetadataV8 {
|
||||
pub modules: DecodeDifferentArray<ModuleMetadata>,
|
||||
}
|
||||
@@ -269,8 +268,8 @@ pub struct RuntimeMetadataV8 {
|
||||
pub type RuntimeMetadataLastVersion = RuntimeMetadataV8;
|
||||
|
||||
/// All metadata about a runtime module.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ModuleMetadata {
|
||||
/// Module name.
|
||||
pub name: DecodeDifferentStr,
|
||||
|
||||
+25
-25
@@ -43,8 +43,8 @@ cfg_if::cfg_if! {
|
||||
pub const META_RESERVED: u32 = 0x6174656d; // 'meta' warn endianness
|
||||
|
||||
/// All the metadata about a function.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct FunctionMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub arguments: DecodeDifferentArray<FunctionArgumentMetadata>,
|
||||
@@ -52,15 +52,15 @@ pub struct FunctionMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about a function argument.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct FunctionArgumentMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub ty: DecodeDifferentStr,
|
||||
}
|
||||
|
||||
/// All the metadata about an outer event.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct OuterEventMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
@@ -71,8 +71,8 @@ pub struct OuterEventMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about an event.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct EventMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub arguments: DecodeDifferentArray<&'static str, StringBuf>,
|
||||
@@ -80,8 +80,8 @@ pub struct EventMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about one storage entry.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct StorageEntryMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub modifier: StorageEntryModifier,
|
||||
@@ -91,8 +91,8 @@ pub struct StorageEntryMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about one module constant.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ModuleConstantMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub ty: DecodeDifferentStr,
|
||||
@@ -101,8 +101,8 @@ pub struct ModuleConstantMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about a module error.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ErrorMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
||||
@@ -166,8 +166,8 @@ impl core::fmt::Debug for DefaultByteGetter {
|
||||
}
|
||||
|
||||
/// Hasher used by storage maps
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub enum StorageHasher {
|
||||
Blake2_128,
|
||||
Blake2_256,
|
||||
@@ -178,8 +178,8 @@ pub enum StorageHasher {
|
||||
}
|
||||
|
||||
/// A storage entry type.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub enum StorageEntryType {
|
||||
Plain(DecodeDifferentStr),
|
||||
Map {
|
||||
@@ -202,16 +202,16 @@ pub enum StorageEntryType {
|
||||
///
|
||||
/// `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)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub enum StorageEntryModifier {
|
||||
Optional,
|
||||
Default,
|
||||
}
|
||||
|
||||
/// All metadata of the storage.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct StorageMetadata {
|
||||
/// The common prefix used by all storage entries.
|
||||
pub prefix: DecodeDifferent<&'static str, StringBuf>,
|
||||
@@ -219,15 +219,15 @@ pub struct StorageMetadata {
|
||||
}
|
||||
|
||||
/// The metadata of a runtime.
|
||||
#[derive(Eq, Encode, PartialEq)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Eq, Encode, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct RuntimeMetadataV9 {
|
||||
pub modules: DecodeDifferentArray<ModuleMetadata>,
|
||||
}
|
||||
|
||||
/// All metadata about an runtime module.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ModuleMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub storage: Option<DecodeDifferent<FnEncode<StorageMetadata>, StorageMetadata>>,
|
||||
|
||||
Reference in New Issue
Block a user