Skip to content
This repository was archived by the owner on Mar 13, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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