mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 11:41:02 +00:00
Asset conversion nits (#2860)
* [asset-conv] Unused Balances type
* [asset-conv] native asset change
* Dedicated `AssetBalance` type for `pallet_assets` instances
* Improved local vs foreign asset handling + test for not allowing pool_assets in pool
* Removed `into_multiasset_id`
* Fix
* Refactor
* Fixed create_pool for benchmark with LocalAndForeignAssets (finally found it)
* ".git/.scripts/commands/fmt/fmt.sh"
* Revert
* fmt
* Migrates pools with `MultiLocation { parents: 0, interior: Here }` to `MultiLocation { parents: 1, interior: Here }`
* Allow `set_storage` for `AllowMultiAssetPools` / `LiquidityWithdrawalFee`
* Benchmarks work
* Removed comment + more defensive migration
* `T::Currency::transfer` -> `Balances::transfer_all` in migration
* Change pool_id in migration
* Update parachains/runtimes/assets/asset-hub-westend/src/lib.rs
* Bump substrate (manually)
* Bump polkadot
* Fixes from polkadot + clippy
* Fix for xcm-emulator tests (thank you Nacho)
---------
Co-authored-by: command-bot <>
Co-authored-by: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com>
This commit is contained in:
@@ -18,9 +18,12 @@ use super::{
|
||||
ParachainSystem, PolkadotXcm, PoolAssets, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
|
||||
TrustBackedAssetsInstance, WeightToFee, XcmpQueue,
|
||||
};
|
||||
use crate::ForeignAssets;
|
||||
use assets_common::matching::{
|
||||
FromSiblingParachain, IsForeignConcreteAsset, StartsWith, StartsWithExplicitGlobalConsensus,
|
||||
use crate::{AllowMultiAssetPools, ForeignAssets, LiquidityWithdrawalFee};
|
||||
use assets_common::{
|
||||
local_and_foreign_assets::MatchesLocalAndForeignAssetsMultiLocation,
|
||||
matching::{
|
||||
FromSiblingParachain, IsForeignConcreteAsset, StartsWith, StartsWithExplicitGlobalConsensus,
|
||||
},
|
||||
};
|
||||
use frame_support::{
|
||||
match_types, parameter_types,
|
||||
@@ -163,6 +166,25 @@ pub type PoolFungiblesTransactor = FungiblesAdapter<
|
||||
pub type AssetTransactors =
|
||||
(CurrencyTransactor, FungiblesTransactor, ForeignFungiblesTransactor, PoolFungiblesTransactor);
|
||||
|
||||
/// Simple `MultiLocation` matcher for Local and Foreign asset `MultiLocation`.
|
||||
pub struct LocalAndForeignAssetsMultiLocationMatcher;
|
||||
impl MatchesLocalAndForeignAssetsMultiLocation for LocalAndForeignAssetsMultiLocationMatcher {
|
||||
fn is_local(location: &MultiLocation) -> bool {
|
||||
use assets_common::fungible_conversion::MatchesMultiLocation;
|
||||
TrustBackedAssetsConvertedConcreteId::contains(location)
|
||||
}
|
||||
|
||||
fn is_foreign(location: &MultiLocation) -> bool {
|
||||
use assets_common::fungible_conversion::MatchesMultiLocation;
|
||||
ForeignAssetsConvertedConcreteId::contains(location)
|
||||
}
|
||||
}
|
||||
impl Contains<MultiLocation> for LocalAndForeignAssetsMultiLocationMatcher {
|
||||
fn contains(location: &MultiLocation) -> bool {
|
||||
Self::is_local(location) || Self::is_foreign(location)
|
||||
}
|
||||
}
|
||||
|
||||
/// 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
|
||||
/// biases the kind of local `Origin` it will become.
|
||||
@@ -217,6 +239,16 @@ impl Contains<RuntimeCall> for SafeCallFilter {
|
||||
}
|
||||
}
|
||||
|
||||
// Allow to change dedicated storage items (called by governance-like)
|
||||
match call {
|
||||
RuntimeCall::System(frame_system::Call::set_storage { items })
|
||||
if items.iter().any(|(k, _)| {
|
||||
k.eq(&AllowMultiAssetPools::key()) | k.eq(&LiquidityWithdrawalFee::key())
|
||||
}) =>
|
||||
return true,
|
||||
_ => (),
|
||||
};
|
||||
|
||||
matches!(
|
||||
call,
|
||||
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
|
||||
@@ -540,7 +572,8 @@ pub struct BenchmarkMultiLocationConverter<SelfParaId> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
impl<SelfParaId> pallet_asset_conversion::BenchmarkHelper<MultiLocation>
|
||||
impl<SelfParaId>
|
||||
pallet_asset_conversion::BenchmarkHelper<MultiLocation, sp_std::boxed::Box<MultiLocation>>
|
||||
for BenchmarkMultiLocationConverter<SelfParaId>
|
||||
where
|
||||
SelfParaId: Get<ParaId>,
|
||||
@@ -555,4 +588,8 @@ where
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
fn multiasset_id(asset_id: u32) -> sp_std::boxed::Box<MultiLocation> {
|
||||
sp_std::boxed::Box::new(Self::asset_id(asset_id))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user