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

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 pallet_foreign_assets::{CurrencyId, NativeCurrency};24use sp_runtime::traits::Convert;25use sp_std::{vec, vec::Vec};26use staging_xcm::latest::{Junction::*, Junctions::*, MultiLocation, Weight};27use staging_xcm_executor::XcmExecutor;28use up_common::{29	constants::*,30	types::{AccountId, Balance},31};3233use crate::{34	runtime_common::config::{35		pallets::TreasuryAccountId,36		substrate::{MaxLocks, MaxReserves},37		xcm::{38			xcm_assets::CurrencyIdConvert, SelfLocation, UniversalLocation, Weigher,39			XcmExecutorConfig,40		},41	},42	RelayChainBlockNumberProvider, Runtime, RuntimeEvent,43};4445// Signed version of balance46pub type Amount = i128;4748parameter_types! {49	pub const MinVestedTransfer: Balance = 10 * UNIQUE;50	pub const MaxVestingSchedules: u32 = 28;5152	pub const BaseXcmWeight: Weight = Weight::from_parts(100_000_000, 1000); // ? TODO: recheck this53	pub const MaxAssetsForTransfer: usize = 2;54}5556parameter_type_with_key! {57	pub ParachainMinFee: |_location: MultiLocation| -> Option<u128> {58		Some(100_000_000_000)59	};60}6162parameter_type_with_key! {63	pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance {64		match currency_id {65			CurrencyId::NativeAssetId(symbol) => match symbol {66				NativeCurrency::Here => 0,67				NativeCurrency::Parent=> 0,68			},69			_ => 100_00070		}71	};72}7374pub fn get_all_module_accounts() -> Vec<AccountId> {75	vec![TreasuryAccountId::get()]76}7778pub struct DustRemovalWhitelist;79impl Contains<AccountId> for DustRemovalWhitelist {80	fn contains(a: &AccountId) -> bool {81		get_all_module_accounts().contains(a)82	}83}8485pub struct AccountIdToMultiLocation;86impl Convert<AccountId, MultiLocation> for AccountIdToMultiLocation {87	fn convert(account: AccountId) -> MultiLocation {88		X1(AccountId32 {89			network: None,90			id: account.into(),91		})92		.into()93	}94}9596pub struct CurrencyHooks;97impl orml_traits::currency::MutationHooks<AccountId, CurrencyId, Balance> for CurrencyHooks {98	type OnDust = orml_tokens::TransferDust<Runtime, TreasuryAccountId>;99	type OnSlash = ();100	type PreTransfer = ();101	type PostTransfer = ();102	type PreDeposit = ();103	type PostDeposit = ();104	type OnNewTokenAccount = ();105	type OnKilledTokenAccount = ();106}107108impl orml_vesting::Config for Runtime {109	type RuntimeEvent = RuntimeEvent;110	type Currency = pallet_balances::Pallet<Runtime>;111	type MinVestedTransfer = MinVestedTransfer;112	type VestedTransferOrigin = EnsureSigned<AccountId>;113	type WeightInfo = ();114	type MaxVestingSchedules = MaxVestingSchedules;115	type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;116}117118impl orml_tokens::Config for Runtime {119	type RuntimeEvent = RuntimeEvent;120	type Balance = Balance;121	type Amount = Amount;122	type CurrencyId = CurrencyId;123	type WeightInfo = ();124	type ExistentialDeposits = ExistentialDeposits;125	type CurrencyHooks = CurrencyHooks;126	type MaxLocks = MaxLocks;127	type MaxReserves = MaxReserves;128	// TODO: Add all module accounts129	type DustRemovalWhitelist = DustRemovalWhitelist;130	/// The id type for named reserves.131	type ReserveIdentifier = ();132}133134impl orml_xtokens::Config for Runtime {135	type RuntimeEvent = RuntimeEvent;136	type Balance = Balance;137	type CurrencyId = CurrencyId;138	type CurrencyIdConvert = CurrencyIdConvert;139	type AccountIdToMultiLocation = AccountIdToMultiLocation;140	type SelfLocation = SelfLocation;141	type XcmExecutor = XcmExecutor<XcmExecutorConfig<Self>>;142	type Weigher = Weigher;143	type BaseXcmWeight = BaseXcmWeight;144	type MaxAssetsForTransfer = MaxAssetsForTransfer;145	type MinXcmFee = ParachainMinFee;146	type MultiLocationsFilter = Everything;147	type ReserveProvider = AbsoluteReserveProvider;148	type UniversalLocation = UniversalLocation;149}