mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 23:21:02 +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:
@@ -17,10 +17,9 @@
|
||||
mod parachain;
|
||||
mod relay_chain;
|
||||
|
||||
use sp_runtime::AccountId32;
|
||||
use xcm_simulator::{decl_test_network, decl_test_parachain, decl_test_relay_chain};
|
||||
|
||||
pub const ALICE: AccountId32 = AccountId32::new([0u8; 32]);
|
||||
pub const ALICE: sp_runtime::AccountId32 = sp_runtime::AccountId32::new([0u8; 32]);
|
||||
|
||||
decl_test_parachain! {
|
||||
pub struct ParaA {
|
||||
@@ -100,13 +99,7 @@ mod tests {
|
||||
|
||||
use codec::Encode;
|
||||
use frame_support::assert_ok;
|
||||
use xcm::v0::{
|
||||
Junction::{self, Parachain, Parent},
|
||||
MultiAsset::*,
|
||||
MultiLocation::*,
|
||||
NetworkId, OriginKind,
|
||||
Xcm::*,
|
||||
};
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_simulator::TestExt;
|
||||
|
||||
#[test]
|
||||
@@ -118,7 +111,7 @@ mod tests {
|
||||
);
|
||||
Relay::execute_with(|| {
|
||||
assert_ok!(RelayChainPalletXcm::send_xcm(
|
||||
Null,
|
||||
Here,
|
||||
X1(Parachain(1)),
|
||||
Transact {
|
||||
origin_type: OriginKind::SovereignAccount,
|
||||
@@ -145,7 +138,7 @@ mod tests {
|
||||
);
|
||||
ParaA::execute_with(|| {
|
||||
assert_ok!(ParachainPalletXcm::send_xcm(
|
||||
Null,
|
||||
Here,
|
||||
X1(Parent),
|
||||
Transact {
|
||||
origin_type: OriginKind::SovereignAccount,
|
||||
@@ -172,7 +165,7 @@ mod tests {
|
||||
);
|
||||
ParaA::execute_with(|| {
|
||||
assert_ok!(ParachainPalletXcm::send_xcm(
|
||||
Null,
|
||||
Here,
|
||||
X2(Parent, Parachain(2)),
|
||||
Transact {
|
||||
origin_type: OriginKind::SovereignAccount,
|
||||
@@ -198,9 +191,10 @@ mod tests {
|
||||
assert_ok!(RelayChainPalletXcm::reserve_transfer_assets(
|
||||
relay_chain::Origin::signed(ALICE),
|
||||
X1(Parachain(1)),
|
||||
X1(Junction::AccountId32 { network: NetworkId::Any, id: ALICE.into() }),
|
||||
vec![ConcreteFungible { id: Null, amount: 123 }],
|
||||
123,
|
||||
X1(AccountId32 { network: Any, id: ALICE.into() }),
|
||||
(Here, 123).into(),
|
||||
0,
|
||||
3,
|
||||
));
|
||||
});
|
||||
|
||||
|
||||
@@ -35,19 +35,10 @@ use polkadot_core_primitives::BlockNumber as RelayBlockNumber;
|
||||
use polkadot_parachain::primitives::{
|
||||
DmpMessageHandler, Id as ParaId, Sibling, XcmpMessageFormat, XcmpMessageHandler,
|
||||
};
|
||||
use xcm::{
|
||||
v0::{
|
||||
Error as XcmError, ExecuteXcm,
|
||||
Junction::{Parachain, Parent},
|
||||
MultiAsset,
|
||||
MultiLocation::{self, X1},
|
||||
NetworkId, Outcome, Xcm,
|
||||
},
|
||||
VersionedXcm,
|
||||
};
|
||||
use xcm::{latest::prelude::*, VersionedXcm};
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowUnpaidExecutionFrom, CurrencyAdapter as XcmCurrencyAdapter,
|
||||
EnsureXcmOrigin, FixedRateOfConcreteFungible, FixedWeightBounds, IsConcrete, LocationInverter,
|
||||
EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, IsConcrete, LocationInverter,
|
||||
NativeAsset, ParentIsDefault, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation,
|
||||
};
|
||||
@@ -129,7 +120,7 @@ pub type XcmOriginToCallOrigin = (
|
||||
|
||||
parameter_types! {
|
||||
pub const UnitWeightCost: Weight = 1;
|
||||
pub KsmPerSecond: (MultiLocation, u128) = (X1(Parent), 1);
|
||||
pub KsmPerSecond: (AssetId, u128) = (Concrete(X1(Parent)), 1);
|
||||
}
|
||||
|
||||
pub type LocalAssetTransactor =
|
||||
@@ -149,7 +140,7 @@ impl Config for XcmConfig {
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
|
||||
type Trader = FixedRateOfConcreteFungible<KsmPerSecond, ()>;
|
||||
type Trader = FixedRateOfFungible<KsmPerSecond, ()>;
|
||||
type ResponseHandler = ();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,13 +26,12 @@ use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32};
|
||||
|
||||
use polkadot_parachain::primitives::Id as ParaId;
|
||||
use polkadot_runtime_parachains::{configuration, origin, shared, ump};
|
||||
use xcm::v0::{MultiAsset, MultiLocation, NetworkId};
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowUnpaidExecutionFrom, ChildParachainAsNative,
|
||||
ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
|
||||
CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfConcreteFungible, FixedWeightBounds,
|
||||
IsConcrete, LocationInverter, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation,
|
||||
CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, FixedWeightBounds, IsConcrete,
|
||||
LocationInverter, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation,
|
||||
};
|
||||
use xcm_executor::{Config, XcmExecutor};
|
||||
|
||||
@@ -92,10 +91,10 @@ impl shared::Config for Runtime {}
|
||||
impl configuration::Config for Runtime {}
|
||||
|
||||
parameter_types! {
|
||||
pub const KsmLocation: MultiLocation = MultiLocation::Null;
|
||||
pub const KsmLocation: MultiLocation = MultiLocation::Here;
|
||||
pub const KusamaNetwork: NetworkId = NetworkId::Kusama;
|
||||
pub const AnyNetwork: NetworkId = NetworkId::Any;
|
||||
pub Ancestry: MultiLocation = MultiLocation::Null;
|
||||
pub Ancestry: MultiLocation = MultiLocation::Here;
|
||||
pub UnitWeightCost: Weight = 1_000;
|
||||
}
|
||||
|
||||
@@ -114,7 +113,7 @@ type LocalOriginConverter = (
|
||||
|
||||
parameter_types! {
|
||||
pub const BaseXcmWeight: Weight = 1_000;
|
||||
pub KsmPerSecond: (MultiLocation, u128) = (KsmLocation::get(), 1);
|
||||
pub KsmPerSecond: (AssetId, u128) = (Concrete(KsmLocation::get()), 1);
|
||||
}
|
||||
|
||||
pub type XcmRouter = super::RelayChainXcmRouter;
|
||||
@@ -131,7 +130,7 @@ impl Config for XcmConfig {
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
|
||||
type Trader = FixedRateOfConcreteFungible<KsmPerSecond, ()>;
|
||||
type Trader = FixedRateOfFungible<KsmPerSecond, ()>;
|
||||
type ResponseHandler = ();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user