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

difftreelog

fix clippy warnings

Grigoriy Simonov2023-10-12parent: #5f71c37.patch.diff
in: master

12 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -10145,6 +10145,7 @@
  "sp-runtime",
  "sp-session",
  "sp-std",
+ "sp-storage",
  "sp-transaction-pool",
  "sp-version",
  "staging-xcm",
@@ -14897,6 +14898,7 @@
  "sp-runtime",
  "sp-session",
  "sp-std",
+ "sp-storage",
  "sp-transaction-pool",
  "sp-version",
  "staging-xcm",
modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -238,7 +238,7 @@
 			vesting: VestingConfig { vesting: vec![] },
 			parachain_info: ParachainInfoConfig {
 				parachain_id: $id.into(),
-				Default::default()
+				..Default::default()
 			},
 			aura: AuraConfig {
 				authorities: $initial_invulnerables
modifiednode/cli/src/command.rsdiffbeforeafterboth
--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -399,6 +399,7 @@
 		Some(Subcommand::TryRuntime(cmd)) => {
 			use std::{future::Future, pin::Pin};
 
+			use polkadot_cli::Block;
 			use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
 			use try_runtime_cli::block_building_info::timestamp_with_aura_info;
 
modifiednode/cli/src/rpc.rsdiffbeforeafterboth
--- a/node/cli/src/rpc.rs
+++ b/node/cli/src/rpc.rs
@@ -67,7 +67,7 @@
 }
 
 /// Instantiate all Full RPC extensions.
-pub fn create_full<C, P, SC, R, A, B>(
+pub fn create_full<C, P, SC, R, B>(
 	io: &mut RpcModule<()>,
 	deps: FullDeps<C, P, SC>,
 ) -> Result<(), Box<dyn std::error::Error + Send + Sync>>
@@ -244,7 +244,7 @@
 			EthFilter::new(
 				client.clone(),
 				eth_backend,
-				graph.clone(),
+				graph,
 				filter_pool,
 				500_usize, // max stored filters
 				max_past_logs,
modifiednode/cli/src/service.rsdiffbeforeafterboth
--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -498,7 +498,7 @@
 				select_chain,
 			};
 
-			create_full::<_, _, _, Runtime, RuntimeApi, _>(&mut rpc_handle, full_deps)?;
+			create_full::<_, _, _, Runtime, _>(&mut rpc_handle, full_deps)?;
 
 			let eth_deps = EthDeps {
 				client,
@@ -547,7 +547,7 @@
 		config: parachain_config,
 		keystore: params.keystore_container.keystore(),
 		backend: backend.clone(),
-		network: network.clone(),
+		network,
 		sync_service: sync_service.clone(),
 		system_rpc_tx,
 		telemetry: telemetry.as_mut(),
@@ -600,19 +600,21 @@
 	if validator {
 		start_consensus(
 			client.clone(),
-			backend.clone(),
-			prometheus_registry.as_ref(),
-			telemetry.as_ref().map(|t| t.handle()),
-			&task_manager,
-			relay_chain_interface.clone(),
 			transaction_pool,
-			sync_service.clone(),
-			params.keystore_container.keystore(),
-			overseer_handle,
-			relay_chain_slot_duration,
-			para_id,
-			collator_key.expect("cli args do not allow this"),
-			announce_block,
+			StartConsensusParameters {
+				backend: backend.clone(),
+				prometheus_registry: prometheus_registry.as_ref(),
+				telemetry: telemetry.as_ref().map(|t| t.handle()),
+				task_manager: &task_manager,
+				relay_chain_interface: relay_chain_interface.clone(),
+				sync_oracle: sync_service,
+				keystore: params.keystore_container.keystore(),
+				overseer_handle,
+				relay_chain_slot_duration,
+				para_id,
+				collator_key: collator_key.expect("cli args do not allow this"),
+				announce_block,
+			}
 		)?;
 	}
 
@@ -670,16 +672,12 @@
 	.map_err(Into::into)
 }
 
-pub fn start_consensus<ExecutorDispatch, RuntimeApi, Runtime>(
-	client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,
+pub struct StartConsensusParameters<'a> {
 	backend: Arc<FullBackend>,
-	prometheus_registry: Option<&Registry>,
+	prometheus_registry: Option<&'a Registry>,
 	telemetry: Option<TelemetryHandle>,
-	task_manager: &TaskManager,
+	task_manager: &'a TaskManager,
 	relay_chain_interface: Arc<dyn RelayChainInterface>,
-	transaction_pool: Arc<
-		sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
-	>,
 	sync_oracle: Arc<SyncingService<Block>>,
 	keystore: KeystorePtr,
 	overseer_handle: OverseerHandle,
@@ -687,6 +685,14 @@
 	para_id: ParaId,
 	collator_key: CollatorPair,
 	announce_block: Arc<dyn Fn(Hash, Option<Vec<u8>>) + Send + Sync>,
+}
+
+pub fn start_consensus<ExecutorDispatch, RuntimeApi, Runtime>(
+	client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,
+	transaction_pool: Arc<
+		sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
+	>,
+	parameters: StartConsensusParameters<'_>,
 ) -> Result<(), sc_service::Error>
 where
 	ExecutorDispatch: NativeExecutionDispatch + 'static,
@@ -697,6 +703,20 @@
 	RuntimeApi::RuntimeApi: RuntimeApiDep<Runtime> + 'static,
 	Runtime: RuntimeInstance,
 {
+	let StartConsensusParameters {
+		backend,
+		prometheus_registry,
+		telemetry,
+		task_manager,
+		relay_chain_interface,
+		sync_oracle,
+		keystore,
+		overseer_handle,
+		relay_chain_slot_duration,
+		para_id,
+		collator_key,
+		announce_block,
+	} = parameters;
 	let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;
 
 	let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
@@ -704,7 +724,7 @@
 		client.clone(),
 		transaction_pool,
 		prometheus_registry,
-		telemetry.clone(),
+		telemetry,
 	);
 	let proposer = Proposer::new(proposer_factory);
 
@@ -1043,7 +1063,7 @@
 				select_chain,
 			};
 
-			create_full::<_, _, _, Runtime, RuntimeApi, _>(&mut rpc_module, full_deps)?;
+			create_full::<_, _, _, Runtime, _>(&mut rpc_module, full_deps)?;
 
 			let eth_deps = EthDeps {
 				client,
modifiedpallets/app-promotion/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/app-promotion/src/benchmarking.rs
+++ b/pallets/app-promotion/src/benchmarking.rs
@@ -161,7 +161,7 @@
 		T::RelayBlockNumberProvider::set_block_number(30_000.into());
 
 		#[extrinsic_call]
-		_(RawOrigin::Signed(pallet_admin.clone()), Some(b as u8));
+		_(RawOrigin::Signed(pallet_admin), Some(b as u8));
 
 		Ok(())
 	}
@@ -178,7 +178,7 @@
 
 		#[extrinsic_call]
 		_(
-			RawOrigin::Signed(caller.clone()),
+			RawOrigin::Signed(caller),
 			share * <T as Config>::Currency::total_balance(&caller),
 		);
 
@@ -211,7 +211,7 @@
 			.collect::<Result<Vec<_>, _>>()?;
 
 		#[extrinsic_call]
-		_(RawOrigin::Signed(caller.clone()));
+		_(RawOrigin::Signed(caller));
 
 		Ok(())
 	}
@@ -242,7 +242,7 @@
 
 		#[extrinsic_call]
 		_(
-			RawOrigin::Signed(caller.clone()),
+			RawOrigin::Signed(caller),
 			Into::<BalanceOf<T>>::into(1000u128) * T::Nominal::get(),
 		);
 
@@ -268,7 +268,7 @@
 		let collection = create_nft_collection::<T>(caller)?;
 
 		#[extrinsic_call]
-		_(RawOrigin::Signed(pallet_admin.clone()), collection);
+		_(RawOrigin::Signed(pallet_admin), collection);
 
 		Ok(())
 	}
@@ -296,7 +296,7 @@
 		)?;
 
 		#[extrinsic_call]
-		_(RawOrigin::Signed(pallet_admin.clone()), collection);
+		_(RawOrigin::Signed(pallet_admin), collection);
 
 		Ok(())
 	}
@@ -319,7 +319,7 @@
 		<EvmMigrationPallet<T>>::finish(RawOrigin::Root.into(), address, data)?;
 
 		#[extrinsic_call]
-		_(RawOrigin::Signed(pallet_admin.clone()), address);
+		_(RawOrigin::Signed(pallet_admin), address);
 
 		Ok(())
 	}
@@ -346,7 +346,7 @@
 		)?;
 
 		#[extrinsic_call]
-		_(RawOrigin::Signed(pallet_admin.clone()), address);
+		_(RawOrigin::Signed(pallet_admin), address);
 
 		Ok(())
 	}
modifiedpallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -75,7 +75,7 @@
 
 		#[block]
 		{
-			create_max_item(&collection, &sender, to.clone())?;
+			create_max_item(&collection, &sender, to)?;
 		}
 
 		Ok(())
modifiedpallets/refungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -82,7 +82,7 @@
 
 		#[block]
 		{
-			create_max_item(&collection, &sender, [(to.clone(), 200)])?;
+			create_max_item(&collection, &sender, [(to, 200)])?;
 		}
 
 		Ok(())
modifiedpallets/unique/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/unique/src/benchmarking.rs
+++ b/pallets/unique/src/benchmarking.rs
@@ -107,7 +107,7 @@
 		let collection = create_nft_collection::<T>(caller.clone())?;
 
 		#[extrinsic_call]
-		_(RawOrigin::Signed(caller.clone()), collection);
+		_(RawOrigin::Signed(caller), collection);
 
 		Ok(())
 	}
@@ -120,7 +120,7 @@
 
 		#[extrinsic_call]
 		_(
-			RawOrigin::Signed(caller.clone()),
+			RawOrigin::Signed(caller),
 			collection,
 			T::CrossAccountId::from_sub(allowlist_account),
 		);
@@ -141,7 +141,7 @@
 
 		#[extrinsic_call]
 		_(
-			RawOrigin::Signed(caller.clone()),
+			RawOrigin::Signed(caller),
 			collection,
 			T::CrossAccountId::from_sub(allowlist_account),
 		);
@@ -156,7 +156,7 @@
 		let new_owner: T::AccountId = account("admin", 0, SEED);
 
 		#[extrinsic_call]
-		_(RawOrigin::Signed(caller.clone()), collection, new_owner);
+		_(RawOrigin::Signed(caller), collection, new_owner);
 
 		Ok(())
 	}
@@ -169,7 +169,7 @@
 
 		#[extrinsic_call]
 		_(
-			RawOrigin::Signed(caller.clone()),
+			RawOrigin::Signed(caller),
 			collection,
 			T::CrossAccountId::from_sub(new_admin),
 		);
@@ -190,7 +190,7 @@
 
 		#[extrinsic_call]
 		_(
-			RawOrigin::Signed(caller.clone()),
+			RawOrigin::Signed(caller),
 			collection,
 			T::CrossAccountId::from_sub(new_admin),
 		);
@@ -204,11 +204,7 @@
 		let collection = create_nft_collection::<T>(caller.clone())?;
 
 		#[extrinsic_call]
-		_(
-			RawOrigin::Signed(caller.clone()),
-			collection,
-			caller.clone(),
-		);
+		_(RawOrigin::Signed(caller), collection, caller.clone());
 
 		Ok(())
 	}
@@ -224,7 +220,7 @@
 		)?;
 
 		#[extrinsic_call]
-		_(RawOrigin::Signed(caller.clone()), collection);
+		_(RawOrigin::Signed(caller), collection);
 
 		Ok(())
 	}
@@ -241,7 +237,7 @@
 		<Pallet<T>>::confirm_sponsorship(RawOrigin::Signed(caller.clone()).into(), collection)?;
 
 		#[extrinsic_call]
-		_(RawOrigin::Signed(caller.clone()), collection);
+		_(RawOrigin::Signed(caller), collection);
 
 		Ok(())
 	}
@@ -252,7 +248,7 @@
 		let collection = create_nft_collection::<T>(caller.clone())?;
 
 		#[extrinsic_call]
-		_(RawOrigin::Signed(caller.clone()), collection, false);
+		_(RawOrigin::Signed(caller), collection, false);
 
 		Ok(())
 	}
@@ -275,7 +271,7 @@
 		};
 
 		#[extrinsic_call]
-		set_collection_limits(RawOrigin::Signed(caller.clone()), collection, cl);
+		set_collection_limits(RawOrigin::Signed(caller), collection, cl);
 
 		Ok(())
 	}
modifiedruntime/common/config/xcm/foreignassets.rsdiffbeforeafterboth
after · runtime/common/config/xcm/foreignassets.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/>.1617use frame_support::{parameter_types, traits::Get};18use orml_traits::location::AbsoluteReserveProvider;19use orml_xcm_support::MultiNativeAsset;20use pallet_foreign_assets::{21	AssetId, AssetIdMapping, CurrencyId, ForeignAssetId, FreeForAll, NativeCurrency, TryAsForeign,22	XcmForeignAssetIdMapping,23};24use sp_runtime::traits::{Convert, MaybeEquivalence};25use sp_std::marker::PhantomData;26use staging_xcm::latest::{prelude::*, MultiAsset, MultiLocation};27use staging_xcm_builder::{ConvertedConcreteId, FungiblesAdapter, NoChecking};28use staging_xcm_executor::traits::{JustTry, TransactAsset};29use up_common::types::{AccountId, Balance};3031use super::{LocationToAccountId, RelayLocation};32use crate::{Balances, ForeignAssets, ParachainInfo, PolkadotXcm, Runtime};3334parameter_types! {35	pub CheckingAccount: AccountId = PolkadotXcm::check_account();36}3738pub struct AsInnerId<ConvertAssetId>(PhantomData<(AssetId, ConvertAssetId)>);39impl<ConvertAssetId: MaybeEquivalence<AssetId, AssetId>> MaybeEquivalence<MultiLocation, AssetId>40	for AsInnerId<ConvertAssetId>41{42	fn convert(id: &MultiLocation) -> Option<AssetId> {43		log::trace!(44			target: "xcm::AsInnerId::Convert",45			"AsInnerId {:?}",46			id47		);4849		let parent = MultiLocation::parent();50		let here = MultiLocation::here();51		let self_location = MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())));5253		if *id == parent {54			return ConvertAssetId::convert(&AssetId::NativeAssetId(NativeCurrency::Parent));55		}5657		if *id == here || *id == self_location {58			return ConvertAssetId::convert(&AssetId::NativeAssetId(NativeCurrency::Here));59		}6061		match XcmForeignAssetIdMapping::<Runtime>::get_currency_id(*id) {62			Some(AssetId::ForeignAssetId(foreign_asset_id)) => {63				ConvertAssetId::convert(&AssetId::ForeignAssetId(foreign_asset_id))64			}65			_ => None,66		}67	}6869	fn convert_back(asset_id: &AssetId) -> Option<MultiLocation> {70		log::trace!(71			target: "xcm::AsInnerId::Reverse",72			"AsInnerId",73		);7475		let parent_id =76			ConvertAssetId::convert(&AssetId::NativeAssetId(NativeCurrency::Parent)).unwrap();77		let here_id =78			ConvertAssetId::convert(&AssetId::NativeAssetId(NativeCurrency::Here)).unwrap();7980		if *asset_id == parent_id {81			return Some(MultiLocation::parent());82		}8384		if *asset_id == here_id {85			return Some(MultiLocation::new(86				1,87				X1(Parachain(ParachainInfo::get().into())),88			));89		}9091		let fid = <AssetId as TryAsForeign<AssetId, ForeignAssetId>>::try_as_foreign(*asset_id)?;92		XcmForeignAssetIdMapping::<Runtime>::get_multi_location(fid)93	}94}9596/// Means for transacting assets besides the native currency on this chain.97pub type FungiblesTransactor = FungiblesAdapter<98	// Use this fungibles implementation:99	ForeignAssets,100	// Use this currency when it is a fungible asset matching the given location or name:101	ConvertedConcreteId<AssetId, Balance, AsInnerId<JustTry>, JustTry>,102	// Convert an XCM MultiLocation into a local account id:103	LocationToAccountId,104	// Our chain's account ID type (we can't get away without mentioning it explicitly):105	AccountId,106	// No Checking for teleported assets since we disallow teleports at all.107	NoChecking,108	// The account to use for tracking teleports.109	CheckingAccount,110>;111112/// Means for transacting assets on this chain.113pub struct AssetTransactor;114impl TransactAsset for AssetTransactor {115	fn can_check_in(116		_origin: &MultiLocation,117		_what: &MultiAsset,118		_context: &XcmContext,119	) -> XcmResult {120		Err(XcmError::Unimplemented)121	}122123	fn check_in(_origin: &MultiLocation, _what: &MultiAsset, _context: &XcmContext) {}124125	fn can_check_out(126		_dest: &MultiLocation,127		_what: &MultiAsset,128		_context: &XcmContext,129	) -> XcmResult {130		Err(XcmError::Unimplemented)131	}132133	fn check_out(_dest: &MultiLocation, _what: &MultiAsset, _context: &XcmContext) {}134135	fn deposit_asset(what: &MultiAsset, who: &MultiLocation, context: &XcmContext) -> XcmResult {136		FungiblesTransactor::deposit_asset(what, who, context)137	}138139	fn withdraw_asset(140		what: &MultiAsset,141		who: &MultiLocation,142		maybe_context: Option<&XcmContext>,143	) -> Result<staging_xcm_executor::Assets, XcmError> {144		FungiblesTransactor::withdraw_asset(what, who, maybe_context)145	}146147	fn internal_transfer_asset(148		what: &MultiAsset,149		from: &MultiLocation,150		to: &MultiLocation,151		context: &XcmContext,152	) -> Result<staging_xcm_executor::Assets, XcmError> {153		FungiblesTransactor::internal_transfer_asset(what, from, to, context)154	}155}156157pub type IsReserve = MultiNativeAsset<AbsoluteReserveProvider>;158159pub type Trader<T> = FreeForAll<160	pallet_configuration::WeightToFee<T, Balance>,161	RelayLocation,162	AccountId,163	Balances,164	(),165>;166167pub struct CurrencyIdConvert;168impl Convert<AssetId, Option<MultiLocation>> for CurrencyIdConvert {169	fn convert(id: AssetId) -> Option<MultiLocation> {170		match id {171			AssetId::NativeAssetId(NativeCurrency::Here) => Some(MultiLocation::new(172				1,173				X1(Parachain(ParachainInfo::get().into())),174			)),175			AssetId::NativeAssetId(NativeCurrency::Parent) => Some(MultiLocation::parent()),176			AssetId::ForeignAssetId(foreign_asset_id) => {177				XcmForeignAssetIdMapping::<Runtime>::get_multi_location(foreign_asset_id)178			}179		}180	}181}182183impl Convert<MultiLocation, Option<CurrencyId>> for CurrencyIdConvert {184	fn convert(location: MultiLocation) -> Option<CurrencyId> {185		if location == MultiLocation::here()186			|| location == MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())))187		{188			return Some(AssetId::NativeAssetId(NativeCurrency::Here));189		}190191		if location == MultiLocation::parent() {192			return Some(AssetId::NativeAssetId(NativeCurrency::Parent));193		}194195		if let Some(currency_id) = XcmForeignAssetIdMapping::<Runtime>::get_currency_id(location) {196			return Some(currency_id);197		}198199		None200	}201}
modifiedruntime/quartz/Cargo.tomldiffbeforeafterboth
--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -271,6 +271,7 @@
 sp-runtime = { workspace = true }
 sp-session = { workspace = true }
 sp-std = { workspace = true }
+sp-storage = { workspace = true }
 sp-transaction-pool = { workspace = true }
 sp-version = { workspace = true }
 staging-xcm = { workspace = true }
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -274,6 +274,7 @@
 sp-runtime = { workspace = true }
 sp-session = { workspace = true }
 sp-std = { workspace = true }
+sp-storage = { workspace = true }
 sp-transaction-pool = { workspace = true }
 sp-version = { workspace = true }
 staging-xcm = { workspace = true }