mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 10:11:03 +00:00
Improve SS58 related errors (#10541)
* Improve SS58 related errors
This improves the SS58 error, especially when it comes to parsing public keys with unknown SS58
address formats.
* Make CI happy
* More fixes
* More
* 🤦
* fml...
This commit is contained in:
@@ -211,7 +211,8 @@ impl<'de> Deserialize<'de> for Public {
|
||||
}
|
||||
|
||||
/// A signature (a 512-bit value).
|
||||
#[derive(Encode, Decode, PassByInner, TypeInfo)]
|
||||
#[cfg_attr(feature = "full_crypto", derive(Hash))]
|
||||
#[derive(Encode, Decode, PassByInner, TypeInfo, PartialEq, Eq)]
|
||||
pub struct Signature(pub [u8; 64]);
|
||||
|
||||
impl sp_std::convert::TryFrom<&[u8]> for Signature {
|
||||
@@ -259,14 +260,6 @@ impl Clone for Signature {
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Signature {
|
||||
fn eq(&self, b: &Self) -> bool {
|
||||
self.0[..] == b.0[..]
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for Signature {}
|
||||
|
||||
impl From<Signature> for H512 {
|
||||
fn from(v: Signature) -> H512 {
|
||||
H512::from(v.0)
|
||||
@@ -309,13 +302,6 @@ impl sp_std::fmt::Debug for Signature {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "full_crypto")]
|
||||
impl sp_std::hash::Hash for Signature {
|
||||
fn hash<H: sp_std::hash::Hasher>(&self, state: &mut H) {
|
||||
sp_std::hash::Hash::hash(&self.0[..], state);
|
||||
}
|
||||
}
|
||||
|
||||
impl UncheckedFrom<[u8; 64]> for Signature {
|
||||
fn unchecked_from(data: [u8; 64]) -> Signature {
|
||||
Signature(data)
|
||||
@@ -360,24 +346,6 @@ pub struct LocalizedSignature {
|
||||
pub signature: Signature,
|
||||
}
|
||||
|
||||
/// An error type for SS58 decoding.
|
||||
#[cfg(feature = "std")]
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Debug, thiserror::Error)]
|
||||
pub enum PublicError {
|
||||
/// Bad alphabet.
|
||||
#[error("Base 58 requirement is violated")]
|
||||
BadBase58,
|
||||
/// Bad length.
|
||||
#[error("Length is bad")]
|
||||
BadLength,
|
||||
/// Unknown version.
|
||||
#[error("Unknown version")]
|
||||
UnknownVersion,
|
||||
/// Invalid checksum.
|
||||
#[error("Invalid checksum")]
|
||||
InvalidChecksum,
|
||||
}
|
||||
|
||||
impl Public {
|
||||
/// A new instance from the given 32-byte `data`.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user