Skip to content

Commit

Permalink
[stable2407] Backport #5599 (#6068)
Browse files Browse the repository at this point in the history
Backport #5599 into `stable2407` from franciscoaguirre.

See the
[documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md)
on how to use this bot.

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

---------

Co-authored-by: Francisco Aguirre <[email protected]>
Co-authored-by: command-bot <>
Co-authored-by: Shawn Tabrizi <[email protected]>
  • Loading branch information
3 people authored Oct 25, 2024
1 parent fc62793 commit fff69c3
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
22 changes: 20 additions & 2 deletions cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,8 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. } |
RuntimeCall::NftFractionalization { .. } |
RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. }
RuntimeCall::Nfts { .. } |
RuntimeCall::Uniques { .. }
)
},
ProxyType::AssetOwner => matches!(
Expand Down Expand Up @@ -1326,7 +1327,24 @@ impl_runtime_apis! {

impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
let acceptable_assets = vec![AssetId(xcm_config::TokenLocation::get())];
let native_token = xcm_config::TokenLocation::get();
let native_token_v3 = xcm_config::TokenLocationV3::get();
// We accept the native token to pay fees.
let mut acceptable_assets = vec![AssetId(native_token.clone())];
// We also accept all assets in a pool with the native token.
acceptable_assets.extend(
pallet_asset_conversion::Pools::<Runtime>::iter_keys().filter_map(
|(asset_1, asset_2)| {
if asset_1 == native_token_v3 {
Some(AssetId(asset_2.try_into().unwrap()))
} else if asset_2 == native_token_v3 {
Some(AssetId(asset_1.try_into().unwrap()))
} else {
None
}
},
),
);
PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
}

Expand Down
22 changes: 20 additions & 2 deletions cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,8 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. } |
RuntimeCall::NftFractionalization { .. } |
RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. }
RuntimeCall::Nfts { .. } |
RuntimeCall::Uniques { .. }
)
},
ProxyType::AssetOwner => matches!(
Expand Down Expand Up @@ -1354,7 +1355,24 @@ impl_runtime_apis! {

impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
let acceptable_assets = vec![AssetId(xcm_config::WestendLocation::get())];
let native_token = xcm_config::WestendLocation::get();
let native_token_v3 = xcm_config::WestendLocationV3::get();
// We accept the native token to pay fees.
let mut acceptable_assets = vec![AssetId(native_token.clone())];
// We also accept all assets in a pool with the native token.
acceptable_assets.extend(
pallet_asset_conversion::Pools::<Runtime>::iter_keys().filter_map(
|(asset_1, asset_2)| {
if asset_1 == native_token_v3 {
Some(AssetId(asset_2.try_into().unwrap()))
} else if asset_2 == native_token_v3 {
Some(AssetId(asset_1.try_into().unwrap()))
} else {
None
}
},
),
);
PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
}

Expand Down
19 changes: 19 additions & 0 deletions prdoc/pr_6068.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: Add assets in pool with native to query_acceptable_payment_assets

doc:
- audience: Runtime Dev
description: |
The `XcmPaymentApi::query_acceptable_payment_assets` API can be used to get a list of all
the assets that can be used for fee payment.
This is usually just the native asset, but the asset hubs have the asset conversion pallet.
In the case of the asset hubs, this list now includes all assets in a liquidity pool with
the native one.

crates:
- name: asset-hub-rococo-runtime
bump: minor
- name: asset-hub-westend-runtime
bump: minor

0 comments on commit fff69c3

Please sign in to comment.