mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-06 16:07:21 +00:00
4c7539cab5
* Use beefy branch with scale-info * Add patches * Sprinkle some TypeInfo derives * Add some TypeInfo deriv * Cargo.lock * Derive TypeInfo and skip type params for Xcm types * Cargo.lock * Fix up scale_info bounds attributes * Fix up dependencies * Use my own beefy-primitives branch * Bump BEEFY * Update patches * Add some scale-info dependencies and TypeInfo derives * More TypeInfo decoration * Update scale-info * Some TypeInfos and remove more Event pallet::metadata * Moar TypeInfos * TypeInfos galore, fix up metadata runtime API * TypeInfo * TypeInfos, update other runtime metadata APIs * Fix up Kusama, comment out some `usize` QueueSize parameter types * Remove local diener patches * Cargo.lock * Cargo.lock * Update to scale-info crates.io release * Update primitive-types branch * Update pallet-beefy to use custom branch * Update other parity-common deps * Update parity-common patches * bump a bunch of deps in parity-common * Remove parity-common patches * Bump finality-grandpa version * Cargo.lock * Update scale-info to 0.9.1 * Add recursion_limit for runtime-parachains * Add some scale_info attributes * Cargo.lock * Revert finality-grandpa bump * Cargo.lock, scale-info update * cargo update * Make sure using patched version of finality-grandpa * Use patched scale-info * Update to scale-info 0.10.0 * Update finality-grandpa * Cargo.lock * Update beefy deps * Update beefy deps again * Add scale-info dependency * Remove deprecated pallet::metadata attributes. * Add some missing scale-info deps and derives * Use some variant struct call syntax * Add missing TypeInfo impl * Add some more TypeInfo impls * Convert some call enum struct variant constructors * More scale-info deps and derives * Call enum struct variants * TypeInfo derives * Call enum variant structs * scale-info deps and derives * Call enum variant struct constructors * Use beefy-primitives scale-info feature * Use grandpa-bridge-gadget master branch * Remove finality-grandpa patch * Add missing scale_info dependency and derive * Fix up some call variant constructors * Add missing scale_info dependency * Fix some test errors * More TypeInfo derives * More call variant structs * Call variant structs in tests * Cargo.lock * Fmt * Fix more call struct variants * Another call struct variant * add scale-info/std features explicitly * More call struct variants * Add missing scale-info dependency * Fmt * review: activate scale-info/std where missing * Remove some duplicate std feature activation * review: add scale_info bounds() attr * More call variant structs * Remove recursion limit * Update beefy-primitives * Update beefy-primitives * Fix simnet call variant struct errors * Fmt * cargo update -p beefy-primitives * Add some missing TypeInfo derives * Fix some call variants * Fix some call variant underscores * Cargo.lock * Cargo.lock * Add missing TypeInfo derive * Add some more missing TypeInfo derives * Even more missing TypeInfo derives * Add TypeInfo derives to new xcm types * Fmt * Cargo.lock * Add missing TypeInfo impls * Cargo.lock * More missing TypeInfos * Fixes * Cargo.lock * Cargo.lock * Add TypeInfo impls to xcm v2 * Update to scale-info 1.0 * Update finality-grandpa 0.14.4, patch for now * Update beefy * Remove patched finality-grandpa * Add TypeInfo impl to Outcome * Fixes * Call variant struct * Call variant struct * Fix test * Add TypeInfo impl * Cargo.lock * Cargo.lock * Cargo.lock * git checkout master Cargo.lock * update Substrate * Add missing scale-info features for beefy-primitives * Fmt * Remove check for now * Update beefy-primitives, removes scale-info feature * Update beefy-primitives again Co-authored-by: adoerr <0xad@gmx.net> Co-authored-by: Andronik Ordian <write@reusable.software> Co-authored-by: thiolliere <gui.thiolliere@gmail.com> Co-authored-by: parity-processbot <> Co-authored-by: Bastian Köcher <info@kchr.de>
116 lines
4.6 KiB
Rust
116 lines
4.6 KiB
Rust
// Copyright 2020 Parity Technologies (UK) Ltd.
|
|
// This file is part of Polkadot.
|
|
|
|
// Polkadot is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
|
|
// Polkadot is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
//! Support data structures for `MultiLocation`, primarily the `Junction` datatype.
|
|
|
|
use super::{BodyId, BodyPart, Junctions, MultiLocation, NetworkId};
|
|
use crate::v0::Junction as Junction0;
|
|
use alloc::vec::Vec;
|
|
use core::convert::TryFrom;
|
|
use parity_scale_codec::{self, Decode, Encode};
|
|
use scale_info::TypeInfo;
|
|
|
|
/// A single item in a path to describe the relative location of a consensus system.
|
|
///
|
|
/// Each item assumes a pre-existing location as its context and is defined in terms of it.
|
|
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)]
|
|
pub enum Junction {
|
|
/// An indexed parachain belonging to and operated by the context.
|
|
///
|
|
/// Generally used when the context is a Polkadot Relay-chain.
|
|
Parachain(#[codec(compact)] u32),
|
|
/// A 32-byte identifier for an account of a specific network that is respected as a sovereign endpoint within
|
|
/// the context.
|
|
///
|
|
/// Generally used when the context is a Substrate-based chain.
|
|
AccountId32 { network: NetworkId, id: [u8; 32] },
|
|
/// An 8-byte index for an account of a specific network that is respected as a sovereign endpoint within
|
|
/// the context.
|
|
///
|
|
/// May be used when the context is a Frame-based chain and includes e.g. an indices pallet.
|
|
AccountIndex64 {
|
|
network: NetworkId,
|
|
#[codec(compact)]
|
|
index: u64,
|
|
},
|
|
/// A 20-byte identifier for an account of a specific network that is respected as a sovereign endpoint within
|
|
/// the context.
|
|
///
|
|
/// May be used when the context is an Ethereum or Bitcoin chain or smart-contract.
|
|
AccountKey20 { network: NetworkId, key: [u8; 20] },
|
|
/// An instanced, indexed pallet that forms a constituent part of the context.
|
|
///
|
|
/// Generally used when the context is a Frame-based chain.
|
|
PalletInstance(u8),
|
|
/// A non-descript index within the context location.
|
|
///
|
|
/// Usage will vary widely owing to its generality.
|
|
///
|
|
/// NOTE: Try to avoid using this and instead use a more specific item.
|
|
GeneralIndex(#[codec(compact)] u128),
|
|
/// A nondescript datum acting as a key within the context location.
|
|
///
|
|
/// Usage will vary widely owing to its generality.
|
|
///
|
|
/// NOTE: Try to avoid using this and instead use a more specific item.
|
|
GeneralKey(Vec<u8>),
|
|
/// The unambiguous child.
|
|
///
|
|
/// Not currently used except as a fallback when deriving ancestry.
|
|
OnlyChild,
|
|
/// A pluralistic body existing within consensus.
|
|
///
|
|
/// Typical to be used to represent a governance origin of a chain, but could in principle be used to represent
|
|
/// things such as multisigs also.
|
|
Plurality { id: BodyId, part: BodyPart },
|
|
}
|
|
|
|
impl TryFrom<Junction0> for Junction {
|
|
type Error = ();
|
|
|
|
fn try_from(value: Junction0) -> Result<Self, Self::Error> {
|
|
match value {
|
|
Junction0::Parent => Err(()),
|
|
Junction0::Parachain(id) => Ok(Self::Parachain(id)),
|
|
Junction0::AccountId32 { network, id } => Ok(Self::AccountId32 { network, id }),
|
|
Junction0::AccountIndex64 { network, index } =>
|
|
Ok(Self::AccountIndex64 { network, index }),
|
|
Junction0::AccountKey20 { network, key } => Ok(Self::AccountKey20 { network, key }),
|
|
Junction0::PalletInstance(index) => Ok(Self::PalletInstance(index)),
|
|
Junction0::GeneralIndex(id) => Ok(Self::GeneralIndex(id)),
|
|
Junction0::GeneralKey(key) => Ok(Self::GeneralKey(key)),
|
|
Junction0::OnlyChild => Ok(Self::OnlyChild),
|
|
Junction0::Plurality { id, part } => Ok(Self::Plurality { id: id.into(), part }),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Junction {
|
|
/// Convert `self` into a `MultiLocation` containing 0 parents.
|
|
///
|
|
/// Similar to `Into::into`, except that this method can be used in a const evaluation context.
|
|
pub const fn into(self) -> MultiLocation {
|
|
MultiLocation { parents: 0, interior: Junctions::X1(self) }
|
|
}
|
|
|
|
/// Convert `self` into a `MultiLocation` containing `n` parents.
|
|
///
|
|
/// Similar to `Self::into`, with the added ability to specify the number of parent junctions.
|
|
pub const fn into_exterior(self, n: u8) -> MultiLocation {
|
|
MultiLocation { parents: n, interior: Junctions::X1(self) }
|
|
}
|
|
}
|