mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-20 01:11:08 +00:00
* 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:
+35
-35
@@ -308,11 +308,11 @@ impl TryFrom<VersionedMultiAssets> for v1::MultiAssets {
|
||||
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
|
||||
#[codec(encode_bound())]
|
||||
#[codec(decode_bound())]
|
||||
#[scale_info(bounds(), skip_type_params(Call))]
|
||||
pub enum VersionedXcm<Call> {
|
||||
V0(v0::Xcm<Call>),
|
||||
V1(v1::Xcm<Call>),
|
||||
V2(v2::Xcm<Call>),
|
||||
#[scale_info(bounds(), skip_type_params(RuntimeCall))]
|
||||
pub enum VersionedXcm<RuntimeCall> {
|
||||
V0(v0::Xcm<RuntimeCall>),
|
||||
V1(v1::Xcm<RuntimeCall>),
|
||||
V2(v2::Xcm<RuntimeCall>),
|
||||
}
|
||||
|
||||
impl<C> IntoVersion for VersionedXcm<C> {
|
||||
@@ -326,27 +326,27 @@ impl<C> IntoVersion for VersionedXcm<C> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Call> From<v0::Xcm<Call>> for VersionedXcm<Call> {
|
||||
fn from(x: v0::Xcm<Call>) -> Self {
|
||||
impl<RuntimeCall> From<v0::Xcm<RuntimeCall>> for VersionedXcm<RuntimeCall> {
|
||||
fn from(x: v0::Xcm<RuntimeCall>) -> Self {
|
||||
VersionedXcm::V0(x)
|
||||
}
|
||||
}
|
||||
|
||||
impl<Call> From<v1::Xcm<Call>> for VersionedXcm<Call> {
|
||||
fn from(x: v1::Xcm<Call>) -> Self {
|
||||
impl<RuntimeCall> From<v1::Xcm<RuntimeCall>> for VersionedXcm<RuntimeCall> {
|
||||
fn from(x: v1::Xcm<RuntimeCall>) -> Self {
|
||||
VersionedXcm::V1(x)
|
||||
}
|
||||
}
|
||||
|
||||
impl<Call> From<v2::Xcm<Call>> for VersionedXcm<Call> {
|
||||
fn from(x: v2::Xcm<Call>) -> Self {
|
||||
impl<RuntimeCall> From<v2::Xcm<RuntimeCall>> for VersionedXcm<RuntimeCall> {
|
||||
fn from(x: v2::Xcm<RuntimeCall>) -> Self {
|
||||
VersionedXcm::V2(x)
|
||||
}
|
||||
}
|
||||
|
||||
impl<Call> TryFrom<VersionedXcm<Call>> for v0::Xcm<Call> {
|
||||
impl<RuntimeCall> TryFrom<VersionedXcm<RuntimeCall>> for v0::Xcm<RuntimeCall> {
|
||||
type Error = ();
|
||||
fn try_from(x: VersionedXcm<Call>) -> Result<Self, ()> {
|
||||
fn try_from(x: VersionedXcm<RuntimeCall>) -> Result<Self, ()> {
|
||||
use VersionedXcm::*;
|
||||
match x {
|
||||
V0(x) => Ok(x),
|
||||
@@ -356,9 +356,9 @@ impl<Call> TryFrom<VersionedXcm<Call>> for v0::Xcm<Call> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Call> TryFrom<VersionedXcm<Call>> for v1::Xcm<Call> {
|
||||
impl<RuntimeCall> TryFrom<VersionedXcm<RuntimeCall>> for v1::Xcm<RuntimeCall> {
|
||||
type Error = ();
|
||||
fn try_from(x: VersionedXcm<Call>) -> Result<Self, ()> {
|
||||
fn try_from(x: VersionedXcm<RuntimeCall>) -> Result<Self, ()> {
|
||||
use VersionedXcm::*;
|
||||
match x {
|
||||
V0(x) => x.try_into(),
|
||||
@@ -368,9 +368,9 @@ impl<Call> TryFrom<VersionedXcm<Call>> for v1::Xcm<Call> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Call> TryFrom<VersionedXcm<Call>> for v2::Xcm<Call> {
|
||||
impl<RuntimeCall> TryFrom<VersionedXcm<RuntimeCall>> for v2::Xcm<RuntimeCall> {
|
||||
type Error = ();
|
||||
fn try_from(x: VersionedXcm<Call>) -> Result<Self, ()> {
|
||||
fn try_from(x: VersionedXcm<RuntimeCall>) -> Result<Self, ()> {
|
||||
use VersionedXcm::*;
|
||||
match x {
|
||||
V0(x) => V1(x.try_into()?).try_into(),
|
||||
@@ -382,18 +382,18 @@ impl<Call> TryFrom<VersionedXcm<Call>> for v2::Xcm<Call> {
|
||||
|
||||
/// Convert an `Xcm` datum into a `VersionedXcm`, based on a destination `MultiLocation` which will interpret it.
|
||||
pub trait WrapVersion {
|
||||
fn wrap_version<Call>(
|
||||
fn wrap_version<RuntimeCall>(
|
||||
dest: &latest::MultiLocation,
|
||||
xcm: impl Into<VersionedXcm<Call>>,
|
||||
) -> Result<VersionedXcm<Call>, ()>;
|
||||
xcm: impl Into<VersionedXcm<RuntimeCall>>,
|
||||
) -> Result<VersionedXcm<RuntimeCall>, ()>;
|
||||
}
|
||||
|
||||
/// `()` implementation does nothing with the XCM, just sending with whatever version it was authored as.
|
||||
impl WrapVersion for () {
|
||||
fn wrap_version<Call>(
|
||||
fn wrap_version<RuntimeCall>(
|
||||
_: &latest::MultiLocation,
|
||||
xcm: impl Into<VersionedXcm<Call>>,
|
||||
) -> Result<VersionedXcm<Call>, ()> {
|
||||
xcm: impl Into<VersionedXcm<RuntimeCall>>,
|
||||
) -> Result<VersionedXcm<RuntimeCall>, ()> {
|
||||
Ok(xcm.into())
|
||||
}
|
||||
}
|
||||
@@ -401,33 +401,33 @@ impl WrapVersion for () {
|
||||
/// `WrapVersion` implementation which attempts to always convert the XCM to version 0 before wrapping it.
|
||||
pub struct AlwaysV0;
|
||||
impl WrapVersion for AlwaysV0 {
|
||||
fn wrap_version<Call>(
|
||||
fn wrap_version<RuntimeCall>(
|
||||
_: &latest::MultiLocation,
|
||||
xcm: impl Into<VersionedXcm<Call>>,
|
||||
) -> Result<VersionedXcm<Call>, ()> {
|
||||
Ok(VersionedXcm::<Call>::V0(xcm.into().try_into()?))
|
||||
xcm: impl Into<VersionedXcm<RuntimeCall>>,
|
||||
) -> Result<VersionedXcm<RuntimeCall>, ()> {
|
||||
Ok(VersionedXcm::<RuntimeCall>::V0(xcm.into().try_into()?))
|
||||
}
|
||||
}
|
||||
|
||||
/// `WrapVersion` implementation which attempts to always convert the XCM to version 1 before wrapping it.
|
||||
pub struct AlwaysV1;
|
||||
impl WrapVersion for AlwaysV1 {
|
||||
fn wrap_version<Call>(
|
||||
fn wrap_version<RuntimeCall>(
|
||||
_: &latest::MultiLocation,
|
||||
xcm: impl Into<VersionedXcm<Call>>,
|
||||
) -> Result<VersionedXcm<Call>, ()> {
|
||||
Ok(VersionedXcm::<Call>::V1(xcm.into().try_into()?))
|
||||
xcm: impl Into<VersionedXcm<RuntimeCall>>,
|
||||
) -> Result<VersionedXcm<RuntimeCall>, ()> {
|
||||
Ok(VersionedXcm::<RuntimeCall>::V1(xcm.into().try_into()?))
|
||||
}
|
||||
}
|
||||
|
||||
/// `WrapVersion` implementation which attempts to always convert the XCM to version 2 before wrapping it.
|
||||
pub struct AlwaysV2;
|
||||
impl WrapVersion for AlwaysV2 {
|
||||
fn wrap_version<Call>(
|
||||
fn wrap_version<RuntimeCall>(
|
||||
_: &latest::MultiLocation,
|
||||
xcm: impl Into<VersionedXcm<Call>>,
|
||||
) -> Result<VersionedXcm<Call>, ()> {
|
||||
Ok(VersionedXcm::<Call>::V2(xcm.into().try_into()?))
|
||||
xcm: impl Into<VersionedXcm<RuntimeCall>>,
|
||||
) -> Result<VersionedXcm<RuntimeCall>, ()> {
|
||||
Ok(VersionedXcm::<RuntimeCall>::V2(xcm.into().try_into()?))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-10
@@ -97,8 +97,8 @@ pub enum Response {
|
||||
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
|
||||
#[codec(encode_bound())]
|
||||
#[codec(decode_bound())]
|
||||
#[scale_info(bounds(), skip_type_params(Call))]
|
||||
pub enum Xcm<Call> {
|
||||
#[scale_info(bounds(), skip_type_params(RuntimeCall))]
|
||||
pub enum Xcm<RuntimeCall> {
|
||||
/// Withdraw asset(s) (`assets`) from the ownership of `origin` and place them into `holding`. Execute the
|
||||
/// orders (`effects`).
|
||||
///
|
||||
@@ -109,7 +109,7 @@ pub enum Xcm<Call> {
|
||||
///
|
||||
/// Errors:
|
||||
#[codec(index = 0)]
|
||||
WithdrawAsset { assets: Vec<MultiAsset>, effects: Vec<Order<Call>> },
|
||||
WithdrawAsset { assets: Vec<MultiAsset>, effects: Vec<Order<RuntimeCall>> },
|
||||
|
||||
/// Asset(s) (`assets`) have been received into the ownership of this system on the `origin` system.
|
||||
///
|
||||
@@ -126,7 +126,7 @@ pub enum Xcm<Call> {
|
||||
///
|
||||
/// Errors:
|
||||
#[codec(index = 1)]
|
||||
ReserveAssetDeposit { assets: Vec<MultiAsset>, effects: Vec<Order<Call>> },
|
||||
ReserveAssetDeposit { assets: Vec<MultiAsset>, effects: Vec<Order<RuntimeCall>> },
|
||||
|
||||
/// Asset(s) (`assets`) have been destroyed on the `origin` system and equivalent assets should be
|
||||
/// created on this system.
|
||||
@@ -144,7 +144,7 @@ pub enum Xcm<Call> {
|
||||
///
|
||||
/// Errors:
|
||||
#[codec(index = 2)]
|
||||
TeleportAsset { assets: Vec<MultiAsset>, effects: Vec<Order<Call>> },
|
||||
TeleportAsset { assets: Vec<MultiAsset>, effects: Vec<Order<RuntimeCall>> },
|
||||
|
||||
/// Indication of the contents of the holding account corresponding to the `QueryHolding` order of `query_id`.
|
||||
///
|
||||
@@ -209,7 +209,11 @@ pub enum Xcm<Call> {
|
||||
///
|
||||
/// Errors:
|
||||
#[codec(index = 6)]
|
||||
Transact { origin_type: OriginKind, require_weight_at_most: u64, call: DoubleEncoded<Call> },
|
||||
Transact {
|
||||
origin_type: OriginKind,
|
||||
require_weight_at_most: u64,
|
||||
call: DoubleEncoded<RuntimeCall>,
|
||||
},
|
||||
|
||||
/// A message to notify about a new incoming HRMP channel. This message is meant to be sent by the
|
||||
/// relay-chain to a para.
|
||||
@@ -276,10 +280,10 @@ pub enum Xcm<Call> {
|
||||
///
|
||||
/// Errors:
|
||||
#[codec(index = 10)]
|
||||
RelayedFrom { who: MultiLocation, message: alloc::boxed::Box<Xcm<Call>> },
|
||||
RelayedFrom { who: MultiLocation, message: alloc::boxed::Box<Xcm<RuntimeCall>> },
|
||||
}
|
||||
|
||||
impl<Call> Xcm<Call> {
|
||||
impl<RuntimeCall> Xcm<RuntimeCall> {
|
||||
pub fn into<C>(self) -> Xcm<C> {
|
||||
Xcm::from(self)
|
||||
}
|
||||
@@ -330,9 +334,9 @@ impl TryFrom<Response1> for Response {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Call> TryFrom<Xcm1<Call>> for Xcm<Call> {
|
||||
impl<RuntimeCall> TryFrom<Xcm1<RuntimeCall>> for Xcm<RuntimeCall> {
|
||||
type Error = ();
|
||||
fn try_from(x: Xcm1<Call>) -> result::Result<Xcm<Call>, ()> {
|
||||
fn try_from(x: Xcm1<RuntimeCall>) -> result::Result<Xcm<RuntimeCall>, ()> {
|
||||
use Xcm::*;
|
||||
Ok(match x {
|
||||
Xcm1::WithdrawAsset { assets, effects } => WithdrawAsset {
|
||||
|
||||
@@ -27,8 +27,8 @@ use parity_scale_codec::{self, Decode, Encode};
|
||||
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
|
||||
#[codec(encode_bound())]
|
||||
#[codec(decode_bound())]
|
||||
#[scale_info(bounds(), skip_type_params(Call))]
|
||||
pub enum Order<Call> {
|
||||
#[scale_info(bounds(), skip_type_params(RuntimeCall))]
|
||||
pub enum Order<RuntimeCall> {
|
||||
/// Do nothing. Not generally used.
|
||||
#[codec(index = 0)]
|
||||
Null,
|
||||
@@ -122,7 +122,7 @@ pub enum Order<Call> {
|
||||
weight: u64,
|
||||
debt: u64,
|
||||
halt_on_error: bool,
|
||||
xcm: Vec<Xcm<Call>>,
|
||||
xcm: Vec<Xcm<RuntimeCall>>,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ pub mod opaque {
|
||||
pub type Order = super::Order<()>;
|
||||
}
|
||||
|
||||
impl<Call> Order<Call> {
|
||||
impl<RuntimeCall> Order<RuntimeCall> {
|
||||
pub fn into<C>(self) -> Order<C> {
|
||||
Order::from(self)
|
||||
}
|
||||
@@ -155,9 +155,9 @@ impl<Call> Order<Call> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Call> TryFrom<Order1<Call>> for Order<Call> {
|
||||
impl<RuntimeCall> TryFrom<Order1<RuntimeCall>> for Order<RuntimeCall> {
|
||||
type Error = ();
|
||||
fn try_from(old: Order1<Call>) -> result::Result<Order<Call>, ()> {
|
||||
fn try_from(old: Order1<RuntimeCall>) -> result::Result<Order<RuntimeCall>, ()> {
|
||||
use Order::*;
|
||||
Ok(match old {
|
||||
Order1::Noop => Null,
|
||||
@@ -195,7 +195,7 @@ impl<Call> TryFrom<Order1<Call>> for Order<Call> {
|
||||
Order1::BuyExecution { fees, weight, debt, halt_on_error, instructions } => {
|
||||
let xcm = instructions
|
||||
.into_iter()
|
||||
.map(Xcm::<Call>::try_from)
|
||||
.map(Xcm::<RuntimeCall>::try_from)
|
||||
.collect::<result::Result<_, _>>()?;
|
||||
BuyExecution { fees: fees.try_into()?, weight, debt, halt_on_error, xcm }
|
||||
},
|
||||
|
||||
@@ -139,11 +139,15 @@ 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: MultiLocation, message: Xcm<Call>, weight_limit: Weight) -> Outcome {
|
||||
fn execute_xcm(
|
||||
origin: MultiLocation,
|
||||
message: Xcm<RuntimeCall>,
|
||||
weight_limit: Weight,
|
||||
) -> Outcome {
|
||||
log::debug!(
|
||||
target: "xcm::execute_xcm",
|
||||
"origin: {:?}, message: {:?}, weight_limit: {:?}",
|
||||
@@ -160,7 +164,7 @@ pub trait ExecuteXcm<Call> {
|
||||
/// execution without associated payment.
|
||||
fn execute_xcm_in_credit(
|
||||
origin: MultiLocation,
|
||||
message: Xcm<Call>,
|
||||
message: Xcm<RuntimeCall>,
|
||||
weight_limit: Weight,
|
||||
weight_credit: Weight,
|
||||
) -> Outcome;
|
||||
|
||||
+16
-12
@@ -136,8 +136,8 @@ pub enum Response {
|
||||
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
|
||||
#[codec(encode_bound())]
|
||||
#[codec(decode_bound())]
|
||||
#[scale_info(bounds(), skip_type_params(Call))]
|
||||
pub enum Xcm<Call> {
|
||||
#[scale_info(bounds(), skip_type_params(RuntimeCall))]
|
||||
pub enum Xcm<RuntimeCall> {
|
||||
/// Withdraw asset(s) (`assets`) from the ownership of `origin` and place them into `holding`. Execute the
|
||||
/// orders (`effects`).
|
||||
///
|
||||
@@ -148,7 +148,7 @@ pub enum Xcm<Call> {
|
||||
///
|
||||
/// Errors:
|
||||
#[codec(index = 0)]
|
||||
WithdrawAsset { assets: MultiAssets, effects: Vec<Order<Call>> },
|
||||
WithdrawAsset { assets: MultiAssets, effects: Vec<Order<RuntimeCall>> },
|
||||
|
||||
/// Asset(s) (`assets`) have been received into the ownership of this system on the `origin` system.
|
||||
///
|
||||
@@ -165,7 +165,7 @@ pub enum Xcm<Call> {
|
||||
///
|
||||
/// Errors:
|
||||
#[codec(index = 1)]
|
||||
ReserveAssetDeposited { assets: MultiAssets, effects: Vec<Order<Call>> },
|
||||
ReserveAssetDeposited { assets: MultiAssets, effects: Vec<Order<RuntimeCall>> },
|
||||
|
||||
/// Asset(s) (`assets`) have been destroyed on the `origin` system and equivalent assets should be
|
||||
/// created on this system.
|
||||
@@ -183,7 +183,7 @@ pub enum Xcm<Call> {
|
||||
///
|
||||
/// Errors:
|
||||
#[codec(index = 2)]
|
||||
ReceiveTeleportedAsset { assets: MultiAssets, effects: Vec<Order<Call>> },
|
||||
ReceiveTeleportedAsset { assets: MultiAssets, effects: Vec<Order<RuntimeCall>> },
|
||||
|
||||
/// Indication of the contents of the holding register corresponding to the `QueryHolding` order of `query_id`.
|
||||
///
|
||||
@@ -249,7 +249,11 @@ pub enum Xcm<Call> {
|
||||
///
|
||||
/// Errors:
|
||||
#[codec(index = 6)]
|
||||
Transact { origin_type: OriginKind, require_weight_at_most: u64, call: DoubleEncoded<Call> },
|
||||
Transact {
|
||||
origin_type: OriginKind,
|
||||
require_weight_at_most: u64,
|
||||
call: DoubleEncoded<RuntimeCall>,
|
||||
},
|
||||
|
||||
/// A message to notify about a new incoming HRMP channel. This message is meant to be sent by the
|
||||
/// relay-chain to a para.
|
||||
@@ -313,7 +317,7 @@ pub enum Xcm<Call> {
|
||||
///
|
||||
/// Errors:
|
||||
#[codec(index = 10)]
|
||||
RelayedFrom { who: InteriorMultiLocation, message: alloc::boxed::Box<Xcm<Call>> },
|
||||
RelayedFrom { who: InteriorMultiLocation, message: alloc::boxed::Box<Xcm<RuntimeCall>> },
|
||||
|
||||
/// Ask the destination system to respond with the most recent version of XCM that they
|
||||
/// support in a `QueryResponse` instruction. Any changes to this should also elicit similar
|
||||
@@ -335,7 +339,7 @@ pub enum Xcm<Call> {
|
||||
UnsubscribeVersion,
|
||||
}
|
||||
|
||||
impl<Call> Xcm<Call> {
|
||||
impl<RuntimeCall> Xcm<RuntimeCall> {
|
||||
pub fn into<C>(self) -> Xcm<C> {
|
||||
Xcm::from(self)
|
||||
}
|
||||
@@ -390,9 +394,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 Xcm::*;
|
||||
Ok(match old {
|
||||
OldXcm::WithdrawAsset { assets, effects } => WithdrawAsset {
|
||||
@@ -443,9 +447,9 @@ impl<Call> TryFrom<OldXcm<Call>> for Xcm<Call> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Call> TryFrom<NewXcm<Call>> for Xcm<Call> {
|
||||
impl<RuntimeCall> TryFrom<NewXcm<RuntimeCall>> for Xcm<RuntimeCall> {
|
||||
type Error = ();
|
||||
fn try_from(old: NewXcm<Call>) -> result::Result<Xcm<Call>, ()> {
|
||||
fn try_from(old: NewXcm<RuntimeCall>) -> result::Result<Xcm<RuntimeCall>, ()> {
|
||||
use Xcm::*;
|
||||
let mut iter = old.0.into_iter();
|
||||
let instruction = iter.next().ok_or(())?;
|
||||
|
||||
@@ -29,8 +29,8 @@ use scale_info::TypeInfo;
|
||||
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
|
||||
#[codec(encode_bound())]
|
||||
#[codec(decode_bound())]
|
||||
#[scale_info(bounds(), skip_type_params(Call))]
|
||||
pub enum Order<Call> {
|
||||
#[scale_info(bounds(), skip_type_params(RuntimeCall))]
|
||||
pub enum Order<RuntimeCall> {
|
||||
/// Do nothing. Not generally used.
|
||||
#[codec(index = 0)]
|
||||
Noop,
|
||||
@@ -148,7 +148,7 @@ pub enum Order<Call> {
|
||||
weight: u64,
|
||||
debt: u64,
|
||||
halt_on_error: bool,
|
||||
instructions: Vec<Xcm<Call>>,
|
||||
instructions: Vec<Xcm<RuntimeCall>>,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ pub mod opaque {
|
||||
pub type Order = super::Order<()>;
|
||||
}
|
||||
|
||||
impl<Call> Order<Call> {
|
||||
impl<RuntimeCall> Order<RuntimeCall> {
|
||||
pub fn into<C>(self) -> Order<C> {
|
||||
Order::from(self)
|
||||
}
|
||||
@@ -182,9 +182,9 @@ impl<Call> Order<Call> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Call> TryFrom<OldOrder<Call>> for Order<Call> {
|
||||
impl<RuntimeCall> TryFrom<OldOrder<RuntimeCall>> for Order<RuntimeCall> {
|
||||
type Error = ();
|
||||
fn try_from(old: OldOrder<Call>) -> result::Result<Order<Call>, ()> {
|
||||
fn try_from(old: OldOrder<RuntimeCall>) -> result::Result<Order<RuntimeCall>, ()> {
|
||||
use Order::*;
|
||||
Ok(match old {
|
||||
OldOrder::Null => Noop,
|
||||
@@ -224,17 +224,19 @@ impl<Call> TryFrom<OldOrder<Call>> for Order<Call> {
|
||||
OldOrder::QueryHolding { query_id, dest, assets } =>
|
||||
QueryHolding { query_id, dest: dest.try_into()?, assets: assets.try_into()? },
|
||||
OldOrder::BuyExecution { fees, weight, debt, halt_on_error, xcm } => {
|
||||
let instructions =
|
||||
xcm.into_iter().map(Xcm::<Call>::try_from).collect::<result::Result<_, _>>()?;
|
||||
let instructions = xcm
|
||||
.into_iter()
|
||||
.map(Xcm::<RuntimeCall>::try_from)
|
||||
.collect::<result::Result<_, _>>()?;
|
||||
BuyExecution { fees: fees.try_into()?, weight, debt, halt_on_error, instructions }
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<Call> TryFrom<Instruction<Call>> for Order<Call> {
|
||||
impl<RuntimeCall> TryFrom<Instruction<RuntimeCall>> for Order<RuntimeCall> {
|
||||
type Error = ();
|
||||
fn try_from(old: Instruction<Call>) -> result::Result<Order<Call>, ()> {
|
||||
fn try_from(old: Instruction<RuntimeCall>) -> result::Result<Order<RuntimeCall>, ()> {
|
||||
use Order::*;
|
||||
Ok(match old {
|
||||
Instruction::DepositAsset { assets, max_assets, beneficiary } =>
|
||||
|
||||
@@ -142,13 +142,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();
|
||||
@@ -168,7 +168,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;
|
||||
|
||||
+20
-20
@@ -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(()),
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user