difftreelog
feat switch `configuration` from `Currency` trait to `fungible::*` traits
in: master
2 files changed
pallets/configuration/src/benchmarking.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//! Benchmarking setup for pallet-configuration1819use super::*;20use frame_benchmarking::benchmarks;21use frame_system::{EventRecord, RawOrigin};22use frame_support::{assert_ok, traits::Currency};2324fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {25 let events = frame_system::Pallet::<T>::events();26 let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();27 // compare to the last event record28 let EventRecord { event, .. } = &events[events.len() - 1];29 assert_eq!(event, &system_event);30}3132benchmarks! {33 where_clause { where T: Config }3435 set_weight_to_fee_coefficient_override {36 let coeff: u64 = 999;37 }: {38 assert_ok!(39 <Pallet<T>>::set_weight_to_fee_coefficient_override(RawOrigin::Root.into(), Some(coeff))40 );41 }4243 set_min_gas_price_override {44 let coeff: u64 = 999;45 }: {46 assert_ok!(47 <Pallet<T>>::set_min_gas_price_override(RawOrigin::Root.into(), Some(coeff))48 );49 }5051 set_app_promotion_configuration_override {52 let configuration: AppPromotionConfiguration<T::BlockNumber> = Default::default();53 }: {54 assert_ok!(55 <Pallet<T>>::set_app_promotion_configuration_override(RawOrigin::Root.into(), configuration)56 );57 }5859 set_collator_selection_desired_collators {60 let max: u32 = 999;61 }: {62 assert_ok!(63 <Pallet<T>>::set_collator_selection_desired_collators(RawOrigin::Root.into(), Some(max.clone()))64 );65 }66 verify {67 assert_last_event::<T>(Event::NewDesiredCollators{desired_collators: Some(max)}.into());68 }6970 set_collator_selection_license_bond {71 let bond_cost: Option<BalanceOf<T>> = Some(T::Currency::minimum_balance() * 10u32.into());72 }: {73 assert_ok!(74 <Pallet<T>>::set_collator_selection_license_bond(RawOrigin::Root.into(), bond_cost.clone())75 );76 }77 verify {78 assert_last_event::<T>(Event::NewCollatorLicenseBond{bond_cost}.into());79 }8081 set_collator_selection_kick_threshold {82 let threshold: Option<T::BlockNumber> = Some(900u32.into());83 }: {84 assert_ok!(85 <Pallet<T>>::set_collator_selection_kick_threshold(RawOrigin::Root.into(), threshold.clone())86 );87 }88 verify {89 assert_last_event::<T>(Event::NewCollatorKickThreshold{length_in_blocks: threshold}.into());90 }91}pallets/configuration/src/lib.rsdiffbeforeafterboth--- a/pallets/configuration/src/lib.rs
+++ b/pallets/configuration/src/lib.rs
@@ -42,23 +42,28 @@
mod pallet {
use super::*;
use frame_support::{
- traits::{Get, ReservableCurrency, Currency},
+ traits::{fungible, Get, ReservableCurrency, Currency},
pallet_prelude::{StorageValue, ValueQuery, DispatchResult, IsType},
log,
};
use frame_system::{pallet_prelude::OriginFor, ensure_root, Config as SystemConfig};
pub use crate::weights::WeightInfo;
- pub type BalanceOf<T> =
- <<T as Config>::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance;
+ pub type BalanceOf<T> =
+ <<T as Config>::Balances as fungible::Inspect<<T as SystemConfig>::AccountId>>::Balance;
#[pallet::config]
pub trait Config: frame_system::Config {
/// Overarching event type.
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
- /// The currency mechanism.
- type Currency: ReservableCurrency<Self::AccountId>;
+ type Balances:
+ fungible::Inspect<Self::AccountId>
+ + fungible::Mutate::<Self::AccountId>
+ + fungible::MutateFreeze::<Self::AccountId>
+ + fungible::InspectHold::<Self::AccountId>
+ + fungible::MutateHold::<Self::AccountId>
+ + fungible::BalancedHold::<Self::AccountId>;
#[pallet::constant]
type DefaultWeightToFeeCoefficient: Get<u64>;