mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 18:05:41 +00:00
Check unreserve and transfer returnvalues in debug code (#8398)
* Check `unreserve` and `transfer` returnvalues in debug code fixes #8106 * few more Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
committed by
GitHub
parent
f93d7b874e
commit
9a72134188
@@ -291,7 +291,8 @@ decl_module! {
|
||||
Reasons::<T>::remove(&tip.reason);
|
||||
Tips::<T>::remove(&hash);
|
||||
if !tip.deposit.is_zero() {
|
||||
let _ = T::Currency::unreserve(&who, tip.deposit);
|
||||
let err_amount = T::Currency::unreserve(&who, tip.deposit);
|
||||
debug_assert!(err_amount.is_zero());
|
||||
}
|
||||
Self::deposit_event(RawEvent::TipRetracted(hash));
|
||||
}
|
||||
@@ -505,7 +506,8 @@ impl<T: Config> Module<T> {
|
||||
|
||||
let mut payout = tips[tips.len() / 2].1.min(max_payout);
|
||||
if !tip.deposit.is_zero() {
|
||||
let _ = T::Currency::unreserve(&tip.finder, tip.deposit);
|
||||
let err_amount = T::Currency::unreserve(&tip.finder, tip.deposit);
|
||||
debug_assert!(err_amount.is_zero());
|
||||
}
|
||||
|
||||
if tip.finders_fee && tip.finder != tip.who {
|
||||
@@ -514,11 +516,13 @@ impl<T: Config> Module<T> {
|
||||
payout -= finders_fee;
|
||||
// this should go through given we checked it's at most the free balance, but still
|
||||
// we only make a best-effort.
|
||||
let _ = T::Currency::transfer(&treasury, &tip.finder, finders_fee, KeepAlive);
|
||||
let res = T::Currency::transfer(&treasury, &tip.finder, finders_fee, KeepAlive);
|
||||
debug_assert!(res.is_ok());
|
||||
}
|
||||
|
||||
// same as above: best-effort only.
|
||||
let _ = T::Currency::transfer(&treasury, &tip.who, payout, KeepAlive);
|
||||
let res = T::Currency::transfer(&treasury, &tip.who, payout, KeepAlive);
|
||||
debug_assert!(res.is_ok());
|
||||
Self::deposit_event(RawEvent::TipClosed(hash, tip.who, payout));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user