Skip to content

Commit

Permalink
Added Trusted Query API implementation for Westend and Rococo relay c…
Browse files Browse the repository at this point in the history
…hains (paritytech#6212)

Added missing API methods to Rococo and Westend parachains.
Preparatory work for making chopstick tests run smoothly.
Follow-up of
[PR#6039](paritytech#6039)
  • Loading branch information
x3c41a authored and mordamax committed Oct 25, 2024
1 parent 5e7dab0 commit f3db492
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
14 changes: 13 additions & 1 deletion polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ use sp_staking::SessionIndex;
#[cfg(any(feature = "std", test))]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use xcm::{latest::prelude::*, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm};
use xcm::{
latest::prelude::*, VersionedAsset, VersionedAssetId, VersionedAssets, VersionedLocation,
VersionedXcm,
};
use xcm_builder::PayOverXcm;

pub use frame_system::Call as SystemCall;
Expand Down Expand Up @@ -2622,6 +2625,15 @@ sp_api::impl_runtime_apis! {
genesis_config_presets::preset_names()
}
}

impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
XcmPallet::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
XcmPallet::is_trusted_teleporter(asset, location)
}
}
}

#[cfg(all(test, feature = "try-runtime"))]
Expand Down
14 changes: 13 additions & 1 deletion polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ use sp_staking::SessionIndex;
#[cfg(any(feature = "std", test))]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use xcm::{latest::prelude::*, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm};
use xcm::{
latest::prelude::*, VersionedAsset, VersionedAssetId, VersionedAssets, VersionedLocation,
VersionedXcm,
};
use xcm_builder::PayOverXcm;

use xcm_runtime_apis::{
Expand Down Expand Up @@ -2791,4 +2794,13 @@ sp_api::impl_runtime_apis! {
genesis_config_presets::preset_names()
}
}

impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
XcmPallet::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
XcmPallet::is_trusted_teleporter(asset, location)
}
}
}
32 changes: 32 additions & 0 deletions prdoc/pr_6212.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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: "Added Trusted Query API calls for Westend and Rococo chains"

doc:
- audience: Runtime Dev
description: |
Added is_trusted_reserve and is_trusted_teleporter API calls to relay chains.
Given an asset and a location, they return if the chain trusts that location as a reserve or teleporter for that asset respectively.
You can implement them on your runtime by simply calling a helper function on `pallet-xcm`.
```rust
impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
```

- audience: Runtime User
description: |
There's a new runtime API to check if a chain trust a Location as a reserve or teleporter for a given Asset.
It's implemented in all the relays and system parachains in Westend and Rococo.

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

0 comments on commit f3db492

Please sign in to comment.