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

difftreelog

source

runtime/common/config/orml.rs4.4 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use frame_support::{18	parameter_types,19	traits::{Contains, Everything},20};21use frame_system::EnsureSigned;22use orml_traits::{location::AbsoluteReserveProvider, parameter_type_with_key};23use sp_runtime::traits::Convert;24use xcm::v1::{Junction::*, Junctions::*, MultiLocation, NetworkId};25use xcm::latest::Weight;26use xcm_builder::LocationInverter;27use xcm_executor::XcmExecutor;28use sp_std::{vec, vec::Vec};29use pallet_foreign_assets::{CurrencyId, NativeCurrency};30use crate::{31	Runtime, RuntimeEvent, RelayChainBlockNumberProvider,32	runtime_common::config::{33		xcm::{34			SelfLocation, Weigher, XcmConfig, Ancestry,35			xcm_assets::{CurrencyIdConvert},36		},37		pallets::TreasuryAccountId,38		substrate::{MaxLocks, MaxReserves},39	},40};4142use up_common::{43	types::{AccountId, Balance},44	constants::*,45};4647// Signed version of balance48pub type Amount = i128;4950parameter_types! {51	pub const MinVestedTransfer: Balance = 10 * UNIQUE;52	pub const MaxVestingSchedules: u32 = 28;5354	pub const BaseXcmWeight: Weight = 100_000_000; // TODO: recheck this55	pub const MaxAssetsForTransfer: usize = 2;56}5758parameter_type_with_key! {59	pub ParachainMinFee: |_location: MultiLocation| -> Option<u128> {60		Some(100_000_000_000)61	};62}6364parameter_type_with_key! {65	pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance {66		match currency_id {67			CurrencyId::NativeAssetId(symbol) => match symbol {68				NativeCurrency::Here => 0,69				NativeCurrency::Parent=> 0,70			},71			_ => 100_00072		}73	};74}7576pub fn get_all_module_accounts() -> Vec<AccountId> {77	vec![TreasuryAccountId::get()]78}7980pub struct DustRemovalWhitelist;81impl Contains<AccountId> for DustRemovalWhitelist {82	fn contains(a: &AccountId) -> bool {83		get_all_module_accounts().contains(a)84	}85}8687pub struct AccountIdToMultiLocation;88impl Convert<AccountId, MultiLocation> for AccountIdToMultiLocation {89	fn convert(account: AccountId) -> MultiLocation {90		X1(AccountId32 {91			network: NetworkId::Any,92			id: account.into(),93		})94		.into()95	}96}9798pub struct CurrencyHooks;99impl orml_traits::currency::MutationHooks<AccountId, CurrencyId, Balance> for CurrencyHooks {100	type OnDust = orml_tokens::TransferDust<Runtime, TreasuryAccountId>;101	type OnSlash = ();102	type PreTransfer = ();103	type PostTransfer = ();104	type PreDeposit = ();105	type PostDeposit = ();106	type OnNewTokenAccount = ();107	type OnKilledTokenAccount = ();108}109110impl orml_vesting::Config for Runtime {111	type RuntimeEvent = RuntimeEvent;112	type Currency = pallet_balances::Pallet<Runtime>;113	type MinVestedTransfer = MinVestedTransfer;114	type VestedTransferOrigin = EnsureSigned<AccountId>;115	type WeightInfo = ();116	type MaxVestingSchedules = MaxVestingSchedules;117	type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;118}119120impl orml_tokens::Config for Runtime {121	type RuntimeEvent = RuntimeEvent;122	type Balance = Balance;123	type Amount = Amount;124	type CurrencyId = CurrencyId;125	type WeightInfo = ();126	type ExistentialDeposits = ExistentialDeposits;127	type CurrencyHooks = CurrencyHooks;128	type MaxLocks = MaxLocks;129	type MaxReserves = MaxReserves;130	// TODO: Add all module accounts131	type DustRemovalWhitelist = DustRemovalWhitelist;132	/// The id type for named reserves.133	type ReserveIdentifier = ();134}135136impl orml_xtokens::Config for Runtime {137	type RuntimeEvent = RuntimeEvent;138	type Balance = Balance;139	type CurrencyId = CurrencyId;140	type CurrencyIdConvert = CurrencyIdConvert;141	type AccountIdToMultiLocation = AccountIdToMultiLocation;142	type SelfLocation = SelfLocation;143	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;144	type Weigher = Weigher;145	type BaseXcmWeight = BaseXcmWeight;146	type LocationInverter = LocationInverter<Ancestry>;147	type MaxAssetsForTransfer = MaxAssetsForTransfer;148	type MinXcmFee = ParachainMinFee;149	type MultiLocationsFilter = Everything;150	type ReserveProvider = AbsoluteReserveProvider;151}