mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 06:21:02 +00:00
Remove xcm::v3 from assets-common nits (#4037)
This PR mainly removes `xcm::v3` stuff from `assets-common` to make it
more generic and facilitate the transition to newer XCM versions. Some
of the implementations here used hard-coded `xcm::v3::Location`, but now
it's up to the runtime to configure according to its needs.
Additional/consequent changes:
- `penpal` runtime uses now `xcm::latest::Location` for `pallet_assets`
as `AssetId`, because we don't care about migrations here
- it pretty much simplify xcm-emulator integration tests, where we don't
need now a lots of boilerplate conversions:
```
v3::Location::try_from(...).expect("conversion works")`
```
- xcm-emulator tests
- split macro `impl_assets_helpers_for_parachain` to the
`impl_assets_helpers_for_parachain` and
`impl_foreign_assets_helpers_for_parachain` (avoids using hard-coded
`xcm::v3::Location`)
This commit is contained in:
@@ -72,18 +72,14 @@ use sp_std::prelude::*;
|
||||
#[cfg(feature = "std")]
|
||||
use sp_version::NativeVersion;
|
||||
use sp_version::RuntimeVersion;
|
||||
use xcm_config::XcmOriginToTransactDispatchOrigin;
|
||||
use xcm_config::{ForeignAssetsAssetId, XcmOriginToTransactDispatchOrigin};
|
||||
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub use sp_runtime::BuildStorage;
|
||||
|
||||
// Polkadot imports
|
||||
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
|
||||
|
||||
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
|
||||
|
||||
// XCM Imports
|
||||
use parachains_common::{AccountId, Signature};
|
||||
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
|
||||
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
|
||||
use xcm::latest::prelude::{AssetId as AssetLocationId, BodyId};
|
||||
|
||||
/// Balance of an account.
|
||||
@@ -474,8 +470,8 @@ pub type ForeignAssetsInstance = pallet_assets::Instance2;
|
||||
impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Balance = Balance;
|
||||
type AssetId = xcm::v3::Location;
|
||||
type AssetIdParameter = xcm::v3::Location;
|
||||
type AssetId = ForeignAssetsAssetId;
|
||||
type AssetIdParameter = ForeignAssetsAssetId;
|
||||
type Currency = Balances;
|
||||
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
|
||||
type ForceOrigin = EnsureRoot<AccountId>;
|
||||
|
||||
@@ -40,7 +40,7 @@ use pallet_xcm::XcmPassthrough;
|
||||
use parachains_common::{xcm_config::AssetFeeAsExistentialDepositMultiplier, TREASURY_PALLET_ID};
|
||||
use polkadot_parachain_primitives::primitives::Sibling;
|
||||
use polkadot_runtime_common::{impls::ToAuthor, xcm_sender::ExponentialPrice};
|
||||
use sp_runtime::traits::{AccountIdConversion, ConvertInto};
|
||||
use sp_runtime::traits::{AccountIdConversion, ConvertInto, Identity, TryConvertInto};
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
@@ -84,7 +84,7 @@ pub type LocationToAccountId = (
|
||||
);
|
||||
|
||||
/// Means for transacting assets on this chain.
|
||||
pub type CurrencyTransactor = FungibleAdapter<
|
||||
pub type FungibleTransactor = FungibleAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
// Use this currency when it is a fungible asset matching the given location or name:
|
||||
@@ -131,7 +131,11 @@ pub type FungiblesTransactor = FungiblesAdapter<
|
||||
CheckingAccount,
|
||||
>;
|
||||
|
||||
pub type ForeignAssetsConvertedConcreteId = assets_common::LocationConvertedConcreteId<
|
||||
// Using the latest `Location`, we don't need to worry about migrations for Penpal.
|
||||
pub type ForeignAssetsAssetId = Location;
|
||||
pub type ForeignAssetsConvertedConcreteId = xcm_builder::MatchedConvertedConcreteId<
|
||||
Location,
|
||||
Balance,
|
||||
EverythingBut<(
|
||||
// Here we rely on fact that something like this works:
|
||||
// assert!(Location::new(1,
|
||||
@@ -139,7 +143,8 @@ pub type ForeignAssetsConvertedConcreteId = assets_common::LocationConvertedConc
|
||||
// assert!([Parachain(100)].into().starts_with(&Here));
|
||||
StartsWith<assets_common::matching::LocalLocationPattern>,
|
||||
)>,
|
||||
Balance,
|
||||
Identity,
|
||||
TryConvertInto,
|
||||
>;
|
||||
|
||||
/// Means for transacting foreign assets from different global consensus.
|
||||
@@ -159,7 +164,7 @@ pub type ForeignFungiblesTransactor = FungiblesAdapter<
|
||||
>;
|
||||
|
||||
/// Means for transacting assets on this chain.
|
||||
pub type AssetTransactors = (CurrencyTransactor, ForeignFungiblesTransactor, FungiblesTransactor);
|
||||
pub type AssetTransactors = (FungibleTransactor, ForeignFungiblesTransactor, FungiblesTransactor);
|
||||
|
||||
/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
|
||||
/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can
|
||||
@@ -416,8 +421,8 @@ impl cumulus_pallet_xcm::Config for Runtime {
|
||||
/// Simple conversion of `u32` into an `AssetId` for use in benchmarking.
|
||||
pub struct XcmBenchmarkHelper;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
impl pallet_assets::BenchmarkHelper<xcm::v3::Location> for XcmBenchmarkHelper {
|
||||
fn create_asset_id_parameter(id: u32) -> xcm::v3::Location {
|
||||
xcm::v3::Location::new(1, [xcm::v3::Junction::Parachain(id)])
|
||||
impl pallet_assets::BenchmarkHelper<ForeignAssetsAssetId> for XcmBenchmarkHelper {
|
||||
fn create_asset_id_parameter(id: u32) -> ForeignAssetsAssetId {
|
||||
Location::new(1, [Parachain(id)])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ pub type LocationToAccountId = (
|
||||
);
|
||||
|
||||
/// Means for transacting assets on this chain.
|
||||
pub type CurrencyTransactor = FungibleAdapter<
|
||||
pub type FungibleTransactor = FungibleAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
// Use this currency when it is a fungible asset matching the given location or name:
|
||||
@@ -385,7 +385,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
|
||||
CheckingAccount,
|
||||
>;
|
||||
/// Means for transacting assets on this chain.
|
||||
pub type AssetTransactors = (CurrencyTransactor, FungiblesTransactor);
|
||||
pub type AssetTransactors = (FungibleTransactor, FungiblesTransactor);
|
||||
|
||||
/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
|
||||
/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can
|
||||
|
||||
Reference in New Issue
Block a user