mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 04:01:02 +00:00
Move Chain trait to runtime primitives (#403)
* extract ChainBase to bp-runtime * post-merge fixes * cargo fmt --all * compilation fixes * reexport BlockNumberOf, HashOf, HeaderOf
This commit is contained in:
committed by
Bastian Köcher
parent
ddeb59d336
commit
9e9ac8df3c
@@ -16,51 +16,19 @@
|
||||
|
||||
use crate::client::Client;
|
||||
|
||||
use bp_runtime::Chain as ChainBase;
|
||||
use frame_support::Parameter;
|
||||
use jsonrpsee::common::{DeserializeOwned, Serialize};
|
||||
use sp_core::Pair;
|
||||
use sp_runtime::{
|
||||
generic::SignedBlock,
|
||||
traits::{
|
||||
AtLeast32Bit, AtLeast32BitUnsigned, Bounded, CheckEqual, Dispatchable, Header as HeaderT, MaybeDisplay,
|
||||
MaybeMallocSizeOf, MaybeSerialize, MaybeSerializeDeserialize, Member, SimpleBitOps,
|
||||
},
|
||||
traits::{AtLeast32Bit, Dispatchable, MaybeDisplay, MaybeSerialize, MaybeSerializeDeserialize, Member},
|
||||
Justification,
|
||||
};
|
||||
use sp_std::fmt::Debug;
|
||||
|
||||
/// Substrate-based chain from minimal relay-client point of view.
|
||||
pub trait Chain {
|
||||
/// The block number type used by the runtime.
|
||||
type BlockNumber: Parameter
|
||||
+ Member
|
||||
+ MaybeSerializeDeserialize
|
||||
+ Debug
|
||||
+ MaybeDisplay
|
||||
+ AtLeast32BitUnsigned
|
||||
+ Default
|
||||
+ Bounded
|
||||
+ Copy
|
||||
+ sp_std::hash::Hash
|
||||
+ sp_std::str::FromStr
|
||||
+ MaybeMallocSizeOf;
|
||||
/// The output of the `Hashing` function.
|
||||
type Hash: Parameter
|
||||
+ Member
|
||||
+ MaybeSerializeDeserialize
|
||||
+ Debug
|
||||
+ MaybeDisplay
|
||||
+ SimpleBitOps
|
||||
+ Ord
|
||||
+ Default
|
||||
+ Copy
|
||||
+ CheckEqual
|
||||
+ sp_std::hash::Hash
|
||||
+ AsRef<[u8]>
|
||||
+ AsMut<[u8]>
|
||||
+ MaybeMallocSizeOf;
|
||||
/// The block header.
|
||||
type Header: Parameter + HeaderT<Number = Self::BlockNumber, Hash = Self::Hash>;
|
||||
pub trait Chain: ChainBase {
|
||||
/// The user account identifier type for the runtime.
|
||||
type AccountId: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + Ord + Default;
|
||||
/// Account index (aka nonce) type. This stores the number of previous transactions associated
|
||||
@@ -96,15 +64,6 @@ pub trait TransactionSignScheme {
|
||||
) -> Self::SignedTransaction;
|
||||
}
|
||||
|
||||
/// Header type used by the chain.
|
||||
pub type HeaderOf<C> = <C as Chain>::Header;
|
||||
|
||||
/// Hash type used by the chain.
|
||||
pub type HashOf<C> = <C as Chain>::Hash;
|
||||
|
||||
/// Block number used by the chain.
|
||||
pub type BlockNumberOf<C> = <C as Chain>::BlockNumber;
|
||||
|
||||
impl<Block> BlockWithJustification for SignedBlock<Block> {
|
||||
fn justification(&self) -> Option<&Justification> {
|
||||
self.justification.as_ref()
|
||||
|
||||
@@ -25,9 +25,10 @@ mod rpc;
|
||||
|
||||
pub mod headers_source;
|
||||
|
||||
pub use crate::chain::{BlockNumberOf, BlockWithJustification, Chain, HashOf, HeaderOf, TransactionSignScheme};
|
||||
pub use crate::chain::{BlockWithJustification, Chain, TransactionSignScheme};
|
||||
pub use crate::client::{Client, OpaqueGrandpaAuthoritiesSet};
|
||||
pub use crate::error::{Error, Result};
|
||||
pub use bp_runtime::{BlockNumberOf, Chain as ChainBase, HashOf, HeaderOf};
|
||||
|
||||
/// Substrate connection params.
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
Reference in New Issue
Block a user