git.delta.rocks / unique-network / refs/commits / 379a12b35ab5

difftreelog

Merge pull request #944 from UniqueNetwork/fix/more-clippy-warnings

Yaroslav Bolyukin2023-06-08parents: #d0e327f #8d05c70.patch.diff
in: master

9 files changed

modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -328,7 +328,7 @@
 macro_rules! pass_method {
 	(
 		$method_name:ident(
-			$($(#[map(|$map_arg:ident| $map:expr)])? $name:ident: $ty:ty),* $(,)?
+			$($(#[map = $map:expr])? $name:ident: $ty:ty),* $(,)?
 		) -> $result:ty $(=> $mapper:expr)?,
 		//$runtime_name:ident $(<$($lt: tt),+>)*
 		$runtime_api_macro:ident
@@ -355,7 +355,7 @@
 			let result = $(if _api_version < $ver {
 				api.$changed_method_name(at, $($changed_name),*).map(|r| r.and_then($fixer))
 			} else)*
-			{ api.$method_name(at, $($((|$map_arg: $ty| $map))? ($name)),*) };
+			{ api.$method_name(at, $($($map)? ($name)),*) };
 
 			Ok(result
 				.map_err(|e| anyhow!("unable to query: {e}"))?
@@ -413,7 +413,7 @@
 	pass_method!(collection_properties(
 		collection: CollectionId,
 
-		#[map(|keys| string_keys_to_bytes_keys(keys))]
+		#[map = string_keys_to_bytes_keys]
 		keys: Option<Vec<String>>
 	) -> Vec<Property>, unique_api);
 
@@ -421,14 +421,14 @@
 		collection: CollectionId,
 		token_id: TokenId,
 
-		#[map(|keys| string_keys_to_bytes_keys(keys))]
+		#[map = string_keys_to_bytes_keys]
 		keys: Option<Vec<String>>
 	) -> Vec<Property>, unique_api);
 
 	pass_method!(property_permissions(
 		collection: CollectionId,
 
-		#[map(|keys| string_keys_to_bytes_keys(keys))]
+		#[map = string_keys_to_bytes_keys]
 		keys: Option<Vec<String>>
 	) -> Vec<PropertyKeyPermission>, unique_api);
 
@@ -437,7 +437,7 @@
 			collection: CollectionId,
 			token_id: TokenId,
 
-			#[map(|keys| string_keys_to_bytes_keys(keys))]
+			#[map = string_keys_to_bytes_keys]
 			keys: Option<Vec<String>>,
 		) -> TokenData<CrossAccountId>, unique_api;
 		changed_in 3, token_data_before_version_3(collection, token_id, string_keys_to_bytes_keys(keys)) => |value| Ok(value.into())
modifiednode/cli/src/command.rsdiffbeforeafterboth
--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -531,7 +531,11 @@
 				debug!("Parachain genesis block: {:?}", block);
 				info!(
 					"Is collating: {}",
-					config.role.is_authority().then_some("yes").unwrap_or("no")
+					if config.role.is_authority() {
+						"yes"
+					} else {
+						"no"
+					}
 				);
 
 				start_node_using_chain_runtime! {
modifiedpallets/app-promotion/src/lib.rsdiffbeforeafterboth
--- a/pallets/app-promotion/src/lib.rs
+++ b/pallets/app-promotion/src/lib.rs
@@ -30,11 +30,11 @@
 //!
 //!
 //! ## Interface
-//!	The pallet provides interfaces for funds, collection/contract operations (see [types] module).
+//! The pallet provides interfaces for funds, collection/contract operations (see [types] module).
 
 //!
 //! ### Dispatchable Functions
-//!	- [`set_admin_address`][`Pallet::set_admin_address`] - sets an address as the the admin.
+//! - [`set_admin_address`][`Pallet::set_admin_address`] - sets an address as the the admin.
 //! - [`stake`][`Pallet::stake`] - stakes the amount of native tokens.
 //! - [`unstake`][`Pallet::unstake`] - unstakes all stakes.
 //! - [`sponsor_collection`][`Pallet::sponsor_collection`] - sets the pallet to be the sponsor for the collection.
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -73,7 +73,7 @@
 //!
 //! - [`WithRecorder`](pallet_evm_coder_substrate::WithRecorder): Trait for EVM support
 //! - [`CommonCollectionOperations`](pallet_common::CommonCollectionOperations): Functions for dealing with collections
-//!	- [`CommonWeightInfo`](pallet_common::CommonWeightInfo): Functions for retrieval of transaction weight
+//! - [`CommonWeightInfo`](pallet_common::CommonWeightInfo): Functions for retrieval of transaction weight
 //! - [`CommonEvmHandler`](pallet_common::erc::CommonEvmHandler): Function for handling EVM runtime calls
 
 #![cfg_attr(not(feature = "std"), no_std)]
@@ -728,7 +728,7 @@
 	/// Transfer fungible tokens from one account to another.
 	/// Same as the [`transfer`][`Pallet::transfer`] but spender doesn't needs to be an owner of the token pieces.
 	/// The owner should set allowance for the spender to transfer pieces.
-	///	See [`set_allowance`][`Pallet::set_allowance`] for more details.
+	/// See [`set_allowance`][`Pallet::set_allowance`] for more details.
 	pub fn transfer_from(
 		collection: &FungibleHandle<T>,
 		spender: &T::CrossAccountId,
@@ -778,7 +778,7 @@
 		Ok(())
 	}
 
-	///	Creates fungible token.
+	/// Creates fungible token.
 	///
 	/// The sender should be the owner/admin of the collection or collection should be configured
 	/// to allow public minting.
@@ -799,7 +799,7 @@
 		)
 	}
 
-	///	Creates fungible token.
+	/// Creates fungible token.
 	///
 	/// - `data`: Contains user who will become the owners of the tokens and amount
 	///   of tokens he will receive.
modifiedpallets/identity/src/lib.rsdiffbeforeafterboth
--- a/pallets/identity/src/lib.rs
+++ b/pallets/identity/src/lib.rs
@@ -95,8 +95,13 @@
 mod types;
 pub mod weights;
 
-use frame_support::traits::{BalanceStatus, Currency, OnUnbalanced, ReservableCurrency};
-use sp_runtime::traits::{AppendZerosInput, Hash, Saturating, StaticLookup, Zero};
+use frame_support::{
+	traits::{BalanceStatus, Currency, OnUnbalanced, ReservableCurrency},
+};
+use sp_runtime::{
+	BoundedVec,
+	traits::{AppendZerosInput, Hash, Saturating, StaticLookup, Zero},
+};
 use sp_std::prelude::*;
 pub use weights::WeightInfo;
 
@@ -112,6 +117,18 @@
 	<T as frame_system::Config>::AccountId,
 >>::NegativeImbalance;
 type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
+type RegistrarInfoOf<T> = RegistrarInfo<BalanceOf<T>, <T as frame_system::Config>::AccountId>;
+type RegistrationOf<T> =
+	Registration<BalanceOf<T>, <T as Config>::MaxRegistrars, <T as Config>::MaxAdditionalFields>;
+type SubAccounts<T> =
+	sp_runtime::BoundedVec<<T as frame_system::Config>::AccountId, <T as Config>::MaxSubAccounts>;
+type SubAccountsByAccountId<T> = (
+	<T as frame_system::Config>::AccountId,
+	(
+		BalanceOf<T>,
+		BoundedVec<(<T as frame_system::Config>::AccountId, Data), <T as Config>::MaxSubAccounts>,
+	),
+);
 
 #[frame_support::pallet]
 pub mod pallet {
@@ -198,13 +215,8 @@
 	/// TWOX-NOTE: OK ― `AccountId` is a secure hash.
 	#[pallet::storage]
 	#[pallet::getter(fn subs_of)]
-	pub(super) type SubsOf<T: Config> = StorageMap<
-		_,
-		Twox64Concat,
-		T::AccountId,
-		(BalanceOf<T>, BoundedVec<T::AccountId, T::MaxSubAccounts>),
-		ValueQuery,
-	>;
+	pub(super) type SubsOf<T: Config> =
+		StorageMap<_, Twox64Concat, T::AccountId, (BalanceOf<T>, SubAccounts<T>), ValueQuery>;
 
 	/// The set of registrars. Not expected to get very big as can only be added through a
 	/// special origin (likely a council motion).
@@ -212,11 +224,8 @@
 	/// The index into this can be cast to `RegistrarIndex` to get a valid value.
 	#[pallet::storage]
 	#[pallet::getter(fn registrars)]
-	pub(super) type Registrars<T: Config> = StorageValue<
-		_,
-		BoundedVec<Option<RegistrarInfo<BalanceOf<T>, T::AccountId>>, T::MaxRegistrars>,
-		ValueQuery,
-	>;
+	pub(super) type Registrars<T: Config> =
+		StorageValue<_, BoundedVec<Option<RegistrarInfoOf<T>>, T::MaxRegistrars>, ValueQuery>;
 
 	#[pallet::error]
 	pub enum Error<T> {
@@ -482,18 +491,21 @@
 				.all(|i| i.0 == sender);
 			ensure!(not_other_sub, Error::<T>::AlreadyClaimed);
 
-			if old_deposit < new_deposit {
-				T::Currency::reserve(&sender, new_deposit - old_deposit)?;
-			} else if old_deposit > new_deposit {
-				let err_amount = T::Currency::unreserve(&sender, old_deposit - new_deposit);
-				debug_assert!(err_amount.is_zero());
+			match old_deposit.cmp(&new_deposit) {
+				core::cmp::Ordering::Less => {
+					T::Currency::reserve(&sender, new_deposit - old_deposit)?
+				}
+				core::cmp::Ordering::Equal => { /* do nothing if they're equal. */ }
+				core::cmp::Ordering::Greater => {
+					let err_amount = T::Currency::unreserve(&sender, old_deposit - new_deposit);
+					debug_assert!(err_amount.is_zero());
+				}
 			}
-			// do nothing if they're equal.
 
 			for s in old_ids.iter() {
 				<SuperOf<T>>::remove(s);
 			}
-			let mut ids = BoundedVec::<T::AccountId, T::MaxSubAccounts>::default();
+			let mut ids = <SubAccounts<T>>::default();
 			for (id, name) in subs {
 				<SuperOf<T>>::insert(&id, (sender.clone(), name));
 				ids.try_push(id)
@@ -1107,10 +1119,7 @@
 		))]
 		pub fn force_insert_identities(
 			origin: OriginFor<T>,
-			identities: Vec<(
-				T::AccountId,
-				Registration<BalanceOf<T>, T::MaxRegistrars, T::MaxAdditionalFields>,
-			)>,
+			identities: Vec<(T::AccountId, RegistrationOf<T>)>,
 		) -> DispatchResult {
 			T::ForceOrigin::ensure_origin(origin)?;
 			for identity in identities.clone() {
@@ -1162,13 +1171,7 @@
 		))]
 		pub fn force_set_subs(
 			origin: OriginFor<T>,
-			subs: Vec<(
-				T::AccountId,
-				(
-					BalanceOf<T>,
-					BoundedVec<(T::AccountId, Data), T::MaxSubAccounts>,
-				),
-			)>,
+			subs: Vec<SubAccountsByAccountId<T>>,
 		) -> DispatchResult {
 			T::ForceOrigin::ensure_origin(origin)?;
 			for identity in subs.clone() {
@@ -1178,7 +1181,7 @@
 					<SuperOf<T>>::remove(old_sub);
 				}
 
-				let mut ids = BoundedVec::<T::AccountId, T::MaxSubAccounts>::default();
+				let mut ids = <SubAccounts<T>>::default();
 				for (id, name) in identity.1 .1 {
 					<SuperOf<T>>::insert(&id, (account.clone(), name));
 					ids.try_push(id)
modifiedpallets/inflation/src/lib.rsdiffbeforeafterboth
before · pallets/inflation/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//! # Inflation18//!19//! The inflation pallet is designed to increase the number of tokens at certain intervals.20//! With each iteration, increases the `total_issuance` value for the native token.21//! Executing an `on_initialize` hook at the beginning of each block, causing inflation to begin.22//!23//! ## Interface24//!25//! ### Dispatchable Functions26//!27//! * `start_inflation` - This method sets the inflation start date. Can be only called once.28//! Inflation start block can be backdated and will catch up. The method will create Treasury29//!	account if it does not exist and perform the first inflation deposit.3031// #![recursion_limit = "1024"]32#![cfg_attr(not(feature = "std"), no_std)]3334#[cfg(feature = "runtime-benchmarks")]35mod benchmarking;3637#[cfg(test)]38mod tests;3940use frame_support::{41	dispatch::{DispatchResult},42	traits::{43		fungible::{Balanced, Inspect, Mutate},44		Get,45		tokens::Precision,46	},47};48pub use pallet::*;49use sp_runtime::{Perbill, traits::BlockNumberProvider};5051use sp_std::convert::TryInto;5253type BalanceOf<T> =54	<<T as Config>::Currency as Inspect<<T as frame_system::Config>::AccountId>>::Balance;5556pub const YEAR: u32 = 5_259_600; // 6-second block57								 // pub const YEAR: u32 = 2_629_800; // 12-second block58pub const TOTAL_YEARS_UNTIL_FLAT: u32 = 9;59pub const START_INFLATION_PERCENT: u32 = 10;60pub const END_INFLATION_PERCENT: u32 = 4;6162#[frame_support::pallet]63pub mod pallet {64	use super::*;65	use frame_support::pallet_prelude::*;66	use frame_system::pallet_prelude::*;6768	#[pallet::config]69	pub trait Config: frame_system::Config {70		type Currency: Balanced<Self::AccountId>71			+ Inspect<Self::AccountId>72			+ Mutate<Self::AccountId>;73		type TreasuryAccountId: Get<Self::AccountId>;7475		// The block number provider76		type BlockNumberProvider: BlockNumberProvider<BlockNumber = Self::BlockNumber>;7778		/// Number of blocks that pass between treasury balance updates due to inflation79		#[pallet::constant]80		type InflationBlockInterval: Get<Self::BlockNumber>;81	}8283	#[pallet::pallet]84	pub struct Pallet<T>(_);8586	/// starting year total issuance87	#[pallet::storage]88	pub type StartingYearTotalIssuance<T: Config> =89		StorageValue<Value = BalanceOf<T>, QueryKind = ValueQuery>;9091	/// Current inflation for `InflationBlockInterval` number of blocks92	#[pallet::storage]93	pub type BlockInflation<T: Config> = StorageValue<Value = BalanceOf<T>, QueryKind = ValueQuery>;9495	/// Next target (relay) block when inflation will be applied96	#[pallet::storage]97	pub type NextInflationBlock<T: Config> =98		StorageValue<Value = T::BlockNumber, QueryKind = ValueQuery>;99100	/// Next target (relay) block when inflation is recalculated101	#[pallet::storage]102	pub type NextRecalculationBlock<T: Config> =103		StorageValue<Value = T::BlockNumber, QueryKind = ValueQuery>;104105	/// Relay block when inflation has started106	#[pallet::storage]107	pub type StartBlock<T: Config> = StorageValue<Value = T::BlockNumber, QueryKind = ValueQuery>;108109	#[pallet::hooks]110	impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {111		fn on_initialize(_: T::BlockNumber) -> Weight112		where113			<T as frame_system::Config>::BlockNumber: From<u32>,114		{115			let mut consumed_weight = Weight::zero();116			let mut add_weight = |reads, writes, weight| {117				consumed_weight += T::DbWeight::get().reads_writes(reads, writes);118				consumed_weight += weight;119			};120121			let block_interval: u32 = T::InflationBlockInterval::get().try_into().unwrap_or(0);122			let current_relay_block = T::BlockNumberProvider::current_block_number();123			let next_inflation: T::BlockNumber = <NextInflationBlock<T>>::get();124			add_weight(1, 0, Weight::from_parts(5_000_000, 0));125126			// Apply inflation every InflationBlockInterval blocks127			// If next_inflation == 0, this means inflation wasn't yet initialized128			if (next_inflation != 0u32.into()) && (current_relay_block >= next_inflation) {129				// Recalculate inflation on the first block of the year (or if it is not initialized yet)130				// Do the "current_relay_block >= next_recalculation" check in the "current_relay_block >= next_inflation"131				// block because it saves InflationBlockInterval DB reads for NextRecalculationBlock.132				let next_recalculation: T::BlockNumber = <NextRecalculationBlock<T>>::get();133				add_weight(1, 0, Weight::zero());134				if current_relay_block >= next_recalculation {135					Self::recalculate_inflation(next_recalculation);136					add_weight(0, 4, Weight::from_parts(5_000_000, 0));137				}138139				T::Currency::mint_into(&T::TreasuryAccountId::get(), <BlockInflation<T>>::get())140					.ok();141142				// Update inflation block143				<NextInflationBlock<T>>::set(next_inflation + block_interval.into());144145				add_weight(3, 3, Weight::from_parts(10_000_000, 0));146			}147148			consumed_weight149		}150	}151152	#[pallet::call]153	impl<T: Config> Pallet<T> {154		/// This method sets the inflation start date. Can be only called once.155		/// Inflation start block can be backdated and will catch up. The method will create Treasury156		/// account if it does not exist and perform the first inflation deposit.157		///158		/// # Permissions159		///160		/// * Root161		///162		/// # Arguments163		///164		/// * inflation_start_relay_block: The relay chain block at which inflation should start165		#[pallet::call_index(0)]166		#[pallet::weight(0)]167		pub fn start_inflation(168			origin: OriginFor<T>,169			inflation_start_relay_block: T::BlockNumber,170		) -> DispatchResult171		where172			<T as frame_system::Config>::BlockNumber: From<u32>,173		{174			ensure_root(origin)?;175176			// Start inflation if it has not been yet initialized177			if <StartBlock<T>>::get() == 0u32.into() {178				// Set inflation global start block179				<StartBlock<T>>::set(inflation_start_relay_block);180181				// Recalculate inflation. This can be backdated and will catch up.182				Self::recalculate_inflation(inflation_start_relay_block);183				let block_interval: u32 = T::InflationBlockInterval::get().try_into().unwrap_or(0);184				<NextInflationBlock<T>>::set(inflation_start_relay_block + block_interval.into());185186				// First time deposit - create Treasury account so that we can call deposit_into_existing everywhere else187				let _ = T::Currency::deposit(188					&T::TreasuryAccountId::get(),189					<BlockInflation<T>>::get(),190					Precision::Exact,191				)?;192			}193194			Ok(())195		}196	}197}198199impl<T: Config> Pallet<T> {200	pub fn recalculate_inflation(recalculation_block: T::BlockNumber) {201		let current_year: u32 = ((recalculation_block - <StartBlock<T>>::get())202			/ T::BlockNumber::from(YEAR))203		.try_into()204		.unwrap_or(0);205		let block_interval: u32 = T::InflationBlockInterval::get().try_into().unwrap_or(0);206207		let one_percent = Perbill::from_percent(1);208209		if current_year <= TOTAL_YEARS_UNTIL_FLAT {210			let amount: BalanceOf<T> = Perbill::from_rational(211				block_interval212					* (START_INFLATION_PERCENT * TOTAL_YEARS_UNTIL_FLAT213						- current_year * (START_INFLATION_PERCENT - END_INFLATION_PERCENT)),214				YEAR * TOTAL_YEARS_UNTIL_FLAT,215			) * (one_percent * T::Currency::total_issuance());216			<BlockInflation<T>>::put(amount);217		} else {218			let amount: BalanceOf<T> =219				Perbill::from_rational(block_interval * END_INFLATION_PERCENT, YEAR)220					* (one_percent * T::Currency::total_issuance());221			<BlockInflation<T>>::put(amount);222		}223		<StartingYearTotalIssuance<T>>::set(T::Currency::total_issuance());224225		// Update recalculation and inflation blocks226		<NextRecalculationBlock<T>>::set(recalculation_block + YEAR.into());227	}228}
after · pallets/inflation/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//! # Inflation18//!19//! The inflation pallet is designed to increase the number of tokens at certain intervals.20//! With each iteration, increases the `total_issuance` value for the native token.21//! Executing an `on_initialize` hook at the beginning of each block, causing inflation to begin.22//!23//! ## Interface24//!25//! ### Dispatchable Functions26//!27//! * `start_inflation` - This method sets the inflation start date. Can be only called once.28//! Inflation start block can be backdated and will catch up. The method will create Treasury29//! account if it does not exist and perform the first inflation deposit.3031// #![recursion_limit = "1024"]32#![cfg_attr(not(feature = "std"), no_std)]3334#[cfg(feature = "runtime-benchmarks")]35mod benchmarking;3637#[cfg(test)]38mod tests;3940use frame_support::{41	dispatch::{DispatchResult},42	traits::{43		fungible::{Balanced, Inspect, Mutate},44		Get,45		tokens::Precision,46	},47};48pub use pallet::*;49use sp_runtime::{Perbill, traits::BlockNumberProvider};5051use sp_std::convert::TryInto;5253type BalanceOf<T> =54	<<T as Config>::Currency as Inspect<<T as frame_system::Config>::AccountId>>::Balance;5556pub const YEAR: u32 = 5_259_600; // 6-second block57								 // pub const YEAR: u32 = 2_629_800; // 12-second block58pub const TOTAL_YEARS_UNTIL_FLAT: u32 = 9;59pub const START_INFLATION_PERCENT: u32 = 10;60pub const END_INFLATION_PERCENT: u32 = 4;6162#[frame_support::pallet]63pub mod pallet {64	use super::*;65	use frame_support::pallet_prelude::*;66	use frame_system::pallet_prelude::*;6768	#[pallet::config]69	pub trait Config: frame_system::Config {70		type Currency: Balanced<Self::AccountId>71			+ Inspect<Self::AccountId>72			+ Mutate<Self::AccountId>;73		type TreasuryAccountId: Get<Self::AccountId>;7475		// The block number provider76		type BlockNumberProvider: BlockNumberProvider<BlockNumber = Self::BlockNumber>;7778		/// Number of blocks that pass between treasury balance updates due to inflation79		#[pallet::constant]80		type InflationBlockInterval: Get<Self::BlockNumber>;81	}8283	#[pallet::pallet]84	pub struct Pallet<T>(_);8586	/// starting year total issuance87	#[pallet::storage]88	pub type StartingYearTotalIssuance<T: Config> =89		StorageValue<Value = BalanceOf<T>, QueryKind = ValueQuery>;9091	/// Current inflation for `InflationBlockInterval` number of blocks92	#[pallet::storage]93	pub type BlockInflation<T: Config> = StorageValue<Value = BalanceOf<T>, QueryKind = ValueQuery>;9495	/// Next target (relay) block when inflation will be applied96	#[pallet::storage]97	pub type NextInflationBlock<T: Config> =98		StorageValue<Value = T::BlockNumber, QueryKind = ValueQuery>;99100	/// Next target (relay) block when inflation is recalculated101	#[pallet::storage]102	pub type NextRecalculationBlock<T: Config> =103		StorageValue<Value = T::BlockNumber, QueryKind = ValueQuery>;104105	/// Relay block when inflation has started106	#[pallet::storage]107	pub type StartBlock<T: Config> = StorageValue<Value = T::BlockNumber, QueryKind = ValueQuery>;108109	#[pallet::hooks]110	impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {111		fn on_initialize(_: T::BlockNumber) -> Weight112		where113			<T as frame_system::Config>::BlockNumber: From<u32>,114		{115			let mut consumed_weight = Weight::zero();116			let mut add_weight = |reads, writes, weight| {117				consumed_weight += T::DbWeight::get().reads_writes(reads, writes);118				consumed_weight += weight;119			};120121			let block_interval: u32 = T::InflationBlockInterval::get().try_into().unwrap_or(0);122			let current_relay_block = T::BlockNumberProvider::current_block_number();123			let next_inflation: T::BlockNumber = <NextInflationBlock<T>>::get();124			add_weight(1, 0, Weight::from_parts(5_000_000, 0));125126			// Apply inflation every InflationBlockInterval blocks127			// If next_inflation == 0, this means inflation wasn't yet initialized128			if (next_inflation != 0u32.into()) && (current_relay_block >= next_inflation) {129				// Recalculate inflation on the first block of the year (or if it is not initialized yet)130				// Do the "current_relay_block >= next_recalculation" check in the "current_relay_block >= next_inflation"131				// block because it saves InflationBlockInterval DB reads for NextRecalculationBlock.132				let next_recalculation: T::BlockNumber = <NextRecalculationBlock<T>>::get();133				add_weight(1, 0, Weight::zero());134				if current_relay_block >= next_recalculation {135					Self::recalculate_inflation(next_recalculation);136					add_weight(0, 4, Weight::from_parts(5_000_000, 0));137				}138139				T::Currency::mint_into(&T::TreasuryAccountId::get(), <BlockInflation<T>>::get())140					.ok();141142				// Update inflation block143				<NextInflationBlock<T>>::set(next_inflation + block_interval.into());144145				add_weight(3, 3, Weight::from_parts(10_000_000, 0));146			}147148			consumed_weight149		}150	}151152	#[pallet::call]153	impl<T: Config> Pallet<T> {154		/// This method sets the inflation start date. Can be only called once.155		/// Inflation start block can be backdated and will catch up. The method will create Treasury156		/// account if it does not exist and perform the first inflation deposit.157		///158		/// # Permissions159		///160		/// * Root161		///162		/// # Arguments163		///164		/// * inflation_start_relay_block: The relay chain block at which inflation should start165		#[pallet::call_index(0)]166		#[pallet::weight(0)]167		pub fn start_inflation(168			origin: OriginFor<T>,169			inflation_start_relay_block: T::BlockNumber,170		) -> DispatchResult171		where172			<T as frame_system::Config>::BlockNumber: From<u32>,173		{174			ensure_root(origin)?;175176			// Start inflation if it has not been yet initialized177			if <StartBlock<T>>::get() == 0u32.into() {178				// Set inflation global start block179				<StartBlock<T>>::set(inflation_start_relay_block);180181				// Recalculate inflation. This can be backdated and will catch up.182				Self::recalculate_inflation(inflation_start_relay_block);183				let block_interval: u32 = T::InflationBlockInterval::get().try_into().unwrap_or(0);184				<NextInflationBlock<T>>::set(inflation_start_relay_block + block_interval.into());185186				// First time deposit - create Treasury account so that we can call deposit_into_existing everywhere else187				let _ = T::Currency::deposit(188					&T::TreasuryAccountId::get(),189					<BlockInflation<T>>::get(),190					Precision::Exact,191				)?;192			}193194			Ok(())195		}196	}197}198199impl<T: Config> Pallet<T> {200	pub fn recalculate_inflation(recalculation_block: T::BlockNumber) {201		let current_year: u32 = ((recalculation_block - <StartBlock<T>>::get())202			/ T::BlockNumber::from(YEAR))203		.try_into()204		.unwrap_or(0);205		let block_interval: u32 = T::InflationBlockInterval::get().try_into().unwrap_or(0);206207		let one_percent = Perbill::from_percent(1);208209		if current_year <= TOTAL_YEARS_UNTIL_FLAT {210			let amount: BalanceOf<T> = Perbill::from_rational(211				block_interval212					* (START_INFLATION_PERCENT * TOTAL_YEARS_UNTIL_FLAT213						- current_year * (START_INFLATION_PERCENT - END_INFLATION_PERCENT)),214				YEAR * TOTAL_YEARS_UNTIL_FLAT,215			) * (one_percent * T::Currency::total_issuance());216			<BlockInflation<T>>::put(amount);217		} else {218			let amount: BalanceOf<T> =219				Perbill::from_rational(block_interval * END_INFLATION_PERCENT, YEAR)220					* (one_percent * T::Currency::total_issuance());221			<BlockInflation<T>>::put(amount);222		}223		<StartingYearTotalIssuance<T>>::set(T::Currency::total_issuance());224225		// Update recalculation and inflation blocks226		<NextRecalculationBlock<T>>::set(recalculation_block + YEAR.into());227	}228}
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -90,7 +90,7 @@
 use crate::erc_token::ERC20Events;
 use crate::erc::ERC721Events;
 
-use core::ops::Deref;
+use core::{ops::Deref, cmp::Ordering};
 use evm_coder::ToLog;
 use frame_support::{ensure, storage::with_transaction, transactional};
 use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
@@ -1266,44 +1266,48 @@
 		<Balance<T>>::insert((collection.id, token, owner), amount);
 		<TotalSupply<T>>::insert((collection.id, token), amount);
 
-		if amount > total_pieces {
-			let mint_amount = amount - total_pieces;
-			<PalletEvm<T>>::deposit_log(
-				ERC20Events::Transfer {
-					from: H160::default(),
-					to: *owner.as_eth(),
-					value: mint_amount.into(),
-				}
-				.to_log(T::EvmTokenAddressMapping::token_to_address(
+		match total_pieces.cmp(&amount) {
+			Ordering::Less => {
+				let mint_amount = amount - total_pieces;
+				<PalletEvm<T>>::deposit_log(
+					ERC20Events::Transfer {
+						from: H160::default(),
+						to: *owner.as_eth(),
+						value: mint_amount.into(),
+					}
+					.to_log(T::EvmTokenAddressMapping::token_to_address(
+						collection.id,
+						token,
+					)),
+				);
+				<PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(
 					collection.id,
 					token,
-				)),
-			);
-			<PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(
-				collection.id,
-				token,
-				owner.clone(),
-				mint_amount,
-			));
-		} else if total_pieces > amount {
-			let burn_amount = total_pieces - amount;
-			<PalletEvm<T>>::deposit_log(
-				ERC20Events::Transfer {
-					from: *owner.as_eth(),
-					to: H160::default(),
-					value: burn_amount.into(),
-				}
-				.to_log(T::EvmTokenAddressMapping::token_to_address(
+					owner.clone(),
+					mint_amount,
+				));
+			}
+			Ordering::Greater => {
+				let burn_amount = total_pieces - amount;
+				<PalletEvm<T>>::deposit_log(
+					ERC20Events::Transfer {
+						from: *owner.as_eth(),
+						to: H160::default(),
+						value: burn_amount.into(),
+					}
+					.to_log(T::EvmTokenAddressMapping::token_to_address(
+						collection.id,
+						token,
+					)),
+				);
+				<PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(
 					collection.id,
 					token,
-				)),
-			);
-			<PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(
-				collection.id,
-				token,
-				owner.clone(),
-				burn_amount,
-			));
+					owner.clone(),
+					burn_amount,
+				));
+			}
+			Ordering::Equal => {}
 		}
 
 		Ok(())
modifiedruntime/common/ethereum/precompiles/utils/macro/src/lib.rsdiffbeforeafterboth
--- a/runtime/common/ethereum/precompiles/utils/macro/src/lib.rs
+++ b/runtime/common/ethereum/precompiles/utils/macro/src/lib.rs
@@ -35,8 +35,8 @@
 /// ```ignore
 /// #[generate_function_selector]
 /// enum Action {
-/// 	Toto = "toto()",
-/// 	Tata = "tata()",
+///     Toto = "toto()",
+///     Tata = "tata()",
 /// }
 /// ```
 ///
@@ -45,8 +45,8 @@
 /// ```rust
 /// #[repr(u32)]
 /// enum Action {
-/// 	Toto = 119097542u32,
-/// 	Tata = 1414311903u32,
+///     Toto = 119097542u32,
+///     Tata = 1414311903u32,
 /// }
 /// ```
 ///
modifiedruntime/common/runtime_apis.rsdiffbeforeafterboth
--- a/runtime/common/runtime_apis.rs
+++ b/runtime/common/runtime_apis.rs
@@ -687,7 +687,7 @@
                 fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
                     log::info!("try-runtime::on_runtime_upgrade unique-chain.");
                     let weight = Executive::try_runtime_upgrade(checks).unwrap();
-                    (weight, crate::config::substrate::RuntimeBlockWeights::get().max_block)
+                    (weight, $crate::config::substrate::RuntimeBlockWeights::get().max_block)
                 }
 
                 fn execute_block(