Skip to content

Commit

Permalink
metadata: Generate runtime outer enums if not present in V14 (#1174)
Browse files Browse the repository at this point in the history
* metadata: Extend outer enum generation for V14

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* metadata: Generate outer enums if not present

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* metadata: Porpagate v14 error instead of panic

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* metadata: Try to find `RuntimeCall` then `Call` enums

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* metadata: Ensure the returned type is variant for outer enums

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* metadata: Replace or with or_else

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* metadata: Apply clippy

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* metadata: Return error and generate only `RuntimeError`

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* metadata: Remove modified path

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* metadata/tests: Check missing runtime types

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
  • Loading branch information
lexnv authored and tadeohepperle committed Sep 26, 2023
1 parent 6e00e19 commit 2ad8291
Show file tree
Hide file tree
Showing 2 changed files with 196 additions and 63 deletions.
10 changes: 8 additions & 2 deletions metadata/src/from_into/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,24 @@ mod v15;

/// An error emitted if something goes wrong converting [`frame_metadata`]
/// types into [`crate::Metadata`].
#[derive(Debug, thiserror::Error)]
#[derive(Debug, thiserror::Error, PartialEq, Eq)]
#[non_exhaustive]
pub enum TryFromError {
/// Type missing from type registry
#[error("Type {0} is expected but not found in the type registry")]
#[error("Type id {0} is expected but not found in the type registry")]
TypeNotFound(u32),
/// Type was not a variant/enum type
#[error("Type {0} was not a variant/enum type, but is expected to be one")]
VariantExpected(u32),
/// An unsupported metadata version was provided.
#[error("Cannot convert v{0} metadata into Metadata type")]
UnsupportedMetadataVersion(u32),
/// Type name missing from type registry
#[error("Type name {0} is expected but not found in the type registry")]
TypeNameNotFound(String),
/// Invalid type path.
#[error("Type has an invalid path {0}")]
InvalidTypePath(String),
}

impl From<crate::Metadata> for frame_metadata::RuntimeMetadataPrefixed {
Expand Down
Loading

0 comments on commit 2ad8291

Please sign in to comment.