tuple to struct event variants (#10206)

* update sudo pallet

* Update mock.rs

* cargo +nightly fmt

* frame-support remote-externalities

* AFNPEV tips

* AFNPEV bin & update sudo

* cargo +nightly fmt

* optional dependency remote-test feature

* fmt

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Doordashcon
2021-11-12 00:48:37 +01:00
committed by GitHub
parent 4aae801ccf
commit 112b7dac47
7 changed files with 51 additions and 41 deletions
+20 -16
View File
@@ -179,16 +179,16 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// A new tip suggestion has been opened. \[tip_hash\]
NewTip(T::Hash),
/// A tip suggestion has reached threshold and is closing. \[tip_hash\]
TipClosing(T::Hash),
/// A tip suggestion has been closed. \[tip_hash, who, payout\]
TipClosed(T::Hash, T::AccountId, BalanceOf<T>),
/// A tip suggestion has been retracted. \[tip_hash\]
TipRetracted(T::Hash),
/// A tip suggestion has been slashed. \[tip_hash, finder, deposit\]
TipSlashed(T::Hash, T::AccountId, BalanceOf<T>),
/// A new tip suggestion has been opened.
NewTip { tip_hash: T::Hash },
/// A tip suggestion has reached threshold and is closing.
TipClosing { tip_hash: T::Hash },
/// A tip suggestion has been closed.
TipClosed { tip_hash: T::Hash, who: T::AccountId, payout: BalanceOf<T> },
/// A tip suggestion has been retracted.
TipRetracted { tip_hash: T::Hash },
/// A tip suggestion has been slashed.
TipSlashed { tip_hash: T::Hash, finder: T::AccountId, deposit: BalanceOf<T> },
}
/// Old name generated by `decl_event`.
@@ -265,7 +265,7 @@ pub mod pallet {
finders_fee: true,
};
Tips::<T>::insert(&hash, tip);
Self::deposit_event(Event::NewTip(hash));
Self::deposit_event(Event::NewTip { tip_hash: hash });
Ok(())
}
@@ -300,7 +300,7 @@ pub mod pallet {
let err_amount = T::Currency::unreserve(&who, tip.deposit);
debug_assert!(err_amount.is_zero());
}
Self::deposit_event(Event::TipRetracted(hash));
Self::deposit_event(Event::TipRetracted { tip_hash: hash });
Ok(())
}
@@ -340,7 +340,7 @@ pub mod pallet {
let hash = T::Hashing::hash_of(&(&reason_hash, &who));
Reasons::<T>::insert(&reason_hash, &reason);
Self::deposit_event(Event::NewTip(hash.clone()));
Self::deposit_event(Event::NewTip { tip_hash: hash.clone() });
let tips = vec![(tipper.clone(), tip_value)];
let tip = OpenTip {
reason: reason_hash,
@@ -390,7 +390,7 @@ pub mod pallet {
let mut tip = Tips::<T>::get(hash).ok_or(Error::<T>::UnknownTip)?;
if Self::insert_tip_and_check_closing(&mut tip, tipper, tip_value) {
Self::deposit_event(Event::TipClosing(hash.clone()));
Self::deposit_event(Event::TipClosing { tip_hash: hash.clone() });
}
Tips::<T>::insert(&hash, tip);
Ok(())
@@ -449,7 +449,11 @@ pub mod pallet {
T::OnSlash::on_unbalanced(imbalance);
}
Reasons::<T>::remove(&tip.reason);
Self::deposit_event(Event::TipSlashed(hash, tip.finder, tip.deposit));
Self::deposit_event(Event::TipSlashed {
tip_hash: hash,
finder: tip.finder,
deposit: tip.deposit,
});
Ok(())
}
}
@@ -544,7 +548,7 @@ impl<T: Config> Pallet<T> {
// same as above: best-effort only.
let res = T::Currency::transfer(&treasury, &tip.who, payout, KeepAlive);
debug_assert!(res.is_ok());
Self::deposit_event(Event::TipClosed(hash, tip.who, payout));
Self::deposit_event(Event::TipClosed { tip_hash: hash, who: tip.who, payout });
}
pub fn migrate_retract_tip_for_tip_new(module: &[u8], item: &[u8]) {
+5 -5
View File
@@ -267,7 +267,7 @@ fn close_tip_works() {
let h = tip_hash();
assert_eq!(last_event(), TipEvent::NewTip(h));
assert_eq!(last_event(), TipEvent::NewTip { tip_hash: h });
assert_ok!(Tips::tip(Origin::signed(11), h.clone(), 10));
@@ -275,7 +275,7 @@ fn close_tip_works() {
assert_ok!(Tips::tip(Origin::signed(12), h.clone(), 10));
assert_eq!(last_event(), TipEvent::TipClosing(h));
assert_eq!(last_event(), TipEvent::TipClosing { tip_hash: h });
assert_noop!(Tips::close_tip(Origin::signed(0), h.into()), Error::<Test>::Premature);
@@ -284,7 +284,7 @@ fn close_tip_works() {
assert_ok!(Tips::close_tip(Origin::signed(0), h.into()));
assert_eq!(Balances::free_balance(3), 10);
assert_eq!(last_event(), TipEvent::TipClosed(h, 3, 10));
assert_eq!(last_event(), TipEvent::TipClosed { tip_hash: h, who: 3, payout: 10 });
assert_noop!(Tips::close_tip(Origin::signed(100), h.into()), Error::<Test>::UnknownTip);
});
@@ -306,14 +306,14 @@ fn slash_tip_works() {
assert_eq!(Balances::free_balance(0), 88);
let h = tip_hash();
assert_eq!(last_event(), TipEvent::NewTip(h));
assert_eq!(last_event(), TipEvent::NewTip { tip_hash: h });
// can't remove from any origin
assert_noop!(Tips::slash_tip(Origin::signed(0), h.clone()), BadOrigin);
// can remove from root.
assert_ok!(Tips::slash_tip(Origin::root(), h.clone()));
assert_eq!(last_event(), TipEvent::TipSlashed(h, 0, 12));
assert_eq!(last_event(), TipEvent::TipSlashed { tip_hash: h, finder: 0, deposit: 12 });
// tipper slashed
assert_eq!(Balances::reserved_balance(0), 0);