Skip to content
Snippets Groups Projects

Refactore Runtime handlers and providers

Merged Benjamin Gallois requested to merge refactore-handlers into master
Files
6
@@ -15,7 +15,10 @@
@@ -15,7 +15,10 @@
// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
use super::{entities::*, AccountId, IdtyIndex};
use super::{entities::*, AccountId, IdtyIndex};
use frame_support::{pallet_prelude::Weight, traits::UnfilteredDispatchable};
use frame_support::{
 
pallet_prelude::Weight,
 
traits::{Imbalance, UnfilteredDispatchable},
 
};
use pallet_smith_members::SmithRemovalReason;
use pallet_smith_members::SmithRemovalReason;
use sp_core::Get;
use sp_core::Get;
@@ -178,3 +181,27 @@ impl<
@@ -178,3 +181,27 @@ impl<
!pallet_authority_members::Pallet::<Runtime>::online().contains(idty_index)
!pallet_authority_members::Pallet::<Runtime>::online().contains(idty_index)
}
}
}
}
 
 
type CreditOf<T, Balances> = frame_support::traits::tokens::fungible::Credit<T, Balances>;
 
pub struct HandleFees<T, TreasuryAccount, Balances>(
 
frame_support::pallet_prelude::PhantomData<T>,
 
frame_support::pallet_prelude::PhantomData<TreasuryAccount>,
 
frame_support::pallet_prelude::PhantomData<Balances>,
 
);
 
impl<T, TreasuryAccount, Balances>
 
frame_support::traits::OnUnbalanced<CreditOf<T::AccountId, Balances>>
 
for HandleFees<T, TreasuryAccount, Balances>
 
where
 
T: frame_system::Config,
 
TreasuryAccount: Get<T::AccountId>,
 
Balances: frame_support::traits::fungible::Balanced<T::AccountId>,
 
{
 
fn on_nonzero_unbalanced(amount: CreditOf<T::AccountId, Balances>) {
 
// fee is moved to treasury
 
let _ = Balances::deposit(
 
&TreasuryAccount::get(),
 
amount.peek(),
 
frame_support::traits::tokens::Precision::Exact,
 
);
 
}
 
}
Loading