Skip to content

Commit

Permalink
Fix for HAL-03 issue.
Browse files Browse the repository at this point in the history
Now burning more reputation that there is balance will cause a revert.
  • Loading branch information
kubaplas committed May 6, 2024
1 parent 4432b75 commit 7397059
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dao/src/core_contracts/reputation/balances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ impl BalanceStorage {

fn dec_balance(&mut self, owner: &Address, amount: Balance) {
let balance = self.balances.get(owner).unwrap_or_default();
let new_balance = balance.saturating_sub(amount);
let new_balance = balance
.checked_sub(amount)
.unwrap_or_revert_with(Error::ArithmeticOverflow);
self.set_balance(owner, new_balance);
}
}
Expand Down

0 comments on commit 7397059

Please sign in to comment.