git.delta.rocks / unique-network / refs/commits / 3cddb472af6f

difftreelog

source

runtime/common/config/orml.rs4.1 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, Event, 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}9798impl orml_vesting::Config for Runtime {99	type Event = Event;100	type Currency = pallet_balances::Pallet<Runtime>;101	type MinVestedTransfer = MinVestedTransfer;102	type VestedTransferOrigin = EnsureSigned<AccountId>;103	type WeightInfo = ();104	type MaxVestingSchedules = MaxVestingSchedules;105	type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;106}107108impl orml_tokens::Config for Runtime {109	type Event = Event;110	type Balance = Balance;111	type Amount = Amount;112	type CurrencyId = CurrencyId;113	type WeightInfo = ();114	type ExistentialDeposits = ExistentialDeposits;115	type OnDust = orml_tokens::TransferDust<Runtime, TreasuryAccountId>;116	type MaxLocks = MaxLocks;117	type MaxReserves = MaxReserves;118	// TODO: Add all module accounts119	type DustRemovalWhitelist = DustRemovalWhitelist;120	/// The id type for named reserves.121	type ReserveIdentifier = ();122	type OnNewTokenAccount = ();123	type OnKilledTokenAccount = ();124}125126impl orml_xtokens::Config for Runtime {127	type Event = Event;128	type Balance = Balance;129	type CurrencyId = CurrencyId;130	type CurrencyIdConvert = CurrencyIdConvert;131	type AccountIdToMultiLocation = AccountIdToMultiLocation;132	type SelfLocation = SelfLocation;133	type XcmExecutor = XcmExecutor<XcmConfig<Self>>;134	type Weigher = Weigher;135	type BaseXcmWeight = BaseXcmWeight;136	type LocationInverter = LocationInverter<Ancestry>;137	type MaxAssetsForTransfer = MaxAssetsForTransfer;138	type MinXcmFee = ParachainMinFee;139	type MultiLocationsFilter = Everything;140	type ReserveProvider = AbsoluteReserveProvider;141}