diff --git a/runtime/common/src/fees.rs b/runtime/common/src/fees.rs index 4fe1d5fd4b88e620f2f3dbc897c681e95da86af2..aec304d1d4f756e8dee94fc2f0c8e06e086f1990 100644 --- a/runtime/common/src/fees.rs +++ b/runtime/common/src/fees.rs @@ -17,7 +17,7 @@ pub use frame_support::weights::{ Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }; -use sp_arithmetic::traits::{BaseArithmetic, Unsigned}; +use sp_arithmetic::traits::{BaseArithmetic, Unsigned, Zero}; pub struct WeightToFeeImpl<T>(sp_std::marker::PhantomData<T>); @@ -36,7 +36,7 @@ where }) } // Force disable fees - fn calc(weight: &Weight) -> Self::Balance { + fn calc(_weight: &Weight) -> Self::Balance { Zero::zero() } } diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index 08f5968cefe620f74bf2ddd581053f2018ad6c9b..f24979285a5c3b649fb78747cf35f691f897163f 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -163,8 +163,19 @@ macro_rules! pallets_config { type WeightInfo = common_runtime::weights::pallet_balances::WeightInfo<Runtime>; } + pub struct HandleFees; + type NegativeImbalance = <Balances as frame_support::traits::Currency<AccountId>>::NegativeImbalance; + impl frame_support::traits::OnUnbalanced<NegativeImbalance> for HandleFees { + fn on_nonzero_unbalanced(amount: NegativeImbalance) { + use frame_support::traits::Currency as _; + + if let Some(author) = Authorship::author() { + Balances::resolve_creating(&author, amount); + } + } + } impl pallet_transaction_payment::Config for Runtime { - type OnChargeTransaction = CurrencyAdapter<Balances, ()>; + type OnChargeTransaction = CurrencyAdapter<Balances, HandleFees>; type TransactionByteFee = TransactionByteFee; type OperationalFeeMultiplier = frame_support::traits::ConstU8<5>; type WeightToFee = common_runtime::fees::WeightToFeeImpl<Balance>;