Skip to content
Snippets Groups Projects
Commit db24a71a authored by Spencer Judge's avatar Spencer Judge Committed by GitHub
Browse files

Provide easy conversions from common key types to `AccountId32` (#5423)

* Provide easy conversions from common key types to `AccountId32`

* Fix spaces instead of tabs
parent 2138004f
No related merge requests found
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
//! Cryptographic utilities. //! Cryptographic utilities.
// end::description[] // end::description[]
use crate::{sr25519, ed25519};
use sp_std::hash::Hash; use sp_std::hash::Hash;
use sp_std::vec::Vec; use sp_std::vec::Vec;
#[cfg(feature = "std")] #[cfg(feature = "std")]
...@@ -615,6 +616,18 @@ impl From<AccountId32> for [u8; 32] { ...@@ -615,6 +616,18 @@ impl From<AccountId32> for [u8; 32] {
} }
} }
impl From<sr25519::Public> for AccountId32 {
fn from(k: sr25519::Public) -> Self {
k.0.into()
}
}
impl From<ed25519::Public> for AccountId32 {
fn from(k: ed25519::Public) -> Self {
k.0.into()
}
}
#[cfg(feature = "std")] #[cfg(feature = "std")]
impl std::fmt::Display for AccountId32 { impl std::fmt::Display for AccountId32 {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment