git.delta.rocks / unique-network / refs/commits / 7fd4751d0ab2

difftreelog

Merge pull request #784 from UniqueNetwork/fix/enable-foreign-assets-qtz-and-minor-fixes

kozyrevdev2022-12-16parents: #9a4bd0b #f08f3da.patch.diff
in: master
Fix/enable foreign assets qtz and minor fixes

6 files changed

modifiedpallets/app-promotion/src/lib.rsdiffbeforeafterboth
--- a/pallets/app-promotion/src/lib.rs
+++ b/pallets/app-promotion/src/lib.rs
@@ -564,7 +564,7 @@
 		/// # Arguments
 		///
 		/// * `stakers_number`: the number of stakers for which recalculation will be performed
-		#[pallet::weight(<T as Config>::WeightInfo::payout_stakers(stakers_number.unwrap_or(20) as u32))]
+		#[pallet::weight(<T as Config>::WeightInfo::payout_stakers(stakers_number.unwrap_or(DEFAULT_NUMBER_PAYOUTS) as u32))]
 		pub fn payout_stakers(admin: OriginFor<T>, stakers_number: Option<u8>) -> DispatchResult {
 			let admin_id = ensure_signed(admin)?;
 
modifiedpallets/configuration/src/lib.rsdiffbeforeafterboth
before · pallets/configuration/src/lib.rs
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/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819use core::marker::PhantomData;2021use frame_support::{22	pallet,23	weights::{WeightToFeePolynomial, WeightToFeeCoefficients, WeightToFeeCoefficient, Weight},24	traits::Get,25};26use parity_scale_codec::{Decode, Encode, MaxEncodedLen};27use scale_info::TypeInfo;28use sp_arithmetic::traits::{BaseArithmetic, Unsigned};29use smallvec::smallvec;3031pub use pallet::*;32use sp_core::U256;33use sp_runtime::Perbill;3435#[pallet]36mod pallet {37	use super::*;38	use frame_support::{39		traits::Get,40		pallet_prelude::{StorageValue, ValueQuery, DispatchResult, OptionQuery},41		BoundedVec,42	};43	use frame_system::{pallet_prelude::OriginFor, ensure_root};44	use xcm::v1::MultiLocation;4546	#[pallet::config]47	pub trait Config: frame_system::Config {48		#[pallet::constant]49		type DefaultWeightToFeeCoefficient: Get<u32>;5051		#[pallet::constant]52		type DefaultMinGasPrice: Get<u64>;5354		#[pallet::constant]55		type MaxOverridedAllowedLocations: Get<u32>;56		#[pallet::constant]57		type AppPromotionDailyRate: Get<Perbill>;58		#[pallet::constant]59		type DayRelayBlocks: Get<Self::BlockNumber>;60	}6162	#[pallet::error]63	pub enum Error<T> {64		InconsistentConfiguration,65	}6667	#[pallet::storage]68	pub type WeightToFeeCoefficientOverride<T: Config> = StorageValue<69		Value = u32,70		QueryKind = ValueQuery,71		OnEmpty = T::DefaultWeightToFeeCoefficient,72	>;7374	#[pallet::storage]75	pub type MinGasPriceOverride<T: Config> =76		StorageValue<Value = u64, QueryKind = ValueQuery, OnEmpty = T::DefaultMinGasPrice>;7778	#[pallet::storage]79	pub type XcmAllowedLocationsOverride<T: Config> = StorageValue<80		Value = BoundedVec<MultiLocation, T::MaxOverridedAllowedLocations>,81		QueryKind = OptionQuery,82	>;8384	#[pallet::storage]85	pub type AppPromomotionConfigurationOverride<T: Config> =86		StorageValue<Value = AppPromotionConfiguration<T::BlockNumber>, QueryKind = ValueQuery>;8788	#[pallet::call]89	impl<T: Config> Pallet<T> {90		#[pallet::weight(T::DbWeight::get().writes(1))]91		pub fn set_weight_to_fee_coefficient_override(92			origin: OriginFor<T>,93			coeff: Option<u32>,94		) -> DispatchResult {95			ensure_root(origin)?;96			if let Some(coeff) = coeff {97				<WeightToFeeCoefficientOverride<T>>::set(coeff);98			} else {99				<WeightToFeeCoefficientOverride<T>>::kill();100			}101			Ok(())102		}103104		#[pallet::weight(T::DbWeight::get().writes(1))]105		pub fn set_min_gas_price_override(106			origin: OriginFor<T>,107			coeff: Option<u64>,108		) -> DispatchResult {109			ensure_root(origin)?;110			if let Some(coeff) = coeff {111				<MinGasPriceOverride<T>>::set(coeff);112			} else {113				<MinGasPriceOverride<T>>::kill();114			}115			Ok(())116		}117118		#[pallet::weight(T::DbWeight::get().writes(1))]119		pub fn set_xcm_allowed_locations(120			origin: OriginFor<T>,121			locations: Option<BoundedVec<MultiLocation, T::MaxOverridedAllowedLocations>>,122		) -> DispatchResult {123			ensure_root(origin)?;124			<XcmAllowedLocationsOverride<T>>::set(locations);125			Ok(())126		}127128		#[pallet::weight(T::DbWeight::get().writes(1))]129		pub fn set_app_promotion_configuration_override(130			origin: OriginFor<T>,131			mut configuration: AppPromotionConfiguration<T::BlockNumber>,132		) -> DispatchResult {133			ensure_root(origin)?;134			if configuration.interval_income.is_some() {135				return Err(<Error<T>>::InconsistentConfiguration.into());136			}137138			configuration.interval_income = configuration.recalculation_interval.map(|b| {139				Perbill::from_rational(b, T::DayRelayBlocks::get())140					* T::AppPromotionDailyRate::get()141			});142143			<AppPromomotionConfigurationOverride<T>>::set(configuration);144145			Ok(())146		}147	}148149	#[pallet::pallet]150	#[pallet::generate_store(pub(super) trait Store)]151	pub struct Pallet<T>(_);152}153154pub struct WeightToFee<T, B>(PhantomData<(T, B)>);155156impl<T, B> WeightToFeePolynomial for WeightToFee<T, B>157where158	T: Config,159	B: BaseArithmetic + From<u32> + Copy + Unsigned,160{161	type Balance = B;162163	fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {164		smallvec!(WeightToFeeCoefficient {165			coeff_integer: <WeightToFeeCoefficientOverride<T>>::get().into(),166			coeff_frac: Perbill::zero(),167			negative: false,168			degree: 1,169		})170	}171}172173pub struct FeeCalculator<T>(PhantomData<T>);174impl<T: Config> fp_evm::FeeCalculator for FeeCalculator<T> {175	fn min_gas_price() -> (U256, Weight) {176		(177			<MinGasPriceOverride<T>>::get().into(),178			T::DbWeight::get().reads(1),179		)180	}181}182183#[derive(Encode, Decode, Clone, Debug, Default, TypeInfo, MaxEncodedLen, PartialEq, PartialOrd)]184pub struct AppPromotionConfiguration<BlockNumber> {185	/// In relay blocks.186	pub recalculation_interval: Option<BlockNumber>,187	/// In parachain blocks.188	pub pending_interval: Option<BlockNumber>,189	/// Value for `RecalculationInterval` based on 0.05% per 24h.190	pub interval_income: Option<Perbill>,191	/// Maximum allowable number of stakers calculated per call of the `app-promotion::PayoutStakers` extrinsic.192	pub max_stakers_per_calculation: Option<u8>,193}
modifiedruntime/common/config/pallets/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/mod.rs
+++ b/runtime/common/config/pallets/mod.rs
@@ -106,7 +106,7 @@
 impl pallet_configuration::Config for Runtime {
 	type DefaultWeightToFeeCoefficient = ConstU32<{ up_common::constants::WEIGHT_TO_FEE_COEFF }>;
 	type DefaultMinGasPrice = ConstU64<{ up_common::constants::MIN_GAS_PRICE }>;
-	type MaxOverridedAllowedLocations = ConstU32<16>;
+	type MaxXcmAllowedLocations = ConstU32<16>;
 	type AppPromotionDailyRate = AppPromotionDailyRate;
 	type DayRelayBlocks = DayRelayBlocks;
 }
modifiedruntime/common/construct_runtime/mod.rsdiffbeforeafterboth
--- a/runtime/common/construct_runtime/mod.rs
+++ b/runtime/common/construct_runtime/mod.rs
@@ -82,7 +82,7 @@
                 #[runtimes(opal, quartz)]
                 AppPromotion: pallet_app_promotion::{Pallet, Call, Storage, Event<T>} = 73,
 
-                #[runtimes(opal)]
+                #[runtimes(opal, quartz)]
                 ForeignAssets: pallet_foreign_assets::{Pallet, Call, Storage, Event<T>} = 80,
 
                 // Frontier
modifiedruntime/quartz/Cargo.tomldiffbeforeafterboth
--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -169,7 +169,7 @@
     "pallet-maintenance/std",
 ]
 limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
-quartz-runtime = ['refungible', 'app-promotion']
+quartz-runtime = ['refungible', 'app-promotion', 'foreign-assets']
 
 refungible = []
 scheduler = []
modifiedtests/src/pallet-presence.test.tsdiffbeforeafterboth
--- a/tests/src/pallet-presence.test.ts
+++ b/tests/src/pallet-presence.test.ts
@@ -80,6 +80,7 @@
         requiredPallets.push(
           refungible,
           appPromotion,
+          foreignAssets,
         );
       } else if (chain.eq('UNIQUE')) {
         // Insert Unique additional pallets here