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:
Branislav Kontur
2023-07-21 23:53:51 +02:00
committed by GitHub
parent 849964bf18
commit 8171890f9b
25 changed files with 1060 additions and 486 deletions
@@ -28,7 +28,8 @@ use asset_hub_westend_runtime::{
AssetFeeAsExistentialDepositMultiplierFeeCharger, ForeignCreatorsSovereignAccountOf,
WestendLocation,
},
MetadataDepositBase, MetadataDepositPerByte, RuntimeCall, RuntimeEvent,
AllowMultiAssetPools, LiquidityWithdrawalFee, MetadataDepositBase, MetadataDepositPerByte,
RuntimeCall, RuntimeEvent,
};
use asset_test_utils::{CollatorSessionKeys, ExtBuilder, RuntimeHelper, XcmReceivedFrom};
use codec::{Decode, DecodeLimit, Encode};
@@ -39,7 +40,10 @@ use frame_support::{
weights::{Weight, WeightToFee as WeightToFeeT},
};
use parachains_common::{AccountId, AssetIdForTrustBackedAssets, AuraId, Balance};
use sp_runtime::traits::MaybeEquivalence;
use sp_runtime::{
traits::{CheckedAdd, CheckedSub, MaybeEquivalence},
Permill,
};
use std::convert::Into;
use xcm::{latest::prelude::*, VersionedXcm, MAX_XCM_DECODE_DEPTH};
use xcm_executor::{
@@ -652,3 +656,39 @@ fn plain_receive_teleported_asset_works() {
assert_eq!(outcome.ensure_complete(), Ok(()));
})
}
#[test]
fn change_allow_multi_asset_pools_by_governance_works() {
asset_test_utils::test_cases::change_storage_constant_by_governance_works::<
Runtime,
AllowMultiAssetPools,
bool,
>(
collator_session_keys(),
1000,
Box::new(|call| RuntimeCall::System(call).encode()),
|| (AllowMultiAssetPools::key().to_vec(), AllowMultiAssetPools::get()),
|old_value| !old_value,
)
}
#[test]
fn change_liquidity_withdrawal_fee_by_governance_works() {
asset_test_utils::test_cases::change_storage_constant_by_governance_works::<
Runtime,
LiquidityWithdrawalFee,
Permill,
>(
collator_session_keys(),
1000,
Box::new(|call| RuntimeCall::System(call).encode()),
|| (LiquidityWithdrawalFee::key().to_vec(), LiquidityWithdrawalFee::get()),
|old_value| {
if let Some(new_value) = old_value.checked_add(&Permill::from_percent(2)) {
new_value
} else {
old_value.checked_sub(&Permill::from_percent(2)).unwrap()
}
},
)
}