--- a/runtime/opal/src/xcm_config.rs +++ b/runtime/opal/src/xcm_config.rs @@ -65,185 +65,14 @@ // Signed version of balance pub type Amount = i128; -/* -parameter_types! { - pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4; - pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4; -} - -impl cumulus_pallet_parachain_system::Config for Runtime { - type Event = Event; - type SelfParaId = parachain_info::Pallet; - type OnSystemEvent = (); - type OutboundXcmpMessageSource = XcmpQueue; - type DmpMessageHandler = DmpQueue; - type ReservedDmpWeight = ReservedDmpWeight; - type ReservedXcmpWeight = ReservedXcmpWeight; - type XcmpMessageHandler = XcmpQueue; -} - -impl parachain_info::Config for Runtime {} - -impl cumulus_pallet_aura_ext::Config for Runtime {} - */ - parameter_types! { pub const RelayLocation: MultiLocation = MultiLocation::parent(); pub const RelayNetwork: NetworkId = NetworkId::Polkadot; pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into(); pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); pub SelfLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into()))); -} - -/* -/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used -/// when determining ownership of accounts for asset transacting and when attempting to use XCM -/// `Transact` in order to determine the dispatch Origin. -pub type LocationToAccountId = ( - // The parent (Relay-chain) origin converts to the default `AccountId`. - ParentIsPreset, - // Sibling parachain origins convert to AccountId via the `ParaId::into`. - SiblingParachainConvertsVia, - // Straight up local `AccountId32` origins just alias directly to `AccountId`. - AccountId32Aliases, -); - -pub struct OnlySelfCurrency; - -impl> MatchesFungible for OnlySelfCurrency { - fn matches_fungible(a: &MultiAsset) -> Option { - match (&a.id, &a.fun) { - (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount), - _ => None, - } - } -} - -/// Means for transacting assets on this chain. -pub type LocalAssetTransactor = CurrencyAdapter< - // Use this currency: - Balances, - // Use this currency when it is a fungible asset matching the given location or name: - OnlySelfCurrency, - // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID: - LocationToAccountId, - // Our chain's account ID type (we can't get away without mentioning it explicitly): - AccountId, - // We don't track any teleports. - (), ->; - - */ - -/* -parameter_types! { - pub CheckingAccount: AccountId = PolkadotXcm::check_account(); -} - -/// Allow checking in assets that have issuance > 0. -pub struct NonZeroIssuance(PhantomData<(AccountId, ForeingAssets)>); -impl Contains<>::AssetId> - for NonZeroIssuance -where - ForeingAssets: fungibles::Inspect, -{ - fn contains(id: &>::AssetId) -> bool { - !ForeingAssets::total_issuance(*id).is_zero() - } -} - -pub struct AsInnerId(PhantomData<(AssetId, ConvertAssetId)>); -impl> - ConvertXcm for AsInnerId -where - AssetId: Borrow, - AssetId: TryAsForeing, - AssetIds: Borrow, -{ - fn convert_ref(id: impl Borrow) -> Result { - let id = id.borrow(); - - log::trace!( - target: "xcm::AsInnerId::Convert", - "AsInnerId {:?}", - id - ); - - let parent = MultiLocation::parent(); - let here = MultiLocation::here(); - let self_location = MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into()))); - - if *id == parent { - return ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Parent)); - } - - if *id == here || *id == self_location { - return ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Here)); - } - - match XcmForeignAssetIdMapping::::get_currency_id(id.clone()) { - Some(AssetIds::ForeignAssetId(foreign_asset_id)) => { - ConvertAssetId::convert_ref(AssetIds::ForeignAssetId(foreign_asset_id)) - } - _ => ConvertAssetId::convert_ref(AssetIds::ForeignAssetId(0)), - } - } - - fn reverse_ref(what: impl Borrow) -> Result { - log::trace!( - target: "xcm::AsInnerId::Reverse", - "AsInnerId", - ); - - let asset_id = what.borrow(); - - let parent_id = - ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Parent)).unwrap(); - let here_id = - ConvertAssetId::convert_ref(AssetIds::NativeAssetId(NativeCurrency::Here)).unwrap(); - - if asset_id.clone() == parent_id { - return Ok(MultiLocation::parent()); - } - - if asset_id.clone() == here_id { - return Ok(MultiLocation::new( - 1, - X1(Parachain(ParachainInfo::get().into())), - )); - } - - match >::try_as_foreing(asset_id.clone()) { - Some(fid) => match XcmForeignAssetIdMapping::::get_multi_location(fid) { - Some(location) => Ok(location), - None => Err(()), - }, - None => Err(()), - } - } } -/// Means for transacting assets besides the native currency on this chain. -pub type FungiblesTransactor = FungiblesAdapter< - // Use this fungibles implementation: - ForeingAssets, - // Use this currency when it is a fungible asset matching the given location or name: - ConvertedConcreteAssetId, JustTry>, - // Convert an XCM MultiLocation into a local account id: - LocationToAccountId, - // Our chain's account ID type (we can't get away without mentioning it explicitly): - AccountId, - // We only want to allow teleports of known assets. We use non-zero issuance as an indication - // that this asset is known. - NonZeroIssuance, - // The account to use for tracking teleports. - CheckingAccount, ->; - -/// Means for transacting assets on this chain. -pub type AssetTransactors = 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 /// biases the kind of local `Origin` it will become. @@ -318,85 +147,6 @@ true } } - -/* /// CHANGEME!!! -pub struct XcmConfig; -impl Config for XcmConfig { - type Call = Call; - type XcmSender = XcmRouter; - // How to withdraw and deposit an asset. - type AssetTransactor = AssetTransactors; - type OriginConverter = XcmOriginToTransactDispatchOrigin; - type IsReserve = AllAsset; //NativeAsset; - type IsTeleporter = (); // Teleportation is disabled - type LocationInverter = LocationInverter; - type Barrier = Barrier; - type Weigher = FixedWeightBounds; - type Trader = - FreeForAll, RelayLocation, AccountId, Balances, ()>; - type ResponseHandler = (); // Don't handle responses for now. - type SubscriptionService = PolkadotXcm; - type AssetTrap = PolkadotXcm; - type AssetClaims = PolkadotXcm; -} - */ - -/* -/// No local origins on this chain are allowed to dispatch XCM sends/executions. -pub type LocalOriginToLocation = (SignedToAccountId32,); - -/// The means for routing XCM messages which are not for local execution into the right message -/// queues. -pub type XcmRouter = ( - // Two routers - use UMP to communicate with the relay chain: - cumulus_primitives_utility::ParentAsUmp, - // ..and XCMP to communicate with the sibling chains. - XcmpQueue, -); - */ - -/* -impl pallet_xcm::Config for Runtime { - type Event = Event; - type SendXcmOrigin = EnsureXcmOrigin; - type XcmRouter = XcmRouter; - type ExecuteXcmOrigin = EnsureXcmOrigin; - type XcmExecuteFilter = Everything; - type XcmExecutor = XcmExecutor>; - type XcmTeleportFilter = Everything; - type XcmReserveTransferFilter = Everything; - type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; - type Origin = Origin; - type Call = Call; - const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; - type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; -} - */ - -/* -impl cumulus_pallet_xcm::Config for Runtime { - type Event = Event; - type XcmExecutor = XcmExecutor; -} - -impl cumulus_pallet_xcmp_queue::Config for Runtime { - type WeightInfo = (); - type Event = Event; - type XcmExecutor = XcmExecutor; - type ChannelInfo = ParachainSystem; - type VersionWrapper = (); - type ExecuteOverweightOrigin = frame_system::EnsureRoot; - type ControllerOrigin = EnsureRoot; - type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; -} - -impl cumulus_pallet_dmp_queue::Config for Runtime { - type Event = Event; - type XcmExecutor = XcmExecutor; - type ExecuteOverweightOrigin = frame_system::EnsureRoot; -} - */ pub struct CurrencyIdConvert; impl Convert> for CurrencyIdConvert { --- a/runtime/quartz/src/xcm_config.rs +++ b/runtime/quartz/src/xcm_config.rs @@ -175,7 +175,6 @@ type ReserveProvider = AbsoluteReserveProvider; } - parameter_type_with_key! { pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance { match currency_id { @@ -194,7 +193,6 @@ get_all_module_accounts().contains(a) } } - pub struct CurrencyIdConvert; impl Convert> for CurrencyIdConvert { @@ -209,31 +207,6 @@ } } } -/* -impl Convert> for CurrencyIdConvert { - fn convert(location: MultiLocation) -> Option { - if location == MultiLocation::here() - || location == MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into()))) - { - return Some(AssetIds::NativeAssetId(NativeCurrency::Here)); - } - - if location == MultiLocation::parent() { - return Some(AssetIds::NativeAssetId(NativeCurrency::Parent)); - } - - if let Some(currency_id) = - XcmForeignAssetIdMapping::::get_currency_id(location.clone()) - { - return Some(currency_id); - } - - None - } -} - - */ - parameter_types! { pub const BaseXcmWeight: Weight = 100_000_000; // TODO: recheck this