git.delta.rocks / unique-network / refs/commits / e2da42b8b024

difftreelog

source

runtime/common/config/pallets/foreign_asset.rs1.3 KiBsourcehistory
1use frame_support::{parameter_types, PalletId};2use pallet_evm::account::CrossAccountId;3use sp_core::H160;4use staging_xcm::prelude::*;5use staging_xcm_builder::AccountKey20Aliases;67use crate::{8	runtime_common::config::{9		ethereum::CrossAccountId as ConfigCrossAccountId,10		governance,11		xcm::{LocationToAccountId, SelfLocation},12	},13	RelayNetwork, Runtime, RuntimeEvent,14};1516parameter_types! {17	pub ForeignAssetPalletId: PalletId = PalletId(*b"frgnasts");18}1920pub struct LocationToCrossAccountId;21impl staging_xcm_executor::traits::ConvertLocation<ConfigCrossAccountId>22	for LocationToCrossAccountId23{24	fn convert_location(location: &MultiLocation) -> Option<ConfigCrossAccountId> {25		LocationToAccountId::convert_location(location)26			.map(|sub| ConfigCrossAccountId::from_sub(sub))27			.or_else(|| {28				let eth_address =29					AccountKey20Aliases::<RelayNetwork, H160>::convert_location(location)?;3031				Some(ConfigCrossAccountId::from_eth(eth_address))32			})33	}34}3536impl pallet_foreign_assets::Config for Runtime {37	type RuntimeEvent = RuntimeEvent;38	type ForceRegisterOrigin = governance::RootOrTechnicalCommitteeMember;39	type PalletId = ForeignAssetPalletId;40	type SelfLocation = SelfLocation;41	type LocationToAccountId = LocationToCrossAccountId;42	type WeightInfo = pallet_foreign_assets::weights::SubstrateWeight<Self>;43}