mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 16:21:02 +00:00
Add Support for Foreign Assets (#2133)
* add foreign assets to westmint * add foreign assets to statemine * use updated api for ensure origin trait * Assets/ForeignAssets tests and fixes (#2167) * Test for create and transfer `TrustBackedAssets` with AssetTransactor * Test for transfer `local Currency` with AssetTransactor * Test for create foreign assets (covers foreign relaychain currency) * Added `ForeignFungiblesTransactor` and test for transfer `ForeignAssets` with AssetTransactor * Removed unused `pub const Local: MultiLocation` * Changed `ParaId -> Sibling` for `SiblingParachainConvertsVia` * Test for create foreign assets (covers local sibling parachain assets) * Reverted stuff for ForeignCreators from different global consensus (moved to transfer asset branch) * Refactor `weight_limit` for `execute_xcm` * Added test for `set_metadata` by ForeignCreator with `xcm::Transact(set_metadata)` * Renamed `receive_teleported_asset_works` -> `receive_teleported_asset_for_native_asset_works` * Allow `ForeignCreators` only for sibling parachains * Unify ReservedDmpWeight/ReservedXcmpWeight usage * Removed hack - replaced with `MatchedConvertedConcreteId` * Refactor `ForeignCreators` to assets-common * Add `ReceiveTeleportedAsset` test * Change test - `Utility::batch` -> Multiple `xcm::Transact` * Reusing the same deposits as for TrustBackedAssets * missing `try_successful_origin` ? * Finished `ForeignAssets` for westmint (converter, FungiblesApi, tests) * Refactoring tests - receive_teleported_asset_for_native_asset_works * ForeignAssets for statemine + refactored `receive_teleported_asset_from_foreign_creator_works` * Add `ForeignAssets` to statemine `FungiblesApi` * Add `asset_transactor_transfer_with_local_consensus_currency_works` to all runtimes * Added `asset_transactor_transfer_with_trust_backed_assets_works` test * Added `asset_transactor_transfer_with_foreign_assets_works` * Fix `missing `try_successful_origin` in implementation` * Added `create_and_manage_foreign_assets_for_local_consensus_parachain_assets_works` * Added `ExpectTransactStatus` check * Small rename * Extended `test_assets_balances_api_works` with ForeignAssets for `statemine` * PR fixes * Update parachains/runtimes/assets/test-utils/src/test_cases.rs --------- Co-authored-by: parity-processbot <> Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Added `StartsWithExplicitGlobalConsensus` to ignores (#2338) * Update parachains/runtimes/assets/common/src/lib.rs Co-authored-by: Gavin Wood <gavin@parity.io> * include mint and burn in SafeCallFilter * include mint and burn in SafeCallFilter (statemine) * clarify doc * Fix compilation (moved trait `InspectMetadata`) * Fix test * Extended test for `teleport` from/to relaychain + `CheckingAccount` (Part I) * Extended test for `teleport` from/to foreign parachain + `CheckingAccount` (Part II) * Fixed TODO - `NonLocal` for `ForeignAssets` * Changed `NonLocal` to `NoChecking` * Fix weight in test --------- Co-authored-by: parity-processbot <> Co-authored-by: muharem <ismailov.m.h@gmail.com> Co-authored-by: Branislav Kontur <bkontur@gmail.com> Co-authored-by: Gavin Wood <gavin@parity.io>
This commit is contained in:
@@ -69,17 +69,20 @@ use parachains_common::{
|
||||
NORMAL_DISPATCH_RATIO, SLOT_DURATION,
|
||||
};
|
||||
use xcm_config::{
|
||||
TrustBackedAssetsConvertedConcreteId, WestendLocation, XcmConfig,
|
||||
XcmOriginToTransactDispatchOrigin,
|
||||
ForeignAssetsConvertedConcreteId, TrustBackedAssetsConvertedConcreteId, WestendLocation,
|
||||
XcmConfig, XcmOriginToTransactDispatchOrigin,
|
||||
};
|
||||
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub use sp_runtime::BuildStorage;
|
||||
|
||||
// Polkadot imports
|
||||
use assets_common::{
|
||||
foreign_creators::ForeignCreators, matching::FromSiblingParachain, MultiLocationForAssetId,
|
||||
};
|
||||
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
use crate::xcm_config::ForeignCreatorsSovereignAccountOf;
|
||||
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
|
||||
|
||||
impl_opaque_keys! {
|
||||
@@ -250,6 +253,48 @@ impl pallet_assets::Config<TrustBackedAssetsInstance> for Runtime {
|
||||
type BenchmarkHelper = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
// we just reuse the same deposits
|
||||
pub const ForeignAssetsAssetDeposit: Balance = AssetDeposit::get();
|
||||
pub const ForeignAssetsAssetAccountDeposit: Balance = AssetAccountDeposit::get();
|
||||
pub const ForeignAssetsApprovalDeposit: Balance = ApprovalDeposit::get();
|
||||
pub const ForeignAssetsAssetsStringLimit: u32 = AssetsStringLimit::get();
|
||||
pub const ForeignAssetsMetadataDepositBase: Balance = MetadataDepositBase::get();
|
||||
pub const ForeignAssetsMetadataDepositPerByte: Balance = MetadataDepositPerByte::get();
|
||||
}
|
||||
|
||||
/// Assets managed by some foreign location. Note: we do not declare a `ForeignAssetsCall` type, as
|
||||
/// this type is used in proxy definitions. We assume that a foreign location would not want to set
|
||||
/// an individual, local account as a proxy for the issuance of their assets. This issuance should
|
||||
/// be managed by the foreign location's governance.
|
||||
pub type ForeignAssetsInstance = pallet_assets::Instance2;
|
||||
impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Balance = Balance;
|
||||
type AssetId = MultiLocationForAssetId;
|
||||
type AssetIdParameter = MultiLocationForAssetId;
|
||||
type Currency = Balances;
|
||||
type CreateOrigin = ForeignCreators<
|
||||
(FromSiblingParachain<parachain_info::Pallet<Runtime>>,),
|
||||
ForeignCreatorsSovereignAccountOf,
|
||||
AccountId,
|
||||
>;
|
||||
type ForceOrigin = AssetsForceOrigin;
|
||||
type AssetDeposit = ForeignAssetsAssetDeposit;
|
||||
type MetadataDepositBase = ForeignAssetsMetadataDepositBase;
|
||||
type MetadataDepositPerByte = ForeignAssetsMetadataDepositPerByte;
|
||||
type ApprovalDeposit = ForeignAssetsApprovalDeposit;
|
||||
type StringLimit = ForeignAssetsAssetsStringLimit;
|
||||
type Freezer = ();
|
||||
type Extra = ();
|
||||
type WeightInfo = weights::pallet_assets::WeightInfo<Runtime>;
|
||||
type CallbackHandle = ();
|
||||
type AssetAccountDeposit = ForeignAssetsAssetAccountDeposit;
|
||||
type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type BenchmarkHelper = xcm_config::XcmBenchmarkHelper;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
// One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes.
|
||||
pub const DepositBase: Balance = deposit(1, 88);
|
||||
@@ -322,6 +367,7 @@ impl Default for ProxyType {
|
||||
Self::Any
|
||||
}
|
||||
}
|
||||
|
||||
impl InstanceFilter<RuntimeCall> for ProxyType {
|
||||
fn filter(&self, c: &RuntimeCall) -> bool {
|
||||
match self {
|
||||
@@ -661,6 +707,7 @@ construct_runtime!(
|
||||
Assets: pallet_assets::<Instance1>::{Pallet, Call, Storage, Event<T>} = 50,
|
||||
Uniques: pallet_uniques::{Pallet, Call, Storage, Event<T>} = 51,
|
||||
Nfts: pallet_nfts::{Pallet, Call, Storage, Event<T>} = 52,
|
||||
ForeignAssets: pallet_assets::<Instance2>::{Pallet, Call, Storage, Event<T>} = 53,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -710,6 +757,7 @@ mod benches {
|
||||
define_benchmarks!(
|
||||
[frame_system, SystemBench::<Runtime>]
|
||||
[pallet_assets, Assets]
|
||||
[pallet_assets, ForeignAssets]
|
||||
[pallet_balances, Balances]
|
||||
[pallet_multisig, Multisig]
|
||||
[pallet_nfts, Nfts]
|
||||
@@ -929,11 +977,17 @@ impl_runtime_apis! {
|
||||
},
|
||||
// collect pallet_assets (TrustBackedAssets)
|
||||
convert::<_, _, _, _, TrustBackedAssetsConvertedConcreteId>(
|
||||
Assets::account_balances(account)
|
||||
Assets::account_balances(account.clone())
|
||||
.iter()
|
||||
.filter(|(_, balance)| balance > &0)
|
||||
)?,
|
||||
// collect ... e.g. pallet_assets ForeignAssets
|
||||
// collect pallet_assets (ForeignAssets)
|
||||
convert::<_, _, _, _, ForeignAssetsConvertedConcreteId>(
|
||||
ForeignAssets::account_balances(account)
|
||||
.iter()
|
||||
.filter(|(_, balance)| balance > &0)
|
||||
)?,
|
||||
// collect ... e.g. other tokens
|
||||
].concat())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user