rename ChainWithMessages -> UnderlyingChainProvider (#1639)

This commit is contained in:
Svyatoslav Nikolsky
2022-11-14 14:33:54 +03:00
committed by Bastian Köcher
parent 6dcecf4425
commit 3c76889948
5 changed files with 20 additions and 20 deletions
@@ -116,7 +116,7 @@ impl MessageBridge for WithRialtoMessageBridge {
#[derive(RuntimeDebug, Clone, Copy)] #[derive(RuntimeDebug, Clone, Copy)]
pub struct Millau; pub struct Millau;
impl messages::ChainWithMessages for Millau { impl messages::UnderlyingChainProvider for Millau {
type Chain = bp_millau::Millau; type Chain = bp_millau::Millau;
} }
@@ -174,7 +174,7 @@ impl messages::ThisChainWithMessages for Millau {
#[derive(RuntimeDebug, Clone, Copy)] #[derive(RuntimeDebug, Clone, Copy)]
pub struct Rialto; pub struct Rialto;
impl messages::ChainWithMessages for Rialto { impl messages::UnderlyingChainProvider for Rialto {
type Chain = bp_rialto::Rialto; type Chain = bp_rialto::Rialto;
} }
@@ -123,7 +123,7 @@ impl MessageBridge for WithRialtoParachainMessageBridge {
#[derive(RuntimeDebug, Clone, Copy)] #[derive(RuntimeDebug, Clone, Copy)]
pub struct Millau; pub struct Millau;
impl messages::ChainWithMessages for Millau { impl messages::UnderlyingChainProvider for Millau {
type Chain = bp_millau::Millau; type Chain = bp_millau::Millau;
} }
@@ -165,7 +165,7 @@ impl messages::ThisChainWithMessages for Millau {
#[derive(RuntimeDebug, Clone, Copy)] #[derive(RuntimeDebug, Clone, Copy)]
pub struct RialtoParachain; pub struct RialtoParachain;
impl messages::ChainWithMessages for RialtoParachain { impl messages::UnderlyingChainProvider for RialtoParachain {
type Chain = bp_rialto_parachain::RialtoParachain; type Chain = bp_rialto_parachain::RialtoParachain;
} }
@@ -120,7 +120,7 @@ impl MessageBridge for WithMillauMessageBridge {
#[derive(RuntimeDebug, Clone, Copy)] #[derive(RuntimeDebug, Clone, Copy)]
pub struct RialtoParachain; pub struct RialtoParachain;
impl messages::ChainWithMessages for RialtoParachain { impl messages::UnderlyingChainProvider for RialtoParachain {
type Chain = bp_rialto_parachain::RialtoParachain; type Chain = bp_rialto_parachain::RialtoParachain;
} }
@@ -181,7 +181,7 @@ impl messages::ThisChainWithMessages for RialtoParachain {
#[derive(RuntimeDebug, Clone, Copy)] #[derive(RuntimeDebug, Clone, Copy)]
pub struct Millau; pub struct Millau;
impl messages::ChainWithMessages for Millau { impl messages::UnderlyingChainProvider for Millau {
type Chain = bp_millau::Millau; type Chain = bp_millau::Millau;
} }
@@ -114,7 +114,7 @@ impl MessageBridge for WithMillauMessageBridge {
#[derive(RuntimeDebug, Clone, Copy)] #[derive(RuntimeDebug, Clone, Copy)]
pub struct Rialto; pub struct Rialto;
impl messages::ChainWithMessages for Rialto { impl messages::UnderlyingChainProvider for Rialto {
type Chain = bp_rialto::Rialto; type Chain = bp_rialto::Rialto;
} }
@@ -172,7 +172,7 @@ impl messages::ThisChainWithMessages for Rialto {
#[derive(RuntimeDebug, Clone, Copy)] #[derive(RuntimeDebug, Clone, Copy)]
pub struct Millau; pub struct Millau;
impl messages::ChainWithMessages for Millau { impl messages::UnderlyingChainProvider for Millau {
type Chain = bp_millau::Millau; type Chain = bp_millau::Millau;
} }
+12 -12
View File
@@ -58,7 +58,7 @@ pub trait MessageBridge {
/// Bridged chain in context of message bridge. /// Bridged chain in context of message bridge.
type BridgedChain: BridgedChainWithMessages; type BridgedChain: BridgedChainWithMessages;
/// Bridged header chain. /// Bridged header chain.
type BridgedHeaderChain: HeaderChain<<Self::BridgedChain as ChainWithMessages>::Chain>; type BridgedHeaderChain: HeaderChain<UnderlyingChainOf<Self::BridgedChain>>;
/// Convert Bridged chain balance into This chain balance. /// Convert Bridged chain balance into This chain balance.
fn bridged_balance_to_this_balance( fn bridged_balance_to_this_balance(
@@ -115,14 +115,14 @@ impl<
} }
} }
/// Chain that has `pallet-bridge-messages` module. /// A trait that provides the type of the underlying chain.
pub trait ChainWithMessages { pub trait UnderlyingChainProvider {
/// Underlying chain type. /// Underlying chain type.
type Chain: Chain; type Chain: Chain;
} }
/// This chain that has `pallet-bridge-messages` module. /// This chain that has `pallet-bridge-messages` module.
pub trait ThisChainWithMessages: ChainWithMessages { pub trait ThisChainWithMessages: UnderlyingChainProvider {
/// Call origin on the chain. /// Call origin on the chain.
type RuntimeOrigin; type RuntimeOrigin;
/// Call type on the chain. /// Call type on the chain.
@@ -149,7 +149,7 @@ pub trait ThisChainWithMessages: ChainWithMessages {
} }
/// Bridged chain that has `pallet-bridge-messages` module. /// Bridged chain that has `pallet-bridge-messages` module.
pub trait BridgedChainWithMessages: ChainWithMessages { pub trait BridgedChainWithMessages: UnderlyingChainProvider {
/// Returns `true` if message dispatch weight is withing expected limits. `false` means /// Returns `true` if message dispatch weight is withing expected limits. `false` means
/// that the message is too heavy to be sent over the bridge and shall be rejected. /// that the message is too heavy to be sent over the bridge and shall be rejected.
fn verify_dispatch_weight(message_payload: &[u8]) -> bool; fn verify_dispatch_weight(message_payload: &[u8]) -> bool;
@@ -171,15 +171,15 @@ pub type ThisChain<B> = <B as MessageBridge>::ThisChain;
/// Bridged chain in context of message bridge. /// Bridged chain in context of message bridge.
pub type BridgedChain<B> = <B as MessageBridge>::BridgedChain; pub type BridgedChain<B> = <B as MessageBridge>::BridgedChain;
/// Underlying chain type. /// Underlying chain type.
pub type UnderlyingChainOf<C> = <C as ChainWithMessages>::Chain; pub type UnderlyingChainOf<C> = <C as UnderlyingChainProvider>::Chain;
/// Hash used on the chain. /// Hash used on the chain.
pub type HashOf<C> = bp_runtime::HashOf<<C as ChainWithMessages>::Chain>; pub type HashOf<C> = bp_runtime::HashOf<<C as UnderlyingChainProvider>::Chain>;
/// Hasher used on the chain. /// Hasher used on the chain.
pub type HasherOf<C> = bp_runtime::HasherOf<<C as ChainWithMessages>::Chain>; pub type HasherOf<C> = bp_runtime::HasherOf<UnderlyingChainOf<C>>;
/// Account id used on the chain. /// Account id used on the chain.
pub type AccountIdOf<C> = bp_runtime::AccountIdOf<<C as ChainWithMessages>::Chain>; pub type AccountIdOf<C> = bp_runtime::AccountIdOf<UnderlyingChainOf<C>>;
/// Type of balances that is used on the chain. /// Type of balances that is used on the chain.
pub type BalanceOf<C> = bp_runtime::BalanceOf<<C as ChainWithMessages>::Chain>; pub type BalanceOf<C> = bp_runtime::BalanceOf<UnderlyingChainOf<C>>;
/// Type of origin that is used on the chain. /// Type of origin that is used on the chain.
pub type OriginOf<C> = <C as ThisChainWithMessages>::RuntimeOrigin; pub type OriginOf<C> = <C as ThisChainWithMessages>::RuntimeOrigin;
/// Type of call that is used on this chain. /// Type of call that is used on this chain.
@@ -996,7 +996,7 @@ mod tests {
struct ThisChain; struct ThisChain;
impl ChainWithMessages for ThisChain { impl UnderlyingChainProvider for ThisChain {
type Chain = ThisUnderlyingChain; type Chain = ThisUnderlyingChain;
} }
@@ -1071,7 +1071,7 @@ mod tests {
struct BridgedChain; struct BridgedChain;
impl ChainWithMessages for BridgedChain { impl UnderlyingChainProvider for BridgedChain {
type Chain = BridgedUnderlyingChain; type Chain = BridgedUnderlyingChain;
} }