From 190f98427b96445bf43b48b896e4b6db153f26c1 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Mon, 28 Jul 2025 10:07:30 -0300 Subject: [PATCH] chore: use the common query_weight_to_asset_fee for relays too --- relay/kusama/src/lib.rs | 20 ++++---------------- relay/polkadot/src/lib.rs | 20 ++++---------------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/relay/kusama/src/lib.rs b/relay/kusama/src/lib.rs index 913a347760..78f94a8688 100644 --- a/relay/kusama/src/lib.rs +++ b/relay/kusama/src/lib.rs @@ -56,7 +56,7 @@ use frame_support::{ }, weights::{ constants::{WEIGHT_PROOF_SIZE_PER_KB, WEIGHT_REF_TIME_PER_MICROS}, - ConstantMultiplier, WeightMeter, WeightToFee as _, + ConstantMultiplier, WeightMeter, }, PalletId, }; @@ -2931,21 +2931,9 @@ sp_api::impl_runtime_apis! { } fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result { - let latest_asset_id: Result = asset.clone().try_into(); - match latest_asset_id { - Ok(asset_id) if asset_id.0 == xcm_config::TokenLocation::get() => { - // for native token - Ok(WeightToFee::weight_to_fee(&weight)) - }, - Ok(asset_id) => { - log::trace!(target: "xcm::xcm_runtime_apis", "query_weight_to_asset_fee - unhandled asset_id: {asset_id:?}!"); - Err(XcmPaymentApiError::AssetNotFound) - }, - Err(_) => { - log::trace!(target: "xcm::xcm_runtime_apis", "query_weight_to_asset_fee - failed to convert asset: {asset:?}!"); - Err(XcmPaymentApiError::VersionedConversionFailed) - } - } + use crate::xcm_config::XcmConfig; + type Trader = ::Trader; + XcmPallet::query_weight_to_asset_fee::(weight, asset) } fn query_xcm_weight(message: VersionedXcm<()>) -> Result { diff --git a/relay/polkadot/src/lib.rs b/relay/polkadot/src/lib.rs index e850d91633..bd4e79861c 100644 --- a/relay/polkadot/src/lib.rs +++ b/relay/polkadot/src/lib.rs @@ -52,7 +52,7 @@ use frame_support::{ }, weights::{ constants::{WEIGHT_PROOF_SIZE_PER_KB, WEIGHT_REF_TIME_PER_MICROS}, - ConstantMultiplier, WeightMeter, WeightToFee as _, + ConstantMultiplier, WeightMeter, }, PalletId, }; @@ -2730,21 +2730,9 @@ sp_api::impl_runtime_apis! { } fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result { - let latest_asset_id: Result = asset.clone().try_into(); - match latest_asset_id { - Ok(asset_id) if asset_id.0 == xcm_config::TokenLocation::get() => { - // for native token - Ok(WeightToFee::weight_to_fee(&weight)) - }, - Ok(asset_id) => { - log::trace!(target: "xcm::xcm_runtime_apis", "query_weight_to_asset_fee - unhandled asset_id: {asset_id:?}!"); - Err(XcmPaymentApiError::AssetNotFound) - }, - Err(_) => { - log::trace!(target: "xcm::xcm_runtime_apis", "query_weight_to_asset_fee - failed to convert asset: {asset:?}!"); - Err(XcmPaymentApiError::VersionedConversionFailed) - } - } + use crate::xcm_config::XcmConfig; + type Trader = ::Trader; + XcmPallet::query_weight_to_asset_fee::(weight, asset) } fn query_xcm_weight(message: VersionedXcm<()>) -> Result {