macro_rules! impl_opaque_keys {
{
$( #[ $attr:meta ] )*
pub struct $name:ident {
$(
$( #[ $inner_attr:meta ] )*
pub $field:ident: $type:ty,
)*
}
} => { ... };
}Expand description
Implement OpaqueKeys for a described struct.
Every field type must implement BoundToRuntimeAppPublic.
The KeyTypeIdProviders type is set to tuple of all field
types passed to the macro.
The proof type used by the generated session keys for
ownership_proof_is_valid is the SCALE encoded tuple of
all signatures. The order of the signatures is the same as the order of the fields in the
struct. Each signature is created by signing the owner given to the generate function.
use sp_runtime::{
impl_opaque_keys, KeyTypeId, BoundToRuntimeAppPublic, app_crypto::{sr25519, ed25519}
};
pub struct KeyModule;
impl BoundToRuntimeAppPublic for KeyModule { type Public = ed25519::AppPublic; }
pub struct KeyModule2;
impl BoundToRuntimeAppPublic for KeyModule2 { type Public = sr25519::AppPublic; }
impl_opaque_keys! {
pub struct Keys {
pub key_module: KeyModule,
pub key_module2: KeyModule2,
}
}