Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
Deposit Event & Adjust Tips Dest (#607)
Browse files Browse the repository at this point in the history
* companion for #substrate-7936 part.2

* all tips to author
  • Loading branch information
AurevoirXavier committed Apr 26, 2021
1 parent e52046b commit 5005c4d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
22 changes: 14 additions & 8 deletions bin/node/runtime/pangolin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,25 +133,31 @@ pub mod impls {
}
}

pub struct Author;
impl OnUnbalanced<NegativeImbalance> for Author {
fn on_nonzero_unbalanced(amount: NegativeImbalance) {
pub struct ToAuthor;
impl OnUnbalanced<RingNegativeImbalance> for ToAuthor {
fn on_nonzero_unbalanced(amount: RingNegativeImbalance) {
let numeric_amount = amount.peek();
let author = Authorship::author();
Ring::resolve_creating(&Authorship::author(), amount);
System::deposit_event(<darwinia_balances::Event<Runtime, RingInstance>>::Deposit(
author,
numeric_amount,
));
}
}

pub struct DealWithFees;
impl OnUnbalanced<NegativeImbalance> for DealWithFees {
fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {
impl OnUnbalanced<RingNegativeImbalance> for DealWithFees {
fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = RingNegativeImbalance>) {
if let Some(fees) = fees_then_tips.next() {
// for fees, 80% to treasury, 20% to author
let mut split = fees.ration(80, 20);
if let Some(tips) = fees_then_tips.next() {
// for tips, if any, 80% to treasury, 20% to author (though this can be anything)
tips.ration_merge_into(80, 20, &mut split);
// for tips, if any, 100% to author
tips.merge_into(&mut split.1);
}
Treasury::on_unbalanced(split.0);
Author::on_unbalanced(split.1);
ToAuthor::on_unbalanced(split.1);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion bin/node/runtime/pangolin/src/pallets/balances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use frame_system::Config as SystemConfig;
use crate::*;
use darwinia_balances::{weights::SubstrateWeight, Config, Pallet};

pub type NegativeImbalance = <Pallet<Runtime, RingInstance> as Currency<
pub type RingNegativeImbalance = <Pallet<Runtime, RingInstance> as Currency<
<Runtime as SystemConfig>::AccountId,
>>::NegativeImbalance;

Expand Down

0 comments on commit 5005c4d

Please sign in to comment.