Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable2407] Backport #5599 #6068

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading