mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 19:41:05 +00:00
Fix fungible unbalanced trait (#12569)
* Fix fungible unbalanced trait * Add simple decrease_balance test Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix decrease_balance_at_most * Fix decrease_balance_at_most in fungibles * Rename free_balanceto balance_on_free * Use reducible_balance instead of balance_on_free Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
@@ -1149,15 +1149,19 @@ impl<T: Config<I>, I: 'static> fungible::Transfer<T::AccountId> for Pallet<T, I>
|
||||
|
||||
impl<T: Config<I>, I: 'static> fungible::Unbalanced<T::AccountId> for Pallet<T, I> {
|
||||
fn set_balance(who: &T::AccountId, amount: Self::Balance) -> DispatchResult {
|
||||
Self::mutate_account(who, |account| {
|
||||
account.free = amount;
|
||||
Self::mutate_account(who, |account| -> DispatchResult {
|
||||
// fungibles::Unbalanced::decrease_balance didn't check account.reserved
|
||||
// free = new_balance - reserved
|
||||
account.free =
|
||||
amount.checked_sub(&account.reserved).ok_or(ArithmeticError::Underflow)?;
|
||||
Self::deposit_event(Event::BalanceSet {
|
||||
who: who.clone(),
|
||||
free: account.free,
|
||||
reserved: account.reserved,
|
||||
});
|
||||
})?;
|
||||
Ok(())
|
||||
|
||||
Ok(())
|
||||
})?
|
||||
}
|
||||
|
||||
fn set_total_issuance(amount: Self::Balance) {
|
||||
|
||||
Reference in New Issue
Block a user