mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
Refactor sr-api to not depend on client anymore (#4086)
* Refactor sr-api to not depend on client anymore * Fix benches * Apply suggestions from code review Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Apply suggestions from code review
This commit is contained in:
committed by
Benjamin Kampmann
parent
e26d1a0b3e
commit
2ecffa1cd0
@@ -45,12 +45,11 @@ use rstd::convert::TryFrom;
|
||||
use primitives::{crypto, ed25519, sr25519, ecdsa, hash::{H256, H512}};
|
||||
use codec::{Encode, Decode};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub mod testing;
|
||||
|
||||
pub mod curve;
|
||||
pub mod generic;
|
||||
pub mod offchain;
|
||||
#[cfg(feature = "std")]
|
||||
pub mod testing;
|
||||
pub mod traits;
|
||||
pub mod transaction_validity;
|
||||
pub mod weights;
|
||||
@@ -93,19 +92,19 @@ impl TypeId for ModuleId {
|
||||
|
||||
/// A String that is a `&'static str` on `no_std` and a `Cow<'static, str>` on `std`.
|
||||
#[cfg(feature = "std")]
|
||||
pub type RuntimeString = ::std::borrow::Cow<'static, str>;
|
||||
pub type RuntimeString = std::borrow::Cow<'static, str>;
|
||||
/// A String that is a `&'static str` on `no_std` and a `Cow<'static, str>` on `std`.
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub type RuntimeString = &'static str;
|
||||
|
||||
/// Create a const [RuntimeString].
|
||||
/// Create a const [`RuntimeString`].
|
||||
#[cfg(feature = "std")]
|
||||
#[macro_export]
|
||||
macro_rules! create_runtime_str {
|
||||
( $y:expr ) => {{ ::std::borrow::Cow::Borrowed($y) }}
|
||||
( $y:expr ) => {{ std::borrow::Cow::Borrowed($y) }}
|
||||
}
|
||||
|
||||
/// Create a const [RuntimeString].
|
||||
/// Create a const [`RuntimeString`].
|
||||
#[cfg(not(feature = "std"))]
|
||||
#[macro_export]
|
||||
macro_rules! create_runtime_str {
|
||||
|
||||
@@ -1250,6 +1250,25 @@ impl Printable for Tuple {
|
||||
}
|
||||
}
|
||||
|
||||
/// Something that can convert a [`BlockId`] to a number or a hash.
|
||||
#[cfg(feature = "std")]
|
||||
pub trait BlockIdTo<Block: self::Block> {
|
||||
/// The error type that will be returned by the functions.
|
||||
type Error: std::fmt::Debug;
|
||||
|
||||
/// Convert the given `block_id` to the corresponding block hash.
|
||||
fn to_hash(
|
||||
&self,
|
||||
block_id: &crate::generic::BlockId<Block>,
|
||||
) -> Result<Option<Block::Hash>, Self::Error>;
|
||||
|
||||
/// Convert the given `block_id` to the corresponding block number.
|
||||
fn to_number(
|
||||
&self,
|
||||
block_id: &crate::generic::BlockId<Block>,
|
||||
) -> Result<Option<NumberFor<Block>>, Self::Error>;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::AccountIdConversion;
|
||||
|
||||
Reference in New Issue
Block a user