diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index cebb892c411f3bac24aa9ad4f07c212b0732c2ef..043b8c67571a60b86782d8f3374be68410f23af2 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -147,7 +147,7 @@ macro_rules! pallets_config { type ReserveIdentifier = [u8; 8]; /// The type for recording an account's balance. type Balance = Balance; - type DustRemoval = (); // TODO Treasury; + type DustRemoval = HandleDust; type ExistentialDeposit = ExistentialDeposit; type AccountStore = Account; type HoldIdentifier = (); @@ -159,6 +159,18 @@ macro_rules! pallets_config { type WeightInfo = common_runtime::weights::pallet_balances::WeightInfo<Runtime>; } + // Take Dust from Balances and put it in the Treasury pot + use crate::sp_api_hidden_includes_construct_runtime::hidden_include::traits::Currency; + use crate::sp_api_hidden_includes_construct_runtime::hidden_include::traits::Imbalance; + pub struct HandleDust; + type CreditOf = frame_support::traits::tokens::fungible::Credit<AccountId, Balances>; + impl frame_support::traits::OnUnbalanced<CreditOf> for HandleDust { + fn on_nonzero_unbalanced(amount: CreditOf) { + let imbalance = NegativeImbalance::new(amount.peek()); + Balances::resolve_creating(&Treasury::account_id(), imbalance); + } + } + pub struct HandleFees; type NegativeImbalance = <Balances as frame_support::traits::Currency<AccountId>>::NegativeImbalance; impl frame_support::traits::OnUnbalanced<NegativeImbalance> for HandleFees {