File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -474,8 +474,16 @@ impl<T: Trait> MultiCurrencyExtended<T::AccountId> for Module<T> {
474474 return Ok ( ( ) ) ;
475475 }
476476
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+
477485 let by_balance =
478- 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 ) ?;
479487 if by_amount. is_positive ( ) {
480488 Self :: deposit ( currency_id, who, by_balance)
481489 } else {
You can’t perform that action at this time.
0 commit comments