diff --git a/polkadot/xcm/xcm-runtime-apis/src/fees.rs b/polkadot/xcm/xcm-runtime-apis/src/fees.rs index 9500a7f7281f4..e7d0ca54a1eeb 100644 --- a/polkadot/xcm/xcm-runtime-apis/src/fees.rs +++ b/polkadot/xcm/xcm-runtime-apis/src/fees.rs @@ -34,6 +34,7 @@ sp_api::decl_runtime_apis! { /// /// To determine the execution weight of the calls required for /// [`xcm::latest::Instruction::Transact`] instruction, `TransactionPaymentCallApi` can be used. + #[api_version(5)] pub trait XcmPaymentApi { /// Returns a list of acceptable payment assets. /// @@ -65,7 +66,18 @@ sp_api::decl_runtime_apis! { /// size of the message. /// * `destination`: The destination to send the message to. Different destinations may use /// different senders that charge different fees. + #[changed_in(5)] fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>) -> Result; + + /// Get delivery fees for sending a specific `message` to a `destination`. + /// These always come in a specific asset, defined by the chain. + /// + /// # Arguments + /// * `message`: The message that'll be sent, necessary because most delivery fees are based on the + /// size of the message. + /// * `destination`: The destination to send the message to. Different destinations may use + /// different senders that charge different fees. + fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>, asset_id: VersionedAssetId) -> Result; } } diff --git a/polkadot/xcm/xcm-runtime-apis/tests/fee_estimation.rs b/polkadot/xcm/xcm-runtime-apis/tests/fee_estimation.rs index c3046b134d1fe..02ff0443edf4f 100644 --- a/polkadot/xcm/xcm-runtime-apis/tests/fee_estimation.rs +++ b/polkadot/xcm/xcm-runtime-apis/tests/fee_estimation.rs @@ -153,9 +153,15 @@ fn fee_estimation_for_teleport() { let (destination, remote_messages) = forwarded_xcms_iter.next().unwrap(); let remote_message = &remote_messages[0]; + let costum_asset = VersionedAssetId::from(AssetId(HereLocation::get())); let delivery_fees = runtime_api - .query_delivery_fees(H256::zero(), destination.clone(), remote_message.clone()) + .query_delivery_fees( + H256::zero(), + destination.clone(), + remote_message.clone(), + costum_asset, + ) .unwrap() .unwrap(); assert_eq!(delivery_fees, VersionedAssets::from((Here, 20u128))); diff --git a/polkadot/xcm/xcm-runtime-apis/tests/mock.rs b/polkadot/xcm/xcm-runtime-apis/tests/mock.rs index 56a77094f1774..6ab0d53708b55 100644 --- a/polkadot/xcm/xcm-runtime-apis/tests/mock.rs +++ b/polkadot/xcm/xcm-runtime-apis/tests/mock.rs @@ -476,8 +476,10 @@ sp_api::mock_impl_runtime_apis! { } } - fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>) -> Result { - XcmPallet::query_delivery_fees(destination, message) + fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>, asset_id: VersionedAssetId) -> Result { + let delivery_fee_dot = XcmPallet::query_delivery_fees(destination, message)?; + quote_price_tokens_for_exact_tokens(delivery_fee_dot, asset_id) + .map_err(|_| XcmPaymentApiError::AssetNotFound) } }