git.delta.rocks / unique-network / refs/commits / 15ea50e38a6d

difftreelog

source

runtime/common/config/pallets/foreign_asset.rs1.5 KiBsourcehistory
1use frame_support::{parameter_types, PalletId};2#[cfg(not(feature = "governance"))]3use frame_system::EnsureRoot;4use pallet_evm::account::CrossAccountId;5use sp_core::H160;6use staging_xcm::prelude::*;7use staging_xcm_builder::AccountKey20Aliases;89#[cfg(feature = "governance")]10use crate::runtime_common::config::governance;11use crate::{12	runtime_common::config::{13		ethereum::CrossAccountId as ConfigCrossAccountId,14		xcm::{LocationToAccountId, SelfLocation},15	},16	RelayNetwork, Runtime, RuntimeEvent,17};1819parameter_types! {20	pub ForeignAssetPalletId: PalletId = PalletId(*b"frgnasts");21}2223pub struct LocationToCrossAccountId;24impl staging_xcm_executor::traits::ConvertLocation<ConfigCrossAccountId>25	for LocationToCrossAccountId26{27	fn convert_location(location: &Location) -> Option<ConfigCrossAccountId> {28		LocationToAccountId::convert_location(location)29			.map(ConfigCrossAccountId::from_sub)30			.or_else(|| {31				let eth_address =32					AccountKey20Aliases::<RelayNetwork, H160>::convert_location(location)?;3334				Some(ConfigCrossAccountId::from_eth(eth_address))35			})36	}37}3839impl pallet_foreign_assets::Config for Runtime {40	type RuntimeEvent = RuntimeEvent;4142	#[cfg(feature = "governance")]43	type ManagerOrigin = governance::RootOrFinancialCouncilMember;4445	#[cfg(not(feature = "governance"))]46	type ManagerOrigin = EnsureRoot<Self::AccountId>;4748	type PalletId = ForeignAssetPalletId;49	type SelfLocation = SelfLocation;50	type LocationToAccountId = LocationToCrossAccountId;51	type WeightInfo = pallet_foreign_assets::weights::SubstrateWeight<Self>;52}