asset_hub_westend_runtime/governance/
impls.rs1#[cfg(feature = "runtime-benchmarks")]
16pub mod benchmarks {
17 use crate::ParachainSystem;
18 use core::marker::PhantomData;
19 use cumulus_primitives_core::{ChannelStatus, GetChannelInfo};
20 use frame_support::traits::{
21 tokens::{Pay, PaymentStatus},
22 Get,
23 };
24
25 pub trait EnsureSuccessful {
27 fn ensure_successful();
28 }
29
30 pub struct OpenHrmpChannel<I>(PhantomData<I>);
33 impl<I: Get<u32>> EnsureSuccessful for OpenHrmpChannel<I> {
34 fn ensure_successful() {
35 if let ChannelStatus::Closed = ParachainSystem::get_channel_status(I::get().into()) {
36 ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(I::get().into())
37 }
38 }
39 }
40
41 pub struct PayWithEnsure<O, E>(PhantomData<(O, E)>);
45 impl<O, E> Pay for PayWithEnsure<O, E>
46 where
47 O: Pay,
48 E: EnsureSuccessful,
49 {
50 type AssetKind = O::AssetKind;
51 type Balance = O::Balance;
52 type Beneficiary = O::Beneficiary;
53 type Error = O::Error;
54 type Id = O::Id;
55
56 fn pay(
57 who: &Self::Beneficiary,
58 asset_kind: Self::AssetKind,
59 amount: Self::Balance,
60 ) -> Result<Self::Id, Self::Error> {
61 O::pay(who, asset_kind, amount)
62 }
63 fn check_payment(id: Self::Id) -> PaymentStatus {
64 O::check_payment(id)
65 }
66 fn ensure_successful(
67 who: &Self::Beneficiary,
68 asset_kind: Self::AssetKind,
69 amount: Self::Balance,
70 ) {
71 E::ensure_successful();
72 O::ensure_successful(who, asset_kind, amount)
73 }
74 fn ensure_concluded(id: Self::Id) {
75 O::ensure_concluded(id)
76 }
77 }
78}