Skip to content

Commit

Permalink
[stable2409] Backport #5599 (#6069)
Browse files Browse the repository at this point in the history
Backport #5599 into `stable2409` 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 <franciscoaguirreperez@gmail.com>
  • Loading branch information
1 parent db2a008 commit 2bb2b7d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
18 changes: 17 additions & 1 deletion cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,23 @@ 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();
// 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 {
Some(asset_2.clone().into())
} else if asset_2 == native_token {
Some(asset_1.clone().into())
} else {
None
}
},
),
);
PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
}

Expand Down
18 changes: 17 additions & 1 deletion cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,23 @@ 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();
// 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 {
Some(asset_2.clone().into())
} else if asset_2 == native_token {
Some(asset_1.clone().into())
} else {
None
}
},
),
);
PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
}

Expand Down
19 changes: 19 additions & 0 deletions prdoc/pr_6069.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 2bb2b7d

Please sign in to comment.