referrerpolicy=no-referrer-when-downgrade

xcm_runtime_apis/
trusted_query.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Polkadot.
3
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// 	http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! Runtime API definition for checking if given <Asset, Location> is trusted reserve or teleporter.
19
20use codec::{Decode, Encode};
21use frame_support::pallet_prelude::TypeInfo;
22use xcm::{VersionedAsset, VersionedLocation};
23
24/// Result of [`TrustedQueryApi`] functions.
25pub type XcmTrustedQueryResult = Result<bool, Error>;
26
27sp_api::decl_runtime_apis! {
28	/// API for querying trusted reserves and trusted teleporters.
29	pub trait TrustedQueryApi {
30		/// Returns if the location is a trusted reserve for the asset.
31		///
32		/// # Arguments
33		/// * `asset`: `VersionedAsset`.
34		/// * `location`: `VersionedLocation`.
35		fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult;
36		/// Returns if the asset can be teleported to the location.
37		///
38		/// # Arguments
39		/// * `asset`: `VersionedAsset`.
40		/// * `location`: `VersionedLocation`.
41		fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult;
42	}
43}
44
45#[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)]
46pub enum Error {
47	/// Converting a versioned Asset structure from one version to another failed.
48	#[codec(index = 0)]
49	VersionedAssetConversionFailed,
50	/// Converting a versioned Location structure from one version to another failed.
51	#[codec(index = 1)]
52	VersionedLocationConversionFailed,
53}