difftreelog
fix cargo fmt
in: master
4 files changed
pallets/configuration/src/lib.rsdiffbeforeafterboth1// 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 sp_arithmetic::traits::{BaseArithmetic, Unsigned};27use smallvec::smallvec;2829pub use pallet::*;30use sp_core::U256;31use sp_runtime::Perbill;3233#[pallet]34mod pallet {35 use super::*;36 use frame_support::{37 traits::Get,38 pallet_prelude::{StorageValue, ValueQuery, DispatchResult, OptionQuery}, BoundedVec,39 };40 use frame_system::{pallet_prelude::OriginFor, ensure_root};41 use xcm::v1::MultiLocation;4243 #[pallet::config]44 pub trait Config: frame_system::Config {45 #[pallet::constant]46 type DefaultWeightToFeeCoefficient: Get<u32>;4748 #[pallet::constant]49 type DefaultMinGasPrice: Get<u64>;5051 #[pallet::constant]52 type MaxOverridedAllowedLocations: Get<u32>;53 }5455 #[pallet::storage]56 pub type WeightToFeeCoefficientOverride<T: Config> = StorageValue<57 Value = u32,58 QueryKind = ValueQuery,59 OnEmpty = T::DefaultWeightToFeeCoefficient,60 >;6162 #[pallet::storage]63 pub type MinGasPriceOverride<T: Config> =64 StorageValue<Value = u64, QueryKind = ValueQuery, OnEmpty = T::DefaultMinGasPrice>;6566 #[pallet::storage]67 pub type XcmAllowedLocationsOverride<T: Config> = StorageValue<68 Value = BoundedVec<MultiLocation, T::MaxOverridedAllowedLocations>,69 QueryKind = OptionQuery,70 >;7172 #[pallet::call]73 impl<T: Config> Pallet<T> {74 #[pallet::weight(T::DbWeight::get().writes(1))]75 pub fn set_weight_to_fee_coefficient_override(76 origin: OriginFor<T>,77 coeff: Option<u32>,78 ) -> DispatchResult {79 let _sender = ensure_root(origin)?;80 if let Some(coeff) = coeff {81 <WeightToFeeCoefficientOverride<T>>::set(coeff);82 } else {83 <WeightToFeeCoefficientOverride<T>>::kill();84 }85 Ok(())86 }8788 #[pallet::weight(T::DbWeight::get().writes(1))]89 pub fn set_min_gas_price_override(90 origin: OriginFor<T>,91 coeff: Option<u64>,92 ) -> DispatchResult {93 let _sender = ensure_root(origin)?;94 if let Some(coeff) = coeff {95 <MinGasPriceOverride<T>>::set(coeff);96 } else {97 <MinGasPriceOverride<T>>::kill();98 }99 Ok(())100 }101102 #[pallet::weight(T::DbWeight::get().writes(1))]103 pub fn set_xcm_allowed_locations(104 origin: OriginFor<T>,105 locations: Option<BoundedVec<MultiLocation, T::MaxOverridedAllowedLocations>>,106 ) -> DispatchResult {107 let _sender = ensure_root(origin)?;108 <XcmAllowedLocationsOverride<T>>::set(locations);109 Ok(())110 }111 }112113 #[pallet::pallet]114 #[pallet::generate_store(pub(super) trait Store)]115 pub struct Pallet<T>(_);116}117118pub struct WeightToFee<T, B>(PhantomData<(T, B)>);119120impl<T, B> WeightToFeePolynomial for WeightToFee<T, B>121where122 T: Config,123 B: BaseArithmetic + From<u32> + Copy + Unsigned,124{125 type Balance = B;126127 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {128 smallvec!(WeightToFeeCoefficient {129 coeff_integer: <WeightToFeeCoefficientOverride<T>>::get().into(),130 coeff_frac: Perbill::zero(),131 negative: false,132 degree: 1,133 })134 }135}136137pub struct FeeCalculator<T>(PhantomData<T>);138impl<T: Config> fp_evm::FeeCalculator for FeeCalculator<T> {139 fn min_gas_price() -> (U256, Weight) {140 (141 <MinGasPriceOverride<T>>::get().into(),142 T::DbWeight::get().reads(1),143 )144 }145}runtime/common/xcm.rsdiffbeforeafterboth--- a/runtime/common/xcm.rs
+++ b/runtime/common/xcm.rs
@@ -20,17 +20,17 @@
pub struct OverridableAllowedLocations<T, L>(PhantomData<(T, L)>)
where
- T: pallet_configuration::Config,
- L: Get<Vec<MultiLocation>>;
+ T: pallet_configuration::Config,
+ L: Get<Vec<MultiLocation>>;
impl<T, L> Get<Vec<MultiLocation>> for OverridableAllowedLocations<T, L>
where
- T: pallet_configuration::Config,
- L: Get<Vec<MultiLocation>>
+ T: pallet_configuration::Config,
+ L: Get<Vec<MultiLocation>>,
{
- fn get() -> Vec<MultiLocation> {
- <pallet_configuration::XcmAllowedLocationsOverride<T>>::get()
- .map(|bounded| bounded.into_inner())
- .unwrap_or_else(|| L::get())
- }
+ fn get() -> Vec<MultiLocation> {
+ <pallet_configuration::XcmAllowedLocationsOverride<T>>::get()
+ .map(|bounded| bounded.into_inner())
+ .unwrap_or_else(|| L::get())
+ }
}
runtime/quartz/src/xcm_barrier.rsdiffbeforeafterboth--- a/runtime/quartz/src/xcm_barrier.rs
+++ b/runtime/quartz/src/xcm_barrier.rs
@@ -30,7 +30,7 @@
runtime_common::{
config::xcm::{DenyThenTry, DenyTransact, DenyExchangeWithUnknownLocation},
xcm::OverridableAllowedLocations,
- }
+ },
};
match_types! {
@@ -74,7 +74,7 @@
(
DenyTransact,
DenyExchangeWithUnknownLocation<
- OverridableAllowedLocations<Runtime, QuartzDefaultAllowedLocations>
+ OverridableAllowedLocations<Runtime, QuartzDefaultAllowedLocations>,
>,
),
(
runtime/unique/src/xcm_barrier.rsdiffbeforeafterboth--- a/runtime/unique/src/xcm_barrier.rs
+++ b/runtime/unique/src/xcm_barrier.rs
@@ -30,7 +30,7 @@
runtime_common::{
config::xcm::{DenyThenTry, DenyTransact, DenyExchangeWithUnknownLocation},
xcm::OverridableAllowedLocations,
- }
+ },
};
match_types! {
@@ -74,7 +74,7 @@
(
DenyTransact,
DenyExchangeWithUnknownLocation<
- OverridableAllowedLocations<Runtime, UniqueDefaultAllowedLocations>
+ OverridableAllowedLocations<Runtime, UniqueDefaultAllowedLocations>,
>,
),
(