Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename ChainWithMessages -> UnderlyingChainProvider #1639

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/millau/runtime/src/rialto_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl MessageBridge for WithRialtoMessageBridge {
#[derive(RuntimeDebug, Clone, Copy)]
pub struct Millau;

impl messages::ChainWithMessages for Millau {
impl messages::UnderlyingChainProvider for Millau {
type Chain = bp_millau::Millau;
}

Expand Down Expand Up @@ -174,7 +174,7 @@ impl messages::ThisChainWithMessages for Millau {
#[derive(RuntimeDebug, Clone, Copy)]
pub struct Rialto;

impl messages::ChainWithMessages for Rialto {
impl messages::UnderlyingChainProvider for Rialto {
type Chain = bp_rialto::Rialto;
}

Expand Down
4 changes: 2 additions & 2 deletions bin/millau/runtime/src/rialto_parachain_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl MessageBridge for WithRialtoParachainMessageBridge {
#[derive(RuntimeDebug, Clone, Copy)]
pub struct Millau;

impl messages::ChainWithMessages for Millau {
impl messages::UnderlyingChainProvider for Millau {
type Chain = bp_millau::Millau;
}

Expand Down Expand Up @@ -165,7 +165,7 @@ impl messages::ThisChainWithMessages for Millau {
#[derive(RuntimeDebug, Clone, Copy)]
pub struct RialtoParachain;

impl messages::ChainWithMessages for RialtoParachain {
impl messages::UnderlyingChainProvider for RialtoParachain {
type Chain = bp_rialto_parachain::RialtoParachain;
}

Expand Down
4 changes: 2 additions & 2 deletions bin/rialto-parachain/runtime/src/millau_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl MessageBridge for WithMillauMessageBridge {
#[derive(RuntimeDebug, Clone, Copy)]
pub struct RialtoParachain;

impl messages::ChainWithMessages for RialtoParachain {
impl messages::UnderlyingChainProvider for RialtoParachain {
type Chain = bp_rialto_parachain::RialtoParachain;
}

Expand Down Expand Up @@ -181,7 +181,7 @@ impl messages::ThisChainWithMessages for RialtoParachain {
#[derive(RuntimeDebug, Clone, Copy)]
pub struct Millau;

impl messages::ChainWithMessages for Millau {
impl messages::UnderlyingChainProvider for Millau {
type Chain = bp_millau::Millau;
}

Expand Down
4 changes: 2 additions & 2 deletions bin/rialto/runtime/src/millau_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl MessageBridge for WithMillauMessageBridge {
#[derive(RuntimeDebug, Clone, Copy)]
pub struct Rialto;

impl messages::ChainWithMessages for Rialto {
impl messages::UnderlyingChainProvider for Rialto {
type Chain = bp_rialto::Rialto;
}

Expand Down Expand Up @@ -172,7 +172,7 @@ impl messages::ThisChainWithMessages for Rialto {
#[derive(RuntimeDebug, Clone, Copy)]
pub struct Millau;

impl messages::ChainWithMessages for Millau {
impl messages::UnderlyingChainProvider for Millau {
type Chain = bp_millau::Millau;
}

Expand Down
24 changes: 12 additions & 12 deletions bin/runtime-common/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub trait MessageBridge {
/// Bridged chain in context of message bridge.
type BridgedChain: BridgedChainWithMessages;
/// 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.
fn bridged_balance_to_this_balance(
Expand Down Expand Up @@ -115,14 +115,14 @@ impl<
}
}

/// Chain that has `pallet-bridge-messages` module.
pub trait ChainWithMessages {
/// A trait that provides the type of the underlying chain.
pub trait UnderlyingChainProvider {
/// Underlying chain type.
type Chain: Chain;
}

/// This chain that has `pallet-bridge-messages` module.
pub trait ThisChainWithMessages: ChainWithMessages {
pub trait ThisChainWithMessages: UnderlyingChainProvider {
/// Call origin on the chain.
type RuntimeOrigin;
/// Call type on the chain.
Expand All @@ -149,7 +149,7 @@ pub trait ThisChainWithMessages: ChainWithMessages {
}

/// 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
/// that the message is too heavy to be sent over the bridge and shall be rejected.
fn verify_dispatch_weight(message_payload: &[u8]) -> bool;
Expand All @@ -171,15 +171,15 @@ pub type ThisChain<B> = <B as MessageBridge>::ThisChain;
/// Bridged chain in context of message bridge.
pub type BridgedChain<B> = <B as MessageBridge>::BridgedChain;
/// Underlying chain type.
pub type UnderlyingChainOf<C> = <C as ChainWithMessages>::Chain;
pub type UnderlyingChainOf<C> = <C as UnderlyingChainProvider>::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.
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.
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.
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.
pub type OriginOf<C> = <C as ThisChainWithMessages>::RuntimeOrigin;
/// Type of call that is used on this chain.
Expand Down Expand Up @@ -996,7 +996,7 @@ mod tests {

struct ThisChain;

impl ChainWithMessages for ThisChain {
impl UnderlyingChainProvider for ThisChain {
type Chain = ThisUnderlyingChain;
}

Expand Down Expand Up @@ -1071,7 +1071,7 @@ mod tests {

struct BridgedChain;

impl ChainWithMessages for BridgedChain {
impl UnderlyingChainProvider for BridgedChain {
type Chain = BridgedUnderlyingChain;
}

Expand Down