Skip to content

Commit

Permalink
add support for unlimited allowance to ERC20Burnable
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx committed Feb 7, 2022
1 parent 7bf3143 commit 5527d66
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions contracts/token/ERC20/extensions/ERC20Burnable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ abstract contract ERC20Burnable is Context, ERC20 {
*/
function burnFrom(address account, uint256 amount) public virtual {
uint256 currentAllowance = allowance(account, _msgSender());
require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance");
unchecked {
_approve(account, _msgSender(), currentAllowance - amount);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance");
unchecked {
_approve(account, _msgSender(), currentAllowance - amount);
}
}
_burn(account, amount);
}
Expand Down

0 comments on commit 5527d66

Please sign in to comment.