Companion for paritytech/substrate#11631 (#5671)

* Companion for paritytech/substrate#11631

* Fixes

* Update sp-runtime

* Fixes

* update lockfile for {"substrate"}

* remove unused

Co-authored-by: parity-processbot <>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Keith Yeung
2022-06-16 19:36:01 +02:00
committed by GitHub
parent 2dfc7cec47
commit 2c85668512
9 changed files with 216 additions and 199 deletions
+174 -173
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -6,7 +6,7 @@ edition = "2021"
[dependencies]
bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] }
parity-scale-codec = { version = "3.1.2", default-features = false, features = ["derive"] }
parity-scale-codec = { version = "3.1.2", default-features = false, features = ["derive", "max-encoded-len"] }
log = { version = "0.4.17", default-features = false }
rustc-hex = { version = "2.1.0", default-features = false }
scale-info = { version = "2.1.2", default-features = false, features = ["derive"] }
+10 -1
View File
@@ -54,7 +54,16 @@ pub mod pallet {
/// Origin for the parachains.
#[pallet::origin]
#[derive(PartialEq, Eq, Clone, Encode, Decode, sp_core::RuntimeDebug, scale_info::TypeInfo)]
#[derive(
PartialEq,
Eq,
Clone,
Encode,
Decode,
sp_core::RuntimeDebug,
scale_info::TypeInfo,
MaxEncodedLen,
)]
pub enum Origin {
/// It comes from a parachain.
Parachain(ParaId),
+2 -1
View File
@@ -38,7 +38,8 @@ use xcm_builder::{
parameter_types! {
pub const WndLocation: MultiLocation = Here.into();
pub const Ancestry: MultiLocation = Here.into();
pub WestendNetwork: NetworkId = NetworkId::Named(b"Westend".to_vec());
pub WestendNetwork: NetworkId =
NetworkId::Named(b"Westend".to_vec().try_into().expect("shorter than length limit; qed"));
pub CheckAccount: AccountId = XcmPallet::check_account();
}
+6 -2
View File
@@ -7,8 +7,9 @@ edition = "2021"
[dependencies]
impl-trait-for-tuples = "0.2.2"
parity-scale-codec = { version = "3.1.2", default-features = false, features = [ "derive" ] }
parity-scale-codec = { version = "3.1.2", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "2.1.2", default-features = false, features = ["derive"] }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
derivative = {version = "2.2.0", default-features = false, features = [ "use_core" ] }
log = { version = "0.4.17", default-features = false }
xcm-procedural = { path = "procedural" }
@@ -16,8 +17,11 @@ xcm-procedural = { path = "procedural" }
[features]
default = ["std"]
wasm-api = []
runtime-benchmarks = []
runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
]
std = [
"parity-scale-codec/std",
"scale-info/std",
"sp-runtime/std",
]
+2 -2
View File
@@ -23,7 +23,7 @@ mod mock;
#[cfg(test)]
mod tests;
use codec::{Decode, Encode, EncodeLike};
use codec::{Decode, Encode, EncodeLike, MaxEncodedLen};
use frame_support::traits::{Contains, EnsureOrigin, Get, OriginTrait};
use scale_info::TypeInfo;
use sp_runtime::{
@@ -212,7 +212,7 @@ pub mod pallet {
}
#[pallet::origin]
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)]
pub enum Origin {
/// It comes from somewhere in the XCM space wanting to transact.
Xcm(MultiLocation),
+9 -9
View File
@@ -16,17 +16,17 @@
//! Support data structures for `MultiLocation`, primarily the `Junction` datatype.
use alloc::vec::Vec;
use parity_scale_codec::{Decode, Encode};
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_runtime::{traits::ConstU32, WeakBoundedVec};
/// A global identifier of an account-bearing consensus system.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]
pub enum NetworkId {
/// Unidentified/any.
Any,
/// Some named network.
Named(Vec<u8>),
Named(WeakBoundedVec<u8, ConstU32<32>>),
/// The Polkadot Relay chain
Polkadot,
/// Kusama.
@@ -34,12 +34,12 @@ pub enum NetworkId {
}
/// An identifier of a pluralistic body.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]
pub enum BodyId {
/// The only body in its context.
Unit,
/// A named body.
Named(Vec<u8>),
Named(WeakBoundedVec<u8, ConstU32<32>>),
/// An indexed body.
Index(#[codec(compact)] u32),
/// The unambiguous executive body (for Polkadot, this would be the Polkadot council).
@@ -55,7 +55,7 @@ pub enum BodyId {
}
/// A part of a pluralistic body.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]
pub enum BodyPart {
/// The body's declaration, under whatever means it decides.
Voice,
@@ -102,7 +102,7 @@ impl BodyPart {
/// 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)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]
pub enum Junction {
/// The consensus system of which the context is a member and state-wise super-set.
///
@@ -147,7 +147,7 @@ pub enum Junction {
/// Usage will vary widely owing to its generality.
///
/// NOTE: Try to avoid using this and instead use a more specific item.
GeneralKey(Vec<u8>),
GeneralKey(WeakBoundedVec<u8, ConstU32<32>>),
/// The unambiguous child.
///
/// Not currently used except as a fallback when deriving ancestry.
+4 -4
View File
@@ -18,14 +18,14 @@
use super::{BodyId, BodyPart, Junctions, MultiLocation, NetworkId};
use crate::v0::Junction as Junction0;
use alloc::vec::Vec;
use parity_scale_codec::{self, Decode, Encode};
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_runtime::{traits::ConstU32, WeakBoundedVec};
/// 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)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]
pub enum Junction {
/// An indexed parachain belonging to and operated by the context.
///
@@ -65,7 +65,7 @@ pub enum Junction {
/// Usage will vary widely owing to its generality.
///
/// NOTE: Try to avoid using this and instead use a more specific item.
GeneralKey(Vec<u8>),
GeneralKey(WeakBoundedVec<u8, ConstU32<32>>),
/// The unambiguous child.
///
/// Not currently used except as a fallback when deriving ancestry.
+8 -6
View File
@@ -18,7 +18,7 @@
use super::Junction;
use core::{mem, result};
use parity_scale_codec::{Decode, Encode};
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
/// A relative path between state-bearing consensus systems.
@@ -47,7 +47,7 @@ use scale_info::TypeInfo;
/// that a value is strictly an interior location, in those cases, `Junctions` may be used.
///
/// The `MultiLocation` value of `Null` simply refers to the interpreting consensus system.
#[derive(Clone, Decode, Encode, Eq, PartialEq, Ord, PartialOrd, Debug, TypeInfo)]
#[derive(Clone, Decode, Encode, Eq, PartialEq, Ord, PartialOrd, Debug, TypeInfo, MaxEncodedLen)]
pub struct MultiLocation {
/// The number of parent junctions at the beginning of this `MultiLocation`.
pub parents: u8,
@@ -425,7 +425,7 @@ const MAX_JUNCTIONS: usize = 8;
///
/// Parent junctions cannot be constructed with this type. Refer to `MultiLocation` for
/// instructions on constructing parent junctions.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]
pub enum Junctions {
/// The interpreting consensus system.
Here,
@@ -1011,7 +1011,6 @@ mod tests {
#[test]
fn conversion_from_other_types_works() {
use crate::v0;
fn takes_multilocation<Arg: Into<MultiLocation>>(_arg: Arg) {}
takes_multilocation(Parent);
@@ -1042,10 +1041,13 @@ mod tests {
v0::MultiLocation::X3(
v0::Junction::Parent,
v0::Junction::Parent,
v0::Junction::GeneralKey(b"foo".to_vec()),
v0::Junction::GeneralKey(b"foo".to_vec().try_into().unwrap()),
)
.try_into(),
Ok(MultiLocation { parents: 2, interior: X1(GeneralKey(b"foo".to_vec())) }),
Ok(MultiLocation {
parents: 2,
interior: X1(GeneralKey(b"foo".to_vec().try_into().unwrap()))
}),
);
}
}