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

Improved TrustedQueryAPI signatures #6129

Merged
merged 9 commits into from
Oct 21, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -1103,8 +1103,6 @@ pub type Executive = frame_executive::Executive<
Migrations,
>;

type XcmTrustedQueryResult = Result<bool, xcm_runtime_apis::trusted_query::Error>;

#[cfg(feature = "runtime-benchmarks")]
pub struct AssetConversionTxHelper;

Expand Down Expand Up @@ -1877,10 +1875,10 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1976,10 +1976,10 @@ impl_runtime_apis! {
}

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> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1530,10 +1530,10 @@ impl_runtime_apis! {
}

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> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1346,10 +1346,10 @@ impl_runtime_apis! {
}

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> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1173,10 +1173,10 @@ impl_runtime_apis! {
}

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> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -885,10 +885,10 @@ impl_runtime_apis! {
}

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> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1153,10 +1153,10 @@ impl_runtime_apis! {
}

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> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1146,10 +1146,10 @@ impl_runtime_apis! {
}

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> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
4 changes: 2 additions & 2 deletions cumulus/parachains/runtimes/people/people-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1064,10 +1064,10 @@ impl_runtime_apis! {
}

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> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
4 changes: 2 additions & 2 deletions cumulus/parachains/runtimes/people/people-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1062,10 +1062,10 @@ impl_runtime_apis! {
}

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> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
4 changes: 2 additions & 2 deletions cumulus/parachains/runtimes/testing/penpal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,10 +1165,10 @@ impl_runtime_apis! {
}

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> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
7 changes: 5 additions & 2 deletions polkadot/xcm/xcm-runtime-apis/src/trusted_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ use codec::{Decode, Encode};
use frame_support::pallet_prelude::TypeInfo;
use xcm::{VersionedAsset, VersionedLocation};

/// Result of [`TrustedQueryApi`] functions.
pub type XcmTrustedQueryResult = Result<bool, Error>;
x3c41a marked this conversation as resolved.
Show resolved Hide resolved

sp_api::decl_runtime_apis! {
// API for querying trusted reserves and trusted teleporters.
pub trait TrustedQueryApi {
Expand All @@ -28,13 +31,13 @@ sp_api::decl_runtime_apis! {
/// # Arguments
/// * `asset`: `VersionedAsset`.
/// * `location`: `VersionedLocation`.
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, Error>;
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult;
/// Returns if the asset can be teleported to the location.
///
/// # Arguments
/// * `asset`: `VersionedAsset`.
/// * `location`: `VersionedLocation`.
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, Error>;
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult;
}
}

Expand Down
32 changes: 32 additions & 0 deletions prdoc/pr_6129.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: "Improved TrustedQueryAPI signatures."

doc:
- audience: Runtime Dev
description: |
Changed returned type of API methods from `Result<bool, xcm_runtime_apis::trusted_query::Error>` to a typed one:
`type XcmTrustedQueryResult = Result<bool, xcm_runtime_apis::trusted_query::Error>`

crates:
- name: asset-hub-westend-runtime
bump: patch
- name: bridge-hub-rococo-runtime
bump: patch
- name: bridge-hub-westend-runtime
bump: patch
- name: collectives-westend-runtime
bump: patch
- name: contracts-rococo-runtime
bump: patch
- name: coretime-rococo-runtime
bump: patch
- name: coretime-westend-runtime
bump: patch
- name: people-rococo-runtime
bump: patch
- name: people-westend-runtime
bump: patch
- name: penpal-runtime
bump: patch
Loading