mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 10:01:17 +00:00
XCM v1 (#2815)
* MultiAsset TWO * Draft next MultiAsset API. * XCM core builds * XCM Executor builds * XCM Builder builds * API changes making their way throughout * Some TODOs * Further build fixes * Basic compile builds * First test fixed * All executor tests fixed * Typo * Optimize subsume_assets and add test * Optimize checked_sub * XCM Builder first test fixed * Fix builder tests * Fix doc test * fix some doc tests * spelling * named fields for AllOf * Update xcm/src/v0/multiasset.rs Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> * Update xcm/src/v0/multiasset.rs Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> * Update xcm/src/v0/multiasset.rs Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> * Update xcm/src/v0/multiasset.rs Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> * Reformat * Move to XCM version 1 * Spelling * warnings * Replace some more v0->v1s * warnings * format * Add max_assets param * building * test fixes * tests * another test * final test * tests * Rename Null -> Here * Introduce * More ergonomics * More ergonomics * test fix * test fixes * docs * BuyExecution includes * Fix XCM extrinsics * fmt * Make Vec<MultiAsset>/MultiAssets conversions safe * More MultiAssets conversion safety * spelling * fix doc test * Apply suggestions from code review Co-authored-by: Amar Singh <asinghchrony@protonmail.com> * Apply suggestions from code review Co-authored-by: Amar Singh <asinghchrony@protonmail.com> * fmt * Add v0, remove VersionedMultiAsset * Remove VersionedMultiLocation * Update xcm/src/v1/order.rs Co-authored-by: Amar Singh <asinghchrony@protonmail.com> * Update xcm/src/v1/mod.rs Co-authored-by: Amar Singh <asinghchrony@protonmail.com> * XCM v0 backwards compatibility * Full compatibility * fmt * Update xcm/pallet-xcm/src/lib.rs * Update xcm/src/v0/order.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * Tweaks to versioning system * Fixes * fmt * Update xcm/xcm-executor/src/assets.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * Update xcm/xcm-executor/src/assets.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * Grumbles * Update xcm/src/v1/multiasset.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * fmt * Update xcm/src/v1/multiasset.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * Update xcm/src/v1/multiasset.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * Fixes * Formatting Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> Co-authored-by: Amar Singh <asinghchrony@protonmail.com> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
@@ -80,7 +80,7 @@ use polkadot_parachain::primitives::Id as ParaId;
|
||||
|
||||
use constants::{currency::*, fee::*, time::*};
|
||||
use frame_support::traits::InstanceFilter;
|
||||
use xcm::v0::{BodyId, MultiLocation, NetworkId, Xcm};
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia,
|
||||
ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds,
|
||||
@@ -583,9 +583,9 @@ impl parachains_paras::Config for Runtime {
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const RocLocation: MultiLocation = MultiLocation::Null;
|
||||
pub const RocLocation: MultiLocation = MultiLocation::Here;
|
||||
pub const RococoNetwork: NetworkId = NetworkId::Polkadot;
|
||||
pub const Ancestry: MultiLocation = MultiLocation::Null;
|
||||
pub const Ancestry: MultiLocation = MultiLocation::Here;
|
||||
pub CheckAccount: AccountId = XcmPallet::check_account();
|
||||
}
|
||||
|
||||
@@ -620,24 +620,15 @@ parameter_types! {
|
||||
/// individual routers.
|
||||
pub type XcmRouter = (
|
||||
// Only one router so far - use DMP to communicate with child parachains.
|
||||
xcm_sender::ChildParachainRouter<Runtime>,
|
||||
xcm_sender::ChildParachainRouter<Runtime, xcm::AlwaysRelease>,
|
||||
);
|
||||
|
||||
use xcm::v0::{
|
||||
Junction::Parachain,
|
||||
MultiAsset,
|
||||
MultiAsset::AllConcreteFungible,
|
||||
MultiLocation::{Null, X1},
|
||||
};
|
||||
parameter_types! {
|
||||
pub const RococoForTick: (MultiAsset, MultiLocation) =
|
||||
(AllConcreteFungible { id: Null }, X1(Parachain(100)));
|
||||
pub const RococoForTrick: (MultiAsset, MultiLocation) =
|
||||
(AllConcreteFungible { id: Null }, X1(Parachain(110)));
|
||||
pub const RococoForTrack: (MultiAsset, MultiLocation) =
|
||||
(AllConcreteFungible { id: Null }, X1(Parachain(120)));
|
||||
pub const RococoForStatemint: (MultiAsset, MultiLocation) =
|
||||
(AllConcreteFungible { id: Null }, X1(Parachain(1001)));
|
||||
pub const Rococo: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(RocLocation::get()) });
|
||||
pub const RococoForTick: (MultiAssetFilter, MultiLocation) = (Rococo::get(), X1(Parachain(100)));
|
||||
pub const RococoForTrick: (MultiAssetFilter, MultiLocation) = (Rococo::get(), X1(Parachain(110)));
|
||||
pub const RococoForTrack: (MultiAssetFilter, MultiLocation) = (Rococo::get(), X1(Parachain(120)));
|
||||
pub const RococoForStatemint: (MultiAssetFilter, MultiLocation) = (Rococo::get(), X1(Parachain(1001)));
|
||||
}
|
||||
pub type TrustedTeleporters = (
|
||||
xcm_builder::Case<RococoForTick>,
|
||||
@@ -692,65 +683,14 @@ pub type LocalOriginToLocation = (
|
||||
SignedToAccountId32<Origin, AccountId, RococoNetwork>,
|
||||
);
|
||||
|
||||
pub struct OnlyWithdrawTeleportForAccounts;
|
||||
impl frame_support::traits::Contains<(MultiLocation, Xcm<Call>)>
|
||||
for OnlyWithdrawTeleportForAccounts
|
||||
{
|
||||
fn contains((ref origin, ref msg): &(MultiLocation, Xcm<Call>)) -> bool {
|
||||
use xcm::v0::{
|
||||
Junction::{AccountId32, Plurality},
|
||||
MultiAsset::{All, ConcreteFungible},
|
||||
Order::{BuyExecution, DepositAsset, InitiateTeleport},
|
||||
Xcm::WithdrawAsset,
|
||||
};
|
||||
match origin {
|
||||
// Root and collective are allowed to execute anything.
|
||||
Null | X1(Plurality { .. }) => true,
|
||||
X1(AccountId32 { .. }) => {
|
||||
// An account ID trying to send a message. We ensure that it's sensible.
|
||||
// This checks that it's of the form:
|
||||
// WithdrawAsset {
|
||||
// assets: [ ConcreteFungible { id: Null } ],
|
||||
// effects: [ BuyExecution, InitiateTeleport {
|
||||
// assets: All,
|
||||
// dest: Parachain,
|
||||
// effects: [ BuyExecution, DepositAssets {
|
||||
// assets: All,
|
||||
// dest: AccountId32,
|
||||
// } ]
|
||||
// } ]
|
||||
// }
|
||||
matches!(msg, WithdrawAsset { ref assets, ref effects }
|
||||
if assets.len() == 1
|
||||
&& matches!(assets[0], ConcreteFungible { id: Null, .. })
|
||||
&& effects.len() == 2
|
||||
&& matches!(effects[0], BuyExecution { .. })
|
||||
&& matches!(effects[1], InitiateTeleport { ref assets, dest: X1(Parachain(..)), ref effects }
|
||||
if assets.len() == 1
|
||||
&& matches!(assets[0], All)
|
||||
&& effects.len() == 2
|
||||
&& matches!(effects[0], BuyExecution { .. })
|
||||
&& matches!(effects[1], DepositAsset { ref assets, dest: X1(AccountId32{..}) }
|
||||
if assets.len() == 1
|
||||
&& matches!(assets[0], All)
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
// Nobody else is allowed to execute anything.
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
type Event = Event;
|
||||
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
|
||||
type XcmRouter = XcmRouter;
|
||||
// Anyone can execute XCM messages locally...
|
||||
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
|
||||
// ...but they must match our filter, which requires them to be a simple withdraw + teleport.
|
||||
type XcmExecuteFilter = OnlyWithdrawTeleportForAccounts;
|
||||
// ...but they must match our filter, which right now rejects everything.
|
||||
type XcmExecuteFilter = ();
|
||||
type XcmExecutor = XcmExecutor<XcmConfig>;
|
||||
type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;
|
||||
type XcmReserveTransferFilter = All<(MultiLocation, Vec<MultiAsset>)>;
|
||||
|
||||
Reference in New Issue
Block a user