Remove derive_more (#1600)

* replace derive_more's 'From' in signer

* replace derive_more's 'From' in core

* Remove `derive_more`'s `Display` usages (#1601)

* Remove derive_more's 'Display' from core

* Remove derive_more's 'Display' from metadata

* Remove derive_more's 'Display' from signer

* Remove derive_more from dependencies (#1602)

closes #1503

* Update signer/src/eth.rs

Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>

* rename convert_error to impl_from

* rename convert_error to impl_from in core

---------

Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
This commit is contained in:
Pavlo Khrystenko
2024-05-24 11:18:51 +02:00
committed by GitHub
parent ae5c0927c6
commit 5a0682c1e0
14 changed files with 239 additions and 98 deletions
+26 -7
View File
@@ -2,34 +2,53 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use core::fmt::Display;
use alloc::string::String;
use derive_more::Display;
mod v14;
mod v15;
/// An error emitted if something goes wrong converting [`frame_metadata`]
/// types into [`crate::Metadata`].
#[derive(Debug, Display, PartialEq, Eq)]
#[derive(Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum TryFromError {
/// Type missing from type registry
#[display(fmt = "Type id {_0} is expected but not found in the type registry")]
TypeNotFound(u32),
/// Type was not a variant/enum type
#[display(fmt = "Type {_0} was not a variant/enum type, but is expected to be one")]
VariantExpected(u32),
/// An unsupported metadata version was provided.
#[display(fmt = "Cannot convert v{_0} metadata into Metadata type")]
UnsupportedMetadataVersion(u32),
/// Type name missing from type registry
#[display(fmt = "Type name {_0} is expected but not found in the type registry")]
TypeNameNotFound(String),
/// Invalid type path.
#[display(fmt = "Type has an invalid path {_0}")]
InvalidTypePath(String),
}
impl Display for TryFromError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
TryFromError::TypeNotFound(e) => write!(
f,
"Type id {e} is expected but not found in the type registry"
),
TryFromError::VariantExpected(e) => write!(
f,
"Type {e} was not a variant/enum type, but is expected to be one"
),
TryFromError::UnsupportedMetadataVersion(e) => {
write!(f, "Cannot convert v{e} metadata into Metadata type")
}
TryFromError::TypeNameNotFound(e) => write!(
f,
"Type name {e} is expected but not found in the type registry"
),
TryFromError::InvalidTypePath(e) => write!(f, "Type has an invalid path {e}"),
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for TryFromError {}