mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 18:07:58 +00:00
Split fees and tips between author and treasury independently (#5207)
* Split fees and tips between author and treasury independently * Docs and cleanup * Fix test
This commit is contained in:
@@ -35,7 +35,7 @@ use sp_std::prelude::*;
|
||||
use codec::{Encode, Decode};
|
||||
use frame_support::{
|
||||
decl_storage, decl_module,
|
||||
traits::{Currency, Get, OnUnbalanced, ExistenceRequirement, WithdrawReason},
|
||||
traits::{Currency, Get, OnUnbalanced, ExistenceRequirement, WithdrawReason, Imbalance},
|
||||
weights::{Weight, DispatchInfo, GetDispatchInfo},
|
||||
};
|
||||
use sp_runtime::{
|
||||
@@ -58,7 +58,9 @@ pub trait Trait: frame_system::Trait {
|
||||
/// The currency type in which fees will be paid.
|
||||
type Currency: Currency<Self::AccountId> + Send + Sync;
|
||||
|
||||
/// Handler for the unbalanced reduction when taking transaction fees.
|
||||
/// Handler for the unbalanced reduction when taking transaction fees. This is either one or
|
||||
/// two separate imbalances, the first is the transaction fee paid, the second is the tip paid,
|
||||
/// if any.
|
||||
type OnTransactionPayment: OnUnbalanced<NegativeImbalanceOf<Self>>;
|
||||
|
||||
/// The fee to be paid for making a transaction; the base.
|
||||
@@ -234,7 +236,9 @@ impl<T: Trait + Send + Sync> SignedExtension for ChargeTransactionPayment<T>
|
||||
Ok(imbalance) => imbalance,
|
||||
Err(_) => return InvalidTransaction::Payment.into(),
|
||||
};
|
||||
T::OnTransactionPayment::on_unbalanced(imbalance);
|
||||
let imbalances = imbalance.split(tip);
|
||||
T::OnTransactionPayment::on_unbalanceds(Some(imbalances.0).into_iter()
|
||||
.chain(Some(imbalances.1)));
|
||||
}
|
||||
|
||||
let mut r = ValidTransaction::default();
|
||||
|
||||
Reference in New Issue
Block a user