Companion for #11981 (#5915)

* Companion for #11981

* more renaming

* fmt

* fixes

* add generic type

* Companion for #11831

* fix

* revert changes

* Delete rename-outer-enum.diff

* revert

* Update run_benches_for_runtime.sh

* rename type Call & type Event

* passing tests

* fmt

* small fixes

* commit

* fix

* fmt

* commit

* error fixes

* fix

* small fix in test

* Update lib.rs

* Update lib.rs

* Update lib.rs

* Update lib.rs

* Update lib.rs

* Update lib.rs

* Update lib.rs

* remove RuntimeCall from pallet_grandpa

* last fix

* commit

* rename

* merge fix

* update lockfile for {"substrate"}

* cargo +nightly fmt

* fix

Co-authored-by: parity-processbot <>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Sergej Sakac
2022-09-13 01:03:47 +02:00
committed by GitHub
parent db0fc60344
commit 8ea6076fe5
73 changed files with 1241 additions and 1151 deletions
+20 -20
View File
@@ -78,10 +78,10 @@ pub type QueryId = u64;
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
#[scale_info(bounds(), skip_type_params(Call))]
pub struct Xcm<Call>(pub Vec<Instruction<Call>>);
#[scale_info(bounds(), skip_type_params(RuntimeCall))]
pub struct Xcm<RuntimeCall>(pub Vec<Instruction<RuntimeCall>>);
impl<Call> Xcm<Call> {
impl<RuntimeCall> Xcm<RuntimeCall> {
/// Create an empty instance.
pub fn new() -> Self {
Self(vec![])
@@ -108,17 +108,17 @@ impl<Call> Xcm<Call> {
}
/// Return the first instruction, if any.
pub fn first(&self) -> Option<&Instruction<Call>> {
pub fn first(&self) -> Option<&Instruction<RuntimeCall>> {
self.0.first()
}
/// Return the last instruction, if any.
pub fn last(&self) -> Option<&Instruction<Call>> {
pub fn last(&self) -> Option<&Instruction<RuntimeCall>> {
self.0.last()
}
/// Return the only instruction, contained in `Self`, iff only one exists (`None` otherwise).
pub fn only(&self) -> Option<&Instruction<Call>> {
pub fn only(&self) -> Option<&Instruction<RuntimeCall>> {
if self.0.len() == 1 {
self.0.first()
} else {
@@ -128,7 +128,7 @@ impl<Call> Xcm<Call> {
/// Return the only instruction, contained in `Self`, iff only one exists (returns `self`
/// otherwise).
pub fn into_only(mut self) -> core::result::Result<Instruction<Call>, Self> {
pub fn into_only(mut self) -> core::result::Result<Instruction<RuntimeCall>, Self> {
if self.0.len() == 1 {
self.0.pop().ok_or(self)
} else {
@@ -233,8 +233,8 @@ pub type Weight = u64;
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
#[scale_info(bounds(), skip_type_params(Call))]
pub enum Instruction<Call> {
#[scale_info(bounds(), skip_type_params(RuntimeCall))]
pub enum Instruction<RuntimeCall> {
/// Withdraw asset(s) (`assets`) from the ownership of `origin` and place them into the Holding
/// Register.
///
@@ -340,7 +340,7 @@ pub enum Instruction<Call> {
origin_type: OriginKind,
#[codec(compact)]
require_weight_at_most: u64,
call: DoubleEncoded<Call>,
call: DoubleEncoded<RuntimeCall>,
},
/// A message to notify about a new incoming HRMP channel. This message is meant to be sent by the
@@ -584,7 +584,7 @@ pub enum Instruction<Call> {
/// Kind: *Instruction*
///
/// Errors: None.
SetErrorHandler(Xcm<Call>),
SetErrorHandler(Xcm<RuntimeCall>),
/// Set the Appendix Register. This is code that should be called after code execution
/// (including the error handler if any) is finished. This will be called regardless of whether
@@ -600,7 +600,7 @@ pub enum Instruction<Call> {
/// Kind: *Instruction*
///
/// Errors: None.
SetAppendix(Xcm<Call>),
SetAppendix(Xcm<RuntimeCall>),
/// Clear the Error Register.
///
@@ -647,16 +647,16 @@ pub enum Instruction<Call> {
UnsubscribeVersion,
}
impl<Call> Xcm<Call> {
impl<RuntimeCall> Xcm<RuntimeCall> {
pub fn into<C>(self) -> Xcm<C> {
Xcm::from(self)
}
pub fn from<C>(xcm: Xcm<C>) -> Self {
Self(xcm.0.into_iter().map(Instruction::<Call>::from).collect())
Self(xcm.0.into_iter().map(Instruction::<RuntimeCall>::from).collect())
}
}
impl<Call> Instruction<Call> {
impl<RuntimeCall> Instruction<RuntimeCall> {
pub fn into<C>(self) -> Instruction<C> {
Instruction::from(self)
}
@@ -707,7 +707,7 @@ impl<Call> Instruction<Call> {
}
// TODO: Automate Generation
impl<Call, W: XcmWeightInfo<Call>> GetWeight<W> for Instruction<Call> {
impl<RuntimeCall, W: XcmWeightInfo<RuntimeCall>> GetWeight<W> for Instruction<RuntimeCall> {
fn weight(&self) -> Weight {
use Instruction::*;
match self {
@@ -775,9 +775,9 @@ impl TryFrom<OldResponse> for Response {
}
}
impl<Call> TryFrom<OldXcm<Call>> for Xcm<Call> {
impl<RuntimeCall> TryFrom<OldXcm<RuntimeCall>> for Xcm<RuntimeCall> {
type Error = ();
fn try_from(old: OldXcm<Call>) -> result::Result<Xcm<Call>, ()> {
fn try_from(old: OldXcm<RuntimeCall>) -> result::Result<Xcm<RuntimeCall>, ()> {
use Instruction::*;
Ok(Xcm(match old {
OldXcm::WithdrawAsset { assets, effects } => Some(Ok(WithdrawAsset(assets)))
@@ -827,9 +827,9 @@ impl<Call> TryFrom<OldXcm<Call>> for Xcm<Call> {
}
}
impl<Call> TryFrom<OldOrder<Call>> for Instruction<Call> {
impl<RuntimeCall> TryFrom<OldOrder<RuntimeCall>> for Instruction<RuntimeCall> {
type Error = ();
fn try_from(old: OldOrder<Call>) -> result::Result<Instruction<Call>, ()> {
fn try_from(old: OldOrder<RuntimeCall>) -> result::Result<Instruction<RuntimeCall>, ()> {
use Instruction::*;
Ok(match old {
OldOrder::Noop => return Err(()),
+3 -3
View File
@@ -160,13 +160,13 @@ impl Outcome {
}
/// Type of XCM message executor.
pub trait ExecuteXcm<Call> {
pub trait ExecuteXcm<RuntimeCall> {
/// Execute some XCM `message` from `origin` using no more than `weight_limit` weight. The weight limit is
/// a basic hard-limit and the implementation may place further restrictions or requirements on weight and
/// other aspects.
fn execute_xcm(
origin: impl Into<MultiLocation>,
message: Xcm<Call>,
message: Xcm<RuntimeCall>,
weight_limit: Weight,
) -> Outcome {
let origin = origin.into();
@@ -186,7 +186,7 @@ pub trait ExecuteXcm<Call> {
/// execution without associated payment.
fn execute_xcm_in_credit(
origin: impl Into<MultiLocation>,
message: Xcm<Call>,
message: Xcm<RuntimeCall>,
weight_limit: Weight,
weight_credit: Weight,
) -> Outcome;