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> {
474
474
return Ok ( ( ) ) ;
475
475
}
476
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
+
477
485
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 ) ?;
479
487
if by_amount. is_positive ( ) {
480
488
Self :: deposit ( currency_id, who, by_balance)
481
489
} else {
You can’t perform that action at this time.
0 commit comments