Browse Source

reserve unchecked for when guarded by explicit require (#2685)

Francisco Giordano 4 years ago
parent
commit
1b37c21da5
2 changed files with 2 additions and 2 deletions
  1. 1 1
      contracts/token/ERC20/ERC20.sol
  2. 1 1
      contracts/token/ERC777/ERC777.sol

+ 1 - 1
contracts/token/ERC20/ERC20.sol

@@ -267,8 +267,8 @@ contract ERC20 is Context, IERC20, IERC20Metadata {
         require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
         unchecked {
             _balances[account] = accountBalance - amount;
-            _totalSupply -= amount;
         }
+        _totalSupply -= amount;
 
         emit Transfer(account, address(0), amount);
     }

+ 1 - 1
contracts/token/ERC777/ERC777.sol

@@ -421,8 +421,8 @@ contract ERC777 is Context, IERC777, IERC20 {
         require(fromBalance >= amount, "ERC777: burn amount exceeds balance");
         unchecked {
             _balances[from] = fromBalance - amount;
-            _totalSupply -= amount;
         }
+        _totalSupply -= amount;
 
         emit Burned(operator, from, amount, data, operatorData);
         emit Transfer(from, address(0), amount);