Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Fix fungible and fungibles set_balance return value (#13851)
Browse files Browse the repository at this point in the history
* Fix fungible set_balance return value

* fix fungibles set_balance return value
  • Loading branch information
liamaharon authored Apr 11, 2023
1 parent a2f6e05 commit a1f71b8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions frame/support/src/traits/tokens/fungible/regular.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ pub trait Mutate<AccountId>: Inspect<AccountId> + Unbalanced<AccountId> {
fn set_balance(who: &AccountId, amount: Self::Balance) -> Self::Balance {
let b = Self::balance(who);
if b > amount {
Self::burn_from(who, b - amount, BestEffort, Force).map(|d| amount.saturating_sub(d))
Self::burn_from(who, b - amount, BestEffort, Force).map(|d| b.saturating_sub(d))
} else {
Self::mint_into(who, amount - b).map(|d| amount.saturating_add(d))
Self::mint_into(who, amount - b).map(|d| b.saturating_add(d))
}
.unwrap_or(b)
}
Expand Down
5 changes: 2 additions & 3 deletions frame/support/src/traits/tokens/fungibles/regular.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,9 @@ pub trait Mutate<AccountId>: Inspect<AccountId> + Unbalanced<AccountId> {
fn set_balance(asset: Self::AssetId, who: &AccountId, amount: Self::Balance) -> Self::Balance {
let b = Self::balance(asset, who);
if b > amount {
Self::burn_from(asset, who, b - amount, BestEffort, Force)
.map(|d| amount.saturating_sub(d))
Self::burn_from(asset, who, b - amount, BestEffort, Force).map(|d| b.saturating_sub(d))
} else {
Self::mint_into(asset, who, amount - b).map(|d| amount.saturating_add(d))
Self::mint_into(asset, who, amount - b).map(|d| b.saturating_add(d))
}
.unwrap_or(b)
}
Expand Down

0 comments on commit a1f71b8

Please sign in to comment.