emit TipClosed event on success tip payout (#5656)

* emit TipClosed event on success tip payout

* test for events

* bump version
This commit is contained in:
Xiliang Chen
2020-04-17 20:37:00 +12:00
committed by GitHub
parent a42d87483c
commit 7dcff4c1e2
3 changed files with 59 additions and 7 deletions
+3 -2
View File
@@ -549,7 +549,7 @@ decl_module! {
// closed.
Reasons::<T>::remove(&tip.reason);
Tips::<T>::remove(hash);
Self::payout_tip(tip);
Self::payout_tip(hash, tip);
}
fn on_initialize(n: T::BlockNumber) -> Weight {
@@ -627,7 +627,7 @@ impl<T: Trait> Module<T> {
///
/// Up to three balance operations.
/// Plus `O(T)` (`T` is Tippers length).
fn payout_tip(tip: OpenTip<T::AccountId, BalanceOf<T>, T::BlockNumber, T::Hash>) {
fn payout_tip(hash: T::Hash, tip: OpenTip<T::AccountId, BalanceOf<T>, T::BlockNumber, T::Hash>) {
let mut tips = tip.tips;
Self::retain_active_tips(&mut tips);
tips.sort_by_key(|i| i.1);
@@ -647,6 +647,7 @@ impl<T: Trait> Module<T> {
}
// same as above: best-effort only.
let _ = T::Currency::transfer(&treasury, &tip.who, payout, KeepAlive);
Self::deposit_event(RawEvent::TipClosed(hash, tip.who, payout));
}
// Spend some money!