@@ -37,7 +37,7 @@ use frame_support::{
37
37
use frame_system:: { ensure_root, ensure_signed, pallet_prelude:: * } ;
38
38
use sp_runtime:: {
39
39
traits:: { AtLeast32Bit , CheckedAdd , Saturating , StaticLookup , Zero } ,
40
- DispatchResult , RuntimeDebug ,
40
+ ArithmeticError , DispatchResult , RuntimeDebug ,
41
41
} ;
42
42
use sp_std:: {
43
43
cmp:: { Eq , PartialEq } ,
@@ -144,8 +144,6 @@ pub mod module {
144
144
ZeroVestingPeriod ,
145
145
/// Number of vests is zero
146
146
ZeroVestingPeriodCount ,
147
- /// Arithmetic calculation overflow
148
- NumOverflow ,
149
147
/// Insufficient amount of balance to lock
150
148
InsufficientBalanceToLock ,
151
149
/// This account have too many vesting schedules
@@ -303,7 +301,7 @@ impl<T: Config> Pallet<T> {
303
301
304
302
let total_amount = Self :: locked_balance ( to)
305
303
. checked_add ( & schedule_amount)
306
- . ok_or ( Error :: < T > :: NumOverflow ) ?;
304
+ . ok_or ( ArithmeticError :: Overflow ) ?;
307
305
308
306
T :: Currency :: transfer ( from, to, schedule_amount, ExistenceRequirement :: AllowDeath ) ?;
309
307
T :: Currency :: set_lock ( VESTING_LOCK_ID , to, total_amount, WithdrawReasons :: all ( ) ) ;
@@ -312,7 +310,7 @@ impl<T: Config> Pallet<T> {
312
310
}
313
311
314
312
fn do_update_vesting_schedules ( who : & T :: AccountId , schedules : Vec < VestingScheduleOf < T > > ) -> DispatchResult {
315
- let total_amount = schedules. iter ( ) . try_fold :: < _ , _ , Result < BalanceOf < T > , Error < T > > > (
313
+ let total_amount = schedules. iter ( ) . try_fold :: < _ , _ , Result < BalanceOf < T > , DispatchError > > (
316
314
Zero :: zero ( ) ,
317
315
|acc_amount, schedule| {
318
316
let amount = Self :: ensure_valid_vesting_schedule ( schedule) ?;
@@ -331,12 +329,12 @@ impl<T: Config> Pallet<T> {
331
329
}
332
330
333
331
/// Returns `Ok(amount)` if valid schedule, or error.
334
- fn ensure_valid_vesting_schedule ( schedule : & VestingScheduleOf < T > ) -> Result < BalanceOf < T > , Error < T > > {
332
+ fn ensure_valid_vesting_schedule ( schedule : & VestingScheduleOf < T > ) -> Result < BalanceOf < T > , DispatchError > {
335
333
ensure ! ( !schedule. period. is_zero( ) , Error :: <T >:: ZeroVestingPeriod ) ;
336
334
ensure ! ( !schedule. period_count. is_zero( ) , Error :: <T >:: ZeroVestingPeriodCount ) ;
337
- ensure ! ( schedule. end( ) . is_some( ) , Error :: < T > :: NumOverflow ) ;
335
+ ensure ! ( schedule. end( ) . is_some( ) , ArithmeticError :: Overflow ) ;
338
336
339
- let total = schedule. total_amount ( ) . ok_or ( Error :: < T > :: NumOverflow ) ?;
337
+ let total = schedule. total_amount ( ) . ok_or ( ArithmeticError :: Overflow ) ?;
340
338
341
339
ensure ! ( total >= T :: MinVestedTransfer :: get( ) , Error :: <T >:: AmountLow ) ;
342
340
0 commit comments