mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 14:11:09 +00:00
Add crypto identifier to RuntimeAppPublic (#5965)
* Add crypto identifier to RuntimeAppPublic * Update primitives/application-crypto/src/traits.rs Co-authored-by: Gavin Wood <github@gavwood.com> Co-authored-by: Gavin Wood <github@gavwood.com>
This commit is contained in:
@@ -25,7 +25,7 @@ pub use sp_core::{self, crypto::{CryptoType, CryptoTypePublicPair, Public, Deriv
|
||||
#[doc(hidden)]
|
||||
#[cfg(feature = "full_crypto")]
|
||||
pub use sp_core::crypto::{SecretStringError, DeriveJunction, Ss58Codec, Pair};
|
||||
pub use sp_core::crypto::{KeyTypeId, key_types};
|
||||
pub use sp_core::crypto::{KeyTypeId, CryptoTypeId, key_types};
|
||||
|
||||
#[doc(hidden)]
|
||||
pub use codec;
|
||||
@@ -55,7 +55,7 @@ pub use traits::*;
|
||||
macro_rules! app_crypto {
|
||||
($module:ident, $key_type:expr) => {
|
||||
$crate::app_crypto_public_full_crypto!($module::Public, $key_type);
|
||||
$crate::app_crypto_public_common!($module::Public, $module::Signature, $key_type);
|
||||
$crate::app_crypto_public_common!($module::Public, $module::Signature, $key_type, $module::CRYPTO_ID);
|
||||
$crate::app_crypto_signature_full_crypto!($module::Signature, $key_type);
|
||||
$crate::app_crypto_signature_common!($module::Signature, $key_type);
|
||||
$crate::app_crypto_pair!($module::Pair, $key_type);
|
||||
@@ -76,7 +76,7 @@ macro_rules! app_crypto {
|
||||
macro_rules! app_crypto {
|
||||
($module:ident, $key_type:expr) => {
|
||||
$crate::app_crypto_public_not_full_crypto!($module::Public, $key_type);
|
||||
$crate::app_crypto_public_common!($module::Public, $module::Signature, $key_type);
|
||||
$crate::app_crypto_public_common!($module::Public, $module::Signature, $key_type, $module::CRYPTO_ID);
|
||||
$crate::app_crypto_signature_not_full_crypto!($module::Signature, $key_type);
|
||||
$crate::app_crypto_signature_common!($module::Signature, $key_type);
|
||||
};
|
||||
@@ -246,7 +246,7 @@ macro_rules! app_crypto_public_not_full_crypto {
|
||||
#[doc(hidden)]
|
||||
#[macro_export]
|
||||
macro_rules! app_crypto_public_common {
|
||||
($public:ty, $sig:ty, $key_type:expr) => {
|
||||
($public:ty, $sig:ty, $key_type:expr, $crypto_type:expr) => {
|
||||
$crate::app_crypto_public_common_if_std!();
|
||||
|
||||
impl AsRef<[u8]> for Public {
|
||||
@@ -267,6 +267,8 @@ macro_rules! app_crypto_public_common {
|
||||
|
||||
impl $crate::RuntimeAppPublic for Public where $public: $crate::RuntimePublic<Signature=$sig> {
|
||||
const ID: $crate::KeyTypeId = $key_type;
|
||||
const CRYPTO_ID: $crate::CryptoTypeId = $crypto_type;
|
||||
|
||||
type Signature = Signature;
|
||||
|
||||
fn all() -> $crate::Vec<Self> {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
use sp_core::crypto::Pair;
|
||||
|
||||
use codec::Codec;
|
||||
use sp_core::crypto::{KeyTypeId, CryptoType, IsWrappedBy, Public};
|
||||
use sp_core::crypto::{KeyTypeId, CryptoType, CryptoTypeId, IsWrappedBy, Public};
|
||||
use sp_std::{fmt::Debug, vec::Vec};
|
||||
|
||||
/// An application-specific key.
|
||||
@@ -115,6 +115,8 @@ pub trait RuntimePublic: Sized {
|
||||
pub trait RuntimeAppPublic: Sized {
|
||||
/// An identifier for this application-specific key type.
|
||||
const ID: KeyTypeId;
|
||||
/// The identifier of the crypto type of this application-specific key type.
|
||||
const CRYPTO_ID: CryptoTypeId;
|
||||
|
||||
/// The signature that will be generated when signing with the corresponding private key.
|
||||
type Signature: Codec + Debug + MaybeHash + Eq + PartialEq + Clone;
|
||||
|
||||
@@ -62,7 +62,7 @@ pub use crate::runtime_string::*;
|
||||
pub use generic::{DigestItem, Digest};
|
||||
|
||||
/// Re-export this since it's part of the API of this crate.
|
||||
pub use sp_core::{TypeId, crypto::{key_types, KeyTypeId, CryptoType, AccountId32}};
|
||||
pub use sp_core::{TypeId, crypto::{key_types, KeyTypeId, CryptoType, CryptoTypeId, AccountId32}};
|
||||
pub use sp_application_crypto::{RuntimeAppPublic, BoundToRuntimeAppPublic};
|
||||
|
||||
/// Re-export `RuntimeDebug`, to avoid dependency clutter.
|
||||
|
||||
@@ -24,7 +24,7 @@ use crate::traits::{
|
||||
SignedExtension, Dispatchable, DispatchInfoOf,
|
||||
};
|
||||
use crate::traits::ValidateUnsigned;
|
||||
use crate::{generic, KeyTypeId, ApplyExtrinsicResult};
|
||||
use crate::{generic, KeyTypeId, CryptoTypeId, ApplyExtrinsicResult};
|
||||
pub use sp_core::{H256, sr25519};
|
||||
use sp_core::{crypto::{CryptoType, Dummy, key_types, Public}, U256};
|
||||
use crate::transaction_validity::{TransactionValidity, TransactionValidityError, TransactionSource};
|
||||
@@ -86,6 +86,7 @@ impl UintAuthorityId {
|
||||
|
||||
impl sp_application_crypto::RuntimeAppPublic for UintAuthorityId {
|
||||
const ID: KeyTypeId = key_types::DUMMY;
|
||||
const CRYPTO_ID: CryptoTypeId = CryptoTypeId(*b"dumm");
|
||||
|
||||
type Signature = TestSignature;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user