frequency_runtime/xcm/
asset_transactor.rs

1use crate::{AccountId, Balances, ForeignAssets, PolkadotXcm};
2use staging_xcm::latest::prelude::*;
3use staging_xcm_builder::{
4	FungibleAdapter, FungiblesAdapter, IsConcrete, IsParentsOnly, MatchedConvertedConcreteId,
5	MintLocation, NoChecking,
6};
7
8use crate::xcm::location_converter::LocationToAccountId;
9
10use frame_support::{parameter_types, traits::ConstU8};
11
12parameter_types! {
13	pub HereLocation: Location = Location::here();
14	pub CheckingAccount: AccountId = PolkadotXcm::check_account();
15	pub Checking: (AccountId, MintLocation) = (CheckingAccount::get(), MintLocation::Local);
16}
17
18/// Adapter for transacting native assets (like balances)
19pub type LocalAssetTransactor = FungibleAdapter<
20	// Use native currency:
21	Balances,
22	// Use this currency when it is a fungible asset matching the native location
23	IsConcrete<HereLocation>,
24	// Do a simple check to convert an AccountId32 Location into a native chain account ID:
25	LocationToAccountId,
26	// Our chain's account ID type (we can't get away without mentioning it explicitly):
27	AccountId,
28	// We track teleports.
29	Checking,
30>;
31
32/// Adapter for transacting foreign assets (like DOT)
33/// Type for specifying how a `Location` can be converted into an `AccountId`.
34pub type ForeignAssetsAdapter = FungiblesAdapter<
35	ForeignAssets,
36	// Use this currency when it is a fungible asset matching the given location or name:
37	MatchedConvertedConcreteId<
38		Location,
39		u128,
40		IsParentsOnly<ConstU8<1>>,
41		xcm_executor::traits::JustTry,
42		xcm_executor::traits::JustTry,
43	>,
44	// Convert an XCM Location into a local account id:
45	LocationToAccountId,
46	// Our chain's account ID type (we can't get away without mentioning it explicitly):
47	AccountId,
48	// We do not allow teleportation of foreign assets
49	NoChecking,
50	CheckingAccount,
51>;
52
53/// The complete set of transactors
54pub type AssetTransactors = (LocalAssetTransactor, ForeignAssetsAdapter);