From db24a71acebdc215f8a671f0c999cc4bee970517 Mon Sep 17 00:00:00 2001
From: Spencer Judge <sushisource@gmail.com>
Date: Fri, 27 Mar 2020 13:41:29 -0700
Subject: [PATCH] Provide easy conversions from common key types to
 `AccountId32` (#5423)

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

* Fix spaces instead of tabs
---
 substrate/primitives/core/src/crypto.rs | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/substrate/primitives/core/src/crypto.rs b/substrate/primitives/core/src/crypto.rs
index c073862f29e..6301600921a 100644
--- a/substrate/primitives/core/src/crypto.rs
+++ b/substrate/primitives/core/src/crypto.rs
@@ -18,6 +18,7 @@
 //! Cryptographic utilities.
 // end::description[]
 
+use crate::{sr25519, ed25519};
 use sp_std::hash::Hash;
 use sp_std::vec::Vec;
 #[cfg(feature = "std")]
@@ -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")]
 impl std::fmt::Display for AccountId32 {
 	fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
-- 
GitLab