ERC20: optimized gas costs in _spendAllowance (#5271)
This commit is contained in:
@ -300,7 +300,7 @@ abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
|
|||||||
*/
|
*/
|
||||||
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
|
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
|
||||||
uint256 currentAllowance = allowance(owner, spender);
|
uint256 currentAllowance = allowance(owner, spender);
|
||||||
if (currentAllowance != type(uint256).max) {
|
if (currentAllowance < type(uint256).max) {
|
||||||
if (currentAllowance < value) {
|
if (currentAllowance < value) {
|
||||||
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
|
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user