From 3df8fc3f97e117dfcac707284e91383d44d3e413 Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Mon, 7 Feb 2022 16:20:28 +0100 Subject: [PATCH] add support for unlimited allowance to ERC20Burnable --- contracts/token/ERC20/extensions/ERC20Burnable.sol | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/contracts/token/ERC20/extensions/ERC20Burnable.sol b/contracts/token/ERC20/extensions/ERC20Burnable.sol index ab961a9e26b..c105884619c 100644 --- a/contracts/token/ERC20/extensions/ERC20Burnable.sol +++ b/contracts/token/ERC20/extensions/ERC20Burnable.sol @@ -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); }