Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

XcmpQueue simplify - PriceForSiblingDelivery replaced by runtime::common::PriceForParachainDelivery #3012

Merged
merged 1 commit into from
Aug 15, 2023
Merged
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
22 changes: 3 additions & 19 deletions pallets/xcmp-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use frame_support::{
traits::{EnsureOrigin, Get},
weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, Weight},
};
use polkadot_runtime_common::xcm_sender::ConstantPrice;
use polkadot_runtime_common::xcm_sender::PriceForParachainDelivery;
use rand_chacha::{
rand_core::{RngCore, SeedableRng},
ChaChaRng,
Expand Down Expand Up @@ -107,7 +107,7 @@ pub mod pallet {
type ControllerOriginConverter: ConvertOrigin<Self::RuntimeOrigin>;

/// The price for delivering an XCM to a sibling parachain destination.
type PriceForSiblingDelivery: PriceForSiblingDelivery;
type PriceForSiblingDelivery: PriceForParachainDelivery;

/// The weight information of this pallet.
type WeightInfo: WeightInfo;
Expand Down Expand Up @@ -1137,22 +1137,6 @@ impl<T: Config> XcmpMessageSource for Pallet<T> {
}
}

pub trait PriceForSiblingDelivery {
fn price_for_sibling_delivery(id: ParaId, message: &Xcm<()>) -> MultiAssets;
}

impl PriceForSiblingDelivery for () {
fn price_for_sibling_delivery(_: ParaId, _: &Xcm<()>) -> MultiAssets {
MultiAssets::new()
}
}

impl<T: Get<MultiAssets>> PriceForSiblingDelivery for ConstantPrice<T> {
fn price_for_sibling_delivery(_: ParaId, _: &Xcm<()>) -> MultiAssets {
T::get()
}
}

/// Xcm sender for sending to a sibling parachain.
impl<T: Config> SendXcm for Pallet<T> {
type Ticket = (ParaId, VersionedXcm<()>);
Expand All @@ -1168,7 +1152,7 @@ impl<T: Config> SendXcm for Pallet<T> {
MultiLocation { parents: 1, interior: X1(Parachain(id)) } => {
let xcm = msg.take().ok_or(SendError::MissingArgument)?;
let id = ParaId::from(*id);
let price = T::PriceForSiblingDelivery::price_for_sibling_delivery(id, &xcm);
let price = T::PriceForSiblingDelivery::price_for_parachain_delivery(id, &xcm);
let versioned_xcm = T::VersionWrapper::wrap_version(&d, xcm)
.map_err(|()| SendError::DestinationUnsupported)?;
Ok(((id, versioned_xcm), price))
Expand Down