From 14aa375a49bcc55467c1cc12835391fa2790066a Mon Sep 17 00:00:00 2001 From: Harald Heckmann Date: Tue, 16 Jan 2024 21:44:31 +0100 Subject: [PATCH] Satisfy Clippy --- primitives/src/constants/mock.rs | 6 ++-- .../battery-station/src/xcm_config/config.rs | 2 +- runtime/zeitgeist/src/xcm_config/config.rs | 2 +- zrml/prediction-markets/src/mock.rs | 36 ++++++++++++++++--- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/primitives/src/constants/mock.rs b/primitives/src/constants/mock.rs index 5d044f42d..6db264bf0 100644 --- a/primitives/src/constants/mock.rs +++ b/primitives/src/constants/mock.rs @@ -185,10 +185,8 @@ parameter_type_with_key! { } parameter_type_with_key! { - pub ExistentialDepositsNew: |currency_id: Currencies| -> Balance { - match currency_id { - _ => 1 - } + pub ExistentialDepositsNew: |_currency_id: Currencies| -> Balance { + 1 }; } diff --git a/runtime/battery-station/src/xcm_config/config.rs b/runtime/battery-station/src/xcm_config/config.rs index e9ca70628..197151614 100644 --- a/runtime/battery-station/src/xcm_config/config.rs +++ b/runtime/battery-station/src/xcm_config/config.rs @@ -223,7 +223,7 @@ impl< let (asset_id, amount) = if let Some(ref asset_id) = CurrencyIdConvert::convert(asset.clone()) { if let Fungible(amount) = asset.fun { - (asset_id.clone(), amount) + (*asset_id, amount) } else { return asset.clone(); } diff --git a/runtime/zeitgeist/src/xcm_config/config.rs b/runtime/zeitgeist/src/xcm_config/config.rs index b0f6c05cd..40b91c5ea 100644 --- a/runtime/zeitgeist/src/xcm_config/config.rs +++ b/runtime/zeitgeist/src/xcm_config/config.rs @@ -225,7 +225,7 @@ impl< let (asset_id, amount) = if let Some(ref asset_id) = CurrencyIdConvert::convert(asset.clone()) { if let Fungible(amount) = asset.fun { - (asset_id.clone(), amount) + (*asset_id, amount) } else { return asset.clone(); } diff --git a/zrml/prediction-markets/src/mock.rs b/zrml/prediction-markets/src/mock.rs index 0ba3c46b7..4d499afb6 100644 --- a/zrml/prediction-markets/src/mock.rs +++ b/zrml/prediction-markets/src/mock.rs @@ -30,7 +30,7 @@ use frame_support::{ use frame_system::{EnsureRoot, EnsureSignedBy, EnsureSigned}; #[cfg(feature = "parachain")] use orml_asset_registry::AssetMetadata; -use sp_arithmetic::per_things::Percent; +use sp_arithmetic::{per_things::Percent}; use sp_runtime::{ testing::Header, traits::{ConstU32, BlakeTwo256, IdentityLookup}, @@ -324,6 +324,34 @@ ord_parameter_types! { pub const AuthorizedDisputeResolutionUser: AccountIdTest = ALICE; } +pallet_assets::runtime_benchmarks_enabled! { + pub struct AssetsBenchmarkHelper; + + impl pallet_assets::BenchmarkHelper + for AssetsBenchmarkHelper + where + AssetIdParameter: From, + { + fn create_asset_id_parameter(id: u32) -> AssetIdParameter { + (id as u128).into() + } + } +} + +pallet_assets::runtime_benchmarks_enabled! { + use zeitgeist_primitives::types::CategoryIndex; + + pub struct MarketAssetsBenchmarkHelper; + + impl pallet_assets::BenchmarkHelper + for MarketAssetsBenchmarkHelper + { + fn create_asset_id_parameter(id: u32) -> MarketAsset { + MarketAsset::CategoricalOutcome(0, id as CategoryIndex) + } + } +} + impl pallet_assets::Config for Runtime { type ApprovalDeposit = AssetsApprovalDeposit; type AssetAccountDeposit = AssetsAccountDeposit; @@ -332,7 +360,7 @@ impl pallet_assets::Config for Runtime { type AssetIdParameter = Compact; type Balance = Balance; #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = (); + type BenchmarkHelper = AssetsBenchmarkHelper; type CallbackHandle = (); type CreateOrigin = AsEnsureOriginWithArg>; type Currency = Balances; @@ -355,7 +383,7 @@ impl pallet_assets::Config for Runtime { type AssetIdParameter = Compact; type Balance = Balance; #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = (); + type BenchmarkHelper = AssetsBenchmarkHelper; type CallbackHandle = (); type CreateOrigin = AsEnsureOriginWithArg>; type Currency = Balances; @@ -378,7 +406,7 @@ impl pallet_assets::Config for Runtime { type AssetIdParameter = MarketAsset; type Balance = Balance; #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = (); + type BenchmarkHelper = MarketAssetsBenchmarkHelper; type CallbackHandle = (); type CreateOrigin = AsEnsureOriginWithArg>; type Currency = Balances;