mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 13:31:10 +00:00
Runtime logging. (#3821)
* Implement Printable for tuples. * Add debugging function. * Add debug 1. * Implement for everything. * RuntimeDebug derive. * Introduce RuntimeDebug. * Add some dummy logging. * Replace RuntimeDebug with Debug. * Revert "Replace RuntimeDebug with Debug." This reverts commit bc47070a8cb30241b2b590b2fa29fd195088162f. * Working on Debug for all. * Fix bounds. * Add debug utils. * Implement runtime logging. * Add some docs and clean up. * Clean up derives. * Fix custom derive impl. * Bump runtime. * Fix long lines. * Fix doc test. * Use CARGO_CFG_STD. * Revert "Use CARGO_CFG_STD." This reverts commit ea429566de18ed0fa052571b359eb9826a64a9f4. * Use parse_macro_input * Update lockfile. * Apply review suggestions. * Remove stray re-export. * Add no-std impl. * Update lockfile.
This commit is contained in:
committed by
Bastian Köcher
parent
934d7aac1c
commit
20a3989785
@@ -21,7 +21,7 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[doc(hidden)]
|
||||
pub use primitives::{self, crypto::{CryptoType, Public, Derive, IsWrappedBy, Wraps}};
|
||||
pub use primitives::{self, crypto::{CryptoType, Public, Derive, IsWrappedBy, Wraps}, RuntimeDebug};
|
||||
#[doc(hidden)]
|
||||
#[cfg(feature = "std")]
|
||||
pub use primitives::crypto::{SecretStringError, DeriveJunction, Ss58Codec, Pair};
|
||||
@@ -139,10 +139,12 @@ macro_rules! app_crypto {
|
||||
$crate::wrap!{
|
||||
/// A generic `AppPublic` wrapper type over $public crypto; this has no specific App.
|
||||
#[derive(
|
||||
Clone, Default, Eq, PartialEq, Ord, PartialOrd, $crate::codec::Encode,
|
||||
Clone, Default, Eq, PartialEq, Ord, PartialOrd,
|
||||
$crate::codec::Encode,
|
||||
$crate::codec::Decode,
|
||||
$crate::RuntimeDebug,
|
||||
)]
|
||||
#[cfg_attr(feature = "std", derive(Debug, Hash))]
|
||||
#[cfg_attr(feature = "std", derive(Hash))]
|
||||
pub struct Public($public);
|
||||
}
|
||||
|
||||
@@ -239,8 +241,12 @@ macro_rules! app_crypto {
|
||||
|
||||
$crate::wrap! {
|
||||
/// A generic `AppPublic` wrapper type over $public crypto; this has no specific App.
|
||||
#[derive(Clone, Default, Eq, PartialEq, $crate::codec::Encode, $crate::codec::Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug, Hash))]
|
||||
#[derive(Clone, Default, Eq, PartialEq,
|
||||
$crate::codec::Encode,
|
||||
$crate::codec::Decode,
|
||||
$crate::RuntimeDebug,
|
||||
)]
|
||||
#[cfg_attr(feature = "std", derive(Hash))]
|
||||
pub struct Signature($sig);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,12 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use primitives::crypto::{KeyTypeId, CryptoType, IsWrappedBy, Public};
|
||||
#[cfg(feature = "std")]
|
||||
use primitives::crypto::Pair;
|
||||
|
||||
use codec::Codec;
|
||||
use primitives::crypto::{KeyTypeId, CryptoType, IsWrappedBy, Public};
|
||||
use rstd::fmt::Debug;
|
||||
|
||||
/// An application-specific key.
|
||||
pub trait AppKey: 'static + Send + Sync + Sized + CryptoType + Clone {
|
||||
@@ -38,23 +40,25 @@ pub trait AppKey: 'static + Send + Sync + Sized + CryptoType + Clone {
|
||||
const ID: KeyTypeId;
|
||||
}
|
||||
|
||||
/// Type which implements Debug and Hash in std, not when no-std (std variant).
|
||||
/// Type which implements Hash in std, not when no-std (std variant).
|
||||
#[cfg(feature = "std")]
|
||||
pub trait MaybeDebugHash: std::fmt::Debug + std::hash::Hash {}
|
||||
pub trait MaybeHash: std::hash::Hash {}
|
||||
#[cfg(feature = "std")]
|
||||
impl<T: std::fmt::Debug + std::hash::Hash> MaybeDebugHash for T {}
|
||||
impl<T: std::hash::Hash> MaybeHash for T {}
|
||||
|
||||
/// Type which implements Debug and Hash in std, not when no-std (no-std variant).
|
||||
/// Type which implements Hash in std, not when no-std (no-std variant).
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub trait MaybeDebugHash {}
|
||||
pub trait MaybeHash {}
|
||||
#[cfg(not(feature = "std"))]
|
||||
impl<T> MaybeDebugHash for T {}
|
||||
impl<T> MaybeHash for T {}
|
||||
|
||||
/// A application's public key.
|
||||
pub trait AppPublic: AppKey + Public + Ord + PartialOrd + Eq + PartialEq + MaybeDebugHash + codec::Codec {
|
||||
pub trait AppPublic:
|
||||
AppKey + Public + Ord + PartialOrd + Eq + PartialEq + Debug + MaybeHash + codec::Codec
|
||||
{
|
||||
/// The wrapped type which is just a plain instance of `Public`.
|
||||
type Generic:
|
||||
IsWrappedBy<Self> + Public + Ord + PartialOrd + Eq + PartialEq + MaybeDebugHash + codec::Codec;
|
||||
IsWrappedBy<Self> + Public + Ord + PartialOrd + Eq + PartialEq + Debug + MaybeHash + codec::Codec;
|
||||
}
|
||||
|
||||
/// A application's key pair.
|
||||
@@ -65,15 +69,15 @@ pub trait AppPair: AppKey + Pair<Public=<Self as AppKey>::Public> {
|
||||
}
|
||||
|
||||
/// A application's signature.
|
||||
pub trait AppSignature: AppKey + Eq + PartialEq + MaybeDebugHash {
|
||||
pub trait AppSignature: AppKey + Eq + PartialEq + Debug + MaybeHash {
|
||||
/// The wrapped type which is just a plain instance of `Signature`.
|
||||
type Generic: IsWrappedBy<Self> + Eq + PartialEq + MaybeDebugHash;
|
||||
type Generic: IsWrappedBy<Self> + Eq + PartialEq + Debug + MaybeHash;
|
||||
}
|
||||
|
||||
/// A runtime interface for a public key.
|
||||
pub trait RuntimePublic: Sized {
|
||||
/// The signature that will be generated when signing with the corresponding private key.
|
||||
type Signature: Codec + MaybeDebugHash + Eq + PartialEq + Clone;
|
||||
type Signature: Codec + Debug + MaybeHash + Eq + PartialEq + Clone;
|
||||
|
||||
/// Returns all public keys for the given key type in the keystore.
|
||||
fn all(key_type: KeyTypeId) -> crate::Vec<Self>;
|
||||
@@ -101,7 +105,7 @@ pub trait RuntimeAppPublic: Sized {
|
||||
const ID: KeyTypeId;
|
||||
|
||||
/// The signature that will be generated when signing with the corresponding private key.
|
||||
type Signature: Codec + MaybeDebugHash + Eq + PartialEq + Clone;
|
||||
type Signature: Codec + Debug + MaybeHash + Eq + PartialEq + Clone;
|
||||
|
||||
/// Returns all public keys for this application in the keystore.
|
||||
fn all() -> crate::Vec<Self>;
|
||||
|
||||
Reference in New Issue
Block a user