Convert Public to CryptoTypePublicPair (#6014)

* Tabify code

* Implement CryptoTypePublicPair in app_crypto

* Cleanup redundancy

* Introduce to_public_crypto_pair to Public trait

* Implement method for test
This commit is contained in:
Rakan Alhneiti
2020-05-13 19:44:54 +02:00
committed by GitHub
parent daf8cf0600
commit 6bdfae2bcb
8 changed files with 52 additions and 50 deletions
@@ -22,24 +22,11 @@ use sp_std::vec::Vec;
mod app {
use sp_application_crypto::{
CryptoTypePublicPair,
key_types::AUTHORITY_DISCOVERY,
Public as _,
app_crypto,
sr25519};
sr25519,
};
app_crypto!(sr25519, AUTHORITY_DISCOVERY);
impl From<Public> for CryptoTypePublicPair {
fn from(key: Public) -> Self {
(&key).into()
}
}
impl From<&Public> for CryptoTypePublicPair {
fn from(key: &Public) -> Self {
CryptoTypePublicPair(sr25519::CRYPTO_ID, key.to_raw_vec())
}
}
}
sp_application_crypto::with_pair! {