From 7397059481b1ad51a8d6876f902ac29fcbfdbfa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20P=C5=82askonka?= Date: Mon, 6 May 2024 15:54:34 +0200 Subject: [PATCH] Fix for HAL-03 issue. Now burning more reputation that there is balance will cause a revert. --- dao/src/core_contracts/reputation/balances.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dao/src/core_contracts/reputation/balances.rs b/dao/src/core_contracts/reputation/balances.rs index 8a4b1a79..e9257668 100644 --- a/dao/src/core_contracts/reputation/balances.rs +++ b/dao/src/core_contracts/reputation/balances.rs @@ -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); } }