mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 13:27:57 +00:00
Add arithmetic dispatch errors. (#8726)
* Add arithmetic dispatch errors. * Replace custom overflow errors. * Replace custom underflow and division by zero errors. * Replace overflow/underflow in token error. * Add token and arithmetic errors in dispatch error equality test. * Trigger CI.
This commit is contained in:
@@ -154,7 +154,7 @@
|
||||
use sp_std::prelude::*;
|
||||
use sp_runtime::{
|
||||
traits::{Dispatchable, SaturatedConversion, CheckedAdd, CheckedMul},
|
||||
DispatchResult
|
||||
DispatchResult, ArithmeticError,
|
||||
};
|
||||
use codec::{Encode, Decode};
|
||||
|
||||
@@ -313,8 +313,6 @@ decl_error! {
|
||||
Threshold,
|
||||
/// There are still active recovery attempts that need to be closed
|
||||
StillActive,
|
||||
/// There was an overflow in a calculation
|
||||
Overflow,
|
||||
/// This account is already set up for recovery
|
||||
AlreadyProxy,
|
||||
/// Some internal state is broken.
|
||||
@@ -443,10 +441,10 @@ decl_module! {
|
||||
// Total deposit is base fee + number of friends * factor fee
|
||||
let friend_deposit = T::FriendDepositFactor::get()
|
||||
.checked_mul(&friends.len().saturated_into())
|
||||
.ok_or(Error::<T>::Overflow)?;
|
||||
.ok_or(ArithmeticError::Overflow)?;
|
||||
let total_deposit = T::ConfigDepositBase::get()
|
||||
.checked_add(&friend_deposit)
|
||||
.ok_or(Error::<T>::Overflow)?;
|
||||
.ok_or(ArithmeticError::Overflow)?;
|
||||
// Reserve the deposit
|
||||
T::Currency::reserve(&who, total_deposit)?;
|
||||
// Create the recovery configuration
|
||||
@@ -581,7 +579,7 @@ decl_module! {
|
||||
let current_block_number = <system::Pallet<T>>::block_number();
|
||||
let recoverable_block_number = active_recovery.created
|
||||
.checked_add(&recovery_config.delay_period)
|
||||
.ok_or(Error::<T>::Overflow)?;
|
||||
.ok_or(ArithmeticError::Overflow)?;
|
||||
ensure!(recoverable_block_number <= current_block_number, Error::<T>::DelayPeriod);
|
||||
// Make sure the threshold is met
|
||||
ensure!(
|
||||
|
||||
Reference in New Issue
Block a user