git.delta.rocks / unique-network / refs/commits / 8d05c70ee567

difftreelog

fix clippy warnings

Grigoriy Simonov2023-06-07parent: #cf59f49.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
95mod types;95mod types;
96pub mod weights;96pub mod weights;
9797
98use frame_support::traits::{BalanceStatus, Currency, OnUnbalanced, ReservableCurrency};98use frame_support::{
99 traits::{BalanceStatus, Currency, OnUnbalanced, ReservableCurrency},
100};
99use sp_runtime::traits::{AppendZerosInput, Hash, Saturating, StaticLookup, Zero};101use sp_runtime::{
102 BoundedVec,
103 traits::{AppendZerosInput, Hash, Saturating, StaticLookup, Zero},
104};
100use sp_std::prelude::*;105use sp_std::prelude::*;
101pub use weights::WeightInfo;106pub use weights::WeightInfo;
102107
112 <T as frame_system::Config>::AccountId,117 <T as frame_system::Config>::AccountId,
113>>::NegativeImbalance;118>>::NegativeImbalance;
114type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;119type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
120type RegistrarInfoOf<T> = RegistrarInfo<BalanceOf<T>, <T as frame_system::Config>::AccountId>;
121type RegistrationOf<T> =
122 Registration<BalanceOf<T>, <T as Config>::MaxRegistrars, <T as Config>::MaxAdditionalFields>;
123type SubAccounts<T> =
124 sp_runtime::BoundedVec<<T as frame_system::Config>::AccountId, <T as Config>::MaxSubAccounts>;
125type SubAccountsByAccountId<T> = (
126 <T as frame_system::Config>::AccountId,
127 (
128 BalanceOf<T>,
129 BoundedVec<(<T as frame_system::Config>::AccountId, Data), <T as Config>::MaxSubAccounts>,
130 ),
131);
115132
116#[frame_support::pallet]133#[frame_support::pallet]
117pub mod pallet {134pub mod pallet {
199 #[pallet::storage]216 #[pallet::storage]
200 #[pallet::getter(fn subs_of)]217 #[pallet::getter(fn subs_of)]
201 pub(super) type SubsOf<T: Config> = StorageMap<218 pub(super) type SubsOf<T: Config> =
202 _,219 StorageMap<_, Twox64Concat, T::AccountId, (BalanceOf<T>, SubAccounts<T>), ValueQuery>;
203 Twox64Concat,
204 T::AccountId,
205 (BalanceOf<T>, BoundedVec<T::AccountId, T::MaxSubAccounts>),
206 ValueQuery,
207 >;
208220
209 /// The set of registrars. Not expected to get very big as can only be added through a221 /// The set of registrars. Not expected to get very big as can only be added through a
213 #[pallet::storage]225 #[pallet::storage]
214 #[pallet::getter(fn registrars)]226 #[pallet::getter(fn registrars)]
215 pub(super) type Registrars<T: Config> = StorageValue<227 pub(super) type Registrars<T: Config> =
216 _,228 StorageValue<_, BoundedVec<Option<RegistrarInfoOf<T>>, T::MaxRegistrars>, ValueQuery>;
217 BoundedVec<Option<RegistrarInfo<BalanceOf<T>, T::AccountId>>, T::MaxRegistrars>,
218 ValueQuery,
219 >;
220229
221 #[pallet::error]230 #[pallet::error]
482 .all(|i| i.0 == sender);491 .all(|i| i.0 == sender);
483 ensure!(not_other_sub, Error::<T>::AlreadyClaimed);492 ensure!(not_other_sub, Error::<T>::AlreadyClaimed);
484493
485 if old_deposit < new_deposit {494 match old_deposit.cmp(&new_deposit) {
486 T::Currency::reserve(&sender, new_deposit - old_deposit)?;495 core::cmp::Ordering::Less => {
496 T::Currency::reserve(&sender, new_deposit - old_deposit)?
497 }
498 core::cmp::Ordering::Equal => { /* do nothing if they're equal. */ }
487 } else if old_deposit > new_deposit {499 core::cmp::Ordering::Greater => {
488 let err_amount = T::Currency::unreserve(&sender, old_deposit - new_deposit);500 let err_amount = T::Currency::unreserve(&sender, old_deposit - new_deposit);
489 debug_assert!(err_amount.is_zero());501 debug_assert!(err_amount.is_zero());
490 }502 }
491 // do nothing if they're equal.503 }
492504
493 for s in old_ids.iter() {505 for s in old_ids.iter() {
494 <SuperOf<T>>::remove(s);506 <SuperOf<T>>::remove(s);
495 }507 }
496 let mut ids = BoundedVec::<T::AccountId, T::MaxSubAccounts>::default();508 let mut ids = <SubAccounts<T>>::default();
497 for (id, name) in subs {509 for (id, name) in subs {
498 <SuperOf<T>>::insert(&id, (sender.clone(), name));510 <SuperOf<T>>::insert(&id, (sender.clone(), name));
499 ids.try_push(id)511 ids.try_push(id)
1107 ))]1119 ))]
1108 pub fn force_insert_identities(1120 pub fn force_insert_identities(
1109 origin: OriginFor<T>,1121 origin: OriginFor<T>,
1110 identities: Vec<(1122 identities: Vec<(T::AccountId, RegistrationOf<T>)>,
1111 T::AccountId,
1112 Registration<BalanceOf<T>, T::MaxRegistrars, T::MaxAdditionalFields>,
1113 )>,
1114 ) -> DispatchResult {1123 ) -> DispatchResult {
1115 T::ForceOrigin::ensure_origin(origin)?;1124 T::ForceOrigin::ensure_origin(origin)?;
1162 ))]1171 ))]
1163 pub fn force_set_subs(1172 pub fn force_set_subs(
1164 origin: OriginFor<T>,1173 origin: OriginFor<T>,
1165 subs: Vec<(1174 subs: Vec<SubAccountsByAccountId<T>>,
1166 T::AccountId,
1167 (
1168 BalanceOf<T>,
1169 BoundedVec<(T::AccountId, Data), T::MaxSubAccounts>,
1170 ),
1171 )>,
1172 ) -> DispatchResult {1175 ) -> DispatchResult {
1173 T::ForceOrigin::ensure_origin(origin)?;1176 T::ForceOrigin::ensure_origin(origin)?;
1174 for identity in subs.clone() {1177 for identity in subs.clone() {
1178 <SuperOf<T>>::remove(old_sub);1181 <SuperOf<T>>::remove(old_sub);
1179 }1182 }
11801183
1181 let mut ids = BoundedVec::<T::AccountId, T::MaxSubAccounts>::default();1184 let mut ids = <SubAccounts<T>>::default();
1182 for (id, name) in identity.1 .1 {1185 for (id, name) in identity.1 .1 {
1183 <SuperOf<T>>::insert(&id, (account.clone(), name));1186 <SuperOf<T>>::insert(&id, (account.clone(), name));
1184 ids.try_push(id)1187 ids.try_push(id)
modifiedpallets/inflation/src/lib.rsdiffbeforeafterboth
--- a/pallets/inflation/src/lib.rs
+++ b/pallets/inflation/src/lib.rs
@@ -26,7 +26,7 @@
 //!
 //! * `start_inflation` - This method sets the inflation start date. Can be only called once.
 //! Inflation start block can be backdated and will catch up. The method will create Treasury
-//!	account if it does not exist and perform the first inflation deposit.
+//! account if it does not exist and perform the first inflation deposit.
 
 // #![recursion_limit = "1024"]
 #![cfg_attr(not(feature = "std"), no_std)]
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(