Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5cf3671
feat: add asset_id parameter to query_delivery_fees
franciscoaguirre Oct 3, 2025
93c29d4
feat: add asset_id to pallet-xcm helper for delivery fees
franciscoaguirre Oct 7, 2025
4dad62d
test: add test in xcm-runtime-apis and asset-hub-westend-integration-…
franciscoaguirre Oct 10, 2025
770e095
Merge branch 'master' into query-delivery-fees-v2
franciscoaguirre Oct 10, 2025
a251dae
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] Oct 10, 2025
97d6c93
Update prdoc/pr_9963.prdoc
franciscoaguirre Oct 10, 2025
3810a16
Update prdoc/pr_9963.prdoc
franciscoaguirre Oct 10, 2025
c5b3984
Merge branch 'master' into query-delivery-fees-v2
franciscoaguirre Oct 20, 2025
d110c33
fix: ci
franciscoaguirre Oct 20, 2025
acc0134
fix(pallet-staking-async): add the asset_id parameter
franciscoaguirre Oct 20, 2025
4a258ca
Merge branch 'master' into query-delivery-fees-v2
franciscoaguirre Oct 20, 2025
c556fbf
ignore let binding
franciscoaguirre Oct 20, 2025
3754b5c
fix(pallet-staking-async): import XcmConfig correctly
franciscoaguirre Oct 20, 2025
9ac267e
fix: clippy
franciscoaguirre Oct 20, 2025
b596027
fix: tests
franciscoaguirre Oct 24, 2025
18b957c
fix: tests
franciscoaguirre Oct 24, 2025
afb31d0
Merge branch 'master' into query-delivery-fees-v2
franciscoaguirre Oct 24, 2025
87e85bf
fix: tests
franciscoaguirre Oct 24, 2025
fdaf184
chore: feedback
franciscoaguirre Oct 27, 2025
59b4874
Merge branch 'master' into query-delivery-fees-v2
franciscoaguirre Oct 27, 2025
6f2a473
Merge branch 'master' into query-delivery-fees-v2
franciscoaguirre Oct 27, 2025
3e704fe
Update polkadot/xcm/pallet-xcm/src/lib.rs
franciscoaguirre Oct 28, 2025
566c3f3
chore: feedback
franciscoaguirre Oct 28, 2025
0c9ee33
Merge branch 'master' into query-delivery-fees-v2
acatangiu Oct 30, 2025
2b3d031
Merge branch 'master' into query-delivery-fees-v2
franciscoaguirre Oct 30, 2025
3406ce0
Merge branch 'master' into query-delivery-fees-v2
franciscoaguirre Oct 30, 2025
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
68 changes: 46 additions & 22 deletions cumulus/parachains/integration-tests/emulated/common/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub use frame_support::{
};
pub use xcm_runtime_apis::{
dry_run::runtime_decl_for_dry_run_api::DryRunApiV2,
fees::{runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, Error as XcmPaymentApiError},
fees::{runtime_decl_for_xcm_payment_api::XcmPaymentApiV2, Error as XcmPaymentApiError},
};

pub use frame_support::traits::{fungible::Mutate, fungibles::Inspect, Currency};
Expand Down Expand Up @@ -124,9 +124,15 @@ macro_rules! test_parachain_is_trusted_teleporter {
.unwrap();
assert_eq!(messages_to_query.len(), 1);
remote_message = messages_to_query[0].clone();
// The native asset of every system chain.
// We want to get the delivery fees in this asset.
let asset_id_for_delivery_fees = VersionedAssetId::from(Location::new(1, []));
let delivery_fees =
<Runtime as $crate::macros::XcmPaymentApiV1<_>>::query_delivery_fees(destination_to_query.clone(),
remote_message.clone()).unwrap();
<Runtime as $crate::macros::XcmPaymentApiV2<_>>::query_delivery_fees(
destination_to_query.clone(),
remote_message.clone(),
asset_id_for_delivery_fees
).unwrap();
let latest_delivery_fees: $crate::macros::Assets = delivery_fees.clone().try_into().unwrap();
let $crate::macros::Fungible(inner_delivery_fees_amount) = latest_delivery_fees.inner()[0].fun else {
unreachable!("asset is non-fungible");
Expand Down Expand Up @@ -261,9 +267,15 @@ macro_rules! test_relay_is_trusted_teleporter {
.unwrap();
assert_eq!(messages_to_query.len(), 1);
remote_message = messages_to_query[0].clone();
// The native asset of every system chain.
// We want to get the delivery fees in this asset.
let asset_id_for_delivery_fees = VersionedAssetId::from(Location::new(0, []));
let delivery_fees =
<Runtime as $crate::macros::XcmPaymentApiV1<_>>::query_delivery_fees(destination_to_query.clone(),
remote_message.clone()).unwrap();
<Runtime as $crate::macros::XcmPaymentApiV2<_>>::query_delivery_fees(
destination_to_query.clone(),
remote_message.clone(),
asset_id_for_delivery_fees
).unwrap();
let latest_delivery_fees: $crate::macros::Assets = delivery_fees.clone().try_into().unwrap();
let $crate::macros::Fungible(inner_delivery_fees_amount) = latest_delivery_fees.inner()[0].fun else {
unreachable!("asset is non-fungible");
Expand Down Expand Up @@ -406,9 +418,15 @@ macro_rules! test_parachain_is_trusted_teleporter_for_relay {
.unwrap();
assert_eq!(messages_to_query.len(), 1);
remote_message = messages_to_query[0].clone();
// The native asset of every system chain.
// We want to get the delivery fees in this asset.
let asset_id_for_delivery_fees = VersionedAssetId::from(Location::parent());
let delivery_fees =
<Runtime as $crate::macros::XcmPaymentApiV1<_>>::query_delivery_fees(destination_to_query.clone(),
remote_message.clone()).unwrap();
<Runtime as $crate::macros::XcmPaymentApiV2<_>>::query_delivery_fees(
destination_to_query.clone(),
remote_message.clone(),
asset_id_for_delivery_fees
).unwrap();
let latest_delivery_fees: $crate::macros::Assets = delivery_fees.clone().try_into().unwrap();
delivery_fees_amount = if let Some(first_asset) = latest_delivery_fees.inner().first() {
let $crate::macros::Fungible(inner_delivery_fees_amount) = first_asset.fun else {
Expand Down Expand Up @@ -689,8 +707,8 @@ macro_rules! test_can_estimate_and_pay_exact_fees {
let result = <Runtime as $crate::macros::DryRunApiV2<_,_,_,_>>::dry_run_call(origin, call.clone(),
$crate::macros::XCM_VERSION).unwrap();
let local_xcm = result.local_xcm.unwrap().clone();
let local_xcm_weight = <Runtime as $crate::macros::XcmPaymentApiV1<_>>::query_xcm_weight(local_xcm).unwrap();
local_execution_fees = <Runtime as $crate::macros::XcmPaymentApiV1<_>>::query_weight_to_asset_fee(
let local_xcm_weight = <Runtime as $crate::macros::XcmPaymentApiV2<_>>::query_xcm_weight(local_xcm).unwrap();
local_execution_fees = <Runtime as $crate::macros::XcmPaymentApiV2<_>>::query_weight_to_asset_fee(
local_xcm_weight,
$crate::macros::VersionedAssetId::from($crate::macros::AssetId($crate::macros::Location::parent())),
)
Expand All @@ -706,9 +724,13 @@ macro_rules! test_can_estimate_and_pay_exact_fees {
.unwrap();
assert_eq!(messages_to_query.len(), 1);
remote_message = messages_to_query[0].clone();
let asset_id_for_delivery_fees = VersionedAssetId::from(Location::parent());
let delivery_fees =
<Runtime as $crate::macros::XcmPaymentApiV1<_>>::query_delivery_fees(destination_to_query.clone(),
remote_message.clone()).unwrap();
<Runtime as $crate::macros::XcmPaymentApiV2<_>>::query_delivery_fees(
destination_to_query.clone(),
remote_message.clone(),
asset_id_for_delivery_fees
).unwrap();
local_delivery_fees = $crate::xcm_helpers::get_amount_from_versioned_assets(delivery_fees);
});

Expand All @@ -721,8 +743,8 @@ macro_rules! test_can_estimate_and_pay_exact_fees {
type RuntimeCall = <$asset_hub as $crate::macros::Chain>::RuntimeCall;

// First we get the execution fees.
let weight = <Runtime as $crate::macros::XcmPaymentApiV1<_>>::query_xcm_weight(remote_message.clone()).unwrap();
intermediate_execution_fees = <Runtime as $crate::macros::XcmPaymentApiV1<_>>::query_weight_to_asset_fee(
let weight = <Runtime as $crate::macros::XcmPaymentApiV2<_>>::query_xcm_weight(remote_message.clone()).unwrap();
intermediate_execution_fees = <Runtime as $crate::macros::XcmPaymentApiV2<_>>::query_weight_to_asset_fee(
weight,
$crate::macros::VersionedAssetId::from($crate::macros::AssetId($crate::macros::Location::new(1, []))),
)
Expand Down Expand Up @@ -750,9 +772,11 @@ macro_rules! test_can_estimate_and_pay_exact_fees {
// We could've gotten the message from the queue without having to dry-run, but
// offchain applications would have to dry-run, so we do it here as well.
intermediate_remote_message = messages_to_query[0].clone();
let delivery_fees = <Runtime as $crate::macros::XcmPaymentApiV1<_>>::query_delivery_fees(
let asset_id_for_delivery_fees = VersionedAssetId::from(Location::parent());
let delivery_fees = <Runtime as $crate::macros::XcmPaymentApiV2<_>>::query_delivery_fees(
destination_to_query.clone(),
intermediate_remote_message.clone(),
asset_id_for_delivery_fees,
)
.unwrap();
intermediate_delivery_fees = $crate::xcm_helpers::get_amount_from_versioned_assets(delivery_fees);
Expand All @@ -763,10 +787,10 @@ macro_rules! test_can_estimate_and_pay_exact_fees {
<$receiver_para as $crate::macros::TestExt>::execute_with(|| {
type Runtime = <$sender_para as $crate::macros::Chain>::Runtime;

let weight = <Runtime as $crate::macros::XcmPaymentApiV1<_>>::query_xcm_weight(
let weight = <Runtime as $crate::macros::XcmPaymentApiV2<_>>::query_xcm_weight(
intermediate_remote_message.clone()).unwrap();
final_execution_fees =
<Runtime as $crate::macros::XcmPaymentApiV1<_>>::query_weight_to_asset_fee(weight,
<Runtime as $crate::macros::XcmPaymentApiV2<_>>::query_weight_to_asset_fee(weight,
$crate::macros::VersionedAssetId::from($crate::macros::AssetId($crate::macros::Location::parent())))
.unwrap();
});
Expand Down Expand Up @@ -903,7 +927,7 @@ macro_rules! test_xcm_fee_querying_apis_work_for_asset_hub {
));

type Runtime = <$asset_hub as $crate::macros::Chain>::Runtime;
let acceptable_payment_assets = <Runtime as $crate::macros::XcmPaymentApiV1<_>>::query_acceptable_payment_assets(
let acceptable_payment_assets = <Runtime as $crate::macros::XcmPaymentApiV2<_>>::query_acceptable_payment_assets(
$crate::macros::XCM_VERSION).unwrap();
assert_eq!(acceptable_payment_assets, vec![
$crate::macros::VersionedAssetId::from($crate::macros::AssetId(wnd.clone())),
Expand All @@ -915,12 +939,12 @@ macro_rules! test_xcm_fee_querying_apis_work_for_asset_hub {
.buy_execution(($crate::macros::Parent, 10u128), $crate::macros::Unlimited)
.deposit_asset($crate::macros::All, [0u8; 32])
.build();
let weight = <Runtime as $crate::macros::XcmPaymentApiV1<_>>::query_xcm_weight(
let weight = <Runtime as $crate::macros::XcmPaymentApiV2<_>>::query_xcm_weight(
$crate::macros::VersionedXcm::from(program)).unwrap();
let fee_in_wnd = <Runtime as $crate::macros::XcmPaymentApiV1<_>>::query_weight_to_asset_fee(weight,
let fee_in_wnd = <Runtime as $crate::macros::XcmPaymentApiV2<_>>::query_weight_to_asset_fee(weight,
$crate::macros::VersionedAssetId::from($crate::macros::AssetId(wnd.clone()))).unwrap();
// Assets not in a pool don't work.
assert!(<Runtime as $crate::macros::XcmPaymentApiV1<_>>::query_weight_to_asset_fee(weight,
assert!(<Runtime as $crate::macros::XcmPaymentApiV2<_>>::query_weight_to_asset_fee(weight,
$crate::macros::VersionedAssetId::from(
$crate::macros::AssetId($crate::macros::Location::new(0,
[$crate::macros::PalletInstance($crate::macros::ASSETS_PALLET_ID),
Expand All @@ -929,7 +953,7 @@ macro_rules! test_xcm_fee_querying_apis_work_for_asset_hub {
)
)
).is_err());
let fee_in_usdt_fail = <Runtime as $crate::macros::XcmPaymentApiV1<_>>::query_weight_to_asset_fee(weight,
let fee_in_usdt_fail = <Runtime as $crate::macros::XcmPaymentApiV2<_>>::query_weight_to_asset_fee(weight,
$crate::macros::VersionedAssetId::from($crate::macros::AssetId(usdt.clone())));
// Weight to asset fee fails because there's not enough asset in the pool.
// We just created it, there's none.
Expand All @@ -953,7 +977,7 @@ macro_rules! test_xcm_fee_querying_apis_work_for_asset_hub {
sender.into()
));
// Now it works.
let fee_in_usdt = <Runtime as $crate::macros::XcmPaymentApiV1<_>>::query_weight_to_asset_fee(weight,
let fee_in_usdt = <Runtime as $crate::macros::XcmPaymentApiV2<_>>::query_weight_to_asset_fee(weight,
$crate::macros::VersionedAssetId::from($crate::macros::AssetId(usdt))
);
$crate::macros::assert_ok!(fee_in_usdt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use emulated_integration_tests_common::test_can_estimate_and_pay_exact_fees;
use frame_support::dispatch::RawOrigin;
use xcm_runtime_apis::{
dry_run::runtime_decl_for_dry_run_api::DryRunApiV2,
fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1,
fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV2,
};

fn sender_assertions(test: ParaToParaThroughAHTest) {
Expand Down Expand Up @@ -157,9 +157,13 @@ fn multi_hop_works() {
.unwrap();
assert_eq!(messages_to_query.len(), 1);
remote_message = messages_to_query[0].clone();
let delivery_fees =
Runtime::query_delivery_fees(destination_to_query.clone(), remote_message.clone())
.unwrap();
let asset_id_for_delivery_fees = VersionedAssetId::from(Location::parent());
let delivery_fees = Runtime::query_delivery_fees(
destination_to_query.clone(),
remote_message.clone(),
asset_id_for_delivery_fees,
)
.unwrap();
delivery_fees_amount = get_amount_from_versioned_assets(delivery_fees);
});

Expand Down Expand Up @@ -200,9 +204,11 @@ fn multi_hop_works() {
// We could've gotten the message from the queue without having to dry-run, but
// offchain applications would have to dry-run, so we do it here as well.
intermediate_remote_message = messages_to_query[0].clone();
let asset_id_for_delivery_fees = VersionedAssetId::from(Location::parent());
let delivery_fees = Runtime::query_delivery_fees(
destination_to_query.clone(),
intermediate_remote_message.clone(),
asset_id_for_delivery_fees,
)
.unwrap();
intermediate_delivery_fees_amount = get_amount_from_versioned_assets(delivery_fees);
Expand Down
Loading
Loading