We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4892257 commit 6ea6029Copy full SHA for 6ea6029
tokens/src/lib.rs
@@ -474,8 +474,16 @@ impl<T: Trait> MultiCurrencyExtended<T::AccountId> for Module<T> {
474
return Ok(());
475
}
476
477
+ // Ensure this doesn't overflow. There isn't any traits that exposes
478
+ // `saturating_abs` so we need to do it manually.
479
+ let by_amount_abs = if by_amount == Self::Amount::min_value() {
480
+ Self::Amount::max_value()
481
+ } else {
482
+ by_amount.abs()
483
+ };
484
+
485
let by_balance =
- TryInto::<Self::Balance>::try_into(by_amount.abs()).map_err(|_| Error::<T>::AmountIntoBalanceFailed)?;
486
+ TryInto::<Self::Balance>::try_into(by_amount_abs).map_err(|_| Error::<T>::AmountIntoBalanceFailed)?;
487
if by_amount.is_positive() {
488
Self::deposit(currency_id, who, by_balance)
489
} else {
0 commit comments