Replace JSON metadata with custom metadata structures (#766)

* Move module metadata from json string to custom metadata

* Revisit the metadata structures

1. Move the structures into the metadata crate.
2. Switch to using Cow/MaybeOwnedArray to support Encode/Decode

* Adapt to new metadata structures

* Convert event json metadata to new metadata structures

* Convert storage json metadata to new metadata structures

* Convert runtime metadata from json to new metadata structs

* Implements new metadata structures in client and runtime

* Fixes errors on `no_std`

* Fixes errors after rebasing master

* Do not use `Cow` anymore in metadata

Also replace `String` with our own type definition `StringBuf`.
This fixes compilation on `no_std`.

* Wrap `RuntimeMetadata` in `RuntimeMetadataVersioned` to support versioning

* Move metadata into `srml` and make core unaware of the implementation
This commit is contained in:
Bastian Köcher
2018-09-20 07:35:32 +02:00
committed by Gav Wood
parent 3c0da110f3
commit 5d64be26c3
22 changed files with 1138 additions and 843 deletions
+10 -10
View File
@@ -275,7 +275,7 @@ macro_rules! construct_runtime {
$name: $module::{ $( $modules $( <$modules_generic> )* ),* }
),*;
);
__decl_json_metadata!(
__decl_runtime_metadata!(
$runtime;
;
;
@@ -664,7 +664,7 @@ macro_rules! __decl_outer_dispatch {
#[macro_export]
#[doc(hidden)]
macro_rules! __decl_json_metadata {
macro_rules! __decl_runtime_metadata {
(
$runtime:ident;
;
@@ -676,7 +676,7 @@ macro_rules! __decl_json_metadata {
$( $rest_modules:ident $( <$rest_modules_generic:ident> )* ),*
})*;
) => {
__decl_json_metadata!(
__decl_runtime_metadata!(
$runtime;
$module { Module, };
$( $parsed_modules { Module $( with $parsed_storage )* } ),*;
@@ -699,7 +699,7 @@ macro_rules! __decl_json_metadata {
$( $rest_modules:ident $( <$rest_modules_generic:ident> )* ),*
})*;
) => {
__decl_json_metadata!(
__decl_runtime_metadata!(
$runtime;
;
$( $parsed_modules { Module $( with $parsed_storage )* }, )* $module { Module with Storage };
@@ -721,7 +721,7 @@ macro_rules! __decl_json_metadata {
$( $rest_modules:ident $( <$rest_modules_generic:ident> )* ),*
})*;
) => {
__decl_json_metadata!(
__decl_runtime_metadata!(
$runtime;
$module { , Storage };
$( $parsed_modules { Module $( with $parsed_storage )* } ),*;
@@ -744,7 +744,7 @@ macro_rules! __decl_json_metadata {
$( $rest_modules:ident $( <$rest_modules_generic:ident> )* ),*
})*;
) => {
__decl_json_metadata!(
__decl_runtime_metadata!(
$runtime;
;
$( $parsed_modules { Module $( with $parsed_storage )* }, )* $module { Module with Storage };
@@ -766,7 +766,7 @@ macro_rules! __decl_json_metadata {
$( $rest_modules:ident $( <$rest_modules_generic:ident> )* ),*
})*;
) => {
__decl_json_metadata!(
__decl_runtime_metadata!(
$runtime;
$( $current_module { $( $current_module_storage )* } )*;
$( $parsed_modules { Module $( with $parsed_storage )* } ),*;
@@ -787,7 +787,7 @@ macro_rules! __decl_json_metadata {
$( $rest_modules:ident $( <$rest_modules_generic:ident> )* ),*
})*;
) => {
__decl_json_metadata!(
__decl_runtime_metadata!(
$runtime;
;
$( $parsed_modules { Module $( with $parsed_storage )* }, )* $module { Module };
@@ -807,7 +807,7 @@ macro_rules! __decl_json_metadata {
$( $rest_modules:ident $( <$rest_modules_generic:ident> )* ),*
})*;
) => {
__decl_json_metadata!(
__decl_runtime_metadata!(
$runtime;
;
$( $parsed_modules { Module $( with $parsed_storage )* } ),*;
@@ -824,7 +824,7 @@ macro_rules! __decl_json_metadata {
$( $parsed_modules:ident { Module $( with $parsed_storage:ident )* } ),*;
;
) => {
impl_json_metadata!(
impl_runtime_metadata!(
for $runtime with modules
$( $parsed_modules::Module $(with $parsed_storage)*, )*
);