Adds with_pair! macro to application-crypto (#4885)

* Adds `with_pair!` macro to application-crypto

This macro will "generate" the given code only when the crypto pair is
available. So, when either the `std` or the `full_crypto` feature is
enabled.

* Fix example
This commit is contained in:
Bastian Köcher
2020-02-14 15:46:41 +01:00
committed by GitHub
parent d3a3e288b6
commit 91989cab46
6 changed files with 54 additions and 24 deletions
+8 -6
View File
@@ -102,9 +102,10 @@ pub mod sr25519 {
app_crypto!(sr25519, IM_ONLINE);
}
/// An i'm online keypair using sr25519 as its crypto.
#[cfg(feature = "std")]
pub type AuthorityPair = app_sr25519::Pair;
sp_application_crypto::with_pair! {
/// An i'm online keypair using sr25519 as its crypto.
pub type AuthorityPair = app_sr25519::Pair;
}
/// An i'm online signature using sr25519 as its crypto.
pub type AuthoritySignature = app_sr25519::Signature;
@@ -119,9 +120,10 @@ pub mod ed25519 {
app_crypto!(ed25519, IM_ONLINE);
}
/// An i'm online keypair using ed25519 as its crypto.
#[cfg(feature = "std")]
pub type AuthorityPair = app_ed25519::Pair;
sp_application_crypto::with_pair! {
/// An i'm online keypair using ed25519 as its crypto.
pub type AuthorityPair = app_ed25519::Pair;
}
/// An i'm online signature using ed25519 as its crypto.
pub type AuthoritySignature = app_ed25519::Signature;