mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
Move some associated types from relay_substrate_client::Chain to bp_runtime::Chain (#1087)
* move some associated types from relay_substrate_client::Chain to bp_runtime::Chain * dummy commit * Revert "dummy commit" This reverts commit 81bc64aa092df115a7c68e7bb7ca5e83ec31fd20.
This commit is contained in:
committed by
Bastian Köcher
parent
1df7076c4f
commit
7369ff9d70
@@ -16,17 +16,14 @@
|
||||
|
||||
use bp_runtime::{Chain as ChainBase, TransactionEraOf};
|
||||
use codec::{Codec, Encode};
|
||||
use frame_support::{weights::WeightToFeePolynomial, Parameter};
|
||||
use frame_support::weights::WeightToFeePolynomial;
|
||||
use jsonrpsee_ws_client::{DeserializeOwned, Serialize};
|
||||
use num_traits::{Bounded, CheckedSub, SaturatingAdd, Zero};
|
||||
use num_traits::Zero;
|
||||
use sp_core::{storage::StorageKey, Pair};
|
||||
use sp_runtime::{
|
||||
generic::SignedBlock,
|
||||
traits::{
|
||||
AtLeast32Bit, AtLeast32BitUnsigned, Block as BlockT, Dispatchable, MaybeDisplay, MaybeSerialize,
|
||||
MaybeSerializeDeserialize, Member,
|
||||
},
|
||||
EncodedJustification, FixedPointOperand,
|
||||
traits::{Block as BlockT, Dispatchable, Member},
|
||||
EncodedJustification,
|
||||
};
|
||||
use std::{fmt::Debug, time::Duration};
|
||||
|
||||
@@ -44,49 +41,15 @@ pub trait Chain: ChainBase + Clone {
|
||||
/// Maximal size (in bytes) of SCALE-encoded account id on this chain.
|
||||
const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32;
|
||||
|
||||
/// The user account identifier type for the runtime.
|
||||
type AccountId: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + Ord + Default;
|
||||
/// Index of a transaction used by the chain.
|
||||
type Index: Parameter
|
||||
+ Member
|
||||
+ MaybeSerialize
|
||||
+ Debug
|
||||
+ Default
|
||||
+ MaybeDisplay
|
||||
+ DeserializeOwned
|
||||
+ AtLeast32Bit
|
||||
+ Copy;
|
||||
/// Block type.
|
||||
type SignedBlock: Member + Serialize + DeserializeOwned + BlockWithJustification<Self::Header>;
|
||||
/// The aggregated `Call` type.
|
||||
type Call: Clone + Dispatchable + Debug;
|
||||
/// Balance of an account in native tokens.
|
||||
///
|
||||
/// The chain may support multiple tokens, but this particular type is for token that is used
|
||||
/// to pay for transaction dispatch, to reward different relayers (headers, messages), etc.
|
||||
type Balance: AtLeast32BitUnsigned
|
||||
+ FixedPointOperand
|
||||
+ Parameter
|
||||
+ Parameter
|
||||
+ Member
|
||||
+ DeserializeOwned
|
||||
+ Clone
|
||||
+ Copy
|
||||
+ Bounded
|
||||
+ CheckedSub
|
||||
+ PartialOrd
|
||||
+ SaturatingAdd
|
||||
+ Zero
|
||||
+ std::convert::TryFrom<sp_core::U256>;
|
||||
|
||||
/// Type that is used by the chain, to convert from weight to fee.
|
||||
type WeightToFee: WeightToFeePolynomial<Balance = Self::Balance>;
|
||||
}
|
||||
|
||||
/// Balance type used by the chain
|
||||
pub type BalanceOf<C> = <C as Chain>::Balance;
|
||||
/// Index type used by the chain
|
||||
pub type IndexOf<C> = <C as Chain>::Index;
|
||||
/// Weight-to-Fee type used by the chain
|
||||
pub type WeightToFeeOf<C> = <C as Chain>::WeightToFee;
|
||||
|
||||
|
||||
@@ -165,6 +165,7 @@ impl<C: ChainWithBalances> Environment<C> for Client<C> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use frame_support::weights::IdentityFee;
|
||||
use futures::{
|
||||
channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender},
|
||||
future::FutureExt,
|
||||
@@ -180,6 +181,11 @@ mod tests {
|
||||
type Hash = sp_core::H256;
|
||||
type Hasher = sp_runtime::traits::BlakeTwo256;
|
||||
type Header = sp_runtime::generic::Header<u32, sp_runtime::traits::BlakeTwo256>;
|
||||
|
||||
type AccountId = u32;
|
||||
type Balance = u32;
|
||||
type Index = u32;
|
||||
type Signature = sp_runtime::testing::TestSignature;
|
||||
}
|
||||
|
||||
impl Chain for TestChain {
|
||||
@@ -188,13 +194,10 @@ mod tests {
|
||||
const STORAGE_PROOF_OVERHEAD: u32 = 0;
|
||||
const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32 = 0;
|
||||
|
||||
type AccountId = u32;
|
||||
type Index = u32;
|
||||
type SignedBlock =
|
||||
sp_runtime::generic::SignedBlock<sp_runtime::generic::Block<Self::Header, sp_runtime::OpaqueExtrinsic>>;
|
||||
type Call = ();
|
||||
type Balance = u32;
|
||||
type WeightToFee = frame_support::weights::IdentityFee<u32>;
|
||||
type WeightToFee = IdentityFee<u32>;
|
||||
}
|
||||
|
||||
impl ChainWithBalances for TestChain {
|
||||
|
||||
@@ -32,13 +32,14 @@ pub mod metrics;
|
||||
use std::time::Duration;
|
||||
|
||||
pub use crate::chain::{
|
||||
BalanceOf, BlockWithJustification, Chain, ChainWithBalances, IndexOf, TransactionSignScheme, UnsignedTransaction,
|
||||
WeightToFeeOf,
|
||||
BlockWithJustification, Chain, ChainWithBalances, TransactionSignScheme, UnsignedTransaction, WeightToFeeOf,
|
||||
};
|
||||
pub use crate::client::{Client, JustificationsSubscription, OpaqueGrandpaAuthoritiesSet};
|
||||
pub use crate::error::{Error, Result};
|
||||
pub use crate::sync_header::SyncHeader;
|
||||
pub use bp_runtime::{BlockNumberOf, Chain as ChainBase, HashOf, HeaderOf, TransactionEra, TransactionEraOf};
|
||||
pub use bp_runtime::{
|
||||
BalanceOf, BlockNumberOf, Chain as ChainBase, HashOf, HeaderOf, IndexOf, TransactionEra, TransactionEraOf,
|
||||
};
|
||||
|
||||
/// Header id used by the chain.
|
||||
pub type HeaderIdOf<C> = relay_utils::HeaderId<HashOf<C>, BlockNumberOf<C>>;
|
||||
|
||||
Reference in New Issue
Block a user