mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-16 22:31:03 +00:00
Metadata V15: Expose API to fetch metadata for version (#13287)
* impl_runtime_apis: Generate getters for `metadata_at` functions Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * runtime: Implement new `Metadata` runtime trait Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * runtime: Move `metadata_at` functions to construct_runtime macro Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * contruct_runtime: Use `OpaqueMetadata` from hidden imports Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Adjust testing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/tests: Add tests for the new API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/tests: Adjust metdata naming Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support: Expose `metadata-v14` feature flag Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support: Expose metadata only under feature flags Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support: Expose v14 metadata by default Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support: Expose metadata feature for testing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support: Test metadata under different feature flags Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update primitives/api/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * client/tests: Adjust testing to reflect trait Metadata change Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/metadata-ir: Add intermediate representation types for metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/metadata-ir: Convert metadata to V14 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/metadata-ir: Add API to convert metadata to multiple versions Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/metadata-ir: Expose V14 under feature flag Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support: Adjust to metadata IR Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support: More adjustments Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support: Guard v14 details under feature flag Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support: Adjust testing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * CI: Ensure `quick-benchmarks` uses `metadata-v14` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support: Use `metadata-v14` for benchmarks Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Adjust cargo fmt Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * kitchensink-runtime: Add feature flag for `metadata-v14` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support/test: Adjust testing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support/test: Check crates locally Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Activate metadata-v14 for pallets Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Remove metadata-v14 feature flag Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/metadata_ir: Move `api.rs` to `mod.rs` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support: Handle latest metadata conversion via IR Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/tests: Add constant for metadata version 14 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support/test: Fix merge conflict Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update frame/support/Cargo.toml Co-authored-by: Bastian Köcher <git@kchr.de> * Update frame/support/src/metadata_ir/mod.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update frame/support/test/Cargo.toml Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * frame/metadata: Collect pallet documentation for MetadataIR Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/tests: Check pallet documentation is propagated to MetadataIR Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support: Improve documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: parity-processbot <> Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -2977,7 +2977,7 @@ macro_rules! __dispatch_impl_metadata {
|
||||
{
|
||||
#[doc(hidden)]
|
||||
#[allow(dead_code)]
|
||||
pub fn call_functions() -> $crate::metadata::PalletCallMetadata {
|
||||
pub fn call_functions() -> $crate::metadata_ir::PalletCallMetadataIR {
|
||||
$crate::scale_info::meta_type::<$call_type<$trait_instance $(, $instance)?>>().into()
|
||||
}
|
||||
}
|
||||
@@ -2998,7 +2998,7 @@ macro_rules! __impl_error_metadata {
|
||||
{
|
||||
#[doc(hidden)]
|
||||
#[allow(dead_code)]
|
||||
pub fn error_metadata() -> Option<$crate::metadata::PalletErrorMetadata> {
|
||||
pub fn error_metadata() -> Option<$crate::metadata_ir::PalletErrorMetadataIR> {
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -3013,8 +3013,8 @@ macro_rules! __impl_error_metadata {
|
||||
{
|
||||
#[doc(hidden)]
|
||||
#[allow(dead_code)]
|
||||
pub fn error_metadata() -> Option<$crate::metadata::PalletErrorMetadata> {
|
||||
Some($crate::metadata::PalletErrorMetadata {
|
||||
pub fn error_metadata() -> Option<$crate::metadata_ir::PalletErrorMetadataIR> {
|
||||
Some($crate::metadata_ir::PalletErrorMetadataIR {
|
||||
ty: $crate::scale_info::meta_type::<$( $error_type )*>()
|
||||
})
|
||||
}
|
||||
@@ -3109,7 +3109,7 @@ macro_rules! __impl_module_constants_metadata {
|
||||
{
|
||||
#[doc(hidden)]
|
||||
#[allow(dead_code)]
|
||||
pub fn pallet_constants_metadata() -> $crate::sp_std::vec::Vec<$crate::metadata::PalletConstantMetadata> {
|
||||
pub fn pallet_constants_metadata() -> $crate::sp_std::vec::Vec<$crate::metadata_ir::PalletConstantMetadataIR> {
|
||||
// Create the `ByteGetter`s
|
||||
$(
|
||||
#[allow(non_upper_case_types)]
|
||||
@@ -3133,7 +3133,7 @@ macro_rules! __impl_module_constants_metadata {
|
||||
)*
|
||||
$crate::sp_std::vec![
|
||||
$(
|
||||
$crate::metadata::PalletConstantMetadata {
|
||||
$crate::metadata_ir::PalletConstantMetadataIR {
|
||||
name: stringify!($name),
|
||||
ty: $crate::scale_info::meta_type::<$type>(),
|
||||
value: $default_byte_name::<$const_trait_instance $(, $const_instance)?>(
|
||||
@@ -3207,7 +3207,7 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
dispatch::{DispatchClass, DispatchInfo, Pays},
|
||||
metadata::*,
|
||||
metadata_ir::*,
|
||||
traits::{
|
||||
CallerTrait, CrateVersion, Get, GetCallName, IntegrityTest, OnFinalize, OnIdle,
|
||||
OnInitialize, OnRuntimeUpgrade, PalletInfo,
|
||||
@@ -3405,7 +3405,7 @@ mod tests {
|
||||
fn module_json_metadata() {
|
||||
let metadata = Module::<TraitImpl>::call_functions();
|
||||
let expected_metadata =
|
||||
PalletCallMetadata { ty: scale_info::meta_type::<Call<TraitImpl>>() };
|
||||
PalletCallMetadataIR { ty: scale_info::meta_type::<Call<TraitImpl>>() };
|
||||
assert_eq!(expected_metadata, metadata);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
//! Hash utilities.
|
||||
|
||||
use crate::metadata;
|
||||
use crate::metadata_ir;
|
||||
use codec::{Codec, MaxEncodedLen};
|
||||
use sp_io::hashing::{blake2_128, blake2_256, twox_128, twox_256, twox_64};
|
||||
use sp_std::prelude::Vec;
|
||||
@@ -59,7 +59,7 @@ impl<T: Codec> Hashable for T {
|
||||
|
||||
/// Hasher to use to hash keys to insert to storage.
|
||||
pub trait StorageHasher: 'static {
|
||||
const METADATA: metadata::StorageHasher;
|
||||
const METADATA: metadata_ir::StorageHasherIR;
|
||||
type Output: AsRef<[u8]>;
|
||||
fn hash(x: &[u8]) -> Self::Output;
|
||||
|
||||
@@ -80,7 +80,7 @@ pub trait ReversibleStorageHasher: StorageHasher {
|
||||
/// Store the key directly.
|
||||
pub struct Identity;
|
||||
impl StorageHasher for Identity {
|
||||
const METADATA: metadata::StorageHasher = metadata::StorageHasher::Identity;
|
||||
const METADATA: metadata_ir::StorageHasherIR = metadata_ir::StorageHasherIR::Identity;
|
||||
type Output = Vec<u8>;
|
||||
fn hash(x: &[u8]) -> Vec<u8> {
|
||||
x.to_vec()
|
||||
@@ -98,7 +98,7 @@ impl ReversibleStorageHasher for Identity {
|
||||
/// Hash storage keys with `concat(twox64(key), key)`
|
||||
pub struct Twox64Concat;
|
||||
impl StorageHasher for Twox64Concat {
|
||||
const METADATA: metadata::StorageHasher = metadata::StorageHasher::Twox64Concat;
|
||||
const METADATA: metadata_ir::StorageHasherIR = metadata_ir::StorageHasherIR::Twox64Concat;
|
||||
type Output = Vec<u8>;
|
||||
fn hash(x: &[u8]) -> Vec<u8> {
|
||||
twox_64(x).iter().chain(x.iter()).cloned().collect::<Vec<_>>()
|
||||
@@ -120,7 +120,7 @@ impl ReversibleStorageHasher for Twox64Concat {
|
||||
/// Hash storage keys with `concat(blake2_128(key), key)`
|
||||
pub struct Blake2_128Concat;
|
||||
impl StorageHasher for Blake2_128Concat {
|
||||
const METADATA: metadata::StorageHasher = metadata::StorageHasher::Blake2_128Concat;
|
||||
const METADATA: metadata_ir::StorageHasherIR = metadata_ir::StorageHasherIR::Blake2_128Concat;
|
||||
type Output = Vec<u8>;
|
||||
fn hash(x: &[u8]) -> Vec<u8> {
|
||||
blake2_128(x).iter().chain(x.iter()).cloned().collect::<Vec<_>>()
|
||||
@@ -142,7 +142,7 @@ impl ReversibleStorageHasher for Blake2_128Concat {
|
||||
/// Hash storage keys with blake2 128
|
||||
pub struct Blake2_128;
|
||||
impl StorageHasher for Blake2_128 {
|
||||
const METADATA: metadata::StorageHasher = metadata::StorageHasher::Blake2_128;
|
||||
const METADATA: metadata_ir::StorageHasherIR = metadata_ir::StorageHasherIR::Blake2_128;
|
||||
type Output = [u8; 16];
|
||||
fn hash(x: &[u8]) -> [u8; 16] {
|
||||
blake2_128(x)
|
||||
@@ -155,7 +155,7 @@ impl StorageHasher for Blake2_128 {
|
||||
/// Hash storage keys with blake2 256
|
||||
pub struct Blake2_256;
|
||||
impl StorageHasher for Blake2_256 {
|
||||
const METADATA: metadata::StorageHasher = metadata::StorageHasher::Blake2_256;
|
||||
const METADATA: metadata_ir::StorageHasherIR = metadata_ir::StorageHasherIR::Blake2_256;
|
||||
type Output = [u8; 32];
|
||||
fn hash(x: &[u8]) -> [u8; 32] {
|
||||
blake2_256(x)
|
||||
@@ -168,7 +168,7 @@ impl StorageHasher for Blake2_256 {
|
||||
/// Hash storage keys with twox 128
|
||||
pub struct Twox128;
|
||||
impl StorageHasher for Twox128 {
|
||||
const METADATA: metadata::StorageHasher = metadata::StorageHasher::Twox128;
|
||||
const METADATA: metadata_ir::StorageHasherIR = metadata_ir::StorageHasherIR::Twox128;
|
||||
type Output = [u8; 16];
|
||||
fn hash(x: &[u8]) -> [u8; 16] {
|
||||
twox_128(x)
|
||||
@@ -181,7 +181,7 @@ impl StorageHasher for Twox128 {
|
||||
/// Hash storage keys with twox 256
|
||||
pub struct Twox256;
|
||||
impl StorageHasher for Twox256 {
|
||||
const METADATA: metadata::StorageHasher = metadata::StorageHasher::Twox256;
|
||||
const METADATA: metadata_ir::StorageHasherIR = metadata_ir::StorageHasherIR::Twox256;
|
||||
type Output = [u8; 32];
|
||||
fn hash(x: &[u8]) -> [u8; 32] {
|
||||
twox_256(x)
|
||||
|
||||
@@ -50,7 +50,7 @@ pub use paste;
|
||||
pub use scale_info;
|
||||
#[cfg(feature = "std")]
|
||||
pub use serde;
|
||||
pub use sp_core::Void;
|
||||
pub use sp_core::{OpaqueMetadata, Void};
|
||||
#[doc(hidden)]
|
||||
pub use sp_core_hashing_proc_macro;
|
||||
#[doc(hidden)]
|
||||
@@ -80,10 +80,10 @@ pub mod error;
|
||||
pub mod crypto;
|
||||
pub mod dispatch_context;
|
||||
pub mod instances;
|
||||
pub mod metadata_ir;
|
||||
pub mod migrations;
|
||||
pub mod traits;
|
||||
pub mod weights;
|
||||
|
||||
#[doc(hidden)]
|
||||
pub mod unsigned {
|
||||
#[doc(hidden)]
|
||||
@@ -827,9 +827,9 @@ pub use serde::{Deserialize, Serialize};
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use crate::metadata::{
|
||||
PalletStorageMetadata, StorageEntryMetadata, StorageEntryModifier, StorageEntryType,
|
||||
StorageHasher,
|
||||
use crate::metadata_ir::{
|
||||
PalletStorageMetadataIR, StorageEntryMetadataIR, StorageEntryModifierIR,
|
||||
StorageEntryTypeIR, StorageHasherIR,
|
||||
};
|
||||
use codec::{Codec, EncodeLike};
|
||||
use frame_support::traits::CrateVersion;
|
||||
@@ -1310,101 +1310,107 @@ pub mod tests {
|
||||
});
|
||||
}
|
||||
|
||||
fn expected_metadata() -> PalletStorageMetadata {
|
||||
PalletStorageMetadata {
|
||||
fn expected_metadata() -> PalletStorageMetadataIR {
|
||||
PalletStorageMetadataIR {
|
||||
prefix: "Test",
|
||||
entries: vec![
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "Value",
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(scale_info::meta_type::<u64>()),
|
||||
modifier: StorageEntryModifierIR::Default,
|
||||
ty: StorageEntryTypeIR::Plain(scale_info::meta_type::<u64>()),
|
||||
default: vec![0, 0, 0, 0, 0, 0, 0, 0],
|
||||
docs: vec![],
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "Data",
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
hashers: vec![StorageHasher::Twox64Concat],
|
||||
modifier: StorageEntryModifierIR::Default,
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![StorageHasherIR::Twox64Concat],
|
||||
key: scale_info::meta_type::<u32>(),
|
||||
value: scale_info::meta_type::<u64>(),
|
||||
},
|
||||
default: vec![0, 0, 0, 0, 0, 0, 0, 0],
|
||||
docs: vec![],
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "OptionLinkedMap",
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Map {
|
||||
hashers: vec![StorageHasher::Blake2_128Concat],
|
||||
modifier: StorageEntryModifierIR::Optional,
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![StorageHasherIR::Blake2_128Concat],
|
||||
key: scale_info::meta_type::<u32>(),
|
||||
value: scale_info::meta_type::<u32>(),
|
||||
},
|
||||
default: vec![0],
|
||||
docs: vec![],
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "GenericData",
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
hashers: vec![StorageHasher::Identity],
|
||||
modifier: StorageEntryModifierIR::Default,
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![StorageHasherIR::Identity],
|
||||
key: scale_info::meta_type::<u32>(),
|
||||
value: scale_info::meta_type::<u32>(),
|
||||
},
|
||||
default: vec![0, 0, 0, 0],
|
||||
docs: vec![],
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "GenericData2",
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Map {
|
||||
hashers: vec![StorageHasher::Blake2_128Concat],
|
||||
modifier: StorageEntryModifierIR::Optional,
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![StorageHasherIR::Blake2_128Concat],
|
||||
key: scale_info::meta_type::<u32>(),
|
||||
value: scale_info::meta_type::<u32>(),
|
||||
},
|
||||
default: vec![0],
|
||||
docs: vec![],
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "DataDM",
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
hashers: vec![StorageHasher::Twox64Concat, StorageHasher::Blake2_128Concat],
|
||||
modifier: StorageEntryModifierIR::Default,
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![
|
||||
StorageHasherIR::Twox64Concat,
|
||||
StorageHasherIR::Blake2_128Concat,
|
||||
],
|
||||
key: scale_info::meta_type::<(u32, u32)>(),
|
||||
value: scale_info::meta_type::<u64>(),
|
||||
},
|
||||
default: vec![0, 0, 0, 0, 0, 0, 0, 0],
|
||||
docs: vec![],
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "GenericDataDM",
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
hashers: vec![StorageHasher::Blake2_128Concat, StorageHasher::Identity],
|
||||
modifier: StorageEntryModifierIR::Default,
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![StorageHasherIR::Blake2_128Concat, StorageHasherIR::Identity],
|
||||
key: scale_info::meta_type::<(u32, u32)>(),
|
||||
value: scale_info::meta_type::<u32>(),
|
||||
},
|
||||
default: vec![0, 0, 0, 0],
|
||||
docs: vec![],
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "GenericData2DM",
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Map {
|
||||
hashers: vec![StorageHasher::Blake2_128Concat, StorageHasher::Twox64Concat],
|
||||
modifier: StorageEntryModifierIR::Optional,
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![
|
||||
StorageHasherIR::Blake2_128Concat,
|
||||
StorageHasherIR::Twox64Concat,
|
||||
],
|
||||
key: scale_info::meta_type::<(u32, u32)>(),
|
||||
value: scale_info::meta_type::<u32>(),
|
||||
},
|
||||
default: vec![0],
|
||||
docs: vec![],
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "AppendableDM",
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
modifier: StorageEntryModifierIR::Default,
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![
|
||||
StorageHasher::Blake2_128Concat,
|
||||
StorageHasher::Blake2_128Concat,
|
||||
StorageHasherIR::Blake2_128Concat,
|
||||
StorageHasherIR::Blake2_128Concat,
|
||||
],
|
||||
key: scale_info::meta_type::<(u32, u32)>(),
|
||||
value: scale_info::meta_type::<Vec<u32>>(),
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Intermediate representation of the runtime metadata.
|
||||
|
||||
mod types;
|
||||
use frame_metadata::{RuntimeMetadataPrefixed, RuntimeMetadataV14};
|
||||
pub use types::*;
|
||||
|
||||
mod v14;
|
||||
|
||||
/// Metadata V14.
|
||||
const V14: u32 = 14;
|
||||
|
||||
/// Transform the IR to the specified version.
|
||||
///
|
||||
/// Use [`supported_versions`] to find supported versions.
|
||||
pub fn into_version(metadata: MetadataIR, version: u32) -> Option<RuntimeMetadataPrefixed> {
|
||||
match version {
|
||||
// Latest stable version.
|
||||
V14 => {
|
||||
let v14: frame_metadata::v14::RuntimeMetadataV14 = metadata.into();
|
||||
Some(v14.into())
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the supported metadata versions.
|
||||
pub fn supported_versions() -> sp_std::vec::Vec<u32> {
|
||||
sp_std::vec![V14,]
|
||||
}
|
||||
|
||||
/// Transform the IR to the latest stable metadata version.
|
||||
pub fn into_latest(metadata: MetadataIR) -> RuntimeMetadataPrefixed {
|
||||
let latest: RuntimeMetadataV14 = metadata.into();
|
||||
latest.into()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::metadata_ir::ExtrinsicMetadataIR;
|
||||
use frame_metadata::{v14::META_RESERVED, RuntimeMetadata};
|
||||
use scale_info::meta_type;
|
||||
|
||||
fn ir_metadata() -> MetadataIR {
|
||||
MetadataIR {
|
||||
pallets: vec![],
|
||||
extrinsic: ExtrinsicMetadataIR {
|
||||
ty: meta_type::<()>(),
|
||||
version: 0,
|
||||
signed_extensions: vec![],
|
||||
},
|
||||
ty: meta_type::<()>(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn into_version_14() {
|
||||
let ir = ir_metadata();
|
||||
let metadata = into_version(ir, V14).expect("Should return prefixed metadata");
|
||||
|
||||
assert_eq!(metadata.0, META_RESERVED);
|
||||
|
||||
assert!(matches!(metadata.1, RuntimeMetadata::V14(_)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use codec::Encode;
|
||||
use scale_info::{
|
||||
form::{Form, MetaForm, PortableForm},
|
||||
prelude::vec::Vec,
|
||||
IntoPortable, MetaType, Registry,
|
||||
};
|
||||
|
||||
/// The intermediate representation for the runtime metadata.
|
||||
/// Contains the needed context that allows conversion to multiple metadata versions.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// Further fields could be added or removed to ensure proper conversion.
|
||||
/// When the IR does not contain enough information to generate a specific version
|
||||
/// of the runtime metadata an appropriate default value is used (ie, empty vector).
|
||||
pub struct MetadataIR<T: Form = MetaForm> {
|
||||
/// Pallet metadata.
|
||||
pub pallets: Vec<PalletMetadataIR<T>>,
|
||||
/// Metadata of the extrinsic.
|
||||
pub extrinsic: ExtrinsicMetadataIR<T>,
|
||||
/// The type of the `Runtime`.
|
||||
pub ty: T::Type,
|
||||
}
|
||||
|
||||
/// The intermediate representation for a pallet metadata.
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
pub struct PalletMetadataIR<T: Form = MetaForm> {
|
||||
/// Pallet name.
|
||||
pub name: T::String,
|
||||
/// Pallet storage metadata.
|
||||
pub storage: Option<PalletStorageMetadataIR<T>>,
|
||||
/// Pallet calls metadata.
|
||||
pub calls: Option<PalletCallMetadataIR<T>>,
|
||||
/// Pallet event metadata.
|
||||
pub event: Option<PalletEventMetadataIR<T>>,
|
||||
/// Pallet constants metadata.
|
||||
pub constants: Vec<PalletConstantMetadataIR<T>>,
|
||||
/// Pallet error metadata.
|
||||
pub error: Option<PalletErrorMetadataIR<T>>,
|
||||
/// Define the index of the pallet, this index will be used for the encoding of pallet event,
|
||||
/// call and origin variants.
|
||||
pub index: u8,
|
||||
/// Pallet documentation.
|
||||
pub docs: Vec<T::String>,
|
||||
}
|
||||
|
||||
impl IntoPortable for PalletMetadataIR {
|
||||
type Output = PalletMetadataIR<PortableForm>;
|
||||
|
||||
fn into_portable(self, registry: &mut Registry) -> Self::Output {
|
||||
PalletMetadataIR {
|
||||
name: self.name.into_portable(registry),
|
||||
storage: self.storage.map(|storage| storage.into_portable(registry)),
|
||||
calls: self.calls.map(|calls| calls.into_portable(registry)),
|
||||
event: self.event.map(|event| event.into_portable(registry)),
|
||||
constants: registry.map_into_portable(self.constants),
|
||||
error: self.error.map(|error| error.into_portable(registry)),
|
||||
index: self.index,
|
||||
docs: registry.map_into_portable(self.docs),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Metadata of the extrinsic used by the runtime.
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
pub struct ExtrinsicMetadataIR<T: Form = MetaForm> {
|
||||
/// The type of the extrinsic.
|
||||
pub ty: T::Type,
|
||||
/// Extrinsic version.
|
||||
pub version: u8,
|
||||
/// The signed extensions in the order they appear in the extrinsic.
|
||||
pub signed_extensions: Vec<SignedExtensionMetadataIR<T>>,
|
||||
}
|
||||
|
||||
impl IntoPortable for ExtrinsicMetadataIR {
|
||||
type Output = ExtrinsicMetadataIR<PortableForm>;
|
||||
|
||||
fn into_portable(self, registry: &mut Registry) -> Self::Output {
|
||||
ExtrinsicMetadataIR {
|
||||
ty: registry.register_type(&self.ty),
|
||||
version: self.version,
|
||||
signed_extensions: registry.map_into_portable(self.signed_extensions),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Metadata of an extrinsic's signed extension.
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
pub struct SignedExtensionMetadataIR<T: Form = MetaForm> {
|
||||
/// The unique signed extension identifier, which may be different from the type name.
|
||||
pub identifier: T::String,
|
||||
/// The type of the signed extension, with the data to be included in the extrinsic.
|
||||
pub ty: T::Type,
|
||||
/// The type of the additional signed data, with the data to be included in the signed payload
|
||||
pub additional_signed: T::Type,
|
||||
}
|
||||
|
||||
impl IntoPortable for SignedExtensionMetadataIR {
|
||||
type Output = SignedExtensionMetadataIR<PortableForm>;
|
||||
|
||||
fn into_portable(self, registry: &mut Registry) -> Self::Output {
|
||||
SignedExtensionMetadataIR {
|
||||
identifier: self.identifier.into_portable(registry),
|
||||
ty: registry.register_type(&self.ty),
|
||||
additional_signed: registry.register_type(&self.additional_signed),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// All metadata of the pallet's storage.
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
/// The common prefix used by all storage entries.
|
||||
pub struct PalletStorageMetadataIR<T: Form = MetaForm> {
|
||||
/// The common prefix used by all storage entries.
|
||||
pub prefix: T::String,
|
||||
/// Metadata for all storage entries.
|
||||
pub entries: Vec<StorageEntryMetadataIR<T>>,
|
||||
}
|
||||
|
||||
impl IntoPortable for PalletStorageMetadataIR {
|
||||
type Output = PalletStorageMetadataIR<PortableForm>;
|
||||
|
||||
fn into_portable(self, registry: &mut Registry) -> Self::Output {
|
||||
PalletStorageMetadataIR {
|
||||
prefix: self.prefix.into_portable(registry),
|
||||
entries: registry.map_into_portable(self.entries),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Metadata about one storage entry.
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
pub struct StorageEntryMetadataIR<T: Form = MetaForm> {
|
||||
/// Variable name of the storage entry.
|
||||
pub name: T::String,
|
||||
/// An `Option` modifier of that storage entry.
|
||||
pub modifier: StorageEntryModifierIR,
|
||||
/// Type of the value stored in the entry.
|
||||
pub ty: StorageEntryTypeIR<T>,
|
||||
/// Default value (SCALE encoded).
|
||||
pub default: Vec<u8>,
|
||||
/// Storage entry documentation.
|
||||
pub docs: Vec<T::String>,
|
||||
}
|
||||
|
||||
impl IntoPortable for StorageEntryMetadataIR {
|
||||
type Output = StorageEntryMetadataIR<PortableForm>;
|
||||
|
||||
fn into_portable(self, registry: &mut Registry) -> Self::Output {
|
||||
StorageEntryMetadataIR {
|
||||
name: self.name.into_portable(registry),
|
||||
modifier: self.modifier,
|
||||
ty: self.ty.into_portable(registry),
|
||||
default: self.default,
|
||||
docs: registry.map_into_portable(self.docs),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 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)]
|
||||
pub enum StorageEntryModifierIR {
|
||||
/// The storage entry returns an `Option<T>`, with `None` if the key is not present.
|
||||
Optional,
|
||||
/// The storage entry returns `T::Default` if the key is not present.
|
||||
Default,
|
||||
}
|
||||
|
||||
/// Hasher used by storage maps
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
pub enum StorageHasherIR {
|
||||
/// 128-bit Blake2 hash.
|
||||
Blake2_128,
|
||||
/// 256-bit Blake2 hash.
|
||||
Blake2_256,
|
||||
/// Multiple 128-bit Blake2 hashes concatenated.
|
||||
Blake2_128Concat,
|
||||
/// 128-bit XX hash.
|
||||
Twox128,
|
||||
/// 256-bit XX hash.
|
||||
Twox256,
|
||||
/// Multiple 64-bit XX hashes concatenated.
|
||||
Twox64Concat,
|
||||
/// Identity hashing (no hashing).
|
||||
Identity,
|
||||
}
|
||||
|
||||
/// A type of storage value.
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
pub enum StorageEntryTypeIR<T: Form = MetaForm> {
|
||||
/// Plain storage entry (just the value).
|
||||
Plain(T::Type),
|
||||
/// A storage map.
|
||||
Map {
|
||||
/// One or more hashers, should be one hasher per key element.
|
||||
hashers: Vec<StorageHasherIR>,
|
||||
/// The type of the key, can be a tuple with elements for each of the hashers.
|
||||
key: T::Type,
|
||||
/// The type of the value.
|
||||
value: T::Type,
|
||||
},
|
||||
}
|
||||
|
||||
impl IntoPortable for StorageEntryTypeIR {
|
||||
type Output = StorageEntryTypeIR<PortableForm>;
|
||||
|
||||
fn into_portable(self, registry: &mut Registry) -> Self::Output {
|
||||
match self {
|
||||
Self::Plain(plain) => StorageEntryTypeIR::Plain(registry.register_type(&plain)),
|
||||
Self::Map { hashers, key, value } => StorageEntryTypeIR::Map {
|
||||
hashers,
|
||||
key: registry.register_type(&key),
|
||||
value: registry.register_type(&value),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Metadata for all calls in a pallet
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
pub struct PalletCallMetadataIR<T: Form = MetaForm> {
|
||||
/// The corresponding enum type for the pallet call.
|
||||
pub ty: T::Type,
|
||||
}
|
||||
|
||||
impl IntoPortable for PalletCallMetadataIR {
|
||||
type Output = PalletCallMetadataIR<PortableForm>;
|
||||
|
||||
fn into_portable(self, registry: &mut Registry) -> Self::Output {
|
||||
PalletCallMetadataIR { ty: registry.register_type(&self.ty) }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<MetaType> for PalletCallMetadataIR {
|
||||
fn from(ty: MetaType) -> Self {
|
||||
Self { ty }
|
||||
}
|
||||
}
|
||||
|
||||
/// Metadata about the pallet Event type.
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
pub struct PalletEventMetadataIR<T: Form = MetaForm> {
|
||||
/// The Event type.
|
||||
pub ty: T::Type,
|
||||
}
|
||||
|
||||
impl IntoPortable for PalletEventMetadataIR {
|
||||
type Output = PalletEventMetadataIR<PortableForm>;
|
||||
|
||||
fn into_portable(self, registry: &mut Registry) -> Self::Output {
|
||||
PalletEventMetadataIR { ty: registry.register_type(&self.ty) }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<MetaType> for PalletEventMetadataIR {
|
||||
fn from(ty: MetaType) -> Self {
|
||||
Self { ty }
|
||||
}
|
||||
}
|
||||
|
||||
/// Metadata about one pallet constant.
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
pub struct PalletConstantMetadataIR<T: Form = MetaForm> {
|
||||
/// Name of the pallet constant.
|
||||
pub name: T::String,
|
||||
/// Type of the pallet constant.
|
||||
pub ty: T::Type,
|
||||
/// Value stored in the constant (SCALE encoded).
|
||||
pub value: Vec<u8>,
|
||||
/// Documentation of the constant.
|
||||
pub docs: Vec<T::String>,
|
||||
}
|
||||
|
||||
impl IntoPortable for PalletConstantMetadataIR {
|
||||
type Output = PalletConstantMetadataIR<PortableForm>;
|
||||
|
||||
fn into_portable(self, registry: &mut Registry) -> Self::Output {
|
||||
PalletConstantMetadataIR {
|
||||
name: self.name.into_portable(registry),
|
||||
ty: registry.register_type(&self.ty),
|
||||
value: self.value,
|
||||
docs: registry.map_into_portable(self.docs),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Metadata about a pallet error.
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Debug)]
|
||||
pub struct PalletErrorMetadataIR<T: Form = MetaForm> {
|
||||
/// The error type information.
|
||||
pub ty: T::Type,
|
||||
}
|
||||
|
||||
impl IntoPortable for PalletErrorMetadataIR {
|
||||
type Output = PalletErrorMetadataIR<PortableForm>;
|
||||
|
||||
fn into_portable(self, registry: &mut Registry) -> Self::Output {
|
||||
PalletErrorMetadataIR { ty: registry.register_type(&self.ty) }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<MetaType> for PalletErrorMetadataIR {
|
||||
fn from(ty: MetaType) -> Self {
|
||||
Self { ty }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Convert the IR to V14 metadata.
|
||||
|
||||
use super::types::{
|
||||
ExtrinsicMetadataIR, MetadataIR, PalletCallMetadataIR, PalletConstantMetadataIR,
|
||||
PalletErrorMetadataIR, PalletEventMetadataIR, PalletMetadataIR, PalletStorageMetadataIR,
|
||||
SignedExtensionMetadataIR, StorageEntryMetadataIR, StorageEntryModifierIR, StorageEntryTypeIR,
|
||||
StorageHasherIR,
|
||||
};
|
||||
|
||||
use frame_metadata::v14::{
|
||||
ExtrinsicMetadata, PalletCallMetadata, PalletConstantMetadata, PalletErrorMetadata,
|
||||
PalletEventMetadata, PalletMetadata, PalletStorageMetadata, RuntimeMetadataV14,
|
||||
SignedExtensionMetadata, StorageEntryMetadata, StorageEntryModifier, StorageEntryType,
|
||||
StorageHasher,
|
||||
};
|
||||
|
||||
impl From<MetadataIR> for RuntimeMetadataV14 {
|
||||
fn from(ir: MetadataIR) -> Self {
|
||||
RuntimeMetadataV14::new(
|
||||
ir.pallets.into_iter().map(Into::into).collect(),
|
||||
ir.extrinsic.into(),
|
||||
ir.ty,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PalletMetadataIR> for PalletMetadata {
|
||||
fn from(ir: PalletMetadataIR) -> Self {
|
||||
PalletMetadata {
|
||||
name: ir.name,
|
||||
storage: ir.storage.map(Into::into),
|
||||
calls: ir.calls.map(Into::into),
|
||||
event: ir.event.map(Into::into),
|
||||
constants: ir.constants.into_iter().map(Into::into).collect(),
|
||||
error: ir.error.map(Into::into),
|
||||
index: ir.index,
|
||||
// Note: ir.docs not part of v14.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StorageEntryModifierIR> for StorageEntryModifier {
|
||||
fn from(ir: StorageEntryModifierIR) -> Self {
|
||||
match ir {
|
||||
StorageEntryModifierIR::Optional => StorageEntryModifier::Optional,
|
||||
StorageEntryModifierIR::Default => StorageEntryModifier::Default,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StorageHasherIR> for StorageHasher {
|
||||
fn from(ir: StorageHasherIR) -> Self {
|
||||
match ir {
|
||||
StorageHasherIR::Blake2_128 => StorageHasher::Blake2_128,
|
||||
StorageHasherIR::Blake2_256 => StorageHasher::Blake2_256,
|
||||
StorageHasherIR::Blake2_128Concat => StorageHasher::Blake2_128Concat,
|
||||
StorageHasherIR::Twox128 => StorageHasher::Twox128,
|
||||
StorageHasherIR::Twox256 => StorageHasher::Twox256,
|
||||
StorageHasherIR::Twox64Concat => StorageHasher::Twox64Concat,
|
||||
StorageHasherIR::Identity => StorageHasher::Identity,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StorageEntryTypeIR> for StorageEntryType {
|
||||
fn from(ir: StorageEntryTypeIR) -> Self {
|
||||
match ir {
|
||||
StorageEntryTypeIR::Plain(ty) => StorageEntryType::Plain(ty),
|
||||
StorageEntryTypeIR::Map { hashers, key, value } => StorageEntryType::Map {
|
||||
hashers: hashers.into_iter().map(Into::into).collect(),
|
||||
key,
|
||||
value,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StorageEntryMetadataIR> for StorageEntryMetadata {
|
||||
fn from(ir: StorageEntryMetadataIR) -> Self {
|
||||
StorageEntryMetadata {
|
||||
name: ir.name,
|
||||
modifier: ir.modifier.into(),
|
||||
ty: ir.ty.into(),
|
||||
default: ir.default,
|
||||
docs: ir.docs,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PalletStorageMetadataIR> for PalletStorageMetadata {
|
||||
fn from(ir: PalletStorageMetadataIR) -> Self {
|
||||
PalletStorageMetadata {
|
||||
prefix: ir.prefix,
|
||||
entries: ir.entries.into_iter().map(Into::into).collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PalletCallMetadataIR> for PalletCallMetadata {
|
||||
fn from(ir: PalletCallMetadataIR) -> Self {
|
||||
PalletCallMetadata { ty: ir.ty }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PalletEventMetadataIR> for PalletEventMetadata {
|
||||
fn from(ir: PalletEventMetadataIR) -> Self {
|
||||
PalletEventMetadata { ty: ir.ty }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PalletConstantMetadataIR> for PalletConstantMetadata {
|
||||
fn from(ir: PalletConstantMetadataIR) -> Self {
|
||||
PalletConstantMetadata { name: ir.name, ty: ir.ty, value: ir.value, docs: ir.docs }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PalletErrorMetadataIR> for PalletErrorMetadata {
|
||||
fn from(ir: PalletErrorMetadataIR) -> Self {
|
||||
PalletErrorMetadata { ty: ir.ty }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SignedExtensionMetadataIR> for SignedExtensionMetadata {
|
||||
fn from(ir: SignedExtensionMetadataIR) -> Self {
|
||||
SignedExtensionMetadata {
|
||||
identifier: ir.identifier,
|
||||
ty: ir.ty,
|
||||
additional_signed: ir.additional_signed,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ExtrinsicMetadataIR> for ExtrinsicMetadata {
|
||||
fn from(ir: ExtrinsicMetadataIR) -> Self {
|
||||
ExtrinsicMetadata {
|
||||
ty: ir.ty,
|
||||
version: ir.version,
|
||||
signed_extensions: ir.signed_extensions.into_iter().map(Into::into).collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
//! Storage counted map type.
|
||||
|
||||
use crate::{
|
||||
metadata::StorageEntryMetadata,
|
||||
metadata_ir::StorageEntryMetadataIR,
|
||||
storage::{
|
||||
generator::StorageMap as _,
|
||||
types::{
|
||||
@@ -459,7 +459,7 @@ where
|
||||
OnEmpty: Get<QueryKind::Query> + 'static,
|
||||
MaxValues: Get<Option<u32>>,
|
||||
{
|
||||
fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec<StorageEntryMetadata>) {
|
||||
fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec<StorageEntryMetadataIR>) {
|
||||
<Self as MapWrapper>::Map::build_metadata(docs, entries);
|
||||
CounterFor::<Prefix>::build_metadata(
|
||||
if cfg!(feature = "no-metadata-docs") {
|
||||
@@ -512,7 +512,7 @@ mod test {
|
||||
use super::*;
|
||||
use crate::{
|
||||
hash::*,
|
||||
metadata::{StorageEntryModifier, StorageEntryType, StorageHasher},
|
||||
metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR},
|
||||
storage::{bounded_vec::BoundedVec, types::ValueQuery},
|
||||
traits::ConstU32,
|
||||
};
|
||||
@@ -1147,21 +1147,21 @@ mod test {
|
||||
assert_eq!(
|
||||
entries,
|
||||
vec![
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "foo",
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
hashers: vec![StorageHasher::Twox64Concat],
|
||||
modifier: StorageEntryModifierIR::Default,
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![StorageHasherIR::Twox64Concat],
|
||||
key: scale_info::meta_type::<u16>(),
|
||||
value: scale_info::meta_type::<u32>(),
|
||||
},
|
||||
default: 97u32.encode(),
|
||||
docs: vec![],
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "counter_for_foo",
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(scale_info::meta_type::<u32>()),
|
||||
modifier: StorageEntryModifierIR::Default,
|
||||
ty: StorageEntryTypeIR::Plain(scale_info::meta_type::<u32>()),
|
||||
default: vec![0, 0, 0, 0],
|
||||
docs: if cfg!(feature = "no-metadata-docs") {
|
||||
vec![]
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
//! StoragePrefixedDoubleMap traits and their methods directly.
|
||||
|
||||
use crate::{
|
||||
metadata::{StorageEntryMetadata, StorageEntryType},
|
||||
metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR},
|
||||
storage::{
|
||||
types::{OptionQuery, QueryKindTrait, StorageEntryMetadataBuilder},
|
||||
KeyLenOf, StorageAppend, StorageDecodeLength, StoragePrefixedMap, StorageTryAppend,
|
||||
@@ -656,13 +656,13 @@ where
|
||||
OnEmpty: Get<QueryKind::Query> + 'static,
|
||||
MaxValues: Get<Option<u32>>,
|
||||
{
|
||||
fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec<StorageEntryMetadata>) {
|
||||
fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec<StorageEntryMetadataIR>) {
|
||||
let docs = if cfg!(feature = "no-metadata-docs") { vec![] } else { docs };
|
||||
|
||||
let entry = StorageEntryMetadata {
|
||||
let entry = StorageEntryMetadataIR {
|
||||
name: Prefix::STORAGE_PREFIX,
|
||||
modifier: QueryKind::METADATA,
|
||||
ty: StorageEntryType::Map {
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![Hasher1::METADATA, Hasher2::METADATA],
|
||||
key: scale_info::meta_type::<(Key1, Key2)>(),
|
||||
value: scale_info::meta_type::<Value>(),
|
||||
@@ -736,7 +736,7 @@ mod test {
|
||||
use super::*;
|
||||
use crate::{
|
||||
hash::*,
|
||||
metadata::{StorageEntryModifier, StorageEntryType, StorageHasher},
|
||||
metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR},
|
||||
storage::types::ValueQuery,
|
||||
};
|
||||
use sp_io::{hashing::twox_128, TestExternalities};
|
||||
@@ -916,13 +916,13 @@ mod test {
|
||||
assert_eq!(
|
||||
entries,
|
||||
vec![
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "foo",
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Map {
|
||||
modifier: StorageEntryModifierIR::Optional,
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![
|
||||
StorageHasher::Blake2_128Concat,
|
||||
StorageHasher::Twox64Concat
|
||||
StorageHasherIR::Blake2_128Concat,
|
||||
StorageHasherIR::Twox64Concat
|
||||
],
|
||||
key: scale_info::meta_type::<(u16, u8)>(),
|
||||
value: scale_info::meta_type::<u32>(),
|
||||
@@ -930,13 +930,13 @@ mod test {
|
||||
default: Option::<u32>::None.encode(),
|
||||
docs: vec![],
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "foo",
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
modifier: StorageEntryModifierIR::Default,
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![
|
||||
StorageHasher::Blake2_128Concat,
|
||||
StorageHasher::Twox64Concat
|
||||
StorageHasherIR::Blake2_128Concat,
|
||||
StorageHasherIR::Twox64Concat
|
||||
],
|
||||
key: scale_info::meta_type::<(u16, u8)>(),
|
||||
value: scale_info::meta_type::<u32>(),
|
||||
|
||||
@@ -41,7 +41,7 @@ pub trait KeyGenerator {
|
||||
type HashFn: FnOnce(&[u8]) -> Vec<u8>;
|
||||
type HArg;
|
||||
|
||||
const HASHER_METADATA: &'static [crate::metadata::StorageHasher];
|
||||
const HASHER_METADATA: &'static [crate::metadata_ir::StorageHasherIR];
|
||||
|
||||
/// Given a `key` tuple, calculate the final key by encoding each element individually and
|
||||
/// hashing them using the corresponding hasher in the `KeyGenerator`.
|
||||
@@ -74,7 +74,7 @@ impl<H: StorageHasher, K: FullCodec + StaticTypeInfo> KeyGenerator for Key<H, K>
|
||||
type HashFn = Box<dyn FnOnce(&[u8]) -> Vec<u8>>;
|
||||
type HArg = (Self::HashFn,);
|
||||
|
||||
const HASHER_METADATA: &'static [crate::metadata::StorageHasher] = &[H::METADATA];
|
||||
const HASHER_METADATA: &'static [crate::metadata_ir::StorageHasherIR] = &[H::METADATA];
|
||||
|
||||
fn final_key<KArg: EncodeLikeTuple<Self::KArg> + TupleToEncodedIter>(key: KArg) -> Vec<u8> {
|
||||
H::hash(&key.to_encoded_iter().next().expect("should have at least one element!"))
|
||||
@@ -114,7 +114,7 @@ impl KeyGenerator for Tuple {
|
||||
for_tuples!( type HArg = ( #(Tuple::HashFn),* ); );
|
||||
type HashFn = Box<dyn FnOnce(&[u8]) -> Vec<u8>>;
|
||||
|
||||
const HASHER_METADATA: &'static [crate::metadata::StorageHasher] =
|
||||
const HASHER_METADATA: &'static [crate::metadata_ir::StorageHasherIR] =
|
||||
&[for_tuples!( #(Tuple::Hasher::METADATA),* )];
|
||||
|
||||
fn final_key<KArg: EncodeLikeTuple<Self::KArg> + TupleToEncodedIter>(key: KArg) -> Vec<u8> {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
//! methods directly.
|
||||
|
||||
use crate::{
|
||||
metadata::{StorageEntryMetadata, StorageEntryType},
|
||||
metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR},
|
||||
storage::{
|
||||
types::{OptionQuery, QueryKindTrait, StorageEntryMetadataBuilder},
|
||||
KeyLenOf, StorageAppend, StorageDecodeLength, StoragePrefixedMap, StorageTryAppend,
|
||||
@@ -409,13 +409,13 @@ where
|
||||
OnEmpty: Get<QueryKind::Query> + 'static,
|
||||
MaxValues: Get<Option<u32>>,
|
||||
{
|
||||
fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec<StorageEntryMetadata>) {
|
||||
fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec<StorageEntryMetadataIR>) {
|
||||
let docs = if cfg!(feature = "no-metadata-docs") { vec![] } else { docs };
|
||||
|
||||
let entry = StorageEntryMetadata {
|
||||
let entry = StorageEntryMetadataIR {
|
||||
name: Prefix::STORAGE_PREFIX,
|
||||
modifier: QueryKind::METADATA,
|
||||
ty: StorageEntryType::Map {
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![Hasher::METADATA],
|
||||
key: scale_info::meta_type::<Key>(),
|
||||
value: scale_info::meta_type::<Value>(),
|
||||
@@ -483,7 +483,7 @@ mod test {
|
||||
use super::*;
|
||||
use crate::{
|
||||
hash::*,
|
||||
metadata::{StorageEntryModifier, StorageEntryType, StorageHasher},
|
||||
metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR},
|
||||
storage::types::ValueQuery,
|
||||
};
|
||||
use sp_io::{hashing::twox_128, TestExternalities};
|
||||
@@ -706,22 +706,22 @@ mod test {
|
||||
assert_eq!(
|
||||
entries,
|
||||
vec![
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "foo",
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Map {
|
||||
hashers: vec![StorageHasher::Blake2_128Concat],
|
||||
modifier: StorageEntryModifierIR::Optional,
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![StorageHasherIR::Blake2_128Concat],
|
||||
key: scale_info::meta_type::<u16>(),
|
||||
value: scale_info::meta_type::<u32>(),
|
||||
},
|
||||
default: Option::<u32>::None.encode(),
|
||||
docs: vec![],
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "foo",
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
hashers: vec![StorageHasher::Blake2_128Concat],
|
||||
modifier: StorageEntryModifierIR::Default,
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![StorageHasherIR::Blake2_128Concat],
|
||||
key: scale_info::meta_type::<u16>(),
|
||||
value: scale_info::meta_type::<u32>(),
|
||||
},
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
//! Storage types to build abstraction on storage, they implements storage traits such as
|
||||
//! StorageMap and others.
|
||||
|
||||
use crate::metadata::{StorageEntryMetadata, StorageEntryModifier};
|
||||
use crate::metadata_ir::{StorageEntryMetadataIR, StorageEntryModifierIR};
|
||||
use codec::FullCodec;
|
||||
use sp_std::prelude::*;
|
||||
|
||||
@@ -50,7 +50,7 @@ pub use value::StorageValue;
|
||||
/// value.
|
||||
pub trait QueryKindTrait<Value, OnEmpty> {
|
||||
/// Metadata for the storage kind.
|
||||
const METADATA: StorageEntryModifier;
|
||||
const METADATA: StorageEntryModifierIR;
|
||||
|
||||
/// Type returned on query
|
||||
type Query: FullCodec + 'static;
|
||||
@@ -73,7 +73,7 @@ impl<Value> QueryKindTrait<Value, crate::traits::GetDefault> for OptionQuery
|
||||
where
|
||||
Value: FullCodec + 'static,
|
||||
{
|
||||
const METADATA: StorageEntryModifier = StorageEntryModifier::Optional;
|
||||
const METADATA: StorageEntryModifierIR = StorageEntryModifierIR::Optional;
|
||||
|
||||
type Query = Option<Value>;
|
||||
|
||||
@@ -95,7 +95,7 @@ where
|
||||
Error: FullCodec + 'static,
|
||||
OnEmpty: crate::traits::Get<Result<Value, Error>>,
|
||||
{
|
||||
const METADATA: StorageEntryModifier = StorageEntryModifier::Optional;
|
||||
const METADATA: StorageEntryModifierIR = StorageEntryModifierIR::Optional;
|
||||
|
||||
type Query = Result<Value, Error>;
|
||||
|
||||
@@ -118,7 +118,7 @@ where
|
||||
Value: FullCodec + 'static,
|
||||
OnEmpty: crate::traits::Get<Value>,
|
||||
{
|
||||
const METADATA: StorageEntryModifier = StorageEntryModifier::Default;
|
||||
const METADATA: StorageEntryModifierIR = StorageEntryModifierIR::Default;
|
||||
|
||||
type Query = Value;
|
||||
|
||||
@@ -136,5 +136,5 @@ where
|
||||
/// Implemented by each of the storage types: value, map, countedmap, doublemap and nmap.
|
||||
pub trait StorageEntryMetadataBuilder {
|
||||
/// Build into `entries` the storage metadata entries of a storage given some `docs`.
|
||||
fn build_metadata(doc: Vec<&'static str>, entries: &mut Vec<StorageEntryMetadata>);
|
||||
fn build_metadata(doc: Vec<&'static str>, entries: &mut Vec<StorageEntryMetadataIR>);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
//! StoragePrefixedDoubleMap traits and their methods directly.
|
||||
|
||||
use crate::{
|
||||
metadata::{StorageEntryMetadata, StorageEntryType},
|
||||
metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR},
|
||||
storage::{
|
||||
types::{
|
||||
EncodeLikeTuple, HasKeyPrefix, HasReversibleKeyPrefix, OptionQuery, QueryKindTrait,
|
||||
@@ -550,13 +550,13 @@ where
|
||||
OnEmpty: Get<QueryKind::Query> + 'static,
|
||||
MaxValues: Get<Option<u32>>,
|
||||
{
|
||||
fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec<StorageEntryMetadata>) {
|
||||
fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec<StorageEntryMetadataIR>) {
|
||||
let docs = if cfg!(feature = "no-metadata-docs") { vec![] } else { docs };
|
||||
|
||||
let entry = StorageEntryMetadata {
|
||||
let entry = StorageEntryMetadataIR {
|
||||
name: Prefix::STORAGE_PREFIX,
|
||||
modifier: QueryKind::METADATA,
|
||||
ty: StorageEntryType::Map {
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
key: scale_info::meta_type::<Key::Key>(),
|
||||
hashers: Key::HASHER_METADATA.to_vec(),
|
||||
value: scale_info::meta_type::<Value>(),
|
||||
@@ -620,7 +620,7 @@ mod test {
|
||||
use super::*;
|
||||
use crate::{
|
||||
hash::{StorageHasher as _, *},
|
||||
metadata::{StorageEntryModifier, StorageHasher},
|
||||
metadata_ir::{StorageEntryModifierIR, StorageHasherIR},
|
||||
storage::types::{Key as NMapKey, ValueQuery},
|
||||
};
|
||||
use sp_io::{hashing::twox_128, TestExternalities};
|
||||
@@ -791,22 +791,22 @@ mod test {
|
||||
assert_eq!(
|
||||
entries,
|
||||
vec![
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "Foo",
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Map {
|
||||
hashers: vec![StorageHasher::Blake2_128Concat],
|
||||
modifier: StorageEntryModifierIR::Optional,
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![StorageHasherIR::Blake2_128Concat],
|
||||
key: scale_info::meta_type::<u16>(),
|
||||
value: scale_info::meta_type::<u32>(),
|
||||
},
|
||||
default: Option::<u32>::None.encode(),
|
||||
docs: vec![],
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "Foo",
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
hashers: vec![StorageHasher::Blake2_128Concat],
|
||||
modifier: StorageEntryModifierIR::Default,
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![StorageHasherIR::Blake2_128Concat],
|
||||
key: scale_info::meta_type::<u16>(),
|
||||
value: scale_info::meta_type::<u32>(),
|
||||
},
|
||||
@@ -991,13 +991,13 @@ mod test {
|
||||
assert_eq!(
|
||||
entries,
|
||||
vec![
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "Foo",
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Map {
|
||||
modifier: StorageEntryModifierIR::Optional,
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![
|
||||
StorageHasher::Blake2_128Concat,
|
||||
StorageHasher::Twox64Concat
|
||||
StorageHasherIR::Blake2_128Concat,
|
||||
StorageHasherIR::Twox64Concat
|
||||
],
|
||||
key: scale_info::meta_type::<(u16, u8)>(),
|
||||
value: scale_info::meta_type::<u32>(),
|
||||
@@ -1005,13 +1005,13 @@ mod test {
|
||||
default: Option::<u32>::None.encode(),
|
||||
docs: vec![],
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "Foo",
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
modifier: StorageEntryModifierIR::Default,
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![
|
||||
StorageHasher::Blake2_128Concat,
|
||||
StorageHasher::Twox64Concat
|
||||
StorageHasherIR::Blake2_128Concat,
|
||||
StorageHasherIR::Twox64Concat
|
||||
],
|
||||
key: scale_info::meta_type::<(u16, u8)>(),
|
||||
value: scale_info::meta_type::<u32>(),
|
||||
@@ -1232,14 +1232,14 @@ mod test {
|
||||
assert_eq!(
|
||||
entries,
|
||||
vec![
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "Foo",
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Map {
|
||||
modifier: StorageEntryModifierIR::Optional,
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![
|
||||
StorageHasher::Blake2_128Concat,
|
||||
StorageHasher::Blake2_128Concat,
|
||||
StorageHasher::Twox64Concat
|
||||
StorageHasherIR::Blake2_128Concat,
|
||||
StorageHasherIR::Blake2_128Concat,
|
||||
StorageHasherIR::Twox64Concat
|
||||
],
|
||||
key: scale_info::meta_type::<(u16, u16, u16)>(),
|
||||
value: scale_info::meta_type::<u32>(),
|
||||
@@ -1247,14 +1247,14 @@ mod test {
|
||||
default: Option::<u32>::None.encode(),
|
||||
docs: vec![],
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "Foo",
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Map {
|
||||
modifier: StorageEntryModifierIR::Default,
|
||||
ty: StorageEntryTypeIR::Map {
|
||||
hashers: vec![
|
||||
StorageHasher::Blake2_128Concat,
|
||||
StorageHasher::Blake2_128Concat,
|
||||
StorageHasher::Twox64Concat
|
||||
StorageHasherIR::Blake2_128Concat,
|
||||
StorageHasherIR::Blake2_128Concat,
|
||||
StorageHasherIR::Twox64Concat
|
||||
],
|
||||
key: scale_info::meta_type::<(u16, u16, u16)>(),
|
||||
value: scale_info::meta_type::<u32>(),
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
//! Storage value type. Implements StorageValue trait and its method directly.
|
||||
|
||||
use crate::{
|
||||
metadata::{StorageEntryMetadata, StorageEntryType},
|
||||
metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR},
|
||||
storage::{
|
||||
generator::StorageValue as StorageValueT,
|
||||
types::{OptionQuery, QueryKindTrait, StorageEntryMetadataBuilder},
|
||||
@@ -221,13 +221,13 @@ where
|
||||
QueryKind: QueryKindTrait<Value, OnEmpty>,
|
||||
OnEmpty: crate::traits::Get<QueryKind::Query> + 'static,
|
||||
{
|
||||
fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec<StorageEntryMetadata>) {
|
||||
fn build_metadata(docs: Vec<&'static str>, entries: &mut Vec<StorageEntryMetadataIR>) {
|
||||
let docs = if cfg!(feature = "no-metadata-docs") { vec![] } else { docs };
|
||||
|
||||
let entry = StorageEntryMetadata {
|
||||
let entry = StorageEntryMetadataIR {
|
||||
name: Prefix::STORAGE_PREFIX,
|
||||
modifier: QueryKind::METADATA,
|
||||
ty: StorageEntryType::Plain(scale_info::meta_type::<Value>()),
|
||||
ty: StorageEntryTypeIR::Plain(scale_info::meta_type::<Value>()),
|
||||
default: OnEmpty::get().encode(),
|
||||
docs,
|
||||
};
|
||||
@@ -278,7 +278,7 @@ where
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::{metadata::StorageEntryModifier, storage::types::ValueQuery};
|
||||
use crate::{metadata_ir::StorageEntryModifierIR, storage::types::ValueQuery};
|
||||
use sp_io::{hashing::twox_128, TestExternalities};
|
||||
|
||||
struct Prefix;
|
||||
@@ -363,17 +363,17 @@ mod test {
|
||||
assert_eq!(
|
||||
entries,
|
||||
vec![
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "foo",
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(scale_info::meta_type::<u32>()),
|
||||
modifier: StorageEntryModifierIR::Optional,
|
||||
ty: StorageEntryTypeIR::Plain(scale_info::meta_type::<u32>()),
|
||||
default: Option::<u32>::None.encode(),
|
||||
docs: vec![],
|
||||
},
|
||||
StorageEntryMetadata {
|
||||
StorageEntryMetadataIR {
|
||||
name: "foo",
|
||||
modifier: StorageEntryModifier::Default,
|
||||
ty: StorageEntryType::Plain(scale_info::meta_type::<u32>()),
|
||||
modifier: StorageEntryModifierIR::Default,
|
||||
ty: StorageEntryTypeIR::Plain(scale_info::meta_type::<u32>()),
|
||||
default: 97u32.encode(),
|
||||
docs: vec![],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user