Skip to content

Commit 79ec5ae

Browse files
x3c41amordamax
authored andcommitted
Added Trusted Query API implementation for Westend and Rococo relay chains (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)
1 parent 6e31925 commit 79ec5ae

3 files changed

Lines changed: 58 additions & 2 deletions

File tree

polkadot/runtime/rococo/src/lib.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ use sp_staking::SessionIndex;
112112
#[cfg(any(feature = "std", test))]
113113
use sp_version::NativeVersion;
114114
use sp_version::RuntimeVersion;
115-
use xcm::{latest::prelude::*, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm};
115+
use xcm::{
116+
latest::prelude::*, VersionedAsset, VersionedAssetId, VersionedAssets, VersionedLocation,
117+
VersionedXcm,
118+
};
116119
use xcm_builder::PayOverXcm;
117120

118121
pub use frame_system::Call as SystemCall;
@@ -2622,6 +2625,15 @@ sp_api::impl_runtime_apis! {
26222625
genesis_config_presets::preset_names()
26232626
}
26242627
}
2628+
2629+
impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
2630+
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
2631+
XcmPallet::is_trusted_reserve(asset, location)
2632+
}
2633+
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
2634+
XcmPallet::is_trusted_teleporter(asset, location)
2635+
}
2636+
}
26252637
}
26262638

26272639
#[cfg(all(test, feature = "try-runtime"))]

polkadot/runtime/westend/src/lib.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ use sp_staking::SessionIndex;
107107
#[cfg(any(feature = "std", test))]
108108
use sp_version::NativeVersion;
109109
use sp_version::RuntimeVersion;
110-
use xcm::{latest::prelude::*, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm};
110+
use xcm::{
111+
latest::prelude::*, VersionedAsset, VersionedAssetId, VersionedAssets, VersionedLocation,
112+
VersionedXcm,
113+
};
111114
use xcm_builder::PayOverXcm;
112115

113116
use xcm_runtime_apis::{
@@ -2791,4 +2794,13 @@ sp_api::impl_runtime_apis! {
27912794
genesis_config_presets::preset_names()
27922795
}
27932796
}
2797+
2798+
impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
2799+
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
2800+
XcmPallet::is_trusted_reserve(asset, location)
2801+
}
2802+
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
2803+
XcmPallet::is_trusted_teleporter(asset, location)
2804+
}
2805+
}
27942806
}

prdoc/pr_6212.prdoc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
2+
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json
3+
4+
title: "Added Trusted Query API calls for Westend and Rococo chains"
5+
6+
doc:
7+
- audience: Runtime Dev
8+
description: |
9+
Added is_trusted_reserve and is_trusted_teleporter API calls to relay chains.
10+
Given an asset and a location, they return if the chain trusts that location as a reserve or teleporter for that asset respectively.
11+
You can implement them on your runtime by simply calling a helper function on `pallet-xcm`.
12+
```rust
13+
impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
14+
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
15+
PolkadotXcm::is_trusted_reserve(asset, location)
16+
}
17+
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
18+
PolkadotXcm::is_trusted_teleporter(asset, location)
19+
}
20+
}
21+
```
22+
23+
- audience: Runtime User
24+
description: |
25+
There's a new runtime API to check if a chain trust a Location as a reserve or teleporter for a given Asset.
26+
It's implemented in all the relays and system parachains in Westend and Rococo.
27+
28+
crates:
29+
- name: westend-runtime
30+
bump: minor
31+
- name: rococo-runtime
32+
bump: minor

0 commit comments

Comments
 (0)