Skip to content

Commit

Permalink
revert DirectSubmitParachainHeadsCallBuilder removal
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik committed May 3, 2024
1 parent 0fabaea commit d54ad81
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion bridges/relays/lib-substrate-relay/src/parachains/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@

use async_trait::async_trait;
use bp_polkadot_core::parachains::{ParaHash, ParaHeadsProof, ParaId};
use pallet_bridge_parachains::{
Call as BridgeParachainsCall, Config as BridgeParachainsConfig, RelayBlockHash,
RelayBlockHasher, RelayBlockNumber,
};
use parachains_relay::ParachainsPipeline;
use relay_substrate_client::{CallOf, ChainWithTransactions, HeaderIdOf, Parachain, RelayChain};
use relay_substrate_client::{
CallOf, Chain, ChainWithTransactions, HeaderIdOf, Parachain, RelayChain,
};
use std::{fmt::Debug, marker::PhantomData};

pub mod source;
Expand Down Expand Up @@ -68,3 +74,37 @@ pub trait SubmitParachainHeadsCallBuilder<P: SubstrateParachainsPipeline>:
is_free_execution_expected: bool,
) -> CallOf<P::TargetChain>;
}

/// Building `submit_parachain_heads` call when you have direct access to the target
/// chain runtime.
pub struct DirectSubmitParachainHeadsCallBuilder<P, R, I> {
_phantom: PhantomData<(P, R, I)>,
}

impl<P, R, I> SubmitParachainHeadsCallBuilder<P> for DirectSubmitParachainHeadsCallBuilder<P, R, I>
where
P: SubstrateParachainsPipeline,
P::SourceRelayChain: Chain<Hash = RelayBlockHash, BlockNumber = RelayBlockNumber>,
R: BridgeParachainsConfig<I> + Send + Sync,
I: 'static + Send + Sync,
R::BridgedChain: bp_runtime::Chain<
BlockNumber = RelayBlockNumber,
Hash = RelayBlockHash,
Hasher = RelayBlockHasher,
>,
CallOf<P::TargetChain>: From<BridgeParachainsCall<R, I>>,
{
fn build_submit_parachain_heads_call(
at_relay_block: HeaderIdOf<P::SourceRelayChain>,
parachains: Vec<(ParaId, ParaHash)>,
parachain_heads_proof: ParaHeadsProof,
_is_free_execution_expected: bool,
) -> CallOf<P::TargetChain> {
BridgeParachainsCall::<R, I>::submit_parachain_heads {
at_relay_block: (at_relay_block.0, at_relay_block.1),
parachains,
parachain_heads_proof,
}
.into()
}
}

0 comments on commit d54ad81

Please sign in to comment.