referrerpolicy=no-referrer-when-downgrade

xcm_runtime_apis/
authorized_aliases.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//! Contains runtime APIs for querying XCM authorized aliases.
19
20use alloc::vec::Vec;
21use codec::{Decode, Encode};
22use frame_support::pallet_prelude::{MaxEncodedLen, TypeInfo};
23use xcm::VersionedLocation;
24
25/// Entry of an authorized aliaser for a local origin. The aliaser `location` is only authorized
26/// until its inner `expiry` block number.
27#[derive(Clone, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)]
28pub struct OriginAliaser {
29	pub location: VersionedLocation,
30	pub expiry: Option<u64>,
31}
32
33sp_api::decl_runtime_apis! {
34	/// API for querying XCM authorized aliases
35	pub trait AuthorizedAliasersApi {
36		/// Returns locations allowed to alias into and act as `target`.
37		fn authorized_aliasers(target: VersionedLocation) -> Result<Vec<OriginAliaser>, Error>;
38		/// Returns whether `origin` is allowed to alias into and act as `target`.
39		fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> Result<bool, Error>;
40	}
41}
42
43/// `AuthorizedAliasersApi` Runtime APIs errors.
44#[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)]
45pub enum Error {
46	/// Converting a location from one version to another failed.
47	#[codec(index = 0)]
48	LocationVersionConversionFailed,
49}